Questions tagged [python-3.3]

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

Python is a dynamically and strongly typed programming language whose design philosophy emphasizes code readability. Two significantly different versions of Python (2 and 3) are in use.

Use this tag if your question is specifically about . If your question applies to Python in general, use the tag . If your question applies to Python 3.x but not to Python 2, use the tag . If you aren't sure, tag your question and mention which version you're using in the body of your question.

Python 3.3 was released on September 29, 2012, and has a number of new features:

Syntax:

  • The yield from expression for generator delegation is introduced.
  • The u'unicode' syntax (which disappeared in Python 3.0) returns.

New standard library modules:

  • faulthandler - helps debugging low-level crashes.
  • ipaddress - high-level objects representing IP addresses and masks.
  • lzma - compress data using the XZ / LZMA algorithm.
  • unittest.mock - replace parts of your system under test with mock objects.
  • venv - Python virtual environments, as in the popular virtualenv package.

... as well as a reworked I/O exception hierarchy, rewritten import machinery based on importlib, more compact unicode strings, and more compact attribute dictionaries.

The C Accelerator for the decimal module has also been significantly improved, as has the unicode handling in the email module.

Finally, for security reasons, hash randomization is now switched on by default.

1158 questions
352
votes
13 answers

Python 3: ImportError "No Module named Setuptools"

I'm having troubles with installing packages in Python 3. I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get: importerror "No Module named Setuptools" I have no idea what to do…
user1994934
  • 3,523
  • 2
  • 12
  • 8
133
votes
14 answers

How to install pip for Python 3 on Mac OS X?

OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which…
Travis Griggs
  • 18,930
  • 17
  • 76
  • 137
119
votes
3 answers

hash function in Python 3.3 returns different results between sessions

I've implemented a BloomFilter in python 3.3, and got different results every session. Drilling down this weird behavior got me to the internal hash() function - it returns different hash values for the same string every session. Example: >>>…
redlus
  • 1,431
  • 2
  • 10
  • 16
79
votes
4 answers

Division in Python 2.7. and 3.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: >>> 20/15 1.3333333333333333 in Python 2: >>> 20/15 1 Isn't this a modulo actually?
Erzsebet
  • 813
  • 1
  • 7
  • 7
76
votes
4 answers

AttributeError: 'module' object has no attribute 'request'

When I run the following code in Python 3.3: import urllib tempfile = urllib.request.urlopen("http://yahoo.com") I get the following error: I did this too to verify: What am I doing wrong?
Pruthvi Raj
  • 2,898
  • 1
  • 20
  • 36
76
votes
4 answers

Import arbitrary python source file. (Python 3.3+)

How can I import an arbitrary python source file (whose filename could contain any characters, and does not always ends with .py) in Python 3.3+? I used imp.load_module as follows: >>> import imp >>> path = '/tmp/a-b.txt' >>> with open(path, 'U') as…
falsetru
  • 314,667
  • 49
  • 610
  • 551
76
votes
5 answers

Writing to CSV with Python adds blank lines

I am trying to write to CSV file but there are blank rows in between. How can I remove the blank rows? import csv b = open('test.csv', 'w') a = csv.writer(b) data = [['Me', 'You'],\ ['293', '219'],\ ['54',…
user2031063
  • 937
  • 1
  • 7
  • 10
63
votes
9 answers

How to use 2to3 properly for python?

I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it.
GhostFrag1
  • 845
  • 2
  • 11
  • 19
54
votes
4 answers

Removing non numeric characters from a string

I have been given the task to remove all non numeric characters including spaces from a either text file or string and then print the new result next to the old characters for example: Before: sd67637 8 After: 676378 As i am a beginner i do not…
Obcure
  • 861
  • 3
  • 10
  • 22
45
votes
2 answers

Why is dictionary ordering non-deterministic?

I recently switched from Python 2.7 to Python 3.3, and it seems that while in Python 2 the ordering of dictionary keys was arbitrary but consistent, in Python 3 the ordering of the keys of a dictionary obtained with e.g. vars() appears…
Anaphory
  • 5,456
  • 4
  • 33
  • 60
39
votes
3 answers

Is there official guide for Python 3.x release lifecycle?

I just noticed Python 3.2 was removed from the drop down selector in Python Docs. I have a framework using Python 3.3, so I'd like to know when it'll share the same fate, and move to a newer version before this happens. Is there an official guide on…
Jovik
  • 2,948
  • 4
  • 19
  • 23
39
votes
5 answers

Iterate over OrderedDict in Python

I have the following OrderedDict: OrderedDict([('r', 1), ('s', 1), ('a', 1), ('n', 1), ('y', 1)]) This actually presents a frequency of a letter in a word. In the first step - I would take the last two elements to create a union tuple like this; …
Dejell
  • 12,840
  • 37
  • 129
  • 217
38
votes
1 answer

Python3 - reload() can not be called on __import__ object?

Ok so for a number of reasons, I've been using s = __import__('parse') for the longest time in Python2, now I sorta need to being my transitions to Python3 for certain projects (mainly due to SSL). But there's no reload() equivilant in Python3 as…
Torxed
  • 19,906
  • 13
  • 73
  • 114
36
votes
5 answers

Random word generator- Python

So i'm basically working on a project where the computer takes a word from a list of words and jumbles it up for the user. there's only one problem: I don't want to keep having to write tons of words in the list, so i'm wondering if there's a way to…
Infamouslyuseless
  • 742
  • 2
  • 7
  • 15
35
votes
12 answers

Can't use chrome driver for Selenium

I'm having trouble using the Chrome driver for Selenium. I have the chromedriver downloaded and saved to C:\Chrome: driver = webdriver.Chrome(executable_path="C:/Chrome/") Using that gives me the following error: Traceback (most recent call last): …
user2540748
1
2 3
77 78