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
239
votes
7 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
  • 47,222
  • 25
  • 87
  • 129
189
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
  • 2,189
  • 3
  • 15
  • 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
  • 551
  • 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,987
  • 10
  • 43
  • 68
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
  • 5,009
  • 10
  • 34
  • 52
30
votes
7 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
  • 24,139
  • 32
  • 108
  • 180
29
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
  • 47,222
  • 25
  • 87
  • 129
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…
24
votes
7 answers

How do you make an installer for your python program?

I'm new to python, but I was thinking about making a program with python to give to my friends. They don't know much about computers so if I asked them to install python by them selves they wouldn't be able to do it, but what if I could make an…
Malcolm2608
  • 249
  • 1
  • 2
  • 4
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
  • 385
  • 1
  • 4
  • 10
20
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
  • 588
  • 1
  • 5
  • 17
18
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,817
  • 2
  • 29
  • 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
  • 941
  • 12
  • 15
12
votes
5 answers

Combining inplace filtering and the setting of encoding in the fileinput module

I am attempting to use the fileinput module's inplace filtering feature to rewrite an input file in place. Needed to set encoding (both for read and write) to latin-1 and attempted to pass openhook=fileinput.hook_encoded('latin-1') to…
iruvar
  • 22,736
  • 7
  • 53
  • 82
1
2 3
22 23