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
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
[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.
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
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
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
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
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
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
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
-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
[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
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
>
>
-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
[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
-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
> "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
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
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
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
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
21 matches
Mail list logo