Suggestions for good programming practices?

David LeBlanc whisper at oz.net
Mon Jun 24 22:30:23 EDT 2002


Grrrr!

Look at it this way:

	a,b,c = func()

	abc = func()
	a = abc[0]
	b = abc[1]
	c = abc[2]

Which would you rather write? In C or C++ you have to use an analog of the
second way since the first way isn't an option. I _like_ this behavior of
Python.

It's a piddling point as to how Python returns the info - they come to rest
in discrete variables, not as elements of one aggregate variable. The
original point was about the flexibility of Python not some technical
hair-splitting about what Python might put on the stack.

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: Peter Hansen [mailto:peter at engcorp.com]
> Sent: Monday, June 24, 2002 19:28
> To: David LeBlanc
> Subject: Re: Suggestions for good programming practices?
>
>
> David LeBlanc wrote:
> >
> > They may be returned in a tuple, but they're PUT in discrete
> variables and
> > not kept in a tuple that I have to programmatically unpack.
> >
> > Language lawyer should be shot, _then_ heard.
>
> I don't understand the above at all.  Sorry. :)  Are you
> unhappy with this behaviour of Python?  And I don't get
> the language lawyer part.  (Pretend I'm really thick...it
> won't be far from the truth.)
>
> -Peter
>
> >
> > David LeBlanc
> > Seattle, WA USA
> >
> > > -----Original Message-----
> > > From: python-list-admin at python.org
> > > [mailto:python-list-admin at python.org]On Behalf Of Peter Hansen
> > > Sent: Monday, June 24, 2002 18:03
> > > To: python-list at python.org
> > > Subject: Re: Suggestions for good programming practices?
> > >
> > >
> > > David LeBlanc wrote:
> > > >
> > > > The one that always gets me is "lat,lon,timezone =
> > > getLocation("seattle")".
> > > > I.E. the ability to return multiple distinct values as opposed
> > > to returning
> > > > multiple values in the form of a struct as in C or C++.
> > >
> > > You _are_ returning them "in a struct".  It's spelled "tuple"
> > > but other than that what's the difference?
> > >
> > > -Peter
> > > --
> > > http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list