os.join --

Pete Shinners shredwheat at mediaone.net
Sun May 13 03:39:31 EDT 2001

"Matthew Turk" <m-turk at nwu.edu> wrote
> Hi all.  I've just got a quick question --
> When Python 2.0 was released, one of the big changes was the fact that
> the append method for lists no longer took an unlimited list of items.
> Why does os.join not follow this?  And why was append changed in the
> first place?  (But more importantly, I wanna know about os.join...

hey matthew, this may not be a 100% representation of
the facts, but as far as i remember, here is why there
is a difference.

what happened is, the list.append() method never changed.
it is exactly the same as it was before. it always has
and still does accept only a single argument.

but, there was a recent change to python that effected
how you could use it. what happened is, python used to
optionally (and magically) reinterpret a list of arguments
into a single argument, if the function was only expecting
one argument.

you see, python was trying to be a little clever there and
say, "oh, this function only wants one argument, but the
user has supplied it with many, i'll just wrap the arguments
into a single tuple, and pass that to the function"

i believe that long ago, python did things this way so
people could write methods that took variable number of
arguments. later in the game the "*args" notation was
created to handle variable number arguments, making the
old magic a bit obsolete (and a touch confusing if not
expected). nowadays python passes your arguments the same
way you send them in, no confusing magic, and i think it
is a change for the better.
(i'm not sure on this part, but it is my reasonable guess
at history)

More information about the Python-list mailing list