Top "Python-3.x" questions

For questions about Python programming that are specific to version 3+ of the language.

How to install pip for Python 3 on Mac OS X?

OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed …

python macos python-3.x pip python-3.3
How to run multiple Python versions on Windows

I had two versions of Python installed on my machine (versions 2.6 and 2.5). I want to run 2.6 for one project and 2.5 …

python windows python-3.x compatibility python-2.x
How to get the current working directory using python 3?

When I run the following script in IDLE import os print(os.getcwd()) I get output as D:\testtool but …

python python-3.x working-directory file-location
What is sys.maxint in Python 3?

I've been trying to find out how to represent a maximum integer, and I've read to use "sys.maxint". However, …

python python-3.x
Difference between except: and except Exception as e: in Python

Both the following snippets of code do the same thing. They catch every exception and execute the code in the …

python python-3.x
builtins.TypeError: must be str, not bytes

I've converted my scripts from Python 2.7 to 3.2, and I have a bug. # -*- coding: utf-8 -*- import time …

python python-3.x lxml
What is the purpose of "pip install --user ..."?

From pip install --help: --user Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python …

python python-3.x pip virtualenv
Writing a dictionary to a text file?

I have a dictionary and am trying to write it to a file. exDict = {1:1, 2:2, 3:3} with open('file.txt', 'r') as …

python-3.x file dictionary file-writing
When should iteritems() be used instead of items()?

Is it legitimate to use items() instead of iteritems() in all places? Why was iteritems() removed from Python 3? Seems like …

python python-3.x
How to use a variable inside a regular expression?

I'd like to use a variable inside a regex, how can I do this in Python? TEXTO = sys.argv[1] if …

python regex python-3.x variables escaping