On 2/17/12, Dave Angel <d...@davea.name> wrote: > Real question is whether some (seldom all) of those variables are in > fact part of a larger concept. If so, it makes sense to define a class > for them, and pass around objects of that class. Notice it's not > global, it's still passed as an argument. This can reduce your > parameters from 20 to maybe 6. But make sure that the things the class > represents are really related. > > Dictionaries are a built-in collection class, as are lists, sets, and > tuples. But you can write your own. An example of needing a class > might be to hold the coordinates of a point in space. You make a > Location class, instantiate it with three arguments, and use that > instance for functions like > move_ship(ship, newlocation) > > DaveA
Understood. In this case, the first half dozen variables are input and the rest are derived from the first ones. A class might make sense and though I understand them a little, not enough to make a good judgement on it. The task is to take parameters for a scuba dive; depth, gas mix, time, air consumption rate, and compute the O2 load, gas required, etc. Leam -- Mind on a Mission <http://leamhall.blogspot.com/> _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor