Top "Python-3.x" questions

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

Python 3: UnboundLocalError: local variable referenced before assignment

The following code gives the error UnboundLocalError: local variable 'Var1' referenced before assignment: Var1 = 1 Var2 = 0 def function(): if Var2 == 0 …

python function python-3.x
What is

Can anyone please explain what is and how it can be configured or used?

python python-3.x pypi python-packaging
How to copy a dictionary and only edit the copy

Can someone please explain this to me? This doesn't make any sense to me. I copy a dictionary into another …

python python-3.x dictionary reference
How do I remove/delete a virtualenv?

I created an environment with the following command: virtualenv venv --distribute I cannot remove it with the following command: rmvirtualenv …

python-3.x virtualenvwrapper python-venv virtual-environment virtualenv-commands
TypeError: method() takes 1 positional argument but 2 were given

If I have a class... class MyClass: def method(arg): print(arg) ...which I use to create an object... my_…

python python-3.x methods arguments self
error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte An error occurred when compiling "" on the above site. …

python python-3.x utf-8
How do I upgrade the Python installation in Windows 10?

I have a Python 2.7.11 installed on one of my LAB stations. I would like to upgrade Python to at least 3.5. …

python python-3.x
How to search and replace text in a file?

How do I search and replace text in a file using Python 3? Here is my code: import os import sys …

python python-3.x string file replace
StringIO in Python3

I am using Python 3.2.1 and I can't import the StringIO module. I use io.StringIO and it works, but I …

python python-3.x io
Relative imports in Python 3

I want to import a function from another file in the same directory. Sometimes it works for me with from .…

python python-3.x python-import