My first Python program
Seebs
usenet-nospam at seebs.net
Wed Oct 13 12:51:27 EDT 2010
On 2010-10-12, Chris Rebert <clp2 at rebertia.com> wrote:
> 2.
> self.f = file(path, 'r')
> if not self.f:
> return None
>
> The "if" here is pointless; I'm reasonably sure files are always
> considered boolean true.
I actually seem to have done this wrong anyway -- I was thinking in
terms of the C-like idiom of returning NULL when a constructor-like thing
fails. This ought to have been a raise of some sort to prevent the caller
from getting an object that didn't work out.
> Python's grammar has "not in" as an "operator" for just such occasions ==>
Ahh!
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
More information about the Python-list
mailing list