Re: ctypes and setjmp

2006-10-06 Thread Gabriel Genellina
At Friday 6/10/2006 16:14, Thomas Heller wrote: > Currently ctypes can't play well with any C code that requires use of setjmp > as part of its API. > libpng is one of those libraries. > I didn't know that setjmp/longjmp is actually used by production libraries for error handling. Using setjm

Re: Names changed to protect the guilty

2006-10-06 Thread MonkeeSage
On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: > The following line of lightly munged code was found in a publicly > available Python library... Yes, this violates the Holy, Inspired, Infallible Style Guide (pbuh), which was written by the very finger of God when the world was still in chaot

Re: Names changed to protect the guilty

2006-10-06 Thread MonkeeSage
On Oct 6, 8:02 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > it is clearer to you to make the condition explicit ("blah not False"), "blah not False" -> "blah is False" -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't get around "IndexError: list index out of range"

2006-10-06 Thread Gabriel Genellina
At Friday 6/10/2006 20:57, erikcw wrote: I ended up using len(sys.argv) > 1 for this particular problem. But I think slicing is closer to the tool I was looking for. I found a.has_key(k) or "k in a" for dictionaries - but haven't found anything similar for lists. Does it exist? if 2 in [1,2

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread Steven D'Aprano
On Fri, 06 Oct 2006 12:42:08 +0200, Fredrik Lundh wrote: > Antoon Pardon wrote: > >> IMO this is a very natural thought process for a python programmer. >> So a python programmer seeing the first will tend to expect that >> last call to work. > > on the other hand, if a Python programmer *writes

Re: Names changed to protect the guilty

2006-10-06 Thread Neil Cerutti
On 2006-10-07, MonkeeSage <[EMAIL PROTECTED]> wrote: > > > On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: >> The following line of lightly munged code was found in a >> publicly available Python library... > > Yes, this violates the Holy, Inspired, Infallible Style Guide > (pbuh), which was wri

Re: Names changed to protect the guilty

2006-10-06 Thread John Machin
MonkeeSage wrote: > On Oct 6, 8:02 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > > it is clearer to you to make the condition explicit ("blah not False"), > > "blah not False" -> "blah is False" Whichever way your team wants to interpret it, d00d. Please consider whether you should be writing "(

Re: Names changed to protect the guilty

2006-10-06 Thread Neil Cerutti
On 2006-10-07, John Machin <[EMAIL PROTECTED]> wrote: > > MonkeeSage wrote: >> On Oct 6, 8:02 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: >> > it is clearer to you to make the condition explicit ("blah not False"), >> >> "blah not False" -> "blah is False" > > Whichever way your team wants to inter

Re: Names changed to protect the guilty

2006-10-06 Thread Gabriel Genellina
At Friday 6/10/2006 22:02, MonkeeSage wrote: > The following line of lightly munged code was found in a publicly > available Python library... Yes, this violates the Holy, Inspired, Infallible Style Guide (pbuh), which was written by the very finger of God when the world was still in It's not

Re: Debugging question: Print out program state (Variables)

2006-10-06 Thread Gabriel Genellina
At Friday 6/10/2006 12:53, Josh Bloom wrote: What I would like to do is write out the state of my script when an error is encountered. I've been looking at the traceback module and think Im on the right track, but I haven't figured out a way to write out all of the programs current variables.

Re: Names changed to protect the guilty

2006-10-06 Thread hanumizzle
On 6 Oct 2006 16:27:51 -0700, Aahz <[EMAIL PROTECTED]> wrote: > The following line of lightly munged code was found in a publicly > available Python library... > > if schema.elements.has_key(key) is False: if not schema.elements.has_key(key): or, actually, if not key in schema.elements: is how

Re: Names changed to protect the guilty

2006-10-06 Thread MonkeeSage
On Oct 6, 8:34 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > And in the original case, I'd agree that "if X.has_key():" is > quite clear, already yielding a boolian value, and so doesn't > need to be tested for if it's False. But I wouldn't like to test > for an empty list or for None implicitly.

Re: Names changed to protect the guilty

2006-10-06 Thread Virgil Dupras
MonkeeSage wrote: > On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: > > The following line of lightly munged code was found in a publicly > > available Python library... > > Yes, this violates the Holy, Inspired, Infallible Style Guide (pbuh), > which was written by the very finger of God when

Re: What value should be passed to make a function use the default argument value?

2006-10-06 Thread hanumizzle
On 6 Oct 2006 10:57:01 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: > Again that is not the fault of those that read the documentation. If > this discinction can't be easily made in python 2.X, you can't fault > the reader for coming to a conclusion that seems to follow rather > naturally from ho

Re: News on versions modules for Python-2.5?

2006-10-06 Thread MC
Hi again! Thank you, for all answers & contribs. -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't get around "IndexError: list index out of range"

