Re: Proposal: Inline Import

2005-12-19 Thread en.karpachov
-- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: Inline Import

2005-12-12 Thread adam
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

Re: Proposal: Inline Import

2005-12-12 Thread bruno at modulix
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

Re: Proposal: Inline Import

2005-12-11 Thread Martin v. Löwis
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,

Re: Proposal: Inline Import

2005-12-11 Thread Martin v. Löwis
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

Re: Proposal: Inline Import

2005-12-11 Thread bonono
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

Re: Proposal: Inline Import

2005-12-11 Thread Bengt Richter
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

Re: Proposal: Inline Import

2005-12-10 Thread Robert Kern
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

Re: Proposal: Inline Import

2005-12-10 Thread Bengt Richter
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,

Re: Proposal: Inline Import

2005-12-10 Thread Alex Martelli
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

Re: Proposal: Inline Import

2005-12-10 Thread Erik Max Francis
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

Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-10 Thread Benji York
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

Re: Proposal: Inline Import

2005-12-10 Thread Thomas Heller
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

Re: Proposal: Inline Import

2005-12-10 Thread Mike Meyer
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

Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-10 Thread Steve Holden
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

Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-09 Thread Stephen Prinster
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

Re: Proposal: Inline Import

2005-12-09 Thread Mike Meyer
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. >

Re: Proposal: Inline Import

2005-12-09 Thread Kent Johnson
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

Re: Proposal: Inline Import

2005-12-09 Thread Shane Hathaway
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*

Re: Proposal: Inline Import

2005-12-09 Thread Mike Meyer
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 >>

Re: Proposal: Inline Import

2005-12-09 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-09 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-09 Thread Erik Max Francis
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

Re: Proposal: Inline Import

2005-12-09 Thread Mike Meyer
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

Re: Proposal: Inline Import

2005-12-09 Thread Xavier Morel
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

Re: Proposal: Inline Import

2005-12-09 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-09 Thread Benji York
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

Re: Proposal: Inline Import

2005-12-09 Thread Shane Hathaway
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

Re: Proposal: Inline Import

2005-12-09 Thread Benji York
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