While everyone is saying what they want in Python :)

Erno Kuusela erno-news at erno.iki.fi
Tue Feb 6 18:05:56 CET 2001


In article <axIf6.35318$p8.7719400 at typhoon.southeast.rr.com>, "Don
Tuttle" <tuttledon at hotmail.com> writes:

| "Jay O'Connor" <joconnor at cybermesa.com> wrote in message
| news:3A7DB154.87E04245 at cybermesa.com...
|| I'm not familiar with the 'with' keyword in Delphi.

| Here's a vbscript example.
| With MyLabel
|    .Height = 2000
|    .Width = 2000
|    .Caption = "This is MyLabel"
| End With

>>> class foo:
...     pass
... 
>>> def with(obj, code):
...     exec code in obj.__dict__
...     del obj.__dict__['__builtins__'] # this gets added by exec
... 
>>> my_foo = foo()
>>> with(my_foo,  '''
... height = 2000
... width = 2000
... caption = "this is mylabel"
... ''')
>>> 
>>> print my_foo.caption
this is mylabel

;)

   -- erno



More information about the Python-list mailing list