[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

importing module conflict

Matias Surdi

1/10/2008 12:33:00 PM

Hi,

Suppose I've a module named "urllib" and from it I need to import the
urllib module from the python standart library.

¿how can I do this?

The problem I found is that when I do:


import urrlib

The imported module is itself, and not the one from the stdlib.

Any idea?

Thanks a lot.

3 Answers

Bruno Desthuilliers

1/10/2008 1:05:00 PM

0

Matias Surdi a écrit :
> Hi,
>
> Suppose I've a module named "urllib" and from it I need to import the
> urllib module from the python standart library.
>
> ¿how can I do this?
>
> The problem I found is that when I do:
>
>
> import urrlib
>
> The imported module is itself, and not the one from the stdlib.
>
> Any idea?

Yes : don't name your module 'urllib' !-)

Else, you can play with sys.path before importing the std urllib, etc,
etc...

Ben Finney

1/10/2008 1:20:00 PM

0

Matias Surdi <matiassurdi@gmail.com> writes:

> Suppose I've a module named "urllib" and from it I need to import
> the urllib module from the python standart library.

What you want is the "absolute import" behaviour, described in PEP 328
<URL:http://www.python.org/peps/pep-032... and implemented in
Python 2.5 <URL:http://docs.python.org/whatsnew/pep-32....

--
\ "The way to build large Python applications is to componentize |
`\ and loosely-couple the hell out of everything." -- Aahz |
_o__) |
Ben Finney

Matias Surdi

1/10/2008 3:12:00 PM

0

Ben Finney escribió:
> Matias Surdi <matiassurdi@gmail.com> writes:
>
>> Suppose I've a module named "urllib" and from it I need to import
>> the urllib module from the python standart library.
>
> What you want is the "absolute import" behaviour, described in PEP 328
> <URL:http://www.python.org/peps/pep-032... and implemented in
> Python 2.5 <URL:http://docs.python.org/whatsnew/pep-32....
>

Thanks a lot.

That was exactly what I was looking for.Excellent.