Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Absolute imports in Python 2.x?

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


dickinsm at gmail

Feb 2, 2010, 4:24 AM

Post #1 of 8 (1118 views)
Permalink
Absolute imports in Python 2.x?

What are the current plans for PEP 328 (the absolute imports PEP) in Python 2.x?

The PEP says:

"""In Python 2.6, any import statement that results in an
intra-package import will raise DeprecationWarning (this also applies
to from <> import that fails to use the relative import syntax). In
Python 2.7, import will always be an absolute import (and the
__future__ directive will no longer be needed)."""

As far as I can tell, there's no DeprecationWarning in 2.6.

I'm wondering whether this decision was revised at some point (I
wasn't able to find anything by searching the archives), or whether
the DeprecationWarning just got forgotten about.

If the latter, should the DeprecationWarning be introduced in 2.7?

Mark
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


eric at trueblade

Feb 2, 2010, 5:20 AM

Post #2 of 8 (1056 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

Mark Dickinson wrote:
> What are the current plans for PEP 328 (the absolute imports PEP) in Python 2.x?
>
> The PEP says:
>
> """In Python 2.6, any import statement that results in an
> intra-package import will raise DeprecationWarning (this also applies
> to from <> import that fails to use the relative import syntax). In
> Python 2.7, import will always be an absolute import (and the
> __future__ directive will no longer be needed)."""
>
> As far as I can tell, there's no DeprecationWarning in 2.6.
>
> I'm wondering whether this decision was revised at some point (I
> wasn't able to find anything by searching the archives), or whether
> the DeprecationWarning just got forgotten about.
>
> If the latter, should the DeprecationWarning be introduced in 2.7?

Not sure about the decision one way or the other. But if there's not
going to be a 2.8, and if DeprecationWarnings are off by default anyway,
I'm not sure it makes any sense to add a DeprecationWarning in 2.7. From
my quick testing, -3 doesn't warn about relative imports. Perhaps a
better strategy in this particular case is to make -3 give that warning?

Aside:
We really need a better way to track things we need to do in the next
version of Python so things like this don't fall through the cracks. We
added a 3.2 version tag before 3.1 was released so that we could add a
few "remember to do this in 3.2" issues dealing with deprecations.
Perhaps it's time to add a 3.3 version tag? I don't think we should add
a 2.8 tag, that would give false hope.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


brett at python

Feb 2, 2010, 12:33 PM

Post #3 of 8 (1044 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

On Tue, Feb 2, 2010 at 05:20, Eric Smith <eric [at] trueblade> wrote:
> Mark Dickinson wrote:
>>
>> What are the current plans for PEP 328 (the absolute imports PEP) in
>> Python 2.x?
>>
>> The PEP says:
>>
>> """In Python 2.6, any import statement that results in an
>> intra-package import will raise DeprecationWarning (this also applies
>> to from <> import that fails to use the relative import syntax). In
>> Python 2.7, import will always be an absolute import (and the
>> __future__ directive will no longer be needed)."""
>>
>> As far as I can tell, there's no DeprecationWarning in 2.6.
>>
>> I'm wondering whether this decision was revised at some point (I
>> wasn't able to find anything by searching the archives), or whether
>> the DeprecationWarning just got forgotten about.
>>
>> If the latter, should the DeprecationWarning be introduced in 2.7?
>
> Not sure about the decision one way or the other. But if there's not going
> to be a 2.8, and if DeprecationWarnings are off by default anyway, I'm not
> sure it makes any sense to add a DeprecationWarning in 2.7. From my quick
> testing, -3 doesn't warn about relative imports. Perhaps a better strategy
> in this particular case is to make -3 give that warning?

+1 on the -3 option.

>
> Aside:
> We really need a better way to track things we need to do in the next
> version of Python so things like this don't fall through the cracks. We
> added a 3.2 version tag before 3.1 was released so that we could add a few
> "remember to do this in 3.2" issues dealing with deprecations. Perhaps it's
> time to add a 3.3 version tag? I don't think we should add a 2.8 tag, that
> would give false hope.

It should definitely be added by the alpha, but I don't know if now is
a bit early. Regardless, I looked at the tracker and the code there
doesn't seem to match what has been pushed to bugs.python.org (3.2 is
not listed and 2.4 still is). Martin, is that correct? Otherwise why
does initial_data.py not match what's live?

-Brett
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


dickinsm at gmail

Feb 3, 2010, 5:45 AM

Post #4 of 8 (1025 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

On Tue, Feb 2, 2010 at 1:20 PM, Eric Smith <eric [at] trueblade> wrote:
> Mark Dickinson wrote:
>>
>> What are the current plans for PEP 328 (the absolute imports PEP) in
>> Python 2.x?
> Not sure about the decision one way or the other. But if there's not going
> to be a 2.8, and if DeprecationWarnings are off by default anyway, I'm not
> sure it makes any sense to add a DeprecationWarning in 2.7. From my quick
> testing, -3 doesn't warn about relative imports. Perhaps a better strategy
> in this particular case is to make -3 give that warning?

Well, if there's any possibility at all of a Python 2.8 (and it's not
clear to me whether this has been absolutely ruled out) then it's
conceivable that the people producing it might want to make imports
absolute for 2.8, perhaps as part of an effort to minimize 2.x -> 3.x
differences. A DeprecationWarning in 2.7 would help with that.

