Re: validate string is valid maths

2008-01-28 Thread Remco Gerlich
Hi, It seems that for every group of 2 or more +-/* signs, one of the following holds: - The group starts with '-', everything after it should be dropped, otherwise - The second character is '-', everything after it should be dropped, otherwise - Drop everything after the first. That should turn

Re: How avoid both a newline and a space between 2 print commands?

2008-01-23 Thread Remco Gerlich
Hi, Use import sys sys.stdout.write("foo") sys.stdout.write("bar") (and, possibly, sys.stdout.flush() to get the text to show up, it might wait for the end of a complete line otherwise). The alternative import sys print "foo", sys.stdout.softspace=0 print "bar" is just too hackish. In Python

Re: Excess whitespace in my soup

2008-01-19 Thread Remco Gerlich
Not sure if this is sufficient for what you need, but how about import re re.sub(u'[\s\xa0]+', ' ', s) That should replace all occurances of 1 or more whitespace or \xa0 characters, by a single space. Remco On Jan 19, 2008 12:38 PM, John Machin <[EMAIL PROTECTED]> wrote: > I'm trying to recove

Re: Loop in a loop?

2008-01-17 Thread Remco Gerlich
Use zip() to combine them into a single list, then loop over that: for x, y in zip(array1, array2): ... Remco On Jan 17, 2008 1:21 PM, Sacred Heart <[EMAIL PROTECTED]> wrote: > Hi, > I'm new to Python and have come across a problem I don't know how to > solve, enter com.lang.python :) > > I'

Re: How to get memory size/usage of python object

2008-01-10 Thread Remco Gerlich
Hi, The only list without references to other objects in it is [ ]. 0, 1, 2, etc are objects. Every value in Python is a reference to an object. Remco On Jan 10, 2008 9:14 AM, Santiago Romero < [EMAIL PROTECTED]> wrote: > > > Would you care to precisely define "REAL size" first? Consider: > >

Re: Question from a python newbie

2007-12-13 Thread Remco Gerlich
line above is equivalent to text.isdigit() ? int(text) : text in, for instance, C. Remco Gerlich -- http://mail.python.org/mailman/listinfo/python-list

Re: what the heck does this mean?

2007-12-13 Thread Remco Gerlich
bignum = 1 > bignumer = repr(bignum) > Searching = Search+bignumer > Searched = eval(Searching) > Maty = Searched[number] > This isn't the actual code that gave the error message - here you used [ ]. > Anyway, doing it like this is really bad and li

Re: multidimensional "arrays"

2007-12-06 Thread Remco Gerlich
s you already found out about that :-) That said, are you sure a list of lists is the best data structure for what you're trying to do? I keep being surprised by Python code that uses other data structures in clever ways; lists of lists seem to be pretty rare! Remco Gerlich On Dec 6, 20