RE: Creating an iterator in a class

2012-12-27 Thread Joseph L. Casale
> It's probably best if you use separate cursors anyway. Say you have > two methods with a shared cursor: > > def iter_table_a(self): > self.cursor.execute("SELECT * FROM TABLE_A") > yield from self.cursor > > def iter_table_b(self): > self.cursor.execute("SELECT *

Re: Creating an iterator in a class

2012-12-27 Thread Ian Kelly
On Thu, Dec 27, 2012 at 7:44 AM, Joseph L. Casale wrote: > I am writing a class to provide a db backed configuration for an application. > > In my programs code, I import the class and pass the ODBC params to the > class for its __init__ to instantiate a connection. > > I would like to create a fu

RE: Creating an iterator in a class

2012-12-27 Thread Joseph L. Casale
>Have the method yield instead of returning: Thanks, that was simple, I was hung up on implementing magic methods. Thanks for the pointers guys! jlc -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating an iterator in a class

2012-12-27 Thread TommyVee
"Joseph L. Casale" wrote in message news:mailman.1346.1356619576.29569.python-l...@python.org... I am writing a class to provide a db backed configuration for an application. In my programs code, I import the class and pass the ODBC params to the class for its __init__ to instantiate a conne

Re: Creating an iterator in a class

2012-12-27 Thread Peter Otten
Joseph L. Casale wrote: > I am writing a class to provide a db backed configuration for an > application. > > In my programs code, I import the class and pass the ODBC params to the > class for its __init__ to instantiate a connection. > > I would like to create a function to generically access