Re: Defending Python

2005-07-12 Thread Andrew Durdin
On 7/13/05, Jorey Bump <[EMAIL PROTECTED]> wrote: > >>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>> > >>> The larch! > > IT'S A TREE ... not a shrubbery? -- http://mail.python.org/mailman/listinfo/python-list

Re: C API : Creating a Py_Method object from a C function.

2005-07-12 Thread Martin v. Löwis
Hugh Macdonald wrote: > PyMethodDef *callbackFunctionDef = new PyMethodDef; > callbackFunctionDef->ml_name = "doLoadCallback"; > callbackFunctionDef->ml_meth = &myPython_doLoadCallback; > callbackFunctionDef->ml_flags = 1; I think this gives a memory leak. I was rather thinking of

Re: Web App like Google

2005-07-12 Thread Godwin
Thanks for providing me with all those informative links about NLTK nad CNL. I'll certainly look into it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Web App like Google

2005-07-12 Thread Godwin
Thanks for informing me about NLTK. I'll certainly look into it and other options. Hope my dream doesn't go into the graves. Godwin Burby -- http://mail.python.org/mailman/listinfo/python-list

Re: extend for loop syntax with if expr like listcomp&genexp ?

2005-07-12 Thread Bengt Richter
On Tue, 12 Jul 2005 23:07:07 -0500, Terry Hancock <[EMAIL PROTECTED]> wrote: >On Monday 11 July 2005 08:53 pm, Bengt Richter wrote: >> On Tue, 12 Jul 2005 10:12:33 +1000, John Machin <[EMAIL PROTECTED]> wrote: >> >Bengt Richter wrote: >> >> for x in (x for x in seq if x is not None): >> >Byzan

Re: set and frozenset unit tests?

2005-07-12 Thread Jacob Page
Reinhold Birkenfeld wrote: > Jacob Page wrote: > >>I'd like to >>run my code through actual set and frozenset unit tests. Does any such >>code exist? Is it in pure Python? If so, where can it be obtained? > > Look at /usr/lib/python2.x/test/ (on unix platforms). Thanks for pointing that to

Re: breaking out of nested loop

2005-07-12 Thread Terry Hancock
On Tuesday 12 July 2005 10:28 am, Tim Golden wrote: > [Jeremy Sanders] > | rbt wrote: > | > | > What is the appropriate way to break out of this while loop > | if the for > | > loop finds a match? > | > | queue discussion why Python doesn't have a "break N" statement... > > > > Presumably you

Content violation

2005-07-12 Thread NAV2_SMTP_Gateway
Content violation found in email message. From: python-list@python.org To: [EMAIL PROTECTED] File(s): message.zip Matching filename: message.zip -- http://mail.python.org/mailman/listinfo/python-list

Re: Defending Python

2005-07-12 Thread Jorey Bump
>> Jorey Bump wrote: >> >>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >>> it's. >>> +1 for this becoming the official name of Python 3000. ;) Monty Python's Flying Circus used to begin with "It's..." I had read at one time that "It's" was one of the original names proposed f

Re: extend for loop syntax with if expr like listcomp&genexp ?

2005-07-12 Thread Terry Hancock
On Monday 11 July 2005 08:53 pm, Bengt Richter wrote: > On Tue, 12 Jul 2005 10:12:33 +1000, John Machin <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: > >> for x in (x for x in seq if x is not None): > >Byzantine ... > Perhaps not if you wanted to enumerate the selected elements, as in >

Re: Frankenstring

2005-07-12 Thread Bengt Richter
On Wed, 13 Jul 2005 03:49:16 +0200, Thomas Lotze <[EMAIL PROTECTED]> wrote: >Scott David Daniels wrote: > >> Now if you want to do it for a file, you could do: >> >> for c in thefile.read(): >> > >The whole point of the exercise is that seeking on a file doesn't >influence iter

Re: if not DEBUG: log = null_log

