Re: better lambda support in the future?

2004-12-17 Thread Terry Reedy
"Dima Dorfman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Both languages compile all three functions (f and the two versions of > g) once and choose which g to return at run-time. *If* OCaml or any other 'other' language compiles the two versions of g to the final and complet

Re: A rational proposal

2004-12-17 Thread Fredrik Lundh
Mike Meyer wrote: > Last-Modified: $Date: 2003/09/22 04:51:50 $ > Created: 16-Dec-2004 > Post-History: 30-Aug-2002 playing with the time machine? -- http://mail.python.org/mailman/listinfo/python-list

Re: Cool object trick

2004-12-17 Thread Fredrik Lundh
Carl Banks wrote: > For example: > > .def lookup_reference(key): > . > .return Bunch(title=title,author=author,...) > > The code quickly and easily returns a object with the desired keys. > The code that calls this function would access the return values > directly, like th

Re: BASIC vs Python

2004-12-17 Thread Andrew Dalke
Adam DePrince wrote: > Sure you could have. There is nothing I hate more than the dumbing down > of technology for the sake of families with children. Having kids > doesn't make you dumb, it only makes you feel that way when you realize > how quickly your children's technical prowess with outstri

Re: expression form of one-to-many dict?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: >> The map form, in this case, parses instantly in my brain, while the listcomp >> certainly takes a few cycles. And note that I'm not talking about the typing >> conciseness, but about the effort for my brain. But maybe I'm just wired >> funny :) > > Well, different at lea

Re: lambdas vs functions: a bytecode question

2004-12-17 Thread Fredrik Lundh
Fernando Perez wrote: > there are a couple of threads on lambdas today, which got me curious about > their differences as far as bytecode goes: > > planck[~]|2> lf=lambda x: x**2 > planck[~]|3> def ff(x): return x**2 > |.> > planck[~]|4> import dis > planck[~]|5> dis.dis(lf) > 1

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Nick Coghlan
Nick Coghlan wrote: Chris Lasher wrote: Hello, I really like the finditer() method of the re module. I'm having difficulty at the moment, however, because finditer() still creates a callable-iterator oject, even when no match is found. This is undesirable in cases where I would like to circumvent e

Re: A completely silly question

2004-12-17 Thread Fredrik Lundh
>> Well, but that's true as well for getchar() (at least in many cases of >> interactive input and line buffering), so in that respect I do think >> it's a fairly direct replacement, depending on how the OP was going to >> use getchar() in the application. > > The OP said "wait for a single charact

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Nick Coghlan
Chris Lasher wrote: Hello, I really like the finditer() method of the re module. I'm having difficulty at the moment, however, because finditer() still creates a callable-iterator oject, even when no match is found. This is undesirable in cases where I would like to circumvent execution of code mea

Re: hello

2004-12-17 Thread Steve Holden
matthew wrote: testing ... Please use alt.test for that. regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list

Re: better lambda support in the future?

2004-12-17 Thread Steve Holden
Harlin Seritt wrote: Jp Calderone wrote: [...] I am quite envious of those who can easily come up with names for any function. Perhaps you lot should go a bit easier on the rest of us and let us keep our crutches. After all, Python is a language which is supposed to make me more productive by l

Re: better lambda support in the future?

2004-12-17 Thread Terry Reedy
"Jp Calderone" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote: >> What puzzles me is 1) why some people apparently think anonymity is >> good -- >> is it really that hard to name non-trivial functions? > R

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
Nick Coghlan wrote: Although, it looks like new-style classes currently don't apply this rule - you get the default hash implementation from object no matter what: That may be a bug rather than a feature :) And indeed it is: http://sourceforge.net/tracker/index.php?func=detail&aid=660098&group_id

Re: BASIC vs Python

2004-12-17 Thread Gregor Horvath
Thomas Bartkus wrote: > On what basis do you think the mechanics of producing a working > language are easier because the language is interpreted. Because: Type code Run code. VB6 goes a step further: Run Code Type Code That means that you can set a breakpoint. While the debugger sto

