Question regarding naming convention

michael spam.trap at btinternet.com
Tue Jul 1 14:28:02 CEST 2003


Sean Ross wrote:
> http://www.python.org/doc/essays/styleguide.html#names

<snip quote>

Yeah, thanks for the quote. Unfortunately, this still leaves me with 
syntax that's a bit unfriendly. Taking the StringIO class as an example, 
I can either write:

     import StringIO
     s = StringIO.StringIO()

or:

     from StringIO import StringIO
     s = StringIO()

Both of the above seem to overcomplicate the syntax. Of the two, I 
prefer the second, but I'm sure I've read on c.l.py that the 
from..import.. version is not a preferred way of doing things.

Is there no way to write a class, such that the statement:

     import MyClass

would dynamically import the MyClass class from MyClass.py ?

It just surprises me that there isn't a neater way around this, as 
Python seems to encapsulate most everything else in a simple way.

Thanks,

Michael.





More information about the Python-list mailing list