On the other hand, it's easy enough to use the 'from __future__
import' in 2.x code.

At any rate, it's clear that there should be a -3 warning. I'll open an issue.

> Aside:
> We really need a better way to track things we need to do in the next
> version of Python so things like this don't fall through the cracks. We
> added a 3.2 version tag before 3.1 was released so that we could add a few
> "remember to do this in 3.2" issues dealing with deprecations. Perhaps it's
> time to add a 3.3 version tag? I don't think we should add a 2.8 tag, that
> would give false hope.

Agreed on all points. Would it be terrible to simply add all relevant
tags the moment a PEP is accepted? E.g., if a PEP pronounces some
particular behaviour deprecated in Python 3.3 and removed in Python
3.4, then corresponding release blockers for 3.3 and 3.4 could be
opened as part of implementing the PEP.

Mark
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


ncoghlan at gmail

Feb 3, 2010, 5:57 AM

Post #5 of 8 (1024 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

Mark Dickinson wrote:
> Agreed on all points. Would it be terrible to simply add all relevant
> tags the moment a PEP is accepted? E.g., if a PEP pronounces some
> particular behaviour deprecated in Python 3.3 and removed in Python
> 3.4, then corresponding release blockers for 3.3 and 3.4 could be
> opened as part of implementing the PEP.

That strikes me as a really good idea, since the tracker already serves
as a global "to do" list for the project (heck, I've used it as a
semi-private to do list at times, when I've thought of things I need to
fix when I don't have the roundtuits free to actually fix them).

Cheers,
Nick.

--
Nick Coghlan | ncoghlan [at] gmail | Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


eric at trueblade

Feb 3, 2010, 6:03 AM

Post #6 of 8 (1025 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

Mark Dickinson wrote:
> On Tue, Feb 2, 2010 at 1:20 PM, Eric Smith <eric [at] trueblade> wrote:
>> Mark Dickinson wrote:
>>> What are the current plans for PEP 328 (the absolute imports PEP) in
>>> Python 2.x?
>> Not sure about the decision one way or the other. But if there's not going
>> to be a 2.8, and if DeprecationWarnings are off by default anyway, I'm not
>> sure it makes any sense to add a DeprecationWarning in 2.7. From my quick
>> testing, -3 doesn't warn about relative imports. Perhaps a better strategy
>> in this particular case is to make -3 give that warning?
>
> Well, if there's any possibility at all of a Python 2.8 (and it's not
> clear to me whether this has been absolutely ruled out) then it's
> conceivable that the people producing it might want to make imports
> absolute for 2.8, perhaps as part of an effort to minimize 2.x -> 3.x
> differences. A DeprecationWarning in 2.7 would help with that.

Certainly the DeprecationWarning couldn't hurt.

> On the other hand, it's easy enough to use the 'from __future__
> import' in 2.x code.
>
> At any rate, it's clear that there should be a -3 warning. I'll open an issue.

Thanks. I'll look at implementing it (and the DeprecationWarning) at PyCon.

> Agreed on all points. Would it be terrible to simply add all relevant
> tags the moment a PEP is accepted? E.g., if a PEP pronounces some
> particular behaviour deprecated in Python 3.3 and removed in Python
> 3.4, then corresponding release blockers for 3.3 and 3.4 could be
> opened as part of implementing the PEP.

+1.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


brett at python

Feb 3, 2010, 12:43 PM

Post #7 of 8 (1006 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

On Wed, Feb 3, 2010 at 05:57, Nick Coghlan <ncoghlan [at] gmail> wrote:
> Mark Dickinson wrote:
>> Agreed on all points.  Would it be terrible to simply add all relevant
>> tags the moment a PEP is accepted?  E.g., if a PEP pronounces some
>> particular behaviour deprecated in Python 3.3 and removed in Python
>> 3.4, then corresponding release blockers for 3.3 and 3.4 could be
>> opened as part of implementing the PEP.
>
> That strikes me as a really good idea, since the tracker already serves
> as a global "to do" list for the project (heck, I've used it as a
> semi-private to do list at times, when I've thought of things I need to
> fix when I don't have the roundtuits free to actually fix them).
>

And with all the proper dependency linkage it will make it obvious
when the PEP is fully implemented. +1 from me.

-Brett
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


brett at python

Feb 6, 2010, 1:50 PM

Post #8 of 8 (847 views)
Permalink
Re: Absolute imports in Python 2.x? [In reply to]

On Wed, Feb 3, 2010 at 05:57, Nick Coghlan <ncoghlan [at] gmail> wrote:
> Mark Dickinson wrote:
>> Agreed on all points.  Would it be terrible to simply add all relevant
>> tags the moment a PEP is accepted?  E.g., if a PEP pronounces some
>> particular behaviour deprecated in Python 3.3 and removed in Python
>> 3.4, then corresponding release blockers for 3.3 and 3.4 could be
>> opened as part of implementing the PEP.
>
> That strikes me as a really good idea, since the tracker already serves
> as a global "to do" list for the project (heck, I've used it as a
> semi-private to do list at times, when I've thought of things I need to
> fix when I don't have the roundtuits free to actually fix them).

Martin filled me in on how to add new versions, so when we need a new
one people can let me know.

-Brett


>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan [at] gmail   |   Brisbane, Australia
> ---------------------------------------------------------------
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/brett%40python.org
>
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.