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.

1148 questions
18
votes
6 answers

Python 3.3 source code setup: modules were not found: _lzma _sqlite3 _tkinter

I am trying to set up the compiled version of CPython, on Ubuntu 12.04, by following the python developer guide. Even after installing the dependent packages lzma and sqlite3, build fails indicating that the dependent modules were not found. Exact…
NaveenBabuE
  • 706
  • 4
  • 7
  • 26
17
votes
5 answers

How to delete everything after a certain character in a string?

How would I delete everything after a certain character of a string in python? For example I have a string containing a file path and some extra characters. How would I delete everything after .zip? I've tried rsplit and split , but neither included…
ThatGuyJay
  • 307
  • 2
  • 5
  • 13
17
votes
3 answers

Passing the library path as a command line argument to setup.py

modules = [Extension("MyLibrary", src, language = "c++", extra_compile_args=["-fopenmp", "-std=c++11", "-DNOLOG4CXX"], # log4cxx is not currently used …
Alexey
  • 379
  • 1
  • 3
  • 10
16
votes
2 answers

Writing a .CSV file in Python that works for both Python 2.7+ and Python 3.3+ in Windows

EDIT: I put it in the title, but just realized I didn't mention it in the body. This seems to be specific to Windows. I'm having a hard time writing output using the csv Python module in a script that works with both Python 2.7 and 3.3. First try…
Tamerz
  • 897
  • 1
  • 10
  • 25
16
votes
3 answers

regex (vim) for print ... to print(...) for python2 to python3

This post is helpful only if you have strings inside of the print command. Now I have tons of sourcecode with a statement such as print milk,butter which should be formatted to print(milk,butter) And capturing the end of the line with \n was not…
varantir
  • 6,624
  • 6
  • 36
  • 57
15
votes
2 answers

Meaning of end='' in the statement print("\t",end='')?

This is the function for printing all values in a nested list (taken from Head first with Python). def printall(the_list, level): for x in the_list: if isinstance(x, list): printall(x, level=level + 1) else: …
Rajath
  • 1,306
  • 2
  • 10
  • 18
15
votes
1 answer

Python - except (OSError, e) - No longer working in 3.3.3?

The following have worked throughout Python 3.X and is not broke in 3.3.3, can't find what's changed in the docs. import os def pid_alive(pid): pid = int(pid) if pid < 0: return False try: os.kill(pid, 0) except…
Torxed
  • 22,866
  • 14
  • 82
  • 131
15
votes
2 answers

Catching TimeoutExpired exception in Python 3.3

Sorry if this is a newbie question, but I'm having trouble catching the timeout exception in Python 3.3, running on win7, e.g. import subprocess try: subprocess.call("ping -t localhost", timeout=3) except TimeoutExpired: print("Timeout…
Sarge Gerbode
  • 153
  • 1
  • 4
15
votes
1 answer

uwsgi python3 plugin doesn't work

i compiled uwsgi with make and it's successfully done,and now i decide to run my django1.5 site with python3.3 . i've checked for the doc (http://projects.unbit.it/uwsgi/wiki/Guide4Packagers) and set up python3.3 development headers through apt-get…
Bill Phun
  • 155
  • 1
  • 1
  • 5
14
votes
3 answers

Using True/False as keys - how/why does this work?

I am comfortable using this simple syntax for initializing a dictionary d = {'a':'Apple','b':'Bat'}; Today, while reading a page, I encountered this weird piece of code {True:0, False:1}[True]; I was wondering why/how that could work? True and…
Patt Mehta
  • 4,110
  • 1
  • 23
  • 47
14
votes
1 answer

Why is print so slow in Python 3.3 and how can I fix it?

I just tried to run this script with Python 3.3. Unfortunately it's about twice as slow than with Python 2.7. #!/usr/bin/env python from sys import stdin def main(): for line in stdin: try: fields = line.split('"', 6) …
Timo
  • 308
  • 2
  • 10
14
votes
4 answers

How to write a dictionary into an existing file?

Let's say I have a dictionary and I want to write it into an existing file. How can I do so without losing anything that could potentially already exist in the file? What I was thinking of is doing the following: def write_report(r, filename): …
user300
  • 445
  • 2
  • 11
  • 20
14
votes
2 answers

Python unittest data provider

I am trying to create a unit test in python that has a data provider. As the unittest library does not support this nativity, I'm using the unittest_data_provider package. I'm getting an error, and am not sure where it is coming from (I'm new to…
Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79
14
votes
2 answers

Does PEP 412 make __slots__ redundant?

PEP 412, implemented in Python 3.3, introduces improved handling of attribute dictionaries, effectively reducing the memory footprint of class instances. __slots__ was designed for the same purpose, so is there any point in using __slots__ any…
aquavitae
  • 17,414
  • 11
  • 63
  • 106
13
votes
3 answers

Python - convert set-cookies response to dict of cookies

How to convert the response['set-cookie'] output string from httplib2 response like "cookie1=xxxyyyzzz;Path=/;Expires=Wed, 03-Feb-2015 08:03:12 GMT;Secure;HttpOnly, cookie2=abcdef;Path=/;Secure" to {'cookie1':'xxxyyyzzz','cookies2':'abcdef'}
Ahmed Daif
  • 379
  • 3
  • 12