Help me understand...

Greg Fortune lists at gregfortune.com
Wed May 7 14:22:51 EDT 2003


Norm wrote:

> I'm learning this slowly...
> 
> As I read the syntax of using split it says this in IDLE.
> s.split(sep [,maxsplit]]) -> list of strings
> 
> Now what I misunderstood out of this was that I should use [brackets] and
> a ,comma such as this.
> 
> s.split([n ,[3]]) - which of course didn't work.

[] in parameter lists like this often means "optional".

> 
> After 30 tries I got this to work
> s.split("n",3) - how come the quotes weren't in the help?

Because it's assumed that you are passing a string in.  If you didn't 
include the quotes, it would look for a variable named n and pass the value 
of n into the function.  Again, note that the second parameter is not 
strictly necessary.

> 
> What is the darn rules for reading help/man/info/syntax in Python?

As with everything, lots of trial and error until you get used to the way 
things are done :)

Greg Fortune
Fortune Solutions








More information about the Python-list mailing list