Re: Why no list heritable type?

2004-12-17 Thread Steve Holden
Jp Calderone wrote: On Fri, 17 Dec 2004 13:24:43 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: Jeff Shannon <[EMAIL PROTECTED]> writes: Sion Arrowsmith wrote: Additionally, as I understand it UserList and UserDict are implemented entirely in Python, which means that there can be significant perform

Re: better lambda support in the future?

2004-12-17 Thread Nick Coghlan
Jp Calderone wrote: > Regarding #1: there must be a great variance between people in the > difficulty of some aspects of programming. I am always amazed to hear > from people who have no difficulty picking names for all of their > functions. This is a task that often stumps me for long minutes.

Re: BASIC vs Python

2004-12-17 Thread Andrew Dalke
[EMAIL PROTECTED] wrote: > Now wait a minute, shouldn't that be... > > PLAY "CGFED>CChttp://mail.python.org/mailman/listinfo/python-list

hello

2004-12-17 Thread matthew
testing ... -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
Jeff Shannon wrote: That does put a kink in my argument that Python is simply refusing to guess in the face of ambiguity. I'm still convinced that disallowing lists as dict keys is a good thing, but it leaves me unable to explain why __hash__()-less user-defined classes (which are mutable almos

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
Jp Calderone wrote: On Fri, 17 Dec 2004 11:21:25 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: The correct characterization is that Python makes user-defined mutable classes hashable (arguably correctly so) as the default behavior. However, that is only achieved by using identity based equality

Re: better lambda support in the future?

2004-12-17 Thread Bengt Richter
On Fri, 17 Dec 2004 22:56:08 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Michael DeHaan wrote: > >> True enough, but suppose you want a hash of anonymous functions as >> opposed to just a lexical? This is where lambas are nice to have. >> Totally agreed about a small use here and there, b

Re: Why are tuples immutable?

2004-12-17 Thread Nick Coghlan
Antoon Pardon wrote: Would you have us construct two related classes each time we find ourselves in such a situation and copy an object from one class to the other depending on the circumstances? Python itself seems to think so, given the pairings of set/frozenset & list/tuple. Using genuinely imm

Re: Why are tuples immutable?

