How to import a standard module in source file with same name?
sdhyok
sdhyok at yahoo.com
Sun Aug 24 14:20:24 EDT 2003
Thanks, Michael.
If I insist the same name,
is there any technical solution for it?
Daehyok
"Michael Peuser" <mpeuser at web.de> wrote in message news:<bi9jpa$3av$07$1 at news.t-online.com>...
> "Christos TZOTZIOY Georgiou" <tzot at sil-tec.gr> schrieb im Newsbeitrag
> news:gbigkvcgl5upje1qe14r8mqe2unsec6vmh at 4ax.com...
> > On 23 Aug 2003 21:52:11 -0700, rumours say that sdhyok at yahoo.com
> > (sdhyok) might have written:
> >
> > [snip of problem description as per the subject]
> >
> > >Under the condition that the absolute path to the standard module
> > >is variable in different machines
> > >(so, imp.find_module may not be a solution),
> > >is there an elegant way to solve this problem?
> >
> > You might try changing the case... call it DateTime for example; there
> > must be some magic in the C code (if you work on Windows) that matches
> > in a case-sensitive way. Or you can do (in the importing module,
> > possibly your main program):
> >
> > import datetime
> > import vp.datetime
> > vp.datetime.datetime = datetime
> > --
>
> It i sgeneraqlly not a good idea to call a package _exactly_ as an already
> existing one, even if you want to superseed it. Because of Windows' case
> insensitivity for files for folders such a distinction should also be
> considered bad style. So the solution could be:
>
> User of package:
>
> import newPackage as Package
> or
> from newPackage import *
>
>
> Implementation of package:
>
> import Package as oldPackage
>
> and qulifying in case of use of oldPackage accordingly.
>
>
> Kindly
> Michael P
More information about the Python-list
mailing list