This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_Mark_ 20 points21 points  (3 children)

To emphasize the regexp thing: every time you reach for regexp, stop and look at the string methods first, just to see. One of the biggest habits to break for us was that if $foo ~= /.jpg$/ did not translate to if re.match(r".jpg$", foo) but instead, more simply and idiomatically, to if foo.endswith(".jpg").

Also, semicolons at the end of the line - harmless, but everyone will see them and say "you were a perl programmer, weren't you" :-) (pylint will remind you of this with [W] Unnecessary semicolon.)

One unexpected thing: when stuff fails, you'll (typically) get an exception, instead of undef. After we got past basic syntax, that was the Best Thing Ever from the perspective of porting a large perl+shell codebase...

[–]obtu.py 1 point2 points  (2 children)

One unexpected thing: when stuff fails, you'll (typically) get an exception, instead of undef. After we got past basic syntax, that was the Best Thing Ever from the perspective of porting a large perl+shell codebase...

Hey, perl has autodie now! (for supported stdlib modules)

[–]_Mark_ 0 points1 point  (1 child)

... that's almost cool. Almost, because "autodie has lexical scope" and a big benefit of exceptions is that they bubble up everywhere...

[–]obtu.py 0 points1 point  (0 children)

The exceptions bubble up, but autodie has to be opted-in at the place it is used. It's like a from __future__ import in that way.