2004-12-17 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Jeff Shannon <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > >All that's needed is to define __hash__() and __cmp__() methods which > >only look at some subset of the object's data atrributes. You can > >keep those attributes constant (perhaps enforced with __seta

Re: BASIC vs Python

2004-12-17 Thread Dan
Steve Holden wrote: Which, now I remember, Digital Equipment extended to floating-point in their FOCAL language. Never used FOCAL, or VAX Basic for that matter (was it the same thing?), but I can remember calling the VAX Basic BAS$EDIT routine from Pascal in college. BAS$EDIT had most of the b

Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-17 Thread Bengt Richter
On Fri, 17 Dec 2004 08:03:12 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: >Steven Bethard wrote: >> Very cool. I didn't know about this. Does anyone know how to make it >> work with Pythonwin[1]? (Obviously, I can type the above in manually >> every time, but I'd much rather have Pythonwin

A rational proposal

2004-12-17 Thread Mike Meyer
PEP: XXX Title: A rational number module for Python Version: $Revision: 1.4 $ Last-Modified: $Date: 2003/09/22 04:51:50 $ Author: Mike Meyer <[EMAIL PROTECTED]> Status: Draft Type: Staqndards Content-Type: text/x-rst Created: 16-Dec-2004 Python-Version: 2.5 Post-History: 30-Aug-2002 Abstract

Weekly Python Patch/Bug Summary

2004-12-17 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 259 open ( +0) / 2707 closed ( +2) / 2966 total ( +2) Bugs: 822 open (+22) / 4685 closed (+23) / 5507 total (+45) RFE : 160 open ( +0) / 139 closed ( +2) / 299 total ( +2) New / Reopened Patches __ repair ty

Re: PyCrust: What am I suppose to do?

2004-12-17 Thread stani_
If you want an IDE with PyCrust, try SPE: http://spe.pycs.net Stani http://www.stani.be -- http://mail.python.org/mailman/listinfo/python-list

Re: better lambda support in the future?

2004-12-17 Thread Dima Dorfman
On 2004-12-18, Jeff Shannon <[EMAIL PROTECTED]> wrote: > Would OCaml (or some > other static language) have something that's equivalent to this? > > def f(x): > if x < 0: > def g(y): > return y * -1 > else: > def g(y): > return y > return g > > f

Re: Why are tuples immutable?

2004-12-17 Thread Bengt Richter
On 17 Dec 2004 08:20:10 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >Op 2004-12-17, Jeff Shannon schreef <[EMAIL PROTECTED]>: >> Adam DePrince wrote: >> >>>And how exactly do you propose to mutate an object without changing its >>>hash value? >>> >>> >>>* Create this mutate-able object type. >

Re: better lambda support in the future?

2004-12-17 Thread Mike Meyer
Jeff Shannon <[EMAIL PROTECTED]> writes: > Steven Bethard wrote: > Hm, possibly. I must confess that my direct knowledge is limited to a > fairly narrow set of languages, and that C and C++ are the only > statically-compiled languages I've used. Still, I'm not sure that > it's just a matter of f

Re: BASIC vs Python

2004-12-17 Thread Mike Meyer
Scott Robinson <[EMAIL PROTECTED]> writes: > Forth seems better than basic, but is *weird* (I tried it for a > while). I'm not sure going from Forth to C (or Python) would be much > easier than Basic to C or Python. The biggest disappointment for > Forth was that no significant Forth chips were

Re: PyCrust: What am I suppose to do?

2004-12-17 Thread M.E.Farmer
It's me wrote: > I am trying out PyCrust and at a lost what to do next. With the previous > IDE I tried, the IDE pops up the console and the editor. From the editor, I > can set up breakpoints and debug and so forth. Yes, I can even run the > script. > > With PyCrust, the nice looking 3-pane win

Re: Cool object trick

2004-12-17 Thread Carl Banks
Alex Stapleton wrote: > Hmm true, (i had forgotten about getattr :/) in that case im indifferent > to Bunch() not that i really see why it's useful except for making code > look a bit nicer occasionaly. When using Bunch, the idea is not to access the elements indirectly. If you need to access elem

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Jp Calderone wrote: On Fri, 17 Dec 2004 11:21:25 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: No -- the mathematical definition of 'hashable' fails for mutable types, and Python doesn't try to pretend that it can hash mutable types. Python also provides features so that user-defined immutab

Re: lambdas vs functions: a bytecode question

2004-12-17 Thread Fernando Perez
Erik Max Francis wrote: > Fernando Perez wrote: > >> Can someone explain to me what the extra two bytecodes at the end of the >> function version (ff) are for? >> >> This is just curiosity, please note that I am NOT making any arguments pro >> or against lambdas, functions or anything else. > >

Re: better lambda support in the future?

2004-12-17 Thread Jeff Shannon
Steven Bethard wrote: Jeff Shannon wrote: It occurs to me that, in a statically compiled language, function definitions all happen before the program starts, and thus that definition can't be affected by other variables (i.e. an outer function's parameters). I think you might be confusing stati

Re: threading priority

2004-12-17 Thread Peter Hansen
[EMAIL PROTECTED] wrote: I googled as suggested, and the answer isn't crystal clear. My impression is that the problem is that a python thread must acquire the GIL in order to execute, and the strategy for deciding which thread should get the GIL when multiple threads are waiting for it is not bas

Re: Is this a good use for lambda

2004-12-17 Thread Jeff Shannon
Charlie Taylor wrote: root = findRoot(xBeg, xEnd, lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15) Um, so which parts of this are the actual lambda?? Just from reading that, it's hard to be sure. My mind keeps wanting to break at 'lambda x: y2 + lp*(x-x2)', but when I sto

Re: lambdas vs functions: a bytecode question

