Fwd: Namespace question

Andrii V. Mishkovskyi mishok13 at gmail.com
Wed Oct 31 15:19:25 CET 2007


2007/10/31, Frank Aune <Frank.Aune at broadpark.no>:
> 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? :)

You mean something like this:

>>>import random
>>>def foo():
...    print '42'
>>>random.randit = foo
>>>random.randit()
42

am I right?
--
Wbr, Andrii Mishkovskyi.

He's got a heart of a little child, and he keeps it in a jar on his desk.



More information about the Python-list mailing list