Suggestions for good programming practices?

Peter Hansen peter at engcorp.com
Mon Jun 24 21:51:10 EDT 2002


Brian Quinlan wrote:
> 
> Peter Hansen wrote:
> > You _are_ returning them "in a struct".  It's spelled "tuple"
> > but other than that what's the difference?
> 
> struct members are access by name while tuple elements are accessed
> positionally.

Okay.  So why is that a problem?

Or to ask it from the other side, what's stopping you from 
returning items in an object?

class Struct:
    pass

def returnStruct():
    result = Struct()

    result.anInt = 5
    result.aString = 'foo bar baz'
    result.spam = ('eggs', 'brian')
 
    return result

-Peter



More information about the Python-list mailing list