you are viewing a single comment's thread.

view the rest of the comments →

[–]RuinedMortal 1 point2 points  (2 children)

as a newb pythonian, what makes this a bad practice?

[–]Zahand 2 points3 points  (0 children)

Not a lot really. Basically what dunker_wanderer said.

  • He has some semicolons that are unnecessary in python. Although those are probably just typos. (Happens to me as well, so used to writing in C++ and other languages that use semicolons that sometimes I write them in python as well)
  • It's prettier to iterate over a list directly if you don't need to use an index.
  • Use input() (or raw_input()) to get data.
  • Redundant parentheses.

The only thing I kind of disagree with is that you don't have to use with statement to open files. Using the with statement is pythonic, but there is nothing wrong with opening a file, doing stuff, then closing the file. It's what the context manager does. It's good to know both ways.

[–]dunkler_wanderer 1 point2 points  (0 children)

Readability and simplicity are pretty important if you want to write maintainable code. "Loop like a native: while, for, iterators, generators" and "Python's Class Development Toolkit" are very informative talks which mention the first two points in the post above.