All Questions

353
votes
5answers
185689 views

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 .mymodule import myfunction but sometimes I get a: SystemError: Parent module '' not loaded, ...
292
votes
8answers
138623 views

What is the best way to remove accents in a Python unicode string?

I have a Unicode string in Python, and I would like to remove all the accents (diacritics). I found on the Web an elegant way to do this in Java: convert the Unicode string to its long normalized f...
90
votes
2answers
8919 views

Accessing class variables from a list comprehension in the class definition

How do you access other class variables from a list comprehension within the class definition? The following works in Python 2 but fails in Python 3: class Foo: x = 5 y = [x for i in range(1...
291
votes
4answers
482878 views

What does "SyntaxError: Missing parentheses in call to 'print'" mean in Python?

When I try to use a print statement in Python, it gives me this error: >>> print "Hello world!" File "<stdin>", line 1 print "Hello world!" ^ SyntaxError: ...
149
votes
3answers
18650 views

Are dictionaries ordered in Python 3.6+?

Dictionaries are ordered in Python 3.6 (under the CPython implementation at least) unlike in previous incarnations. This seems like a substantial change, but it's only a short paragraph in the documen...
284
votes
16answers
598516 views

How to install pip with Python 3?

I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2. How can I install pip with Python 3?
9
votes
3answers
28945 views

error in python d not defined.

I am learning python and have this error . I can figure out where\what the error is in the code. File "<string>", line 1, in <module>. Name = "" Desc = "" Gender = "" Race = "" # Prompt u...
167
votes
10answers
152284 views

Using both Python 2.x and Python 3.x in IPython Notebook

I use IPython notebooks and would like to be able to select to create a 2.x or 3.x python notebook in IPython. I initially had Anaconda. With Anaconda a global environment variable had to be changed...
332
votes
9answers
496093 views

How do I use raw_input in Python 3

import sys print (sys.platform) print (2 ** 100) raw_input( ) I am using Python 3.1 and can't get the raw_input to "freeze" the dos pop-up. The book I'm reading is for 2.5 and I'm using 3.1 What sh...
9
votes
2answers
3171 views

Nested List Indices

I have experienced some problem by using a nested list in Python in the code shown bleow. Basically, I have a 2D list contains all 0 values, I want to update the list value in a loop. However, Pytho...

Previous Next