Python for Java programmer

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Fri Dec 14 16:54:27 EST 2007


Nirav Thaker a écrit :
> Yo Group,
 >
> I'm excited to learn Python as new language coming year, I consider
> myself good Java developer and, not so unusually, with very limited
> experience with dynamic programming languages such as Python or Ruby.

Then you'll probably have to unlearn a few things...

> I have started with basics at http://docs.python.org, but I'm more
> interested in learning philosophies in programming dynamically typed
> languages, I really want to get rid of those Enterprisely weird Java
> techniques.

Fine !-)

A good start is of course the now famous "Python is not Java" article:
http://dirtsimple.org/2004/12/python-is-not-java.html

Also FWIW, the dynamic part is not restricted to typing. You can 
dynamically modify class or instance attribute set (including methods), 
hook into lookup rules or class creation, dynamically create functions, 
classes or modules, etc... Syntax errors set aside, everything happens 
at run time.

> I'm looking for good resources and a better technique to learn Python,
> would appreciate book references or URLs for them (Google explodes me
> with info. and I don't really have time to read all that).

Having a decent knowledge of Python's object model (with special
attention to the lookup rules - and how you can hook into -, the
operators overloading and other __magic__ methods, and of course
metaclasses) may help - since everything in Python is an object
(including modules, classes, functions etc). Once you understand what's
a Python object and how it works, you have a chance to start thinking
otherwise about how to structure your programs. Most of the relevant doc
is here:

http://docs.python.org/ref/objects.html
http://docs.python.org/ref/node33.html
http://python.org/doc/newstyle/
http://docs.python.org/ref/specialnames.html

Sadly, there isn't AFAIK any in-depth material exposing these features 
and how they can used in real-world. But anyway:

> Also, I'm
> looking forward to hack some framework or library written in Python to
> get a good deal of exposure to language and class library, 

Note that the Python libraries (standard and thir-part) are not 
necessarily that much class-oriented. With dynamic typing, you don't 
need deep class hierarchies. And with everything being an object, you 
end up thinking more in term of objects than in terms of classes.

> So it would
> be great if anyone would suggest such framework as well.

Here are a couple packages I learned (and I'm still learning) from:

- SqlAlchemy : a hi-level interface to RDBMS, including (but not 
restricted to) an ORM layer,
- Elixir: a declarative layer on top of sqlAlchmy's ORM features,
- FormEncode : a conversion/validation lib, mostly used for the web but
usable for any outer-world/your-program data exchange. The "declarative"
API it's built upon is really worth reading if you want to see Python's
power in action, but beware, there are really things in it one should
not show to childrens !-)

HTH. And welcome onboard.



More information about the Python-list mailing list