[python-uk] Library for (undirected) graphs in Python?
Jonathan Hartley
tartley at tartley.com
Tue Jan 25 12:25:50 CET 2011
On 25/01/2011 02:08, Alec Battles wrote:
>> Now, maybe the solution is to use Python 2.6 instead. Before starting
>> working on my project I knew nothing about Python, which is one of the
>> reasons I chose it over, say, Java, and thought that the 3rd version is the
>> way to go. Is it not?
> afaik, the main difference is the assert statement. i'm sure there are
> other differences, but as someone who rarely uses python that
> 'deeply', you should be fine if you start off on python 2.
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> http://mail.python.org/mailman/listinfo/python-uk
Personally I think there's *heaps* of new stuff in Python 3.0, 3.1 and
3.2 which really make the language nicer to use. Some of these have been
backported to Python 2.7, where it could be done without breaking
compatibility, but if you can use version 3, then you really should!
Some new features of Python 3.0 that I care about:
* Many things that used to return lists now return iterators. e.g.
dict.keys(), map, filter, range, zip, etc. These can be used just the
same in 95% of your code, and are much more memory efficient, especially
when chaining them.
* Set literals: {1, 2, 3} creates a set.
* Division is now sane: 5/2 returns 2.5, instead of 2. Use operator '//'
for the old behaviour.
* extended iterable unpacking: stuff like this just works: "a, b,
*everything_else = my_list"
* packages and modules in the standard library have been moved and
renamed to be more consistent and comprehensible.
* Ordering comparisons (<, >=, etc) are now sane - comparing different
types will now in the general case raise a type error, unless they are
specific pairs of types which make sense to compare (e.g. int to float)
* Dict comprehensions: Mirroring list comprehensions, create dicts using
"{k: v for k, v in stuff}"
* no more confusion between int and long - everything is now an int
(which behaves much like the old 'long' did)
* no more confusion between old- and new-style classes, everything is
now a new-style class
Jonathan
--
Jonathan Hartley Made of meat. http://tartley.com
tartley at tartley.com +44 7737 062 225 twitter/skype: tartley
More information about the python-uk
mailing list