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


Groups > comp.lang.python > #19646

Re: except clause syntax question

Subject Re: except clause syntax question
From Charles Yeomans <charles@declareSub.com>
Date 2012-01-31 11:23 -0500
References <mailman.5218.1327946109.27778.python-list@python.org> <4f272f1f$0$29989$c3e8da3$5496439d@news.astraweb.com> <mailman.5243.1328018257.27778.python-list@python.org> <4f27ffd8$0$29989$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.5251.1328026988.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Jan 31, 2012, at 9:51 AM, Steven D'Aprano wrote:

> On Tue, 31 Jan 2012 08:57:31 -0500, Charles Yeomans wrote:
> 
>> I don't think of a tuple as a container, and I don't think it a
>> misunderstanding on my part to think this.
> 
> Well, it is a misunderstanding, because tuples ARE containers. You might 
> as well say "I don't think of boxes as containers". What exactly are they 
> if not containers?


Tuple is a heterogenous datatype that allows one to define objects ad hoc. That is to say, a tuple represents a single thing distinct from its components.  For example, suppose you need to represent a location in text by line number and offset within a line.  A tuple object makes it easy to do so without writing a class having no methods other than a constructor.  Here, the components, a line number and an offset, define a new object distinct from the pieces.

One can certainly view a tuple as a list, just as one can view a string as a list of characters, and sometimes that's useful; the Python dictum "there should only be one way to do it" doesn't imply that there is only one way to think of it.

Nor am I the only person who sees such a distinction between tuple and list.


Charles Yeomans

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


Thread

except clause syntax question Charles Yeomans <charles@declareSub.com> - 2012-01-30 12:41 -0500
  Re: except clause syntax question Mel Wilson <mwilson@the-wire.com> - 2012-01-30 14:15 -0500
  Re: except clause syntax question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-31 00:00 +0000
    Re: except clause syntax question Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-01-30 19:25 -0500
    Re: except clause syntax question Charles Yeomans <charles@declareSub.com> - 2012-01-31 08:57 -0500
      Re: except clause syntax question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-31 14:51 +0000
        Re: except clause syntax question Charles Yeomans <charles@declareSub.com> - 2012-01-31 11:23 -0500
        Re: except clause syntax question Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-01-31 11:38 -0500
        Re: except clause syntax question Charles Yeomans <charles@declaresub.com> - 2012-01-31 12:29 -0500
        Re: except clause syntax question Ethan Furman <ethan@stoneleaf.us> - 2012-01-31 08:56 -0800
    Re: except clause syntax question Terry Reedy <tjreedy@udel.edu> - 2012-01-31 19:12 -0500
    Re: except clause syntax question Charles Yeomans <charles@declareSub.com> - 2012-01-31 19:27 -0500
  Re: except clause syntax question Mel Wilson <mwilson@the-wire.com> - 2012-01-31 08:24 -0500
    Re: except clause syntax question Charles Yeomans <charles@declareSub.com> - 2012-01-31 13:04 -0500
  Re: except clause syntax question Duncan Booth <duncan.booth@invalid.invalid> - 2012-01-31 22:03 +0000
    Re: except clause syntax question Chris Angelico <rosuav@gmail.com> - 2012-02-01 11:53 +1100
      Re: except clause syntax question Mel Wilson <mwilson@the-wire.com> - 2012-01-31 23:39 -0500
    Re: except clause syntax question Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-31 18:09 -0700
    Re: except clause syntax question Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-31 18:12 -0700
    Re: except clause syntax question Chris Angelico <rosuav@gmail.com> - 2012-02-01 13:46 +1100

csiph-web