2005-07-12 Thread @(none)
Bengt Richter wrote: > On Wed, 13 Jul 2005 11:00:14 +1000, Simon Burton <[EMAIL PROTECTED]> wrote: > > >>Hi, >> >>I'm after a no-op command, so that i can redirect >>logging commands in performance critical code. >> >>Something like this: >> >>def log(*args): print args >>def null_log(*args): pas

Re: Help with report

2005-07-12 Thread ChrisH
> You know, this is the most concise example of feature-creep in a > specification that I've ever seen. > You're right. I'm afraid it's from too much work and too little sleep. I'll try to be more precise next time. Thanks to everyone for their help. Chris -- http://mail.python.org/mailman/lis

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Christopher Subich
Thomas Lotze wrote: > Neither does it to me. What about > > try: > f=file('file_here') > except IOError: #File doesn't exist > error_handle > else: > do_setup_code > do_stuff_with(f) > > (Not that I'd want to defend Joel's article, mind you...) That works. I'm still not used to

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Dark Cowherd
OK, I can see that the Python way of doing things is very different. However I think Roy made a very pertinent point "Imagine if do_setup_code or do_stuff_with(f) unexpectedly threw an IOError for some reason totally unrelated to the file not existing." This is the kind of situation that the rule '

Re: if not DEBUG: log = null_log

2005-07-12 Thread Bengt Richter
On Wed, 13 Jul 2005 11:00:14 +1000, Simon Burton <[EMAIL PROTECTED]> wrote: > >Hi, > >I'm after a no-op command, so that i can redirect >logging commands in performance critical code. > >Something like this: > >def log(*args): print args >def null_log(*args): pass >if not DEBUG: log = null_log > >

Re: Help with inverted dictionary

2005-07-12 Thread Steven D'Aprano
On Wed, 13 Jul 2005 11:38:44 +1000, John Machin wrote: > [EMAIL PROTECTED] wrote: >> I will transfer eventually use a database but is there any way for now >> you could help me make the text files? Thank you so much. Reece >> > > No. There is utterly no reason why you should create 5000 or 300

Re: math.nroot [was Re: A brief question.]

2005-07-12 Thread Steven D'Aprano
(All previous quoting ruthlessly snipped.) A question for Tim Peters, as I guess he'll have the most experience in this sort of thing. With all the cross-platform hassles due to the various C compilers not implementing the IEEE standard completely or correctly, I wonder how much work would be inv

Re: new division in Pythonwin

2005-07-12 Thread Mike Meyer
"Jive Dadson" <[EMAIL PROTECTED]> writes: > I like to use Pythonwin as my desktop calculator. It's bothersome > to have to type in "from __future__ import division" into the > interactive window every time I open it. I've tried various ways to > attempt to get it to import new division at startu

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Mike Meyer
Dark Cowherd <[EMAIL PROTECTED]> writes: > But one advise that he gives which I think is of great value and is > good practice is > "Always catch any possible exception that might be thrown by a library > I'm using on the same line as it is thrown and deal with it > immediately." Yuch. That sort

Re: if not DEBUG: log = null_log

2005-07-12 Thread Steven D'Aprano
On Wed, 13 Jul 2005 11:00:14 +1000, Simon Burton wrote: > Hi, > > I'm after a no-op command, so that i can redirect > logging commands in performance critical code. > > Something like this: > > def log(*args): print args > def null_log(*args): pass > if not DEBUG: log = null_log > > is unaccep

Multivariable polynomials

2005-07-12 Thread Chris
Does anyone know of a good standalone implementation of multivariable polynomials in python? Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list

Fredericksburg, VA ZPUG Meeting

2005-07-12 Thread Benji York
When: July 13, 7:30-9:00 PM Where: Zope Corp offices (513 Prince Edward Street; Fredericksburg, VA 22408) Details at http://www.zope.org/Members/poster/fxbgzpug_announce_2 Hope to see you there! -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Re: Browser plug-in for Python?

