Feature suggestion -- return if true
James Mills
prologic at shortcircuit.net.au
Tue Apr 12 23:28:35 EDT 2011
On Wed, Apr 13, 2011 at 1:00 PM, Chris Angelico <rosuav at gmail.com> wrote:
> def foo(param):
> resource=malloc(50000) # Shtarker, zis is Python! We don't malloc here!
> if not resource: return 0
> resource[param]=5
> del resource
> return 1
In Python this can probably be done and perhaps is slightly more
readble with the "with" statement and a context manager:
def foo(param):
try:
with ResourceAllocator(50000) as resource:
resource[param] = 5
return 1
except:
return 0
Now I know I'm only adding to the discussion (argument) but
hey it's all in good fun until someone looses an eyeball!
cheers
James
--
-- James Mills
--
-- "Problems are solved by method"
More information about the Python-list
mailing list