Expression can be simplified on list
Chris Angelico
rosuav at gmail.com
Thu Sep 29 17:35:31 EDT 2016
More information about the Python-list mailing list
Thu Sep 29 17:35:31 EDT 2016
- Previous message (by thread): Expression can be simplified on list
- Next message (by thread): Expression can be simplified on list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Sep 30, 2016 at 5:58 AM, Random832 <random832 at fastmail.com> wrote: > On Thu, Sep 29, 2016, at 02:47, Rustom Mody wrote: >> Your example is exactly what I am saying; if a type has a behavior in >> which all values are always True (true-ish) its a rather strange kind >> of bool-nature. > > For a given type T, if all objects of type T are true (true-ish, truthy, > whatever), it does make using an expression of type T in an if-statement > an incoherent thing to do, but it makes using an expression of type > Union[T, NoneType] reasonable. Or, as it would more commonly be spelled, Optional[T]. Very common situation; re.match was mentioned, and lots of data types can be clearly demonstrated by implementing them in Python using some kind of "optional node" structure - eg a linked list, where the last one has "self.next = None", or a binary tree where leaf nodes have None for both children, or a hash table where empty buckets have None. ChrisA
- Previous message (by thread): Expression can be simplified on list
- Next message (by thread): Expression can be simplified on list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list