a small problem

Justin Sheehy dworkin at ccs.neu.edu
Wed Jan 19 22:58:26 EST 2000


m.faassen at vet.uu.nl (Martijn Faassen) writes:

> I have scant knowledge of Perl (being Saved by Python just in time), but
> as far as I recall the $ @ stuff can be used to somehow make a particular
> variable behave like a number, list, or whatever. So I imagine it allows
> arbitrary arguments which you then may analyze and then treat in the way
> you desire. Or something. My mind never really wrapped around the concept.

You've pretty much got it, but it's even scarier than you may be thinking.

Arguments to a subroutine are generally not declared, but rather are
automatically assigned to the special variable @_ inside the scope of
the function.  Thus, the first argument is referenced by $_[0], the
second by $_[1], etc.  

This has nothing to do with the $_ variable, by the way, which has an
entirely different meaning.

reminded-why-I-program-with-Python-instead-of-magical-line-noise-ly y'rs,

-Justin

 




More information about the Python-list mailing list