Changes by Chris Rebert pyb...@rebertia.com:
--
nosy: +cvrebert
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
___
___
Python-bugs-list
Shai Berger added the comment:
Just got bit by this.
Tim Peters said:
It is odd, but really no odder than zero values of other types evaluating to
false in Boolean contexts.
I disagree. Midnight is not a zero value, it is just a value. It does not
have any special qualities analogous to
Andreas Pelme added the comment:
I agree with Danilo and Shai -- this behavior very surprising. I deal with
datetimes a lot, and this bug has bitten me a number of times.
I cannot really think of a single case where if timeobj: is useful with the
current behavior. It results in a check for is
Alexander Belopolsky added the comment:
Please reopen.
Please bring your case to python-ideas. All developers who commented on this
issue agree that it is invalid.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
Danilo Bargen added the comment:
I disagree, I think this bug should be reopened and fixed.
A use case that I just ran into: I'm using a Django form with time fields that
aren't required, but that are only valid in combination (if there's a open time
there has to be a close time).
if not
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
___
___
Python-bugs-list
New submission from Lakin Wecker lakin.wec...@gmail.com:
midnight is represented by datetime.time(0,0,0). However, this time (unlike
all other valid times, including datetime.time(0,0,1)) evalutes to false in if
conditions:
import datetime
if datetime.time(0,0,0):
print
Lakin Wecker lakin.wec...@gmail.com added the comment:
I'm updating the versions to the ones that I've actually tried it on - this is
not an exhaustive search at this point.
--
versions: +Python 2.6, Python 2.7
___
Python tracker
Changes by Lakin Wecker lakin.wec...@gmail.com:
--
components: +Library (Lib)
type: - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
___
R. David Murray rdmur...@bitdance.com added the comment:
I don't think I would have ever thought of testing a datetime for its truth
value. But the behavior you observe is consistent with the rest of Python: 0
is false.
I wonder if this is by design or by accident.
--
nosy:
Changes by R. David Murray rdmur...@bitdance.com:
--
nosy: +belopolsky
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
___
___
Lakin Wecker lakin.wec...@gmail.com added the comment:
Right. I've updated my code to be more correct:
instead of:
if not start_time:
start_time = default_time
it now reads:
if start_time is None:
start_time = default_time
which operates correctly and works fine for my case, I just
Georg Brandl ge...@python.org added the comment:
It must be by design -- someone has implemented a __bool__ (formerly
__nonzero__) method; otherwise all objects would be true.
--
nosy: +georg.brandl, lemburg
___
Python tracker rep...@bugs.python.org
Georg Brandl ge...@python.org added the comment:
BTW, being a valid time is not a good argument: 0, or False are all valid
instances of their types.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
Alexander Belopolsky alexander.belopol...@gmail.com added the comment:
This is by design. I don't have a reference, but I do remember this being
discussed. Suggestions for improving the documentation are welcome.
--
___
Python tracker
Tim Peters tim.pet...@gmail.com added the comment:
From the docs, at:
http://docs.python.org/library/datetime.html#time-objects
in Boolean contexts, a time object is considered to be true if and only if,
after converting it to minutes and subtracting utcoffset() (or 0 if that’s
None), the
Lakin Wecker lakin.wec...@gmail.com added the comment:
Although I find it odd, you are all correct.
It is documented. (I don't know how I missed that when I read those docs
looking for that exact documentation).
It is consistent with the rest of python.
Do I close this? Do you guys? I'm
Tim Peters tim.pet...@gmail.com added the comment:
It is odd, but really no odder than zero values of other types evaluating to
false in Boolean contexts ;-) Closing as invalid.
--
resolution: - invalid
status: open - closed
___
Python tracker
Lakin Wecker lakin.wec...@gmail.com added the comment:
Yeah - good point, and I agree.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13936
___
19 matches
Mail list logo