2004-12-17 Thread Erik Max Francis
Fernando Perez wrote: Can someone explain to me what the extra two bytecodes at the end of the function version (ff) are for? This is just curiosity, please note that I am NOT making any arguments pro or against lambdas, functions or anything else. It's returning None. I would guess that it's a sa

Re: Is this a good use for lambda

2004-12-17 Thread Steven Bethard
Harlin Seritt wrote: Charlie Taylor wrote: I find that I use lambda functions mainly for callbacks to things like integration or root finding routines as follows. flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd) root = findRoot(xBeg, xEnd, lambda x: y2+ lp*(x-x2) -wallF

Re: Bug in inspect.py for python 2.3?

2004-12-17 Thread Fernando Perez
Peter Otten wrote: > Fernando Perez wrote: > >> I'd like to hear from some of our resident gurus if this is really an >> inspect.py bug before I bother the developers with a formal bug report on >> SF. >> The script below illustrates the problem. Just run it, and you'll get a >> traceback comin

Re: BASIC vs Python

2004-12-17 Thread Scott Robinson
On Fri, 17 Dec 2004 15:00:54 -0600, Mike Meyer <[EMAIL PROTECTED]> wrote: >"not [quite] more i squared" <[EMAIL PROTECTED]> writes: > >> Adam DePrince wrote: >> Given the hardware constraints of the early 1980s, which language do you think should have been used instead of BASIC? >>> Lisp >

lambdas vs functions: a bytecode question

2004-12-17 Thread Fernando Perez
Hi all, there are a couple of threads on lambdas today, which got me curious about their differences as far as bytecode goes: planck[~]|2> lf=lambda x: x**2 planck[~]|3> def ff(x): return x**2 |.> planck[~]|4> import dis planck[~]|5> dis.dis(lf) 1 0 LOAD_FAST0

Re: expression form of one-to-many dict?

2004-12-17 Thread Steven Bethard
Fernando Perez wrote: outlist = map(foo,inlist) is still better in my book, and far more readable, than outlist = [foo(x) for x in inlist] The map form, in this case, parses instantly in my brain, while the listcomp certainly takes a few cycles. And note that I'm not talking about the typing conci

Re: A completely silly question

2004-12-17 Thread Mike Meyer
David Bolen <[EMAIL PROTECTED]> writes: > Mike Meyer <[EMAIL PROTECTED]> writes: > >> Steven Bethard <[EMAIL PROTECTED]> writes: >> >> > Amir Dekel wrote: >> >> What I need from the program is to wait for a single character >> >> input, something like while(getchar()) in C. All those Python >> >>

Re: Bug in inspect.py for python 2.3?

2004-12-17 Thread Fernando Perez
Terry Reedy wrote: > [I removed the blank lines which made it diffificult to cut and paste.] > [Here is the output (from 2.2) you forgot to include'-):] Yes, that's exactly the output I see. Note that in ipython I have had to protect ALL calls for inspect.get* functions in blanket excepts, becau

Re: Is this a good use for lambda

2004-12-17 Thread Stephen Thorne
On Fri, 17 Dec 2004 15:58:09 -0800, Charlie Taylor <[EMAIL PROTECTED]> wrote: > > I find that I use lambda functions mainly for callbacks to things like > integration or root finding routines as follows. > > flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd) > > root = findRo

Re: better lambda support in the future?

2004-12-17 Thread Harlin Seritt
Jp Calderone wrote: > On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote: >> >> "Jason Zheng" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > Steven Bethard wrote: >> >> Jason Zheng wrote: >> >> >> >>> I'm wondering why python still has limited lambda sup

Re: expression form of one-to-many dict?

2004-12-17 Thread Fernando Perez
Steven Bethard wrote: > Actually, it's even smaller now, because I've pretty much removed map > from all my code in favor of list comprehensions, which I find much > easier to read. While I agree that listcomps are more readable in most cases (and certainly for all cases with any amount of comple

Re: Socket being garbage collected too early

2004-12-17 Thread Scott Robinson
On 16 Dec 2004 20:38:29 -0500, David Bolen <[EMAIL PROTECTED]> wrote: >Scott Robinson <[EMAIL PROTECTED]> writes: > >> I have been having trouble with the garbage collector and sockets. > >Are you actually getting errors or is this just theoretical? > >> Unfortunately, google keeps telling me that

Re: Bug in inspect.py for python 2.3?

2004-12-17 Thread Peter Otten
Fernando Perez wrote: > IPython has suffered quite a few problems with the inspect module in > python > 2.3. For these, unfortunately all I've been able to do is guard with > overreaching except clauses, as I had not been able to find small, > reproducible examples to pass on to the devs. But to

Re: Is this a good use for lambda

2004-12-17 Thread Harlin Seritt
Charlie Taylor wrote: > > I find that I use lambda functions mainly for callbacks to things like > integration or root finding routines as follows. > > flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd) > > root = findRoot(xBeg, xEnd, >lambda x: y2+ lp*(x-x2) -wallFu

Re: Html or Pdf to Rtf (Linux) with Python

2004-12-17 Thread Stephen Thorne
On Fri, 17 Dec 2004 07:55:10 + (UTC), Axel Straschil <[EMAIL PROTECTED]> wrote: > Hello! > > > I've been able to successfully get konqueror to generate a pdf from a > > html file via dcop. It's something along the lines of: > > For that stuff, I'm using htmloc (http://www.htmldoc.org/). I fo

Re: better lambda support in the future?

2004-12-17 Thread Jp Calderone
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote: > > "Jason Zheng" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Steven Bethard wrote: > >> Jason Zheng wrote: > >> > >>> I'm wondering why python still has limited lambda support. What's > >>> stopping

Re: A completely silly question

2004-12-17 Thread David Bolen
Mike Meyer <[EMAIL PROTECTED]> writes: > Steven Bethard <[EMAIL PROTECTED]> writes: > > > Amir Dekel wrote: > >> What I need from the program is to wait for a single character > >> input, something like while(getchar()) in C. All those Python > >> modules don't make much sence to me... > > > > sy

Re: Why no list heritable type?

2004-12-17 Thread Steven Bethard
Mike Meyer wrote: Actually, UserList and UserDict are just wrappers around the builtin types. So the performance hit is one Python function call - pretty much neglible. But new code should still subclass the builtins. Interesting that they're not fully compatible with the builtins: >>> dict(dict=35

Re: Is this a good use for lambda

2004-12-17 Thread Jp Calderone
On Fri, 17 Dec 2004 15:58:09 -0800, Charlie Taylor <[EMAIL PROTECTED]> wrote: > > I find that I use lambda functions mainly for callbacks to things like > integration or root finding routines as follows. > > flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd) > > root = find

Re: Bug in inspect.py for python 2.3?

2004-12-17 Thread Terry Reedy
"Fernando Perez" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'd like to hear from some of our resident gurus if this is really an > inspect.py bug before I bother the developers with a formal bug report on > SF. I know nothing of inspect, but this certainly look like a bug (s

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Roy Smith wrote: Jeff Shannon <[EMAIL PROTECTED]> wrote: The aesthetic purity I'm referring to is that Python respects the proper meaning of hashing, even if it doesn't force the programmer to. The builtin objects that Python provides don't offer a __hash__() method that fails to meet the m

Re: expression form of one-to-many dict?

2004-12-17 Thread Steven Bethard
Larry Bates wrote: Suggestion: It is a bad idea to name any variable "map". When you do, you destroy your ability to call Python's map function. Same goes for "list", "str", or any other built-in function. If you haven't been bitten by this you will, I was. A good reminder for all the newbies out

Re: BASIC vs Python

2004-12-17 Thread [EMAIL PROTECTED]
Andrew Dalke wrote: [snip] > The BASICs of my youth also supported graphics and sounds. > > PLAY "CGFED>http://mail.python.org/mailman/listinfo/python-list

Is this a good use for lambda

2004-12-17 Thread Charlie Taylor
I find that I use lambda functions mainly for callbacks to things like integration or root finding routines as follows. flow = integrate(lambda x: 2.0*pi * d(x)* v(x) * sin(a(x)),xBeg, xEnd) root = findRoot(xBeg, xEnd, lambda x: y2+ lp*(x-x2) -wallFunc( x )[0], tolerance=1.0E-15) I hav

Re: threading priority

2004-12-17 Thread alecwy
I googled as suggested, and the answer isn't crystal clear. My impression is that the problem is that a python thread must acquire the GIL in order to execute, and the strategy for deciding which thread should get the GIL when multiple threads are waiting for it is not based on priority. Is that

Re: Why no list heritable type?

2004-12-17 Thread Mike Meyer
Jeff Shannon <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>Jeff Shannon <[EMAIL PROTECTED]> writes: >>>Additionally, as I understand it UserList and UserDict are implemented >>>entirely in Python, which means that there can be significant >>>performance differences as well. >> >>Actually, User

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Jeff Shannon wrote: It occurs to me that, in a statically compiled language, function definitions all happen before the program starts, and thus that definition can't be affected by other variables (i.e. an outer function's parameters). I think you might be confusing static compilation in a lang

