Re: recommended way to insert data into a one to many relationship using python

2010-05-02 Thread Wolfgang Meiners
Peter Otten schrieb: > Peter Otten wrote: > > If you create indices for floors (and rooms) > > cur.execute("""create unique index room_index on rooms (fid, number);""") > cur.execute("""create unique index floor_index on floors (floor);""") > > the addition of missing rows can be simplified to >

Re: Problems with 'scipy.sparse.linalg.dsolve.umfpack'

2010-05-02 Thread Chris Rebert
On Sun, May 2, 2010 at 11:24 PM, pp wrote: > Hello all, > > I have this equation to solve where variable > LHS is a sparse matrix and RHS is an array . > c = linsolve.spsolve(LHS, RHS) > > > i get this error > warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'\ >                  ' instal

Problems with 'scipy.sparse.linalg.dsolve.umfpack'

2010-05-02 Thread pp
Hello all, I have this equation to solve where variable LHS is a sparse matrix and RHS is an array . c = linsolve.spsolve(LHS, RHS) i get this error warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'\ ' install scikits.umfpack instead' what is the reason for this and d

Re: Parser

2010-05-02 Thread Stefan Behnel
dmtr, 03.05.2010 07:39: ANTLR I don't know if it's that easy to get started with though. The companion for-pay book is *most excellent*, but it seems to have been written to the detriment of the normal online docs. IMO ANTLR is much easier to use compared to any other tool simply because it h

Re: Parser

2010-05-02 Thread dmtr
> > > ANTLR > > I don't know if it's that easy to get started with though. The > companion for-pay book is *most excellent*, but it seems to have been > written to the detriment of the normal online docs. > > Cheers, > Chris > --http://blog.rebertia.com IMO ANTLR is much easier to use compared to

Re: Parser

2010-05-02 Thread Chris Rebert
On Sun, May 2, 2010 at 10:10 PM, dmtr wrote: > On May 2, 12:54 pm, Andreas Löscher chemnitz.de> wrote: >> Hi, >> I am looking for an easy to use parser. I am want to get an overview >> over parsing and want to try to get some information out of a C-Header >> file. Which parser would you recommend

Re: Parser

2010-05-02 Thread dmtr
On May 2, 12:54 pm, Andreas Löscher wrote: > Hi, > I am looking for an easy to use parser. I am want to get an overview > over parsing and want to try to get some information out of a C-Header > file. Which parser would you recommend? ANTLR -- http://mail.python.org/mailman/listinfo/python-list

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Alf P. Steinbach
* Terry Reedy: * Alf P. Steinbach: * Aahz: and sometimes they rebind the original target to the same object. At the Python level that seems to be an undetectable null-operation. If you try t=(1,2,3); t[1]+=3, if very much matters that a rebind occurs. Testing: >>> t = ([], [], []) >>>

Re: Fast Efficient way to transfer an object to another list

2010-05-02 Thread Bryan
Steven D'Aprano wrote: > The simplest way to speed the above code up is not to start from the > beginning each time. That requires two very small changes. And since > deletions from the front of the list are slow, MRAB's suggestion is also > a good idea. Those two speed-ups provide worst-case line

Re: ANN: expy 0.6.6 released!

2010-05-02 Thread Yingjie Lan
> Subject: ANN: expy 0.6.6 released! > To: "python list" > Cc: "CAPI Python" > Date: Monday, May 3, 2010, 3:24 AM > EXPY is an express way to extend Python! > > EXPY provides a way to extend python in an elegant way. For > more information and a tutorial, see: http://expy.sourceforge.net/ > I'

Re: condition and True or False

2010-05-02 Thread John Machin
On May 3, 9:14 am, Steven D'Aprano wrote: > If it is any arbitrary object, then "x and True or False" is just an > obfuscated way of writing "bool(x)". Perhaps their code predates the > introduction of bools, and they have defined global constants True and > False but not bool. Then they removed

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Gregory Ewing
James Porter wrote: Functions like numpy.zeros_like use ndarray.__new__(subtype, ...) to create new arrays based on the shape of other arrays. Maybe the real answer to this question is "NumPy is doing it wrong" Yes, I think NumPy is doing it wrong, even for subclasses written in Python. If th

