A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/020836.html below:

[Python-Dev] For review: PEP 285: Adding a bool type

[Python-Dev] For review: PEP 285: Adding a bool type [Python-Dev] For review: PEP 285: Adding a bool typeSamuele Pedroni pedroni@inf.ethz.ch
Sat, 9 Mar 2002 22:01:36 +0100
From: M.-A. Lemburg <mal@lemburg.com>
> 
> +1 on making bool an abstract subtype of integers
>    and having Py_True and Py_False as only instances
> 
> -1 on overriding interfaces other than informational
>    ones such as __repr__
> 

So you mean just:

class truth(int): # other names?, should not be subclassable
  def __new__(cls,val): # ??
    if val:
      return true
    else:
      return false
  def __repr__(self):
    if  self:
      return 'true'
   else:
     return 'false'

true = int.__new__(truth,1) # also Py_True
false = int.__new__(truth,0) # also Py_False


    






RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4