[Python-Dev] New PEP: 319

Delaney, Timothy C (Timothy) tdelaney@avaya.com
Mon, 16 Jun 2003 16:26:49 +1000


> From: Roman Suzi [mailto:rnd@onego.ru]
>=20
> What about just adding a parameter to try operator?
>=20
>              def increment(self):
>                  try self.counter_lock:
>                      self.counter +=3D 1
>=20
> - this will save from keyword and could also be used with
> except part with, for example, se-syncronization outcomes
> for some kinds of locks:
>=20
>              def increment(self):
>                  try self.counter_lock:
>                      self.counter +=3D 1
>                  except SomeLockError:
>                      bla-bla-bla

Hmm - so this is essentially the

initially:
    self.counter_lock.acquire()
try:
    ...
finally:
    self.counter_lock.release()

but with the condition that the "parameter" to try implement the =
Lockable interface (or something along those lines).

Interesting idea. Not sure about the syntax, but I think we could go =
somewhere with this.

Tim Delaney