Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
a witch
Jan 12, 2017

I would avoid it if it would cause any friction with someone else who might use your code.

Adbot
ADBOT LOVES YOU

a witch
Jan 12, 2017

a witch posted:

I would avoid it if it would cause any friction with someone else who might use your code.

Please also note that "someone else" might be you in six months.

a witch
Jan 12, 2017

If someone was typing "unused" instead of "_" I would immediately assume they were inexperienced with Python.

Practicality beats purity and all that.

a witch
Jan 12, 2017

Well, what do you mean when you say "elegant"? What don't you like about the code you posted ?

a witch
Jan 12, 2017

Look into the logging module, it has a decent tutorial.

If you want to write messages to the console and a file at the same time, you'll want a logger with a FileHandler and a StreamHandler attached.

E: I'm on a phone so can't type code, here's the basic tutorial https://docs.python.org/3/howto/logging.html

a witch fucked around with this message at 17:43 on Mar 1, 2017

Adbot
ADBOT LOVES YOU

a witch
Jan 12, 2017

huhu posted:

I want the function to return false. However, with that code I'm getting "NameError: global name 'MaxRetryError' is not defined".

Is MaxRetryError the type of the exception being thrown? You will have to import it to make the name visible.

  • Locked thread