2005-07-12 Thread Bill Janssen
Yes, thanks, back in the day I used Grail and played with rexec. I notice that one of the Summer of Code projects was to recreate rexec, but don't know if it was funded. Presumably a Firefox plug-in for Python would restrict the execution environment in some safe way, and provide some kind of UI

Re: Frankenstring

2005-07-12 Thread Thomas Lotze
Scott David Daniels wrote: > Now if you want to do it for a file, you could do: > > for c in thefile.read(): > The whole point of the exercise is that seeking on a file doesn't influence iteration over its content. In the loop you suggest, I can seek() on thefile to my heart's

Re: Help with inverted dictionary

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > I will transfer eventually use a database but is there any way for now > you could help me make the text files? Thank you so much. Reece > No. There is utterly no reason why you should create 5000 or 3 text files. While you are waiting to get a clue about databas

Re: plot module

2005-07-12 Thread Robert Kern
Shankar Iyer ([EMAIL PROTECTED]) wrote: > Hi, > > I am looking for documentation on the plot module. Does anyone know where I > can find this information? Thanks. What is "the plot module"? There are any number of Python modules for making plots and charts. Some of them may even be called "pl

Re: plot module

2005-07-12 Thread Titi Anggono
I just use Gnuplot for plot module. Maybe you can visit http://gnuplot-py.sourceforge.net/ or the mailing list http://lists.sourceforge.net/lists/listinfo/gnuplot-py-users --- "Shankar Iyer ([EMAIL PROTECTED])" <[EMAIL PROTECTED]> wrote: > Hi, > > I am looking for documentation on the plot mo

Re: math.nroot [was Re: A brief question.]

2005-07-12 Thread Tim Peters
[Michael Hudson] > I doubt anyone else is reading this by now, so I've trimmed quotes > fairly ruthlessly :) Damn -- there goes my best hope at learning how large a message gmail can handle before blowing up . OK, I'll cut even more. [Michael] >>> Can't we use the stuff defined in Appendix F and

Re: Creating anonymous functions using eval

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 17:17:46 -0600, Joseph Garvin wrote: > Robert Kern wrote: > >>Not everyone is reading this list in a conveniently threaded >>form >> >> > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. Technology as a substitute for manners

if not DEBUG: log = null_log

2005-07-12 Thread Simon Burton
Hi, I'm after a no-op command, so that i can redirect logging commands in performance critical code. Something like this: def log(*args): print args def null_log(*args): pass if not DEBUG: log = null_log is unacceptable because of the overhead of calling functions in python. log ("about to sl

Re: Creating anonymous functions using eval

2005-07-12 Thread Robert Kern
Joseph Garvin wrote: > Robert Kern wrote: > >>Not everyone is reading this list in a conveniently threaded >>form > > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. Good point. Allow me to modify my statement: not all newsreaders/email apps thre

Re: Creating anonymous functions using eval

2005-07-12 Thread Dave Benjamin
Joseph Garvin wrote: > Robert Kern wrote: > >> Not everyone is reading this list in a conveniently threaded form >> >> > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. My newsreader supports threading, but the first message I see in this thread

Re: Browser plug-in for Python?

2005-07-12 Thread Jeff Epler
Back in the day there was 'grail', which was a browser in its own right. There may also have been a plug-in for other browsers, but I don't know any real details about them. Python itself has deprecated the 'restricted execution' environment it had in previous versions, because ways to break out o

Re: append one file to another

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > > I want to append one (huge) file to another (huge) file. The current > way I'm doing it is to do something like: > > infile = open (infilename, 'r') > filestr = infile.read() > outfile = open(outfilename, 'a') > outfile.write(filestr) > > I wonder if there is

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread George Sakkis
This should give you an idea of how to go about it (needs python 2.3 or newer): import re slashPattern = re.compile(r'\\(.*?)\\') for i,line in enumerate(file("parseinput")): print "line", i+1, match = slashPattern.search(line) if match: print "matched:", match.group(1) e

