Beautiful Python

Gekitsuu gekitsuu at gmail.com
Tue Dec 27 13:02:17 EST 2005


That is part of what I was asking but I was also hoping to hear the
common wisdom so to speak. When I posted I had considered the idea for
a bit and the situations people have mentioned were similar to the
scenario I came up with as a good time to break such a rule. My
hypothetical situation was as follows. I'm writing a new generic SQL
module and I want to make it so I only call the appropriate module for
the type of SQL server I'm talking to. Then it would make sense to
load, for instance, the mysql module and not the sqlite, postgresql,
etc. But should it be part of the PEP to include what to do in a
situation were it makes sense to break the rule? Something like if an
import needs to be in a location other than the top of the module
because of conditions determining if it will be loaded, there should be
a comment at the top of the module where the other imports are declared
stating what is loaded, why it is elsewhere, and a general idea of
where it is. Something like..

# import mysql_module
# This is imported in the useMysql() function and is only imported if
needed

I looked for a way to make a suggestion to the PEP but it wasn't
obvious to me from the link how you'd do it.




More information about the Python-list mailing list