Clarification of notation

Seebs usenet-nospam at
Thu Sep 30 06:27:38 CEST 2010

On 2010-09-30, Bruce Whealton <bruce at> wrote:
> Next, from the documentation I see and this is just an example (this 
> kind of notation is seen elsewhere in the documentation:

> str.count(sub[, start[, end]])
> This particular example is from the string methods.
> Is this a nesting of two lists inside a a third list?

No, it's not -- it's a different use of [] to indicate that things
are optional, a convention which dates back to long before Python

>I know that it 
> would suggest that some of the arguments are optional, so perhaps if 
> there are 2 items the first is the sub, and the second is start?  Or did 
> I read that backwards?

That is exactly correct.  The key is the implication that you can omit
end, or both start and end.  (But you can't omit start and provide end.)

Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at <-- lawsuits, religion, and funny pictures <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

More information about the Python-list mailing list