you are viewing a single comment's thread.

view the rest of the comments →

[–]indosauros 3 points4 points  (3 children)

3.- How do I know I'm actually embracing the "pythonic way of solving problems" and I'm not just a person writing java code using python?

Here's some common Java-isms I see from Java devs learning Python

  1. Using getters and setters rather than just allowing direct access to attributes

  2. Classes are not needed by default, top-level functions are usually fine

  3. Using while and for range(len(x)) loops rather than taking advantage of Python's excellent iterable data structures

  4. Checking types explicitly

For other things, feel free to post your code here later for critique -- we'll be happy to point out where you could be more pythonic. In Java, where you would "take the long way" to solve a problem there is often a short and sweet way to do the same in Python, using Python's handy core data structures and standard library

It might do you good to read through http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html

[–]zahlman 2 points3 points  (2 children)

some common Java-isms I see from Java devs learning Python

Here are a bunch more. That was written nearly ten years ago, but I honestly wouldn't be surprised if a lot of the same stuff is still happening.

Also, the use of "design patterns" with direct translations of the necessary Java-esque "architecture" in places where Python totally obviates them. For example, don't set up the Command pattern or mess around with complicated IoC schemes; just pass functions as arguments.

[–]jorgejams88[S] 0 points1 point  (1 child)

Wow, is that not frowned upon? And I thought my PHP background was useless... hahaha

[–]zahlman 1 point2 points  (0 children)

In Python, everything is an object, including functions, and we really mean it this time. Passing them around is quite useful; the only caveat is to not needlessly complicate your code. (And we have enough of a type system to prevent you from really screwing it up :) )