Namespace question

Chris M chris.monsanto at gmail.com
Wed Oct 31 16:12:24 EDT 2007


On Oct 31, 10:06 am, Frank Aune <Frank.A... at broadpark.no> wrote:
> Hello,
>
> Is it possible writing custom modules named the same as modules in the
> standard library, which in turn use the same module from the standard
> library?
>
> Say I want my application to have a random.py module, which in turn must
> import the standard library random.py module also, to get hold of the randint
> function for example.
>
> My attempts so far only causes my random.py to import itself instead of the
> standard library random.py
>
> Receipt for disaster? :)
>
> Regards,
> Frank

Read up on absolute imports (In Python 2.5, from __future__ import
absolute_imports) is required. You can load your random.py with
import .random, which can import the standard lib with import random.




More information about the Python-list mailing list