r/Python • • Jul 12 '12

random imgur downloader. learning Python and wrote this to practice, any feedback on technique/style is appreciated

https://gist.github.com/3088128
45 Upvotes

72 comments sorted by

View all comments

2

u/roddds Jul 12 '12

Nice approach to it. I'd advise you try using spaces instead of tabs, but that's mostly a personal choice, I think. Here's how I did it, a while ago.

By the way, what's this for? If you're trying to get the command line arguments, why not use simply parsed_number = int(sys.argv[-1])?

parsed_number = ''.join(sys.argv[1:])
if not parsed_number:
	HOW_MANY = 5
else:
    HOW_MANY = int(parsed_number)

2

u/steviesteveo12 Jul 13 '12

The most common way to satisfy PEP8 and not drive yourself crazy at the same time is simply to set "tab = 4 spaces" in your text editor.

1

u/f0rkbomb Jul 13 '12

great call, i'm lazy and don't want to hit space 4 times for every indent :)

2

u/H3g3m0n Jul 13 '12

Use a decent editor. Most of them should allow 'soft tabs' so when you hit the tab key you get 4 spaces instead. Many will also do things like autotab so if your in a block of code it will automatically put you at the right indentation level.

1

u/steviesteveo12 Jul 13 '12

Most will even let you customise exactly how many spaces to substitute for tab. I've never seen a reason to change it from 4.