Re: Confused updating 2.3 to 2.4 on Linux

2004-12-17 Thread Glen
> > Being a new'ish user to both Linux and Python, I've been 'happily' > > learning Python (2.3) with Idle and Tkinter as installed with Mandrake > > 10. > > All seemed to work without any errors, but starting Python from Idle > > or a console displays the same statup text, > > > > Python 2.3.3

Re: Why no list heritable type?

2004-12-17 Thread Jeff Shannon
Mike Meyer wrote: Jeff Shannon <[EMAIL PROTECTED]> writes: Additionally, as I understand it UserList and UserDict are implemented entirely in Python, which means that there can be significant performance differences as well. Actually, UserList and UserDict are just wrappers around the built

Re: better lambda support in the future?

2004-12-17 Thread Jeff Shannon
Steven Bethard wrote: Jason Zheng wrote: The true beauty of lambda function is not the convenience of creating functions without naming them. Lambda constructs truly enables higher-order function. For example, I can create a function A that returns a function B that does something interesting ac

Re: BASIC vs Python

2004-12-17 Thread not [quite] more i squared
Mike Meyer wrote: "not [quite] more i squared" <[EMAIL PROTECTED]> writes: Adam DePrince wrote: Given the hardware constraints of the early 1980s, which language do you think should have been used instead of BASIC? Lisp Forth Exactly my pick Logo (my pick) has been called "Lisp without the paren

