How to import a standard module in source file with same name?
Christos TZOTZIOY Georgiou
tzot at sil-tec.gr
Mon Aug 25 03:50:08 EDT 2003
On 24 Aug 2003 11:17:13 -0700, rumours say that sdhyok at yahoo.com
(sdhyok) might have written:
>In addition, you can't import the standard datetime with the following
>script in vp/datetime.py.
>
>Daehyok
>
>
>> import datetime
>> import vp.datetime
>> vp.datetime.datetime = datetime
Like I said (including the sentence before the code),
>>Or you can do (in the importing module,
>>possibly your main program):
>>
>>import datetime
>>import vp.datetime
>>vp.datetime.datetime = datetime
Obviously I wasn't clear. If module A imports vp.datetime, then the
code above should be entered in your A module. For this to work,
vp.datetime should just define functions and/or classes (since there
would be no vp.datetime.datetime attribute while vp.datetime is
imported).
This all is theoretical since you agreed with Michael Peuser that having
a module with the same name as one of the standard library is not
"elegant".
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
More information about the Python-list
mailing list