Brett Cannon <br...@python.org> added the comment:

The singleton dislike from Antoine and me is that they are generally just not 
liked in the stdlib. None/True/False are special cases because they are syntax, 
so having ``None is None`` ever not work would just be weird. Otherwise 
singletons are unnecessary in Python. Just look through the stdlib and you will 
find very few singletons as they are generally considered bad. Having to write 
a custom __eq__ or __hash__ is just part of being explicit. And trying to make 
a factory function that always returns the same instance is not a solution 
either. I understand pytz might use them, but this is the stdlib, so we need to 
go with what we consider best practice for Python since it will lead to much 
more use than pytz gets.

Now if a simple FixedOffsetTimeZone class was added and we just pre-populated 
the datetime module with a utc attribute that contained an instance of that 
class set to the proper values for UTC, that I could support without 
controversy. That would get you your "singleton" by reliably using the same 
instance without having to try to hack in singleton support.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5094>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to