2006-10-06 Thread hanumizzle
On 6 Oct 2006 16:57:23 -0700, erikcw <[EMAIL PROTECTED]> wrote: > I ended up using len(sys.argv) > 1 for this particular problem. But I > think slicing is closer to the tool I was looking for. > > I found a.has_key(k) or "k in a" for dictionaries - but haven't found > anything similar for lists.

Re: dictionary containing a list

2006-10-06 Thread Bryan Olson
Ben wrote: > I have set up a dictionary into whose values I am putting a list. I > loop around and around filling my list each time with new values, then > dumping this list into the dictionary. Or so I thought... > > It would appear that what I am dumping into the dictionary value is > only a poi

Re: dictionary containing a list

2006-10-06 Thread hanumizzle
On 6 Oct 2006 14:37:59 -0700, Ben <[EMAIL PROTECTED]> wrote: > Is there a way to acheive what I was attempting ? I have done something > almost identical with classes in a list before, and in that case a new > instance was created for each list entry... Not sure what you're trying to pull off, b

Re: [Linux] Detect a key press

2006-10-06 Thread hanumizzle
On 10/6/06, Sergei Organov <[EMAIL PROTECTED]> wrote: > Try > > print "->%s\r" % ch > > or just > > sys.stdout.write(ch) Ah! -- http://mail.python.org/mailman/listinfo/python-list

Re: Names changed to protect the guilty

2006-10-06 Thread Aahz
In article <[EMAIL PROTECTED]>, MonkeeSage <[EMAIL PROTECTED]> wrote: >On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: >> >> The following line of lightly munged code was found in a publicly >> available Python library... > >Yes, this violates the Holy, Inspired, Infallible Style Guide (pbuh), >

Re: error handling in user input: is this natural or just laborious

2006-10-06 Thread James Stroud
sam wrote: > this does what i want, though i don't like the inner while loop having > to be there > > > def get_pct(): > while True: > pct_list=[['cash', 0], ['bond', 0], ['blue', 0], ['tech', 0], > ['dev', > 0]] > total=0 > for i in range(len(pct_

Re: ctypes and setjmp

2006-10-06 Thread Richard Jones
Gabriel Genellina wrote: > At Friday 6/10/2006 16:14, Thomas Heller wrote: >>For ctypes, the only solution I can think of is to invent a new calling >>convention, which will call setjmp() first internally before calling the >>libpng api function... > > May be reasonable - a non-zero in setjmp woul

Re: Graph Theory

2006-10-06 Thread boggom
Other than reading the reference on the website https://networkx.lanl.gov/reference/networkx/ you can read the code (eg by browsing the svn by pointing your web browser at https://networkx.lanl.gov/browser/networkx/trunk and then look at networkx -> generators -> random_graphs.py) If you are not

Re: Recursive descent algorithm able to parse Python?

2006-10-06 Thread hanumizzle
On 10/6/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Lawrence D'Oliveiro schrieb: > > In message <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > > > >> I have to admit that I have difficulties to compare LR(k) to recursive > >> descent, but the fact that the latter contains backtracking makes i

Re: Skullsocks to the rescue - was [irrelevant squabble of IL]

2006-10-06 Thread hanumizzle
On 10/6/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Fredrik Lundh schrieb: > > Diez B. Roggisch wrote: > > > >> This is on the same level of interest to the communities of python, > >> ruby & java as the color of my socks this morning - a deep black with > >> cute little skulls imprinted. > >

Re: error handling in user input: is this natural or just laborious

2006-10-06 Thread James Stroud
James Stroud wrote: > sam wrote: > >> this does what i want, though i don't like the inner while loop having >> to be there [snip] > A little cleaner. Now, lets tighten it up a bit more, and put nested > loops into functions. Im getting rid of keeping track of the running > total, that will clea

problem with split

