--
http://mail.python.org/mailman/listinfo/python-list
When I'm feeling too lazy to do imports while moving large blocks of
code, I use this little hack. It lets me proceed with checking whether
the move does what I wanted and at the end I fix the imports and remove
the try/except wrapper. I think it would achieve your desired result
and not have an im
Mike Meyer wrote:
> Shane Hathaway <[EMAIL PROTECTED]> writes:
>
(snip)
>
>>What's really got me down is the level of effort required to move code
>>between modules. After I cut 100 lines from a 500 line module and
>>paste them to a different 500 line module, I have to examine every
>>import in
Shane Hathaway wrote:
> Thoughts?
I have two reasons to dislike it:
1. It's a language change. Others have pointed out that you can achieve
the same without a language change; it would be easy to write
name_expr = _import.re.compile('[a-zA-Z]+')
2. In the form in which you have written it,
Shane Hathaway wrote:
> Do you have any ideas on how to improve the process of maintaining
> imports? Benji's suggestion of jumping around doesn't work for moving
> code and it interrupts my train of thought. Sprinkling the code with
> import statements causes a speed penalty and a lot of clutter
Shane Hathaway wrote:
> Mike Meyer wrote:
> > Shane Hathaway <[EMAIL PROTECTED]> writes:
> >>I'd like a way to import modules at the point where I need the
> >>functionality, rather than remember to import ahead of time. This
> >>might eliminate a step in my coding process. Currently, my process
On Sat, 10 Dec 2005 19:40:08 -0800, Robert Kern <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> Are you willing to type a one-letter prefix to your .re ? E.g.,
>>
>> >>> class I(object):
>> ... def __getattr__(self, attr):
>> ... return __import__(attr)
>
>[snip]
>
>> There a
Bengt Richter wrote:
> Are you willing to type a one-letter prefix to your .re ? E.g.,
>
> >>> class I(object):
> ... def __getattr__(self, attr):
> ... return __import__(attr)
[snip]
> There are special caveats re imports in threads, but otherwise
> I don't know of any significa
On Fri, 09 Dec 2005 12:24:59 -0700, Shane Hathaway <[EMAIL PROTECTED]> wrote:
>Here's a heretical idea.
>
>I'd like a way to import modules at the point where I need the
>functionality, rather than remember to import ahead of time. This might
>eliminate a step in my coding process. Currently,
Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Shane Hathaway wrote:
>
> > Let me fully elaborate the heresy I'm suggesting: I am talking about
> > inline imports on every other line of code. The obvious implementation
> > would drop performance by a double digit percentage.
>
> Module importing
Shane Hathaway wrote:
> Let me fully elaborate the heresy I'm suggesting: I am talking about
> inline imports on every other line of code. The obvious implementation
> would drop performance by a double digit percentage.
Module importing is already idempotent. If you try to import an
already
Benji York wrote:
> Shane Hathaway wrote:
>
>> Benji York wrote:
>>
>>> OK, good. You won't have to worry about that. :)
>>
>>
>> You didn't give a reason for disliking it.
>
>
> Oh, I don't particularly dislike it. I hadn't come up with a reason to
> like or dislike it, other than a predilec
Shane Hathaway wrote:
> Benji York wrote:
>
>> OK, good. You won't have to worry about that. :)
>
> You didn't give a reason for disliking it.
Oh, I don't particularly dislike it. I hadn't come up with a reason to
like or dislike it, other than a predilection for the status quo.
--
Benji York
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Xavier Morel wrote:
>> Shane Hathaway wrote:
>>
>>>Thoughts?
>> >>> import re; name_expr = re.compile('[a-zA-Z]+')
>> >>> name_expr
>> <_sre.SRE_Pattern object at 0x00F9D338>
>> >>>
>> the import statement can be called anywhere in the code, why woul
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Let me fully elaborate the heresy I'm suggesting: I am talking about
> inline imports on every other line of code. The obvious
> implementation would drop performance by a double digit percentage.
No, it wouldn't. The semantics of import pretty much re
Steve Holden wrote:
> Shane Hathaway wrote:
>> The structure of the Java language makes this relatively easy.
>>
>
> And there's so much more busywork in Java that it's probably worth
> automating. See
>
>http://www.artima.com/weblogs/viewpost.jsp?thread=42242
Agreed. Here's my take on Ja
Shane Hathaway wrote:
> Benji York wrote:
>
>>Why not: 1) jump to the top of the file when you need to do an import
>>(1G in Vim), 2) add the import, 3) jump back to where you were (Ctrl-o
>>in Vim) and keep coding. This isn't Vim specific, I suspect all decent
>>editors have similar capabilit
Kent Johnson wrote:
> Shane Hathaway wrote:
>>I'm talking about using imports *everywhere*. The penalty would be
>>appreciable.
>
>
> Have you tried it?
>
> D:\Projects\CB>python -m timeit -s "import re" "import re"
> 100 loops, best of 3: 1.36 usec per loop
>
> You need a lot of imports
Shane Hathaway wrote:
> Do you have any ideas on how to improve the process of maintaining
> imports? Benji's suggestion of jumping around doesn't work for moving
> code and it interrupts my train of thought. Sprinkling the code with
> import statements causes a speed penalty and a lot of clutter
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>> Shane Hathaway <[EMAIL PROTECTED]> writes:
>>>That syntax is verbose and avoided by most coders because of the speed
>>>penalty.
>> What speed penalty? "import re" is a cheap operation, every time but
>> the first one in a program.
>
Shane Hathaway wrote:
> Mike Meyer wrote:
>
>> Shane Hathaway <[EMAIL PROTECTED]> writes:
>>
>>> That syntax is verbose and avoided by most coders because of the speed
>>> penalty.
>>
>> What speed penalty? "import re" is a cheap operation, every time but
>> the first one in a program.
>
> I'm ta
Mike Meyer wrote:
> Shane Hathaway <[EMAIL PROTECTED]> writes:
>>That syntax is verbose and avoided by most coders because of the speed
>>penalty.
>
>
> What speed penalty? "import re" is a cheap operation, every time but
> the first one in a program.
I'm talking about using imports *everywhere*
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Xavier Morel wrote:
>> Shane Hathaway wrote:
>>>Thoughts?
>> >>> import re; name_expr = re.compile('[a-zA-Z]+')
>> >>> name_expr
>> <_sre.SRE_Pattern object at 0x00F9D338>
>> >>>
>> the import statement can be called anywhere in the code, why would
>>
Mike Meyer wrote:
> Shane Hathaway <[EMAIL PROTECTED]> writes:
>>I'd like a way to import modules at the point where I need the
>>functionality, rather than remember to import ahead of time. This
>>might eliminate a step in my coding process. Currently, my process is
>>I change code and later sca
Xavier Morel wrote:
> Shane Hathaway wrote:
>
>>Thoughts?
>
>
> >>> import re; name_expr = re.compile('[a-zA-Z]+')
> >>> name_expr
> <_sre.SRE_Pattern object at 0x00F9D338>
> >>>
>
> the import statement can be called anywhere in the code, why would you
> add strange syntactic sugar that do
Shane Hathaway wrote:
> I'd like a way to import modules at the point where I need the
> functionality, rather than remember to import ahead of time.
You can already do this; import statements don't have to be at the top
of a Python script. This proposal is pretty much dead on arrival.
--
Er
Shane Hathaway <[EMAIL PROTECTED]> writes:
> Here's a heretical idea.
Not really.
> I'd like a way to import modules at the point where I need the
> functionality, rather than remember to import ahead of time. This
> might eliminate a step in my coding process. Currently, my process is
> I chan
Shane Hathaway wrote:
> Thoughts?
>>> import re; name_expr = re.compile('[a-zA-Z]+')
>>> name_expr
<_sre.SRE_Pattern object at 0x00F9D338>
>>>
the import statement can be called anywhere in the code, why would you
add strange syntactic sugar that doesn't actually bring anything?
--
http://ma
Benji York wrote:
> OK, good. You won't have to worry about that. :)
You didn't give a reason for disliking it.
Shane
--
http://mail.python.org/mailman/listinfo/python-list
Shane Hathaway wrote:
> Benji York wrote:
[a quicker, but still manual, way to handle adding new imports]
> That's something the computer should do for me. It's busywork.
> Eclipse practically eliminates this busywork when I'm writing Java
> code: if I autocomplete a name, it also quietly adds
Benji York wrote:
> Why not: 1) jump to the top of the file when you need to do an import
> (1G in Vim), 2) add the import, 3) jump back to where you were (Ctrl-o
> in Vim) and keep coding. This isn't Vim specific, I suspect all decent
> editors have similar capabilities (I know Emacs does). T
Shane Hathaway wrote:
> I'd like a way to import modules at the point where I need the
> functionality, rather than remember to import ahead of time. This might
> eliminate a step in my coding process. Currently, my process is I
> change code and later scan my changes to make matching changes
32 matches
Mail list logo