what does 0 mean in MyApp(0)

Peter Hansen peter at engcorp.com
Sun Oct 2 18:10:58 EDT 2005


Alex wrote:
> Thanks for the replies. It seems that I have three options
> 1. app=MyApp()
> 2. app=MyApp(0)
> 3. app=MyApp('myfile.txt')

I just want to emphasize the part of vincent's reply in which he points 
out that using the keyword arguments makes this more readable.

If more examples and actual code would just use the darned "redirect=" 
keyword argument, you probably wouldn't have had to ask the question.

I remember when I had the same question and spent more time than I 
should have had to digging out the answer.  Now I try to make sure that 
all my wx.Apps are initialized with redirect=False or whatever else I 
need to make clear to a reader what I'm doing.  For some widely used and 
understood methods and constructors, using positional arguments might be 
adequate.  For ones like wx.App where everyone initializes them but 
nobody seems to know what the arguments are doing (sometimes they seem 
to be handed down from earlier generations), keyword arguments are a 
real blessing.

The world needs more keyword arguments.  Use them everywhere!  ;-)

-Peter



More information about the Python-list mailing list