Re: expression form of one-to-many dict?

2004-12-17 Thread Larry Bates
Steven, Suggestion: It is a bad idea to name any variable "map". When you do, you destroy your ability to call Python's map function. Same goes for "list", "str", or any other built-in function. If you haven't been bitten by this you will, I was. Larry Bates Steven Bethard wrote: So I end up writi

Re: better lambda support in the future?

2004-12-17 Thread Terry Reedy
"Jason Zheng" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Steven Bethard wrote: >> Jason Zheng wrote: >> >>> I'm wondering why python still has limited lambda support. What's >>> stopping the developers of python to support more lisp-like lambda >>> function? They already hav

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Fredrik Lundh wrote: Steven Bethard wrote: I've seen at least one reasonable example of this kind of thing: http://mail.python.org/pipermail/python-list/2004-October/245432.html the code he's referring to doesn't seem to use that construct anymore, so it's not obvious what "dejavu.icontains" etc re

Bug in inspect.py for python 2.3?

2004-12-17 Thread Fernando Perez
Hi all, IPython has suffered quite a few problems with the inspect module in python 2.3. For these, unfortunately all I've been able to do is guard with overreaching except clauses, as I had not been able to find small, reproducible examples to pass on to the devs. But today I got a crash report

Re: better lambda support in the future?

