Why does passing tuple as arg WITHOUT scattering work?

Alf P. Steinbach alfps at start.no
Tue Oct 20 23:42:07 CEST 2009

Hi all.

I'm just learning Python from scratch, on my own. Apologies if this question is 
too newbie... Or perhaps answered in some FAQ (where?).

Here's my original code for simple starter program, using the ActivePython 
implementation in Windows XP Prof, Python version is 2.6:

import Tkinter

window = Tkinter.Tk()
window.title( "A fixed size ellipse..." )
window.geometry( "350x200" )            # Client area size, not window size.
window.resizable( width = 0, height = 0 )

canvas = Tkinter.Canvas( window, bg = "white" )
bbox = 2, 2, 347, 197                   # Pixel coors left, top, right, bottom
canvas.create_oval( bbox, fill = "PeachPuff" )
canvas.pack()                           # Fill the entire client area, please.

window.mainloop()                       # Process events until window is closed.

It worked nicely, and I thought this code was fairly perfect until I started 
studying the language reference.

It seems that formally correct code should apply the scatter operator to the 
tuple, like this:

canvas.create_oval( *bbox, fill = "PeachPuff" )

And this /also/ works nicely!

I think it's this latter that is correct, and that the former just worked by 
accident, due to e.g. the way that some C function parses arguments or such?

But I'm unable to figure it out, so, what's correct (both? one?), and assuming 
it's the latter that's correct, would the first version still work in practice 
regardless of Python / Tkinter implementation?


- Alf (total newbie)

More information about the Python-list mailing list