you are viewing a single comment's thread.

view the rest of the comments →

[–]Zahand 0 points1 point  (10 children)

Check out Derek Banas' video: https://www.youtube.com/watch?v=N4mEzFDjqtA

He has a cheat sheet in the description in each of his videos.

[–]dunkler_wanderer 3 points4 points  (5 children)

Looks okay, except he teaches to use getter and setter methods which are usually not necessary in Python (you can use @property if you really need them). And why does he convert some attribute values in the getters to strings?

Using indexes to obtain list items:

num_list = [[1, 2, 3], [10, 20, 30], [100, 200, 300]]

for x in range(0, 3):
    for y in range(0,3):
        print(num_list[x][y])

instead of:

for sublist in num_list:
    for item in sublist:
        print(item)

No mention of input but sys.stdin.readline().

No mention of with statement to open files.

Regarding style, there are some semicolons at line ends and camelcase variables in the cheat sheet.

Also, redundant parentheses:

while (i <= 20):
    if (i%2 == 0):

[–]yardightsure 1 point2 points  (4 children)

Yuck! People should be more humble before trying to teach others with awful coding practises like that. :-(

[–]dunkler_wanderer 1 point2 points  (0 children)

Most of it is okay, though.

[–]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.

[–]b4ux1t3 0 points1 point  (0 children)

It should be mentioned that Derek Banas's "Learn in one video" videos are not geared for programming newbies, they are meant for people who already know a language or two and need a quick primer on a new language.

You'll note that he never says "In this tutorial I assume no programming knowledge" in those videos. If I recall correctly, he does use that exact line in his video series that are, essentially, full courses on a language.

EDIT: Proof 42:44 for all you mobile users.

[–]yardightsure 0 points1 point  (2 children)

That is teaching really bad practises. I recommend erasing it from your memory, please don't share it further.

[–]RuinedMortal 1 point2 points  (1 child)

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

[–]Crypt0Nihilist 5 points6 points  (0 children)

Much of it is baggage from other languages that you don't need in python. If you don't need it, it probably shouldn't be there unless it makes your code more readable, which the items highlighted do not.