retry in try:...except:
John J. Lee
phrxy at csv.warwick.ac.uk
Sun Feb 11 18:07:51 EST 2001
On Sun, 11 Feb 2001, Dan Parisien wrote:
> Does something like this exist
>
> def getval(self, key)
> try:
> return self.__keys[key]
> except KeyError:
> self.__keys[key] = None
> retry #!!!!
[...]
For this particular case,
>>> foo={"eggs": 1}
>>> print foo.get("eggs")
1
>>> print foo.get("spam")
None
But maybe you had another example in mind that this doesn't apply to?
John
More information about the Python-list
mailing list