[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2014-03-05 Thread Chris Rebert
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13936 ___ ___ Python-bugs-list

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2014-03-04 Thread Shai Berger
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2014-03-04 Thread Andreas Pelme
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2014-03-04 Thread Alexander Belopolsky
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-11-27 Thread Danilo Bargen
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-05-07 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13936 ___ ___ Python-bugs-list

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
Changes by Lakin Wecker lakin.wec...@gmail.com: -- components: +Library (Lib) type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13936 ___

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread R. David Murray
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:

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13936 ___ ___

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Georg Brandl
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Georg Brandl
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Alexander Belopolsky
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Tim Peters
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Tim Peters
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

[issue13936] datetime.time(0, 0, 0) evaluates to False despite being a valid time

2012-02-03 Thread Lakin Wecker
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 ___