On 03/26/12 08:59, Thomas Rachel wrote:
Am 25.03.2012 15:03 schrieb Tim Chase:
while True:
data = conn.fetchmany()
if not data: break
for row in data:
process(row)
Or simpler
for data in iter(conn.fetchmany, []):
for row in data:
process(row)
Nice! T
On 3/26/2012 1:36 AM, Steven D'Aprano wrote:
(I seem to recall a language that used a single = for both assignment and
equality testing, guessing which one you meant from context. BASIC
perhaps?
Right. In some Basics, such as MS GW-Basic (I still have their book), a
= b = c meant a = (b = c),
Am 26.03.2012 00:59 schrieb Dennis Lee Bieber:
If you use the longer form
con = db.connect()
cur = con.cursor()
the cursor object, in all that I've worked with, does function for
iteration
I use this form regularly with MySQLdb and am now surprised to see that
this is optional according to
Am 25.03.2012 15:03 schrieb Tim Chase:
Perhaps a DB example
works better. With assignment allowed in an evaluation, you'd be able to
write
while data = conn.fetchmany():
for row in data:
process(row)
whereas you have to write
while True:
data = conn.fetchmany()
if not data:
On 3/26/2012 13:13, Jussi Piitulainen wrote:
Kiuhnm writes:
On 3/26/2012 10:52, Devin Jeanpierre wrote:
On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm
wrote:
On 3/25/2012 15:48, Tim Chase wrote:
The old curmudgeon in me likes the Pascal method of using "=" for
equality-testing, and ":=" for ass
Dennis Lee Bieber wrote:
> On Sun, 25 Mar 2012 19:09:12 -0400, mwil...@the-wire.com declaimed the
> following in gmane.comp.python.general:
>
>
>> Most of my database programs wind up having the boilerplate (not tested):
>>
>> def rowsof (cursor):
>> names = [x[0] for x in cursor.descriptio
Kiuhnm writes:
> On 3/26/2012 10:52, Devin Jeanpierre wrote:
> > On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm
> > wrote:
> >> On 3/25/2012 15:48, Tim Chase wrote:
> >>>
> >>> The old curmudgeon in me likes the Pascal method of using "=" for
> >>> equality-testing, and ":=" for assignment which feels
On 3/26/2012 10:52, Devin Jeanpierre wrote:
On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm
wrote:
On 3/25/2012 15:48, Tim Chase wrote:
The old curmudgeon in me likes the Pascal method of using "=" for
equality-testing, and ":=" for assignment which feels a little closer to
mathematical use of "=".
On 03/25/12 17:59, Dennis Lee Bieber wrote:
On Sun, 25 Mar 2012 08:48:31 -0500, Tim Chase
Yeah, it has the same structure internally, but I'm somewhat
surprised that the DB connection object doesn't have an
__iter__() that does something like this automatically under the
covers.
I beli
On Sun, Mar 25, 2012 at 11:16 AM, Kiuhnm
wrote:
> On 3/25/2012 15:48, Tim Chase wrote:
>>
>> The old curmudgeon in me likes the Pascal method of using "=" for
>> equality-testing, and ":=" for assignment which feels a little closer to
>> mathematical use of "=".
>
>
> Unfortunately, ":=" means "is
On Sun, 25 Mar 2012 17:16:16 +0200, Kiuhnm wrote:
> On 3/25/2012 15:48, Tim Chase wrote:
>> The old curmudgeon in me likes the Pascal method of using "=" for
>> equality-testing, and ":=" for assignment which feels a little closer
>> to mathematical use of "=".
>
> Unfortunately, ":=" means "is d
On Sun, 25 Mar 2012 08:03:14 -0500, Tim Chase wrote:
> I think the complaint was backed by a bad example. Perhaps a DB example
> works better. With assignment allowed in an evaluation, you'd be able
> to write
>
>while data = conn.fetchmany():
> for row in data:
>process(row)
Tim Chase wrote:
> On 03/25/12 08:11, Chris Angelico wrote:
>> On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase
>> wrote:
>>> Granted, this can be turned into an iterator with a yield, making the
>>> issue somewhat moot:
>>
>> No, just moving the issue to the iterator. Your iterator has exactly
>> th
On 03/25/12 10:16, Kiuhnm wrote:
On 3/25/2012 15:48, Tim Chase wrote:
The old curmudgeon in me likes the Pascal method of using "=" for
equality-testing, and ":=" for assignment which feels a little closer to
mathematical use of "=".
Unfortunately, ":=" means "is defined as" in mathematics. Th
On Mar 25, 6:48 pm, Tim Chase wrote:
>
> The old curmudgeon in me likes the Pascal method of using "=" for
> equality-testing, and ":=" for assignment which feels a little
> closer to mathematical use of "=".
>
> -tkc
Carroll Morgan author of programming from specifications
http://www.cs.ox.ac.uk
On 3/25/2012 15:48, Tim Chase wrote:
The old curmudgeon in me likes the Pascal method of using "=" for
equality-testing, and ":=" for assignment which feels a little closer to
mathematical use of "=".
Unfortunately, ":=" means "is defined as" in mathematics. The "right"
operator would have bee
On 3/25/2012 16:11, Chris Angelico wrote:
On Mon, Mar 26, 2012 at 12:48 AM, Tim Chase
wrote:
Yeah, it has the same structure internally, but I'm somewhat surprised that
the DB connection object doesn't have an __iter__() that does something like
this automatically under the covers.
Sure. Tha
On Mon, Mar 26, 2012 at 12:48 AM, Tim Chase
wrote:
> Yeah, it has the same structure internally, but I'm somewhat surprised that
> the DB connection object doesn't have an __iter__() that does something like
> this automatically under the covers.
Sure. That's definitely the truly Pythonic techniq
On 03/25/12 08:11, Chris Angelico wrote:
On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase
wrote:
Granted, this can be turned into an iterator with a yield, making the issue
somewhat moot:
No, just moving the issue to the iterator. Your iterator has exactly
the same structure in it.
Yeah, it has
On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase
wrote:
> Granted, this can be turned into an iterator with a yield, making the issue
> somewhat moot:
No, just moving the issue to the iterator. Your iterator has exactly
the same structure in it.
Personally, I quite like assignment-in-conditional nota
On 03/25/12 07:18, Alexander Blinne wrote:
I am not sure I understand your argument. The doc section states that
" [...] in Python you’re forced to write this:
while True:
line = f.readline()
if not line:
break
... # do something with line".
That simply isn't true as on
I am not sure I understand your argument. The doc section states that
" [...] in Python you’re forced to write this:
while True:
line = f.readline()
if not line:
break
... # do something with line".
That simply isn't true as one can simply write:
for line in f:
#do s
In article <4f6d0060$0$6634$9b4e6...@newsspool2.arcor-online.net>,
Alexander Blinne wrote:
> The last sentence "For example, in the current version of Python file
> objects support the iterator protocol, so you can now write simply
> (for line in file:)" ...
In general, words like "current",
23 matches
Mail list logo