[Tutor] using dynamic import statements

wolfrage8765 at gmail.com wolfrage8765 at gmail.com
Mon Jul 9 14:47:41 CEST 2012


Might I recommend you use the logging module that is part of core
Python rather than rolling your own if Debug. I found the logging
module made growing my logging across multiple applications so easy!
http://docs.python.org/library/logging.html

On Mon, Jul 9, 2012 at 2:10 PM, Chris Hare <chare at labr.net> wrote:
>
> 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
>
> _______________________________________________
> 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