tagged [python]

Integer division in Python 2 and Python 3

Integer division in Python 2 and Python 3 How can I divide two numbers in Python 2.7 and get the result with decimals? I don't get it why there is difference: in Python 3: in Python 2: Isn't this a mo...

Modifying a variable in a module imported using from ... import *

Modifying a variable in a module imported using from ... import * Consider the following code: As it seems, this creates one variable in each module with different content. How can I modify the variab...

13 Sep at 20:6

How to add an element to the beginning of an OrderedDict?

How to add an element to the beginning of an OrderedDict? I have this: If I do this: Then I get this: but I want this: without creating new dictionary.

How to specify multiple return types using type-hints

How to specify multiple return types using type-hints I have a function in python that can either return a `bool` or a `list`. Is there a way to specify the return types using type hints? For example,...

What does the "at" (@) symbol do in Python?

What does the "at" (@) symbol do in Python? What does the `@` symbol do in Python?

19 Apr at 01:39

ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?

ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle? I use pickle to dump a file on python 3, and I use pickle to load the file on python 2, the ...

Relative imports in Python 3

Relative imports in Python 3 I want to import a function from another file in the same directory. Usually, one of the following works: ...but the other one gives me one of these errors: ``` ModuleNotF...

29 Aug at 12:4

When import docx in python3.3 I have error ImportError: No module named 'exceptions'

When import docx in python3.3 I have error ImportError: No module named 'exceptions' when I import `docx` I have this error: How to fix this error (`python3.3

26 Oct at 17:55

What is setup.py?

What is setup.py? What is `setup.py` and how can it be configured or used?

How to check deque length in Python

How to check deque length in Python How to check a deque's length in python? I don't see they provide deque.length in Python... [http://docs.python.org/tutorial/datastructures.html](http://docs.python...