Re: Quote aware split

2007-05-15 Thread obaudys
On May 16, 1:18 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:

> The "is" operator checks object *identity*, that is, if both operands are
> actually the same object. It may or may not work here, depending on many
> implementation details. You really should check if they are *equal*
> instead:
>
>   if c == quote:
>   qcount += 1
>   if c == sep and qcount % 2 == 0:
>   splitpoints.append(index)

I was always under the impression the 'a' and 'a' were always the same
object and
*is* and == were interchangeble with strings, since they were
immutable.  But
sure enough running your code snippet example:

> See:
> py> x='a'
> py> y='A'.lower()
> py> y
> 'a'
> py> x==y
> True
> py> x is y
> False

I got the same result as you.  Point taken, thank you!

Interestingly:

py> id('a')
-1209815264
py> id(x)
-1209815264
py> id(y)
-1210219808
py> id('A'.lower())
-1210219712

So there are at least three 'a' string objects registered in whatever
hashtable implementation
lies underneath Python's string datatype.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Quote aware split

2007-05-16 Thread obaudys
On May 16, 8:51 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote:
> How is the code different from shlex.split?

Shlex only splits by whitespace.  I needed something to split out SQL
statements from a Postgresql dump, so the ideal way of doing that is
to split by semicolons.  However, postgresql function definitions have
semicolons inside single quoted blocks which I didnt want to split by.

--
Ondrej

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble with pyvtk

2007-05-17 Thread obaudys
On May 18, 2:22 pm, LokiDawg <[EMAIL PROTECTED]> wrote:



> All is well until the last line (writing the file), after which the
> following error occurs:



>   File "/usr/lib/python2.4/site-packages/pyvtk/common.py", line 140,
> in get_datatype
> if is_int(obj): return self.default_int
> RuntimeError: maximum recursion depth exceeded
>
> I'm assuming my pyvtk installation is at issue here (?), but I don't
> know enough about python to tell what has gone wrong, or how to fix
> it. Can someone point me in the right direction?

This could be very well be a bug where infinite recursion happens, but
see if changing the recursion limit fixes this:

>>> import sys
>>> sys.getrecursionlimit()
1000
>>> sys.setrecursionlimit(1)

Regards,
Ondrej

-- 
http://mail.python.org/mailman/listinfo/python-list