[Tutor] Bad time to get into Python?

Andre Roberge andre.roberge at gmail.com
Mon Feb 4 20:35:03 CET 2008


On Feb 4, 2008 1:26 PM, Eric Brunson <brunson at brunson.com> wrote:
>
>  Dotan Cohen wrote:
>
>  Like I mentioned earlier, I'm more interested in my learning being 3.x
> compatible, not my scripts. If all I need to do is learn to print("")
> instead of print"" then that's fine.
>
>
>  Basically, if you follow a few simple rules you'll avoid 99% of 3.0
> incompatibilities:
>
>  1) Always use:
>
> print( "like it was a function" )
>  rather than:
>  print "like it was a statement"
>  2) Always use:
>
> class NewStyle( object ):
>  rather than:
>  class OldStyle():
>  3) Never try to be clever with side effects of internal implementations of
> language
>
>
>  Pretty much everything else you learn in 2.5 will be applicable in 3.0.
>
>  (Others on the list, please feel free to extend my rules with things that
> you feel will be important)
>

No, this seems about right.  For the record, I have attempted an
experiment to see if I could make my program (Crunchy) run under 2.4,
2.5, 3.0a1 and 3.0a2 simulatenously. This is a program with about 40
different modules, using a number of other modules from the standard
library.   I managed to get everything working almost perfectly using
3.0a1 and about 95% under 3.0a2 - I am convinced that, with a bit more
effort, I could have gotten everything working under all 4 Python
versions.

I have complete unit tests for about 20 of the modules I wrote and it
was very easy to make them work (with no errors) under all 4 Python
versions.   There are only a small number of places where the
transition from 2.x to 3.0 is going to be tricky - and most of these
are related to dealings with strings and unicode characters, something
not everyone has to deal with.

So, based on actual experience, I am confident in telling anyone
interested that they should not fear learning Python 2.x (thinking it
might become obsolete) as 99% of your code (excluding print
statements) is probably going to work unchanged.

André


More information about the Tutor mailing list