Re: [Python-Dev] Syntax suggestion for imports

2008-01-04 Thread Toby Dickenson
Raymond Hettinger wrote: > [Jeroen Ruigrok van der Werven] >> On the Trac project using your grep gives me 203 lines, if we take ~2 >> lines for and after in consideration, it still means 203/5 ~= 40 >> occurences. > > Thanks. I'm more curious about the content of those lines. Does the > propos

Re: [Python-Dev] Syntax suggestion for imports

2008-01-04 Thread Scott Dial
Jeroen Ruigrok van der Werven wrote: > [Half tongue-in-cheek] > > -On [20080104 08:04], Drew Perttula ([EMAIL PROTECTED]) wrote: >> When I saw the OP, I actually wondered why people whose codebases are >> "filled" with the same try/except block over and over hadn't just >> written their own impo

Re: [Python-Dev] Syntax suggestion for imports

2008-01-04 Thread Jeroen Ruigrok van der Werven
[Half tongue-in-cheek] -On [20080104 08:04], Drew Perttula ([EMAIL PROTECTED]) wrote: >When I saw the OP, I actually wondered why people whose codebases are >"filled" with the same try/except block over and over hadn't just >written their own import_with_alternative function in the first place.

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Drew Perttula
Simon Percivall wrote: > Wouldn't a (stdlib) function suffice in the cases where this is needed? > > ET = import_with_alternative("xml.etree.CElementTree", "cElementTree", > "elementtree.ElementTree") > > It's not as elegant, but it's easier than status quo. > I like that direction a lot bett

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Tony Nelson
At 3:20 PM +0100 1/3/08, Christian Heimes wrote: >Raymond Hettinger wrote: >> How about a new, simpler syntax: ... >> * import readline or emptymodule > >The syntax idea has a nice ring to it, except for the last idea. As >others have already said, the name emptymodule is too magic. > >The readlin

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Facundo Batista
2008/1/2, Raymond Hettinger <[EMAIL PROTECTED]>: > How about a new, simpler syntax: > > * import threading or dummy_threading as threading > > * import xml.etree.CElementTree or cElementTree or elementree.ElementTree as > ET > > * from cStringIO or StringIO import StringIO > > * import readline o

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Aahz
On Wed, Jan 02, 2008, Raymond Hettinger wrote: > > Before posting, I ran some scans of our code base at work and found > plenty of examples (mostly third-party cmodules vs python equivalents > and a few that searched for similar functionality in different > packages). It might be helpful if others

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Ron Adam
Raymond Hettinger wrote: > The standard library, my personal code, third-party packages, and my > employer's code base are filled with examples of the following pattern: > > try: >import threading > except ImportError: >import dummy_threading as threading > > try: > import xml.etre

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Simon Percivall
On 3 jan 2008, at 02.19, Raymond Hettinger wrote: > How about a new, simpler syntax: > > * import threading or dummy_threading as threading > > * import xml.etree.CElementTree or cElementTree or > elementree.ElementTree as ET > > * from cStringIO or StringIO import StringIO > > * import readline

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Christian Heimes
Raymond Hettinger wrote: > How about a new, simpler syntax: > > * import threading or dummy_threading as threading > > * import xml.etree.CElementTree or cElementTree or elementree.ElementTree as > ET > > * from cStringIO or StringIO import StringIO > > * import readline or emptymodule The s

Re: [Python-Dev] Syntax suggestion for imports

2008-01-03 Thread Jeroen Ruigrok van der Werven
-On [20080103 08:53], Raymond Hettinger ([EMAIL PROTECTED]) wrote: >Thanks. I'm more curious about the content of those lines. Does the >proposed syntax help, does the need go away in Py3.0, what is the typical >pattern? These are some of the examples, I've tried to reduce them to specific use

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Raymond Hettinger
[Jeroen Ruigrok van der Werven] > On the Trac project using your grep gives me 203 lines, if we take ~2 lines > for and after in consideration, it still means 203/5 ~= 40 occurences. Thanks. I'm more curious about the content of those lines. Does the proposed syntax help, does the need go away

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Michael Urman
On Jan 2, 2008 7:19 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > How about a new, simpler syntax: > > * import threading or dummy_threading as threading > > * import xml.etree.CElementTree or cElementTree or elementree.ElementTree as > ET > > * from cStringIO or StringIO import StringIO > >

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Jeroen Ruigrok van der Werven
-On [20080103 04:29], Raymond Hettinger ([EMAIL PROTECTED]) wrote: >Am curious to see what everyone else finds in their own code searches. On the Trac project using your grep gives me 203 lines, if we take ~2 lines for and after in consideration, it still means 203/5 ~= 40 occurences. -- Jeroen

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Raymond Hettinger
[GvR] > I wonder if your perceived need for this isn't skewed by your > working within the core? The need was perceived by a colleague who does not work on the core. My own skew was in the opposite direction -- I've seen the pattern so often that I'm oblivious to it. Before posting, I ran some

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jan 2, 2008, at 9:08 PM, Aahz wrote: > On Wed, Jan 02, 2008, Raymond Hettinger wrote: >> >> The standard library, my personal code, third-party packages, and >> my employer's code base are filled with examples of the following >> pattern: >> >> try

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Terry Jones
> "John" == John Barham <[EMAIL PROTECTED]> writes: >> * import readline or emptymodule John> This I find more problematic as "emptymodule" seems too magical. John> Even now any code that wants to use a module that might not have been John> successfully imported needs to check if that's the c

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Aahz
On Wed, Jan 02, 2008, Raymond Hettinger wrote: > > The standard library, my personal code, third-party packages, and > my employer's code base are filled with examples of the following > pattern: > > try: >import threading > except ImportError: >import dummy_threading as threading > > How a

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Guido van Rossum
I wonder if your perceived need for this isn't skewed by your working within the core? Also, in 3.0 many of the use cases should go away -- e.g. cStringIO vs, StringIO, etc., as we switch the stdlib to having a single "public" name for an API which automatically replaces or augments itself with th

Re: [Python-Dev] Syntax suggestion for imports

2008-01-02 Thread John Barham
Raymond Hettinger wrote: > How about a new, simpler syntax: > > * import threading or dummy_threading as threading > * import xml.etree.CElementTree or cElementTree or elementree.ElementTree as > ET > * from cStringIO or StringIO import StringIO These all look good to me. The "short circuit" im

[Python-Dev] Syntax suggestion for imports

2008-01-02 Thread Raymond Hettinger
The standard library, my personal code, third-party packages, and my employer's code base are filled with examples of the following pattern: try: import threading except ImportError: import dummy_threading as threading try: import xml.etree.cElementTree as ET except ImportError: tr