2004-12-17 Thread Michael Hoffman
Jason Zheng wrote: The true beauty of lambda function is not the convenience of creating functions without naming them. Lambda constructs truly enables higher-order function. For example, I can create a function A that returns a function B that does something interesting according to the argume

Re: ".>>>" is a good idea! (OT, was: Re: do you master list comprehensions?)

2004-12-17 Thread Fernando Perez
Keith Dart wrote: > Fernando Perez wrote: > >> >> >> You might want to look at ipython: >> >> http://ipython.scipy.org, >> >> >> >> > > I did just recently install that. It looks very nice. Would make a great > interactive prompt for an IDE, as well. Glad you like it :) And yes, there are

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: > I've seen at least one reasonable example of this kind of thing: > > http://mail.python.org/pipermail/python-list/2004-October/245432.html the code he's referring to doesn't seem to use that construct anymore, so it's not obvious what "dejavu.icontains" etc really is, but

RE: expression form of one-to-many dict?

2004-12-17 Thread Robert Brewer
Steven Bethard wrote: > So I end up writing code like this a fair bit: > > map = {} > for key, value in sequence: > map.setdefault(key, []).append(value) > > This code basically constructs a one-to-many mapping -- each > value that > a key occurs with is stored in the list for that key. >

Re: expression form of one-to-many dict?

2004-12-17 Thread Steven Bethard
Tim Peters wrote: The point here is that there's a simple sequence or GE that I can throw to the dict constructor that spits out a dict with my one-to- one mapping. It's a simple sequence because it's a simple task. It's even simpler than perhaps it "should be", since it arbitrarily decides that,

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Jason Zheng wrote: The true beauty of lambda function is not the convenience of creating functions without naming them. Lambda constructs truly enables higher-order function. For example, I can create a function A that returns a function B that does something interesting according to the argume

Re: better lambda support in the future?

2004-12-17 Thread Jason Zheng
Steven Bethard wrote: Jason Zheng wrote: I'm wondering why python still has limited lambda support. What's stopping the developers of python to support more lisp-like lambda function? This comes up every few weeks on the list. If you haven't already, check the archives in Google for 'anonymous

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Michael DeHaan wrote: > True enough, but suppose you want a hash of anonymous functions as > opposed to just a lexical? This is where lambas are nice to have. > Totally agreed about a small use here and there, but they do have some > use in dispatch tables, as they are a lot easier to read somet

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Michael DeHaan wrote: True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? I've seen at least one reasonable example of this kind of thing: http://mail.python.org/pipermail/python-list/2004-October/245432.html Though I haven't yet seen an example that actual

Re: Troubleshooting: re.finditer() creates object even when nomatch found

2004-12-17 Thread Fredrik Lundh
Chris Lasher wrote: > That's odd that there's no built-in method to do this. It seems like > it would be a common task. if you do this a lot, maybe you shouldn't use finditer? iterators are designed to give you the next item (if any) when you're ready to deal with it... if that's not what you w

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Fredrik Lundh wrote: I'm not sure what "func" is supposed to be in your examples... Just an extra variable used to make sure that the lambda was being used in a context (i.e. in an expression) where a simple def wouldn't suffice. If the example is confusing, consider the dict example instead.

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: > You're welcome to name the function whatever you want -- notice in my example > that the function is > used in the statement: > > x = func or f > > If you'd prefer the statement to read: > > x = func or x > > that's also fine. Depends on what exactly 'x' is, and whether

Re: expression form of one-to-many dict?

2004-12-17 Thread Tim Peters
[Steven Bethard] > So I end up writing code like this a fair bit: > > map = {} > for key, value in sequence: > map.setdefault(key, []).append(value) > > This code basically constructs a one-to-many mapping -- each > value that a key occurs with is stored in the list for that key. > > This code'

Re: better lambda support in the future?

2004-12-17 Thread Michael DeHaan
True enough, but suppose you want a hash of anonymous functions as opposed to just a lexical? This is where lambas are nice to have. Totally agreed about a small use here and there, but they do have some use in dispatch tables, as they are a lot easier to read sometimes than very long case stat

