471,337 Members | 882 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Namespace question

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
Oct 31 '07 #1
1 1054
On Oct 31, 10:06 am, Frank Aune <Frank.A...@broadpark.nowrote:
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.

Oct 31 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John L. Clark | last post: by
25 posts views Thread by kj | last post: by
3 posts views Thread by Mike Dickens | last post: by
6 posts views Thread by clinton__bill | last post: by
2 posts views Thread by Tony Johansson | last post: by
20 posts views Thread by Patrick Guio | last post: by
4 posts views Thread by Programatix | last post: by
32 posts views Thread by toolmaster | last post: by
3 posts views Thread by CrazyJohn | last post: by
17 posts views Thread by Peng Yu | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.