Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22149

Re: Documentation, assignment in expression.

From mwilson@the-wire.com
Newsgroups comp.lang.python
Subject Re: Documentation, assignment in expression.
Followup-To comp.lang.python
Date 2012-03-25 19:09 -0400
Organization A noiseless patient Spider
Message-ID <jko8io$q3u$1@dont-email.me> (permalink)
References (1 earlier) <mailman.948.1332551363.3037.python-list@python.org> <4f6f0d24$0$6561$9b4e6d93@newsspool4.arcor-online.net> <4F6F1792.1060709@tim.thechases.com> <CAPTjJmpnYxZkLGQ4Tksw-2aaG5KAgPwoUe0EP8_OW8MdsijPdA@mail.gmail.com> <mailman.968.1332683287.3037.python-list@python.org>

Followups directed to: comp.lang.python

Show all headers | View raw


Tim Chase wrote:

> On 03/25/12 08:11, Chris Angelico wrote:
>> On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase
>> <python.list@tim.thechases.com>  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 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.

Most of my database programs wind up having the boilerplate (not tested):

def rowsof (cursor):
    names = [x[0] for x in cursor.description]
    r = cursor.fetchone()
    while r:
        yield dict (zip (names, r))
        r = cursor.fetchone()


	Mel.
> 
>> Personally, I quite like assignment-in-conditional notation. Yes, it's
>> a pretty common cause of problems; but what happened to the
>> "consenting adults" policy? Python permits operator overloading and
>> even the reassignment of builtins, both of which can cause similar
>> confusion.
> 
> In my past years of C programming, I've accidentally omitted the
> second "=" in a comparison test numerous times, requiring me to
> track down the missing character.  When I finally catch it, it's
> obvious what the problem is, but I've come to love having Python
> yell at me contextually.
> 
>> But, that's the choice Python's made. And being able to use the same
>> symbol for assignment and comparison does have its advantages.
> 
> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Documentation, assignment in expression. Alexander Blinne <news@blinne.net> - 2012-03-23 23:59 +0100
  Re: Documentation, assignment in expression. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-23 21:09 -0400
    Re: Documentation, assignment in expression. Alexander Blinne <news@blinne.net> - 2012-03-25 14:18 +0200
      Re: Documentation, assignment in expression. Tim Chase <python.list@tim.thechases.com> - 2012-03-25 08:03 -0500
        Re: Documentation, assignment in expression. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-26 05:36 +0000
          Re: Documentation, assignment in expression. Terry Reedy <tjreedy@udel.edu> - 2012-03-26 12:00 -0400
        Re: Documentation, assignment in expression. Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-03-26 15:59 +0200
          Re: Documentation, assignment in expression. Tim Chase <python.list@tim.thechases.com> - 2012-03-26 12:42 -0500
      Re: Documentation, assignment in expression. Chris Angelico <rosuav@gmail.com> - 2012-03-26 00:11 +1100
      Re: Documentation, assignment in expression. Tim Chase <python.list@tim.thechases.com> - 2012-03-25 08:48 -0500
        Re: Documentation, assignment in expression. Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-25 17:16 +0200
          Re: Documentation, assignment in expression. Tim Chase <python.list@tim.thechases.com> - 2012-03-25 13:22 -0500
          Re: Documentation, assignment in expression. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-26 05:47 +0000
          Re: Documentation, assignment in expression. Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-03-26 04:52 -0400
            Re: Documentation, assignment in expression. Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-26 12:56 +0200
              Re: Documentation, assignment in expression. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-03-26 14:13 +0300
                Re: Documentation, assignment in expression. Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-26 13:58 +0200
        Re: Documentation, assignment in expression. rusi <rustompmody@gmail.com> - 2012-03-25 09:17 -0700
        Re: Documentation, assignment in expression. mwilson@the-wire.com - 2012-03-25 19:09 -0400
          Re: Documentation, assignment in expression. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-25 22:29 -0400
            Re: Documentation, assignment in expression. mwilson@the-wire.com - 2012-03-26 07:27 -0400
      Re: Documentation, assignment in expression. Chris Angelico <rosuav@gmail.com> - 2012-03-26 01:11 +1100
        Re: Documentation, assignment in expression. Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-25 17:17 +0200
      Re: Documentation, assignment in expression. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-25 18:59 -0400
        Re: Documentation, assignment in expression. Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-03-26 15:54 +0200
          Re: Documentation, assignment in expression. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-26 12:16 -0400
      Re: Documentation, assignment in expression. Tim Chase <python.list@tim.thechases.com> - 2012-03-26 05:14 -0500
  Re: Documentation, assignment in expression. Roy Smith <roy@panix.com> - 2012-03-23 21:37 -0400

csiph-web