On May 10, 7:45 am, Spider <[EMAIL PROTECTED]> wrote:
> Python guru Fredrik Lundh has an article 
> athttp://effbot.org/zone/import-confusion.htm
> in which he discusses use of the import statement. He says,
> essentially :
>    "import X" should be the normal method of importing
>    "from X import *" is bad practice
>    "from X import Y" is sometime ok
> That seems to be the general agreement in the python world.
>
> Some of the sample pylons applications and documentation use the "from
> X import *" format. Maybe we should consider changing that over time.
>
> For me as a newbie to Pylons, one of the drawbacks to the "from X
> import *" method is that imported objects end up in the global
> namespace, which makes it difficult to work out where a object comes
> from (made more complex since Pylons is a "glue" framework). I think
> I'd find Pylons code easier to read if objects were coded as X.<name>
> rather than just plain <name>.

I agree that this is newbie-unfriendly (and exacerbated in Pylons) and
should be discouraged in the future as Pylons becomes less a hacker's
framework and more widely used.

In fact, I undo this * manually as much as is practical in all my
Pylons code and import only to the module level.

import formencode.validators
int_validator = formencode.validators.Int()

davep


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to