[Tutor] loading modules only when needed and PEP 008
timmichelsen at gmx-topmail.de
Thu Mar 20 00:59:03 CET 2008
> When I do this sort of thing I like
> to move my imports into my functions/methods.
Would this then be compliant with the style recommendations?
> The 'main' code then
> conditionally calls the function/method. All the code in the
> function safely assumes that the import has been done but code in the
> calling function assumes the import hasn't been done.
Yes, this should a the solution.
> And as we are talking about style, note that your else: pass isn't
> really necessary but it does make it explicitly clear that you are
> choosing not to do anything if the plot_data isn't 'yes'.
Ok, so I already got some style here, at least...
> Are those
> tabs you're using? Four spaces are preferred, according to the
> style guide.
I always use 4 spaces. This sometimes leads to confusions when working
with the same editor on text files that rely tabs but this is another
Thanks very much for your fast response!
More information about the Tutor