Re: condition and True or False

2010-05-02 Thread Patrick Maupin
On May 2, 12:14 pm, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >     x = and True or False > > What is "and True or False" adding to this picture?  The boolean > expr

Re: List size versus list allocation

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 18:07:31 +0200, Christian Heimes wrote: >> I'm interested in gathering some statistics on this, and to do so I >> need a way of measuring the list's logical size versus its actual size. >> The first is easy: it's just len(list). Is there some way of getting >> the allocated siz

ANN: expy 0.6.6 released!

2010-05-02 Thread Yingjie Lan
EXPY is an express way to extend Python! EXPY provides a way to extend python in an elegant way. For more information and a tutorial, see: http://expy.sourceforge.net/ What's new: 1. Special methods can now take @throws decorators. 2. Added convenience macros _NEW and _CheckExact for extension

Re: condition and True or False

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 10:14:44 -0700, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code that > might better be coded using "y if x else z", I came across this puzzler: > > x = and True or False > > What is "and True or False" adding to this picture? Th

Re: sometype.__new__ and C subclasses

2010-05-02 Thread James Porter
On 5/2/2010 3:58 PM, Robert Kern wrote: Well, I think we can change zeros_like() and the rest to work around this issue. Can you bring it up on the numpy mailing list? def zeros_like(a): if isinstance(a, ndarray): res = numpy.empty(a.shape, a.dtype, order=a.flags.fnc) res.fill(0) res = res.view(

Re: Parser

2010-05-02 Thread Martin v. Loewis
Andreas Löscher wrote: > Hi, > I am looking for an easy to use parser. I am want to get an overview > over parsing and want to try to get some information out of a C-Header > file. To get information from a header file, try Tools/scripts/h2py.py Regards, Martin -- http://mail.python.org/mailman/

Re: condition and True or False

2010-05-02 Thread Carl Banks
On May 2, 10:14 am, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >     x = and True or False > > What is "and True or False" adding to this picture?  The boolean > expr

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Carl Banks
On May 2, 1:51 pm, Robert Kern wrote: > On 2010-05-02 15:28 , Carl Banks wrote: > > > > > On May 2, 10:48 am, James Porter  wrote: > >> On 5/2/2010 4:34 AM, Carl Banks wrote: > > >>> Why don't you use mysubtype.__new__(mysubtype,...)? > > >>> If you wrote mysubtype in C, and defined a different tp

Re: PyObject_SetAttrString - doesn't set instance attribute

2010-05-02 Thread Carl Banks
On May 2, 3:26 am, Jason wrote: > On May 2, 5:52 pm, Carl Banks wrote: > > > Not sure what you're doing here.  It looks like you are being passed > > an object of a given type, then you get the type object, call it to > > create another object of that type, and assign it to object->instance. > >

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Robert Kern
On 2010-05-02 15:03 , James Porter wrote: And then in Python: A = iMesh.Array(numpy.array([1,2,3,4,5]), instance=mesh) numpy.zeros_like(A) # fails here Inside NumPy, zeros_like looks like this (there's a bit more than this, but it's irrelevant to this problem): def zeros_like(a): if isinstanc

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Robert Kern
On 2010-05-02 15:28 , Carl Banks wrote: On May 2, 10:48 am, James Porter wrote: On 5/2/2010 4:34 AM, Carl Banks wrote: Why don't you use mysubtype.__new__(mysubtype,...)? If you wrote mysubtype in C, and defined a different tp_new than ndarray, then this exception will trigger. And it oug

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Carl Banks
On May 2, 10:48 am, James Porter wrote: > On 5/2/2010 4:34 AM, Carl Banks wrote: > > > Why don't you use mysubtype.__new__(mysubtype,...)? > > > If you wrote mysubtype in C, and defined a different tp_new than > > ndarray, then this exception will trigger.  And it ought to; you don't > > want to u

Re: Parser

2010-05-02 Thread Jason Scheirer
On May 2, 12:54 pm, Andreas Löscher wrote: > Hi, > I am looking for an easy to use parser. I am want to get an overview > over parsing and want to try to get some information out of a C-Header > file. Which parser would you recommend? > > Best, > Andreas Pyparsing: http://pyparsing.wikispaces.com

Re: condition and True or False

2010-05-02 Thread David Robinow
On Sun, May 2, 2010 at 1:14 PM, Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > >    x = and True or False > > What is "and True or False" adding to this picture?  The boo

Re: sometype.__new__ and C subclasses

2010-05-02 Thread James Porter
On 5/2/2010 1:43 PM, Robert Kern wrote: Perhaps things would be clearer if you could post the C code that you've written that fails. So far, you've only alluded at what you are doing using Python-syntax examples. I'm not sure how much this will help, but here you go. The actual C code probably

Parser

2010-05-02 Thread Andreas Löscher
Hi, I am looking for an easy to use parser. I am want to get an overview over parsing and want to try to get some information out of a C-Header file. Which parser would you recommend? Best, Andreas -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in Python set

2010-05-02 Thread Terry Reedy
On 5/2/2010 8:11 AM, dmitrey wrote: Python 2.6.5 r265:79063 set().update(set()) is None True while I expect result of update to be set. Also, result of set().add(None) is None while I expect it to be set with element None (or, maybe, it should be empty set?) 'Expect' has two different meaning

Re: recommended way to insert data into a one to many relationship using python

2010-05-02 Thread Bryan
Wolfgang Meiners wrote: > one to many relationships are fairly common, i think. So there should be > a recommended way to insert data into such a relation using python. > > Given the following programm, what is the recommended way to insert the > list of NewEmployees to the database? > > ==

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Robert Kern
On 2010-05-02 12:48 , James Porter wrote: On 5/2/2010 4:34 AM, Carl Banks wrote: Why don't you use mysubtype.__new__(mysubtype,...)? If you wrote mysubtype in C, and defined a different tp_new than ndarray, then this exception will trigger. And it ought to; you don't want to use ndarray's tp_ne

Re: condition and True or False

2010-05-02 Thread Vito 'ZeD' De Tullio
Peter Otten wrote: > def f(): > big_beast = list(range(10**100)) > return big_beast and True or False > x = f() > > it would prevent that a big_beast reference becomes visible outside the > function and allow for immediate release of its memory. what's wrong in bool(big_beast)? -- By Z

Re: assigning multi-line strings to variables

2010-05-02 Thread Sibylle Koczian
goldtech schrieb: Thank you to posters for help to my question. Seems I had trouble with triple quotes strings in the PythonWin shell. But using the Idle shell things work as expected. But this is probably another issue...any way, w/Idle's shell I got the "action" regarding multiline strings I ex

Re: condition and True or False

2010-05-02 Thread Peter Otten
Paul McGuire wrote: > While sifting through some code looking for old "x and y or z" code > that might better be coded using "y if x else z", I came across this > puzzler: > > x = and True or False > > What is "and True or False" adding to this picture? The boolean > expression part is alr

Python debuggers with sys.settrace()

2010-05-02 Thread Sarah Mount
This is a bit of an odd question, but is there any way for a Python debugger to suppress I/O generated by the program which is being debugged? I guess an "obvious" thing to do would be to replace core parts of the standard library and change any relevant imports in the locals and globals dicts to f

Re: sometype.__new__ and C subclasses

2010-05-02 Thread James Porter
On 5/2/2010 4:34 AM, Carl Banks wrote: Why don't you use mysubtype.__new__(mysubtype,...)? If you wrote mysubtype in C, and defined a different tp_new than ndarray, then this exception will trigger. And it ought to; you don't want to use ndarray's tp_new to create an object of your subclass, if

condition and True or False

2010-05-02 Thread Paul McGuire
While sifting through some code looking for old "x and y or z" code that might better be coded using "y if x else z", I came across this puzzler: x = and True or False What is "and True or False" adding to this picture? The boolean expression part is already evaluating to a boolean, so I do

Re: List size versus list allocation

2010-05-02 Thread Peter Otten
Christian Heimes wrote: def slots(lst): > ... return (sys.getsizeof(lst) - sys.getsizeof([])) / D'oh! Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: List size versus list allocation

2010-05-02 Thread Christian Heimes
I'm interested in gathering some statistics on this, and to do so I need a way of measuring the list's logical size versus its actual size. The first is easy: it's just len(list). Is there some way of getting the allocated size of the list? With Python 2.6 and newer you can use sys.getsizeof() t

Re: List size versus list allocation

2010-05-02 Thread Peter Otten
Steven D'Aprano wrote: > Python lists are over-allocated: whenever they need to be resized, they > are made a little bit larger than necessary so that appends will be fast. > > See: > > http://code.python.org/hg/trunk/file/e9d930f8b8ff/Objects/listobject.c > > I'm interested in gathering some s

Re: help req setting python executable

2010-05-02 Thread D'Arcy J.M. Cain
On Sun, 2 May 2010 12:59:35 +0100 michel parker wrote: > > hi, > i have just installed python3.1 with opt=g option. > but when i set python executable in wingide to usr/local/bin/python3.1 it > says : I don't know anything about wingide but I think your problem is simply a missing slash. /usr/

Re: Fast Efficient way to transfer an object to another list

2010-05-02 Thread Hans Mulder
Francesco Bochicchio wrote: Anyway i think that list.extract( old_list, predicate ) -> new_list would be a nice addition to the standard library You could use filter( predicate, old_list ) -> new_list -- HansM -- http://mail.python.org/mailman/listinfo/python-list

List size versus list allocation

2010-05-02 Thread Steven D'Aprano
Python lists are over-allocated: whenever they need to be resized, they are made a little bit larger than necessary so that appends will be fast. See: http://code.python.org/hg/trunk/file/e9d930f8b8ff/Objects/listobject.c I'm interested in gathering some statistics on this, and to do so I need

Re: Bug in Python set

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 05:11:40 -0700, dmitrey wrote: > Python 2.6.5 r265:79063 set().update(set()) is None > True > while I expect result of update to be set. Change your expectations. Generally, methods which modify the object rather than creating a new one return None. >>> s = set([1,2,3])

Re: Bug in Python set

2010-05-02 Thread Aahz
In article <0bd314a8-db65-43f1-a999-521e2ed71...@n15g2000yqf.googlegroups.com>, dmitrey wrote: > >Python 2.6.5 r265:79063 set().update(set()) is None >True >while I expect result of update to be set. >Also, result of >set().add(None) >is None while I expect it to be set with element None (or,

Re: recommended way to insert data into a one to many relationship using python

2010-05-02 Thread Peter Otten
Peter Otten wrote: If you create indices for floors (and rooms) cur.execute("""create unique index room_index on rooms (fid, number);""") cur.execute("""create unique index floor_index on floors (floor);""") the addition of missing rows can be simplified to missing = c2.execute("""select distin

Bug in Python set

2010-05-02 Thread dmitrey
Python 2.6.5 r265:79063 >>>set().update(set()) is None True while I expect result of update to be set. Also, result of set().add(None) is None while I expect it to be set with element None (or, maybe, it should be empty set?) Regards, D. -- http://mail.python.org/mailman/listinfo/python-list

help req setting python executable

2010-05-02 Thread michel parker
hi, i have just installed python3.1 with opt=g option. but when i set python executable in wingide to usr/local/bin/python3.1 it says : Some values are invalid: - Python executable 'usr/local/bin/python3.1' is not in path Please correct the values and try again. Please help. What is going to be

RE: help error : Failed to build these modules: _dbm

2010-05-02 Thread michel parker
hi, yup problem solved module was missing libgdbm-dev > From: kushal.kumaran+pyt...@gmail.com > Date: Sun, 2 May 2010 16:38:28 +0530 > Subject: Re: help error : Failed to build these modules: _dbm > To: michelpar...@live.com > CC: python-list@python.org > > On Sun, May 2, 2010 at 3:30 PM, miche

Re: matching strings in a large set of strings

2010-05-02 Thread Albert van der Horst
In article <877hnpjtdw@rudin.co.uk>, Paul Rudin wrote: >"Karin Lagesen" writes: > >> Hello. >> >> I have approx 83 million strings, all 14 characters long. I need to be >> able to take another string and find out whether this one is present >> within the 83 million strings. >> >> Now, I have

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Albert van der Horst
In article , Jean-Michel Pichavant wrote: >Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: >> >> vbl.=func(args) >> >> this would be equivalent to >> >> vbl = vbl.func(args) >> >> example: >> >> foo = "Hello world" >> foo.=split(" ") >> print foo

Re: help error : Failed to build these modules: _dbm

2010-05-02 Thread Kushal Kumaran
On Sun, May 2, 2010 at 3:30 PM, michel parker wrote: > Hi, > When i make python 3.1 on my ubuntu 9.10 i get following error : > > Failed to build these modules: > _dbm > Please help me. > I have done : > > apt-get build-dep python2.5 > > but to no avail. > Cheers > > Probably the packages libdb4.

Re: PyObject_SetAttrString - doesn't set instance attribute

2010-05-02 Thread Jason
On May 2, 5:52 pm, Carl Banks wrote: > Not sure what you're doing here.  It looks like you are being passed > an object of a given type, then you get the type object, call it to > create another object of that type, and assign it to object->instance. Sorry, I should have noted that the "NautilusP

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 04:04:11 -0400, Terry Reedy wrote: > On 5/2/2010 1:05 AM, Alf P. Steinbach wrote: >> On 02.05.2010 06:06, * Aahz: > >>> and sometimes >>> they rebind the original target to the same object. >> >> At the Python level that seems to be an undetectable null-operation. > > If you

help error : Failed to build these modules: _dbm

2010-05-02 Thread michel parker
Hi, When i make python 3.1 on my ubuntu 9.10 i get following error : Failed to build these modules: _dbm Please help me. I have done : apt-get build-dep python2.5 but to no avail. Cheers

Re: PyObject_SetAttrString - doesn't set instance attribute

2010-05-02 Thread Carl Banks
On May 1, 4:04 am, Jason wrote: > I'm having a bit of trouble with C/Python bindings. Particularly, > trying to set an instance variable from C when the object is > initialised using PyObject_SetAttrString, but nothing seems to happen. > The C initialisation code is: > > static void > nautilus_pyt

Re: sometype.__new__ and C subclasses

2010-05-02 Thread Carl Banks
On May 1, 11:03 pm, James Porter wrote: > I've been trying to write a Python C extension module that uses NumPy > and has a subtype of numpy.ndarray written in C. However, I've run into > a snag: calling numpy.ndarray.__new__(mysubtype, ...) triggers an > exception in the bowels of Python (this is

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 17:09:36 +1000, Lie Ryan wrote: > On 05/02/10 10:58, Steven D'Aprano wrote: >> On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote: >> >>> > On 05/01/10 11:16, Steven D'Aprano wrote: >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: >> >> In practic

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Steven D'Aprano
On Sun, 02 May 2010 16:28:28 +1000, Lie Ryan wrote: > On 05/02/10 10:58, Steven D'Aprano wrote: >>> > And Python's object system >>> > makes it that the argument to __getattr__ is always a string even >>> > though there might be a valid variable that corresponds to it: >> That is nothing to do wit

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Terry Reedy
On 5/2/2010 1:05 AM, Alf P. Steinbach wrote: On 02.05.2010 06:06, * Aahz: and sometimes they rebind the original target to the same object. At the Python level that seems to be an undetectable null-operation. If you try t=(1,2,3); t[1]+=3, if very much matters that a rebind occurs. Grant

Re: pyjamas 0.7 released

2010-05-02 Thread Wolfgang Strobl
lkcl : > at least _some_ input would be good! the knowledge doesn't have to >be there: just the bugreports saying "there's a problem and here's >exactly how you reproduce it" would be a start! >> So please make it simpler for more people to help. > ... how?? there's a bugtracker, wiki, svn repo

Re: Python dot-equals (syntax proposal)

2010-05-02 Thread Lie Ryan
On 05/02/10 10:58, Steven D'Aprano wrote: > On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote: > >> > On 05/01/10 11:16, Steven D'Aprano wrote: >>> >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: >>> >> >>> >> In practice though, I think that's a difference that makes no >>> >> di