PyCrust: What am I suppose to do?

2004-12-17 Thread It's me
I am trying out PyCrust and at a lost what to do next. With the previous IDE I tried, the IDE pops up the console and the editor. From the editor, I can set up breakpoints and debug and so forth. Yes, I can even run the script. With PyCrust, the nice looking 3-pane window pops up with lots of t

expression form of one-to-many dict?

2004-12-17 Thread Steven Bethard
So I end up writing code like this a fair bit: map = {} for key, value in sequence: map.setdefault(key, []).append(value) This code basically constructs a one-to-many mapping -- each value that a key occurs with is stored in the list for that key. This code's fine, and seems pretty simple, bu

Re: Why are tuples immutable?

2004-12-17 Thread John Roth
I came in on this thread a bit late. The strictly pragmatic answer to the question in the header should be obvious. If tuples were mutable, then there would be no difference between tuples and lists, so there would be no need for tuples. Whether you think an immutable list is worth while is a diffe

Re: better lambda support in the future?

2004-12-17 Thread Steven Bethard
Fredrik Lundh wrote: Steven Bethard wrote: Even if you could settle the syntax issue, once you've decided that you really do need a true block in an anonymous function, you're not really saving much space by not declaring it: def f(*args): # body line 1 # body line 2 # ... # body lin

Re: BASIC vs Python

2004-12-17 Thread Mike Meyer
"not [quite] more i squared" <[EMAIL PROTECTED]> writes: > Adam DePrince wrote: > >>>Given the hardware constraints of the early 1980s, which >>>language do you think should have been used instead of BASIC? >> Lisp >> Forth > Exactly my pick Logo (my pick) has been called "Lisp without the parent

Re: A completely silly question

2004-12-17 Thread Amir Dekel
Mike Meyer wrote: Hmm. That tells me he's probably on a Windows box, so my unix solution wouldn't do him much good. Yes, Windows...too bad -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused updating 2.3 to 2.4 on Linux

2004-12-17 Thread Mike Meyer
Glen <[EMAIL PROTECTED]> writes: > Being a new'ish user to both Linux and Python, I've been 'happily' > learning Python (2.3) with Idle and Tkinter as installed with Mandrake > 10. > All seemed to work without any errors, but starting Python from Idle > or a console displays the same statup text,

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Steven Bethard
Chris Lasher wrote: Is there any way to request a feature like this from the RE module keepers, whomever they may be? The most direct way would be to go to Python at sourceforge[1] and make a feature request to add peek to itertools. (This is probably the most reasonable location for it.) Reque

Re: A completely silly question

2004-12-17 Thread Mike Meyer
Steven Bethard <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> That doesn't do what he wants, because it doesn't return until you hit >> a newline. > Of course if the intent is to have this work with terminal input, then > yes, sys.stdin.read(1) is probably not going to do the right thing... T

RE: Troubleshooting: re.finditer() creates object even when nomatch found

2004-12-17 Thread Robert Brewer
Chris Lasher wrote: > That's odd that there's no built-in method to do this. It seems like > it would be a common task. Is there any way to request a feature like > this from the RE module keepers, whomever they may be? The best way to request such a feature would be to write a patch. ;) FuManCh

Re: better lambda support in the future?

2004-12-17 Thread Fredrik Lundh
Steven Bethard wrote: > Even if you could settle the syntax issue, once you've decided that you > really do need a true > block in an anonymous function, you're not really saving much space by not > declaring it: > > def f(*args): > # body line 1 > # body line 2 > # ... > # body

Re: Troubleshooting: re.finditer() creates object even when no match found

2004-12-17 Thread Chris Lasher
Thanks Steve, That's odd that there's no built-in method to do this. It seems like it would be a common task. Is there any way to request a feature like this from the RE module keepers, whomever they may be? In the meantime, may I use your code, with accredation to you? Thanks, Chris -- http://ma

  1   2   3   >