Questions tagged [python-3.2]

For issues that are specific to Python 3.2. Use the more generic [python] and [python-3.x] tags where possible.

Although Python 3 itself is ready for primetime and stable, many of the popular libraries have not yet been ported.

See also Python2 or Python3.

Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed for 3.x only.

It has been superseded by Python 3.3.


Tagging recommendation:

Use the tag for all Python related questions. If you believe your question includes issues specific to the incompatible Python 2.x or Python 3.x, in addition to the main tag, use or . If you believe your question may be even more specific, you can include a version specific tag such as .

336 questions
232
votes
7 answers

How to know/change current directory in Python shell?

I am using Python 3.2 on Windows 7. When I open the Python shell, how can I know what the current directory is and how can I change it to another directory where my modules are?
astay13
  • 6,137
  • 8
  • 36
  • 52
212
votes
5 answers

NameError: name 'reduce' is not defined in Python

I'm using Python 3.2. Tried this: xor = lambda x,y: (x+y)%2 l = reduce(xor, [1,2,3,4]) And got the following error: l = reduce(xor, [1,2,3,4]) NameError: name 'reduce' is not defined Tried printing reduce into interactive console - got this…
Sergey
  • 39,828
  • 24
  • 80
  • 122
135
votes
3 answers

Remove and Replace Printed items

I was wondering if it was possible to remove items you have printed in Python - not from the Python GUI, but from the command prompt. e.g. a = 0 for x in range (0,3): a = a + 1 b = ("Loading" + "." * a) print (a) so it…
Alex
  • 1,649
  • 3
  • 13
  • 9
42
votes
5 answers

Python dictionary.keys() error

I am trying to use the .keys() and instead of getting a list of the keys like always have in the past. However I get this. b = { 'video':0, 'music':23 } k = b.keys() print( k[0] ) >>>TypeError: 'dict_keys' object does not support indexing print(…
tokageKitayama
  • 523
  • 1
  • 4
  • 5
39
votes
6 answers

How to install matplotlib with Python3.2

I installed python3.2 in ubuntu (the default edition is not deleted), and I follow the steps in here However when i use python3.2 setup.py install I got: "error: command 'gcc' failed with exit status 1", "src/ft2font.cpp:2224:29: error: ‘Int’ is…
itsuper7
  • 735
  • 1
  • 6
  • 12
33
votes
1 answer

python 3.2 error saying urllib.parse.urlencode() is not defined

I am trying to use urllib.parse.urlencode() method in one of my scripts. import urllib #!/usr/bin/python3.2 import urllib data = urllib.parse.urlencode({'type': 'device_code','client_id': 150792241632891}) It was working before but now I get…
Rakesh
  • 3,507
  • 8
  • 40
  • 63
30
votes
4 answers

UnicodeEncodeError: 'ascii' codec can't encode character in position 0: ordinal not in range(128)

I'm working on a Python script that uses the scissor character (9986 - ✂) and I'm trying to port my code to Mac, but I'm running into this error. The scissor character shows up fine when run from IDLE (Python 3.2.5 - OS X 10.4.11 iBook G4 PPC) and…
RPiAwesomeness
  • 4,319
  • 6
  • 30
  • 46
28
votes
2 answers

Python center string using format specifier

I have a string called message. message = "Hello, welcome!\nThis is some text that should be centered!" And I'm trying to center it for a default Terminal window, i.e. of 80 width, with this statement: print('{:^80}'.format(message)) Which…
25
votes
8 answers

PyEval_InitThreads in Python 3: How/when to call it? (the saga continues ad nauseam)

Basically there seems to be massive confusion/ambiguity over when exactly PyEval_InitThreads() is supposed to be called, and what accompanying API calls are needed. The official Python documentation is unfortunately very ambiguous. There are…
Channel72
  • 22,459
  • 30
  • 97
  • 168
23
votes
2 answers

Usage of pickle.dump in Python

I'm trying to learn how to use the pickle module in Python: import pickle x = 123 f = open('data.txt','w') pickle.dump(x,f) Here's what I get: Traceback (most recent call last): File "D:\python\test.py", line 5, in
Sergey
  • 39,828
  • 24
  • 80
  • 122
23
votes
3 answers

Why do I get "ImportError: cannot import name find_spec" when I start a new Django project?

I'm learning Python in tandem with Django. I initially installed Python 3 on my machine (Debian Wheezy), but read about possible conflicts and removed it with some difficulty. Now I'm using virtualenv and installed python3 within the env and Django…
Axolotl
  • 369
  • 1
  • 3
  • 9
18
votes
1 answer

Python3 AttributeError: 'list' object has no attribute 'clear'

I am working on a Linux machine with Python version 3.2.3. Whenever I try to do list.clear() I get an exception >>> l = [1, 2, 3, 4, 5, 6, 7] >>> l.clear() Traceback (most recent call last): File "", line 1, in AttributeError:…
oranJess
  • 546
  • 1
  • 5
  • 15
16
votes
2 answers

Hashing an immutable dictionary in Python

Short version: What's the best hashing algorithm for a multiset implemented as a dictionary of unordered items? I'm trying to hash an immutable multiset (which is a bag or multiset in other languages: like a mathematical set except that it can hold…
wkschwartz
  • 3,346
  • 1
  • 24
  • 33
14
votes
2 answers

Python 'string' % [1, 2, 3] doesn't raise TypeError

Is the exact behavior of the str.__mod__ documented? These two lines of code works just as expected: >>> 'My number is: %s.' % 123 'My number is: 123.' >>> 'My list is: %s.' % [1, 2, 3] 'My list is: [1, 2, 3].' This line behaves as expected…
darw
  • 489
  • 6
  • 12
12
votes
1 answer

SQLAlchemy won't update my database

I'm making a Pyramid app using SQLAlchemy-0.7.8. I'm using 64bit Python3.2. The question is, why does the following function not commit anything to the database? def create_card(sText,sCard): """ create a wildcard instance if all is well…
Sheena
  • 13,328
  • 11
  • 65
  • 103
1
2 3
22 23