On 21 Nov 2005, at 00:41, Adrian Holovaty wrote:
That's quite an interesting idea! The immediate question I have is: What would it do if "a" is empty or not an integer? Raise an exception? Return an empty string?
Hmm... good question. Since you asked for an integer it could return 0, but that's pretty misleading. Raising an exception would be a bit of a pain as you would have to wrap all your input filtering code in a try block. Returning an empty string would result in errors if you then tried to treat it as an int. Maybe it should return None? That would still break if used in integer expressions.
Hmm. Bit stumped on that for the moment. I'll sleep on it :) Cheers, Simon
