sensiblecodeio / scraperwiki-python

ScraperWiki Python library for scraping and saving data
https://scraperwiki.com
BSD 2-Clause "Simplified" License
160 stars 69 forks source link

Import should not have side-effects #34

Closed fawkesley closed 11 years ago

fawkesley commented 11 years ago

On further thought, it's devious that just importing something should have a side effect. An explicit activation call would be more polite.

Not least because it breaks my PEP8 checker due to it being an "unused" import!

It's very non-standard (I have never seen an import "doing" stuff before) and therefore it's a trap for the unwary. I can imagine the "fun" that will ensue when someone carelessly copy / pastes a load of imports, "knowing" that it's safe to do so.

pwaller commented 11 years ago

Okay, I agree. How about we call it setup(), and write from scraperwiki.runlog import setup; setup() ?

drj11 commented 11 years ago

Here's a good example of the rant I wanted paul to find yesterday: http://www.plope.com/Members/chrism/import_time_side_effects

Memorable quote: "keep it to yourself and wash your hands afterwards".

fawkesley commented 11 years ago

Nice rant, like it. S'long as I can alternatively run import scraperwiki; scraperwiki.runlog.setup() then I'm happy with @pwaller's proposed solution.