On Apr 11, 10:44 am, "Scott" <[EMAIL PROTECTED]> wrote: > As said before I'm new to programming, and I need in depth explaination to > understand everything the way I want to know it, call it a personality quirk > ;p. > > With pop() you remove the last element of a list and return its value: > > Now I know list is a bad name, but for the sake of arguement lets assume its > not a built in sequence> > > >>>list = ['this', 'is', 'an', 'example'] > >>>list.pop() > 'example' > >>>list > > ['this', 'is', 'an'] > > I understand all that. What I don't understand is why all the documentation > I see says, "When removing a specific element from a list using pop() it > must be in this format: list.pop([i]). > At first I took that to mean that list.pop(i) would return some type of > error, but it doesn't.
It's understandable that the definition of pop() is confusing in that way. It looks like the argument should be a list. As others have said, that is not what the brackets mean when the documents show the formal definition of a function. A clearer example might be a function definition that requires some mandatory arguments and has some optional arguments: dict.get(key[, default]) That shows that the get() function requires one mandatory argument "key" and that you can also send it one optional argument "default". If a function were to require a list as an argument, it's definition would be written something like this: somefunc(aList) -- where 'aList' is a list of integers -- http://mail.python.org/mailman/listinfo/python-list