2006-10-06 Thread [EMAIL PROTECTED]
apologies if I annoy and for spacing (google) def csdInstrumentList(from_file): "Returns a list of .csd instruments and any comment lines after the instrument" infile = open(from_file, 'r') temp_number = 0 for line in infile: if 'instr' in line: s = re.split(r

Re: problem with split

2006-10-06 Thread [EMAIL PROTECTED]
p.s. this is the one I need to finish to release the csoundroutines library www.dexrow.com [EMAIL PROTECTED] wrote: > apologies if I annoy and for spacing (google) > > > > def csdInstrumentList(from_file): > "Returns a list of .csd instruments and any comment lines after the > instrument" >

Re: extract certain values from file with re

2006-10-06 Thread hanumizzle
On 6 Oct 2006 13:16:13 -0700, Matteo <[EMAIL PROTECTED]> wrote: > Coming from C++, using exceptions in this way still feels a bit creepy > to me, but I've been assured that this is very pythonic, and I'm slowly > adopting this style in my python code. > > Parsing the line can be easy too: >(um

Re: problem with split

2006-10-06 Thread hanumizzle
On 6 Oct 2006 21:07:43 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I want comment returned in an array and instr_number returned in an > array. Let me see if I understand what you want: if there is a line that starts with instr (best tested with line.startswith('instr') :)), you want th

Weekly Python Patch/Bug Summary

2006-10-06 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 428 open ( +6) / 3417 closed ( +2) / 3845 total ( +8) Bugs: 939 open ( +6) / 6229 closed (+17) / 7168 total (+23) RFE : 240 open ( +3) / 239 closed ( +0) / 479 total ( +3) New / Reopened Patches __ Speed up

Re: dictionary containing a list

2006-10-06 Thread goyatlah
I think what you mean is that if you change your list, it is changed somewhere in your dicrionary to. Lists are always copied as pointers, except explicitly told other wise. So a = b = [] makes a and be the same list, and a.append(1) makes b -> [1]. So do something like mydict[mykey] = mylist[:] (

Re: humble coin head or tail game script I wrote

2006-10-06 Thread Camellia
Oh I get it and ashamed, thank you for explaining it to me:) so I sould: ini_guess=random.randrange(2) ... for item in list: if item=='h': ... if item ==t': ... [EMAIL PROTECTED] wrote: > Camellia wrote: > > Well...It' doesn't, have you run it yet? > > Yes it does, and ru

Re: Python to use a non open source bug tracker?

2006-10-06 Thread [EMAIL PROTECTED]
Jira is a remarkably well done product. We've adopted it internally and use it for project planning (we're doing Agile) as well as defect tracking. The plugin support and user interface just can't be touched by the competition and I've been looking. I'd prefer an open source python based system and

Re: Can't get around "IndexError: list index out of range"

2006-10-06 Thread MonkeeSage
On Oct 6, 8:23 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > if 2 in [1,2,3]: print "Use the same (in) operator" > elif 'E' in ('E','r','i','k'): print "Works for any sequence" > elif 'o' in 'hello': print "Even strings" This isn't really analogous is it? For "somedict.has_key(k)" or "k in

Re: problem with split

2006-10-06 Thread goyatlah
Think you need a regex like this: regex = r"\s*instr\s+([0-9]+)\s*(;.*)?" Then: import re test = re.compile(regex) testing is done as follows: res = test.match(mystring) if res: number = res.group(1) # always a string consisting of decimals comment = res.group(2) # string starting with ;

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Paddy
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Ah, wait a moment. One more tweak. Make the body class a psyco class. > > That improves the runtime to 3.02s. Diff appended. > > Nice. Maybe you can do the same trick with: > from psyco.classes import __metaclass__ > > If you want you can

Re: problem with split

2006-10-06 Thread hanumizzle
On 10/7/06, goyatlah wrote: > Think you need a regex like this: regex = > r"\s*instr\s+([0-9]+)\s*(;.*)?" [0-9] maybe written simply as \d (d for digit) > Then: > import re > test = re.compile(regex) Regexes are usually passed as literals directly to re.compile(). > testing is done as follows:

Notice from auto reply program

2006-10-06 Thread Yoichi Maeda
An e-mail address of Yoichi Maeda has been moved to [EMAIL PROTECTED] Your mail has been forwarded to the new address. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: Names changed to protect the guilty

2006-10-06 Thread John Machin
Aahz wrote: > In article <[EMAIL PROTECTED]>, > MonkeeSage <[EMAIL PROTECTED]> wrote: > >On Oct 6, 6:27 pm, [EMAIL PROTECTED] (Aahz) wrote: > >> > >> The following line of lightly munged code was found in a publicly > >> available Python library... > > > >Yes, this violates the Holy, Inspired, Inf

Re: problem with split

2006-10-06 Thread MonkeeSage
On Oct 6, 11:33 pm, hanumizzle <[EMAIL PROTECTED]> wrote: > import re > > > > if line.startswith('instr'): > p = re.compile(r'(\d+)\s+;(.*)$') > m = p.search(line) > > return (m.group(1), m.group(2)) You probably don't want startswith, in case there are initial spaces in the line. Also, sin

Re: problem with split

2006-10-06 Thread [EMAIL PROTECTED]
I was trying something like this digits = re.compile("\d") if digits in line instr_number = digits.search(line) because it looked realy cool when I saw it in a recent post... and then the same thing for just (';') didn't seem to return anything except one line and some hex that cam

Re: problem with split

2006-10-06 Thread hanumizzle
On 6 Oct 2006 23:09:08 -0700, MonkeeSage <[EMAIL PROTECTED]> wrote: > > > On Oct 6, 11:33 pm, hanumizzle <[EMAIL PROTECTED]> wrote: > > import re > > > > > > > > if line.startswith('instr'): > > p = re.compile(r'(\d+)\s+;(.*)$') > > m = p.search(line) > > > > return (m.group(1), m.group(2)) >

Re: problem with split

2006-10-06 Thread [EMAIL PROTECTED]
I think I am very close the return line is tripping me up. (this is the first list that I have tried to program in python) return (s.group[1], s.group[2]) Traceback (most recent call last): File "C:\Python24\Lib\site-packages\boa-constructor\test of snake\test_of_csoundroutines_list.py", line

<    1   2   3