[Tutor] using dynamic import statements

Chris Hare chare at labr.net
Mon Jul 9 14:10:55 CEST 2012


Thanks all for the ideas.  I wanted to have my own error messages printed for the user - something a little more meaningful than the standard error. 

Thanks for the advice - very helpful!

On Jul 9, 2012, at 6:12 AM, Alan Gauld wrote:

> On 09/07/12 10:19, Kwpolska wrote:
>> Why does this bloody ML want me to respond to the last person instead
>> of tutor at python.org?
> 
> Because that's how it, along with many other mailing lists, works.
> If it helps, think of it as you receiving a mail from the sender and CCd to the list. Therefore hitting reply sends to the person who sent the mail and ReplyAll goes to everyone. Seems logical to me! :-)
> It allows me to choose to reply to the OP only or to the group, I use both depending on the nature of my reply. (About 80% of my replies go to the everyone.) But some prefer it differently... :-)
> 
>>> Why not the more usual:
>>> 
>>> import sys, os, imp, stat,    \
>>>        re, webbrowser, Image, \
>>>        StringIO, shutil, datetime
>> 
>> Why not the more standard:
>> import sys
>> import os
>> and so on?  http://www.python.org/dev/peps/pep-0008/#imports
> 
> Indeed but the OP seemed to want to remove duplicate coding so I assumed that he included using multiple imports.
> 
> Personally I'd probably code the above as:
> 
> import sys, os, shutil, stat, datetime
> import re, StringIO
> import webbrowser,
> import Image,
> import imp
> 
> Which groups things into roughly related categories - system,
> strings, other...
> 
> OTOH I ignore large chunks of Pep 8 because I find its style harder to read than the one I'm used to. But then, I'm not contributing to the standard library etc... Style is largely a matter of taste.
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list