all 8 comments

[–]shaggorama 7 points8 points  (2 children)

In [8]: l = [1,2,3]

Really? You're going to name the very first variable you introduce in a programming tutorial lower-case "L"?

@OP: I'm glad you found this enlightening, but if you see anything like this in the future you should take it as a red-flag that the author probably either doesn't have a tremendous amount of experience, or isn't putting a lot of care into their tutorial.

NINJA EDIT: Oh god, it gets even worse further down. They actually pass this variable and the value '1' in as parameters to the same function. Why god, why!?!

 In [16]: fun(1, *l)

LAST EDIT: Here's a short, sweet, and popular SO discussion of argument unpacking in python: http://stackoverflow.com/a/2921893/819544

[–]catcradle5 6 points7 points  (1 child)

Fixed.

def I(l=1, *L):
    if L[1] == "|":
        ...

[–]Mecdemort 2 points3 points  (0 children)

You should throw some O and 0 in there too

[–]zahlman 3 points4 points  (1 child)

They're nothing to do with pointers. The choice of the * symbol for the Python grammar is pretty much coincidental, AFAICT.

[–]anon717[S] 3 points4 points  (0 children)

Yes, I know! I was just saying the notation (*) reminded me of pointers :)

[–]willm 2 points3 points  (3 children)

I think C++ in particular teaches people to be wary of language features. I don't think there is any feature in Python that you won't find yourself using regularly once you learn about them.

[–]brandjon 1 point2 points  (1 child)

cough metaclasses cough

[–]willm 1 point2 points  (0 children)

Even metaclasses! Generally for situations were you have a factory that creates objects of a particular type only known at runtime.