[Tutor] Python Documentation Clarification

Nick Raptis airscorp at otenet.gr
Mon Jul 12 17:29:47 CEST 2010


>
> compile(source, filename, mode[, flags[, dont_inherit]])
>
> I see within this built in function, the first argument can be what 
> they define as source, the second argument as the filename and the 
> third as the mode.
>
> But what confuses me is sometimes I see a bracket, above as [, flags[, 
> dont_inherit]]. Is this an optional argument like flags=dont_inherit?
>
>
Brackets do indeed mean optional arguments.
So you can do
compile(source, filename, mode, flags=whatever, dont_inherit=True)
or something.

The nested brackets most likely show that (in your example), 
dont_inherit is optional, but can be used only if you (optionally) also 
provide the flags argument.

Of course, don't take my word for it and read the rest of the 
description in the documentation.

Also read here:
<http://docs.python.org/reference/introduction.html?highlight=brackets>http://docs.python.org/reference/introduction.html?highlight=brackets#notation

Nick


More information about the Tutor mailing list