How to access args as a list?

Andreas Waldenburger usenot at geekmail.INVALID
Sat Apr 3 21:42:14 EDT 2010


On Sat, 3 Apr 2010 23:52:42 +0000 (UTC) kj <no.email at please.post> wrote:

> In <hp8h73$k17$1 at reader1.panix.com> kj <no.email at please.post> writes:
> 
> [snip]
> >P.S. this is just an example; the function I want to implement has
> >more parameters in its signature, with longer, more informative
> >names.
> 
> Andreas, perhaps this paragraph explains why I find your solution
> unappealing:  it requires typing the same thing over and over,
> which increases the chances of bugs.  That's the reason I avoid
> such repetitiveness, not laziness, as you so were so quick to accuse
> me of.
> 
First up: I am sorry, I did not mean to offend. I apologize if I did.

But I stand by my point: If this class is the only instance of this
pattern, you'll only do this once. I see no reason to automate
something that will run only once anyway.

From your own reply to the above it seems that the *args-notation
solves your problem (if I understand correctly). Since I'm patronizing
by nature, I'd like to weigh in on this: The approach you describe
seems like a Perl-ism[1]. *args is meant for variable argument lists.
Using it as a shortcut for "many formal parameters" is misuse of that
feature (not the worst kind, but not very good either). In addition to
creating the impression that the function takes a variable number of
arguments, it breaks introspection/self-documentation. Also, "many
formal parameters" can be a signal to rethink the approach altogether.
I feel that if a function has more than 6 or so parameters, I'm missing
an opportunity to simplify my code.

All of the above is philosophy, of course, and mine to boot, so feel
free to ignore my rambling. But maybe you can elaborate a bit on why
you need names *and* sequence of your parameters preserved and why
there need to be so many of them. Perhaps a fresh perspective on this
will yield a less problematic approach.

Then again, maybe I have wasted your time enough already. ;)

/W

-- 
INVALID? DE!




More information about the Python-list mailing list