While everyone is saying what they want in Python :)

Jay O'Connor joconnor at cybermesa.com
Sun Feb 4 20:45:24 CET 2001


Erik Max Francis wrote:

> This general type of functionality (compare to the `with' keyword in
> Pascal/Delphi) 

I'm not familiar with the 'with' keyword in Delphi.

> The amount of typing required should never be the primary concern in
> desiging a language; clarity of what you're typing is much more
> important than how many keys you physically have to hit.

Actually, this construct in Smalltalk adds clarity because you don't
have the redundancy of the same object name repeated so the whitespace
helps clarify which objects are receiving which messages.

Plus it allows building complex structures without building needing to
create temporary variables to hold them.  Such as... (this is quasi
Python with  what I have in mind based on Smalltalk)

	win = GtKWindow();
		connect ("destroy", mainquit);
		set_name("window");
		set_title("My Window");
		set_location (100,100);
		add (GtkHBox();
			add (GtkLabel ("Hi There");
				show());
			add (GtkButton ("Push Me");
				connect ("clicked", buttonClicked);
				show());
			show());
		show()

Here I've created four widgets without needing extra temp variables. 
More importantly, the whitespace indicates the exact structural
relationship of the widgets.  I find this much easier to read than the
normal way of doing it.

	win = GtkWindow()
	
	win.connect("destroy", mainquit)
	win.set_name ("window")	
	win.set_title ("My Window")
	win.show()
	box = GtkHBox ()
	label = GtkLabel("Hi There")
	button = GtkButton ("Hi there")
	box.add (label)
	box.add (button)
	win.add (box)
	box.show()
	label.show()
	button.show()
	button.connect ("clicked", buttonClicked)
	win.show()


Take care,

-- 
Jay O'Connor
joconnor at cybermesa.com
http://www.cybermesa.com/~joconnor

"God himself plays the bass strings first when He tunes the soul"



More information about the Python-list mailing list