Re: Inconsistency in hex()

2005-07-12 Thread Raymond Hettinger
[Steven D'Aprano] > > hex() of an int appears to return lowercase hex digits, and hex() of a > > long uppercase. [Terry Reedy] > Already bug-reported and fixed for 2.5 (to use lowercase, I believe). > http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1224347 Score another

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > I'm parsing a text file to extract word definitions. For example the > input text file contains the following content: > > di.va.gate \'di_--v*-.ga_-t\ vb > pas.sim \'pas-*m\ adv : here and there : THROUGHOUT > > I am trying to obtain words between two literal backslash

Re: Earthquake Forecasting Program July 11, 2005

2005-07-12 Thread Hank Oredson
"edgrsprj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Hank Oredson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> "edgrsprj" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > "edgrsprj" <[EMAIL PROTECTED]> wrote in message >> > news:[EMAIL P

Re: Thoughts on Guido's ITC audio interview

2005-07-12 Thread Markus Wankus
Markus Wankus wrote: > > My opinion - If you aren't willing to try something new, or have an > aversion to it in the first place, nothing we can say will change your > mind. Correction... *There are some people, who* if they aren't willing to try something new, or have an aversion to it in th

Browser plug-in for Python?

2005-07-12 Thread Bill Janssen
Has anyone written a browser plug-in for Python, similar to the Java plug-in that Sun has switched to for applets? Bill -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on Guido's ITC audio interview

2005-07-12 Thread Markus Wankus
Stephen Toledo-Brown wrote: > Tony Meyer wrote: > >>> Everyone complaining about Eclipse in this thread needs to go try >>> 3.1. The interface is much much much more responsive. >> >> >> >> The problem with Eclipse, IMO, is Java. I've tried 3.1 on a WinXP >> machine >> and, like just about any

Re: Slicing every element of a list

2005-07-12 Thread John Machin
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: "slice"? Interesting terminology. Next problem you have, try posting an example of your input, and your expected output. E.g. repr(input_string): '"foo"\t"barre"\t"zot"\t"X"\n' repr(output_list): [

Re: Creating anonymous functions using eval

2005-07-12 Thread Joseph Garvin
Robert Kern wrote: >Not everyone is reading this list in a conveniently threaded >form > > Why not? Just about every modern newsgroup reader and e-mail app has a threaded view option. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistency in hex()

2005-07-12 Thread Bengt Richter
On Tue, 12 Jul 2005 21:17:07 +1000, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >hex() of an int appears to return lowercase hex digits, and hex() of a >long uppercase. > hex(75) >'0x4b' hex(75*256**4) >'0x4BL' > >By accident or design? Apart from the aesthetic value that lowercas

new division in Pythonwin

2005-07-12 Thread Jive Dadson
I like to use Pythonwin as my desktop calculator. It's bothersome to have to type in "from __future__ import division" into the interactive window every time I open it. I've tried various ways to attempt to get it to import new division at startup, but no luck. I can get it to execute a file, bu

How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread cricfan
I'm parsing a text file to extract word definitions. For example the input text file contains the following content: di.va.gate \'di_--v*-.ga_-t\ vb pas.sim \'pas-*m\ adv : here and there : THROUGHOUT I am trying to obtain words between two literal backslashes (\ .. \). I am not able to match wo

Re: Earthquake Forecasting Program July 11, 2005

2005-07-12 Thread edgrsprj
"Hank Oredson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "edgrsprj" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > "edgrsprj" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> PROPOSED EARTHQUAKE FORECASTING > >> COMPUTER PROGRAM DEVELOPMENT

Re: Frankenstring

2005-07-12 Thread Scott David Daniels
Thomas Lotze wrote: > Hi, > I think I need an iterator over a string of characters pulling them out > one by one, like a usual iterator over a str does. At the same time the > thing should allow seeking and telling like a file-like object: > > f = frankenstring("0123456789") for c in f: >

Re: Searching through a list of tuples

2005-07-12 Thread Alan Green
Peter Otten wrote: > Repton wrote: > > > I often find myself storing data in a list of tuples, and I want to ask > > questions like "what is the index of the first tuple whose 3rd element > > is x", or "give me the first tuple whose 2nd element is y". > >>> items = [(1, "a", 10), (2, "b", 20), (3,

Re: python parser

2005-07-12 Thread Bengt Richter
On Tue, 12 Jul 2005 13:30:14 -0700, Robert Kern <[EMAIL PROTECTED]> wrote: >tuxlover wrote: >> Hello everyone >> >> I have to write a verilog parser in python for a class project. I was >> wondering if all you folks could advise me on choosing the right python >> parser module. I am not comfortab

Re: Frankenstring

2005-07-12 Thread Thomas Lotze
jay graves wrote: > see StringIO or cStringIO in the standard library. Just as with files, iterating over them returns whole lines, which is unfortunately not what I want. -- Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Frankenstring

2005-07-12 Thread Bengt Richter
On Tue, 12 Jul 2005 22:08:55 +0200, Thomas Lotze <[EMAIL PROTECTED]> wrote: >Hi, > >I think I need an iterator over a string of characters pulling them out >one by one, like a usual iterator over a str does. At the same time the >thing should allow seeking and telling like a file-like object: > >>

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'

2005-07-12 Thread Alan Green
Ric Da Force wrote: > Hi guys, > > Thank you all for your input! It was good to see so much convergence in the > approach! Just for divergence, you can also do this with regular expressions: >>> import re >>> re.sub("(.*),(.*)", r"\1 and\2", "C1, C2, C3") 'C1, C2 and C3' Alan. -- http://mail.

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Roy Smith
Christopher Subich <[EMAIL PROTECTED]> wrote: >try: >f = file('file_here') >do_setup_code >do_stuff_with(f) >except IOError: # File doesn't exist >error_handle It's also a good idea to keep try blocks as small as possible, so you know exactly where the error happened. Imagine if

Re: Inconsistency in hex()

2005-07-12 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hex() of an int appears to return lowercase hex digits, and hex() of a > long uppercase. Already bug-reported and fixed for 2.5 (to use lowercase, I believe). http://sourceforge.net/tracker/?group_id=5470&atid=105470

Re: Web client, https and session management

2005-07-12 Thread Yannick Turgeon
Well... Thanks for that! The work is almost completed now! ;o) Yannick -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'

2005-07-12 Thread Bengt Richter
On Wed, 13 Jul 2005 03:47:07 +0800, "Ric Da Force" <[EMAIL PROTECTED]> wrote: >Hi guys, > >Thank you all for your input! It was good to see so much convergence in the >approach! Again, I think that it speaks loudly for the concise way of doing >thins in Python... Anyway, I have typed in all of

Re: Frankenstring

2005-07-12 Thread Mike C. Fletcher
Thomas Lotze wrote: >Hi, > >I think I need an iterator over a string of characters pulling them out >one by one, like a usual iterator over a str does. At the same time the >thing should allow seeking and telling like a file-like object: > > Okay, first off, this is never going to be *fast* comp

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
> You missed Steven's point which is to quote the message to which you are > replying. Not everyone is reading this list in a conveniently threaded > form, so you need to provide some context for them to be able to follow > along. Ah, sorry, I didn't quite get what he was referring to. -- http:/

Re: python parser

2005-07-12 Thread Robert Kern
tuxlover wrote: > Hello everyone > > I have to write a verilog parser in python for a class project. I was > wondering if all you folks could advise me on choosing the right python > parser module. I am not comfortable with lex/yacc and as a result find > myself strugging with any module which use

Re: Trying to come to grips with static methods

2005-07-12 Thread Terry Reedy
| I've been doing a lot of reading about static methods in Python, and possibly getting over-confused by the minutia of the CPython implementation, as well as by the misnomer. Conceptually, a 'static method' is a function attribute of a class that is to be used as a function and not as a method

Re: automatically assigning names to indexes

2005-07-12 Thread Devan L
import math class Vector: def __init__(self, coordinates): self.coordinates = coordinates self.magnitude = sum([c**2 for c in coordinates])**0.5 self.direction = getangle(Vector([1]+[0 for i in range(len(coordinates)-1)])) def dotproduct(self, vector): sum([a

Re: Slicing every element of a list

2005-07-12 Thread Thomas Lotze
Alex Dempsey wrote: > for line in lines: > line = line[1:-5] > line = line.split('\"\t\"') > > This went without returning any errors, but nothing was sliced or split. > Next I tried: > > for i in range(len(lines)): > lines[i] = lines[i][1:-5] > lines[i] = lines[i].split('\"\t\"'

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Thomas Lotze
Christopher Subich wrote: > try: > f=file('file_here') > except IOError: #File doesn't exist > error_handle > error_flag = 1 > if not error_flag: > do_setup_code > do_stuff_with(f) > > which nests on weird, arbitrary error flags, and doesn't seem like good > programming to me.

plot module

2005-07-12 Thread Shankar Iyer ([EMAIL PROTECTED])
Hi, I am looking for documentation on the plot module. Does anyone know where I can find this information? Thanks. Shankar -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating anonymous functions using eval

2005-07-12 Thread Robert Kern
Devan L wrote: > Well, the string that gets passed is more or less a function > definition, which is then called with exec. I don't see why you'd need > to write a string out with the function definition and then call it. > You could just write the function. > > As for the nested functions, I had

Re: Frankenstring

2005-07-12 Thread jay graves
see StringIO or cStringIO in the standard library. -- http://mail.python.org/mailman/listinfo/python-list

Re: python parser

2005-07-12 Thread matt
I recently was successful using pyparsing after messing around with ply for a few hours. See my blog for more details ( http://panela.blog-city.com/icfp_contest_implementation_in_python_notes.htm ). I personally corresponded with the author and he was very helpful as well, giving my useful critiq

Re: Environment Variable

2005-07-12 Thread Sybren Stuvel
tuxlover enlightened us with: > No, the replies from Grant's and Sybren's do answer my question. It would be a lot more polite to actually thank the people helping you. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for stupidity, but why don't

Re: Slicing every element of a list

2005-07-12 Thread Scott David Daniels
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: > > f = open("export.xls", "r") > lines = f.readlines() > > for line in lines: > line = line[1:-5] > line = line.split('\"\t\"') > > This went without returning any errors, but nothing was

Re: Searching through a list of tuples

2005-07-12 Thread Scott David Daniels
Peter Otten wrote: > Repton wrote: > >>I often find myself storing data in a list of tuples, and I want to ask >>questions like "what is the index of the first tuple whose 3rd element >>is x", iter(n for n, elem in enumerate(lst) if elem[3] == x).next() >>or "give me the first tuple whose 2

Frankenstring

2005-07-12 Thread Thomas Lotze
Hi, I think I need an iterator over a string of characters pulling them out one by one, like a usual iterator over a str does. At the same time the thing should allow seeking and telling like a file-like object: >>> f = frankenstring("0123456789") >>> for c in f: ... print c ... if c == "

Re: Slicing every element of a list

2005-07-12 Thread Christopher Subich
Gary Herron wrote: > Alex Dempsey wrote: >> for line in lines: >>line = line[1:-5] >>line = line.split('\"\t\"') > This, in fact, did do the operation you expected, but after creating the > new value and assigning it to line, you promptly threw it away. (Because > the loop then went back

Re: python parser

2005-07-12 Thread Christopher Subich
tuxlover wrote: > I have to write a verilog parser in python for a class project. I was > wondering if all you folks could advise me on choosing the right python > parser module. I am not comfortable with lex/yacc and as a result find > myself strugging with any module which use lex/yacc syntax/phi

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads'C1, C2 and C3'

2005-07-12 Thread Ric Da Force
Hi guys, Thank you all for your input! It was good to see so much convergence in the approach! Again, I think that it speaks loudly for the concise way of doing thins in Python... Anyway, I have typed in all of the solutions and have gained a great understanding of how to do this in future. T

Re: Fwd: Should I use "if" or "try" (as a matter of speed)?

2005-07-12 Thread Christopher Subich
Dark Cowherd wrote: > But one advise that he gives which I think is of great value and is > good practice is > "Always catch any possible exception that might be thrown by a library > I'm using on the same line as it is thrown and deal with it > immediately." That's fine advice, except for when it

Re: Minor correction July 11, 2005

2005-07-12 Thread Hank Oredson
"edgrsprj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "edgrsprj" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> PROPOSED EARTHQUAKE FORECASTING >> COMPUTER PROGRAM DEVELOPMENT EFFORT > >> it jumps strait to the display routine and uses the entered command to >

Re: Slicing every element of a list

2005-07-12 Thread Gary Herron
Alex Dempsey wrote: >Recently I tried to slice every element of a list of strings. First I tried: > >f = open("export.xls", "r") >lines = f.readlines() > >for line in lines: >line = line[1:-5] >line = line.split('\"\t\"') > > This, in fact, did do the operation you expected, but after cr

Re: Web client, https and session management

2005-07-12 Thread Gregory Piñero
How's this for an answer, it even uses yahoo in the example! http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/391929 Greg -- http://mail.python.org/mailman/listinfo/python-list

Slicing every element of a list

2005-07-12 Thread Alex Dempsey
Recently I tried to slice every element of a list of strings. First I tried: f = open("export.xls", "r") lines = f.readlines() for line in lines: line = line[1:-5] line = line.split('\"\t\"') This went without returning any errors, but nothing was sliced or split. Next I tried: for i in

Re: automatically assigning names to indexes

2005-07-12 Thread George Sakkis
<[EMAIL PROTECTED]> wrote > > And what should happen for vectors of size != 3 ? I don't think that a > > general purpose vector class should allow it; a Vector3D subclass would > > be more natural for this. > > That's the 'magic' good idea I'm looking for. I think a unified Vector > class for all

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread Bengt Richter
On Tue, 12 Jul 2005 11:52:41 -0400, Tim Peters <[EMAIL PROTECTED]> wrote: >[Peter Hansen] >... >> I suppose I shouldn't blame setdefault() itself for being poorly named, > >No, you should blame Guido for that . > >> but it's confusing to me each time I see it in the above, because the >> name does

Re: Efficiency of using long integers to hold bitmaps

2005-07-12 Thread Jack Diederich
On Wed, Jul 13, 2005 at 03:24:48AM +1000, Jeff Melvaine wrote: > Bengt, > > Thanks for your informative reply, further comments interleaved. > > "Bengt Richter" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Mon, 11 Jul 2005 02:37:21 +1000, "Jeff Melvaine" > > <[EMAIL PROT

Re: Efficiency of using long integers to hold bitmaps

2005-07-12 Thread Bengt Richter
On Wed, 13 Jul 2005 03:24:48 +1000, "Jeff Melvaine" <[EMAIL PROTECTED]> wrote: >Bengt, > >Thanks for your informative reply, further comments interleaved. Can't reply fully now, but just had the thought that maybe some ideas from 8-queens solvers might be useful or interesting. There is an old th

Re: removing list comprehensions in Python 3.0

2005-07-12 Thread Steven Bethard
Steven Bethard wrote: > py> def ge(items): > ... return (item for item in items if item) > ... Bengt Richter wrote: > >>> dis.dis(ge) >2 0 LOAD_CONST 1 ( expression> at 02EE4FA0, file "", line 2>) >3 MAKE_FUNCTION0 >6 LOA

python parser

2005-07-12 Thread tuxlover
Hello everyone I have to write a verilog parser in python for a class project. I was wondering if all you folks could advise me on choosing the right python parser module. I am not comfortable with lex/yacc and as a result find myself strugging with any module which use lex/yacc syntax/philosophy.

Re: Inconsistency in hex()

2005-07-12 Thread Dan Bishop
Steven D'Aprano wrote: > hex() of an int appears to return lowercase hex digits, and hex() of a > long uppercase. > > >>> hex(75) > '0x4b' > >>> hex(75*256**4) > '0x4BL' > > By accident or design? Apart from the aesthetic value that lowercase hex > digits are ugly, should we care? > > It wo

Re: pywin32 com server "cash" question

2005-07-12 Thread Philippe C. Martin
Sorry: "Cache", not "Cash" Philippe C. Martin wrote: > Hi, > > I just got the pywin32 "hello world" COM server to install and I did > manage to use it from VB 6.0. > > However, there are some glitches I do not comprehend: > > 1) at one point I got a python runtime error telling me the > "tes

pywin32 com server "cash" question

2005-07-12 Thread Philippe C. Martin
Hi, I just got the pywin32 "hello world" COM server to install and I did manage to use it from VB 6.0. However, there are some glitches I do not comprehend: 1) at one point I got a python runtime error telling me the "testcomserver" was not found - I got rid of that problem by deleteting the app

Re: Environment Variable

2005-07-12 Thread tuxlover
No, the replies from Grant's and Sybren's do answer my question. I posted twice because my browser locked itself up, and I ended up typing twice :( -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread rorley
Thanks for the hints, I think I've figured it out. I've only been using Python for 2 days so I really needed the direction. If you were curious, this is not homework but an attempt to use the ConceptNet data (its an MIT AI project) to make a website in a Wiki-like format that would allow the data

Re: Efficiency of using long integers to hold bitmaps

2005-07-12 Thread Jeff Melvaine
Bengt, Thanks for your informative reply, further comments interleaved. "Bengt Richter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 11 Jul 2005 02:37:21 +1000, "Jeff Melvaine" > <[EMAIL PROTECTED]> wrote: > >>I note that I can write expressions like "1 << 100" and the

Re: Help with inverted dictionary

2005-07-12 Thread rorley
Not quite homework but a special project. Thanks for the advice. I'll let you know if I run into anymore stumbling blocks. Reece -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread Dark Cowherd
As Steven said this looks too much like home work But what the heck I am also learning python. So I wrote a small program. A very small program. I am fairly new to Python, I am stunned each time to see how small programs like this can be. Since I am also learning can somebody comment if anything h

Re: Web App like Google

2005-07-12 Thread Graham Fawcett
In translating natural language to SQL, be sure you're not introducing opportunities for SQL injection attacks. Code like sql = 'SELECT %s FROM %s' % (this, that) is considered dangerous, because a well-crafted value for "that" can be used to, e.g., delete rows from your tables, run system com

Re: Why does reply to messages on this list put the sender in the To

2005-07-12 Thread Rocco Moretti
Peter Decker wrote: > On 7/12/05, Dark Cowherd <[EMAIL PROTECTED]> wrote: > > >>Most lists when i hit reply it puts the list address back in the To >>address and some lists allow you to configure this. >> >>But in this list reply sends the mail back as a private mail and there >>seems to be no op

Re: automatic form filling

2005-07-12 Thread ulrice jardin
Thanks A LOT for your help! __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistency in hex()

2005-07-12 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > hex() of an int appears to return lowercase hex digits, and hex() of a > long uppercase. > > >>> hex(75) > '0x4b' > >>> hex(75*256**4) > '0x4BL' > > By accident or design? Apart from the aesthetic value that lowercase hex > digits are ugly, should we care? No, ju

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
Well, the string that gets passed is more or less a function definition, which is then called with exec. I don't see why you'd need to write a string out with the function definition and then call it. You could just write the function. As for the nested functions, I had been presuming that it was

  1   2   3   >