syntax questions

Philippe Gendreau philippe.gendreau at savoirfairelinux.com
Wed Jul 24 13:13:07 EDT 2002


* Chris Liechti <cliechti at gmx.net> [2002-07-24 18:50]:
> you want to call "append" on the variable "self.theme" which seems to be a 
> list, therefore the outher parantheses:
> self.theme.append(...)
> 
> you want to add a tuple to the list:
> (...,)
> 
> a tuple with just one argument needs a coma at the end, otherwise it would 
> be an arithmetic expression ans no tupple.

The imbrication of those structures can sometime be confusing...
Thanks for clearing that out.

> and finaly you call a function with the name "_":
> _(dir)
> that is sometimes used to localize names i.e. the "_" function translates 
> the given string to the local language. to be sure what it does you have to 
> search for the implementation in you current sourcecode.

Ah! this is a function name?
As you say, I will have to look
into the code to see what it does...

> note that "dir" is somewhat a bad name for that variable because
> a) there is a builtin function that name that you hide
> b) its not a directory name but a filename without path in the above case

Note taken.
I know about the dir() function,  but I'm surprised that my list object
hides a function object (even if they have the same name). 
Is that how python treats names all the time? Does it mean you can't
have a class, def and variable of the same name?

> in the intercative prompt "_" is bound to the last result so that you can 
> do further calculations:
> >>> 1+1
> 2
> >>> _*3
> 6

Nice, this is probably why It seemed to be used for many purpose.
if I understand well, this behavior is just in the interactive mode.
If I use '_' in a module it is just an identifier.

Thank you.
--
Philippe Gendreau




More information about the Python-list mailing list