Lichen

Change of lib/__builtins__/int.py

920:b4b4179c39f2
lib/__builtins__/int.py int-as-function
     1.1 --- a/lib/__builtins__/int.py	Tue Jun 22 23:03:52 2021 +0200
     1.2 +++ b/lib/__builtins__/int.py	Tue Jun 22 23:36:04 2021 +0200
     1.3 @@ -3,7 +3,7 @@
     1.4  """
     1.5  Integer objects.
     1.6  
     1.7 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
     1.8 +Copyright (C) 2015, 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk>
     1.9  
    1.10  This program is free software; you can redistribute it and/or modify it under
    1.11  the terms of the GNU General Public License as published by the Free Software
    1.12 @@ -26,18 +26,19 @@
    1.13                     int_neg, int_not, int_or, int_pow, int_rshift, int_str, \
    1.14                     int_sub, int_xor
    1.15  
    1.16 -class int:
    1.17 +def int(number_or_string):
    1.18 +
    1.19 +    "Initialise the integer with the given 'number_or_string'."
    1.20 +
    1.21 +    if is_int(number_or_string):
    1.22 +        return number_or_string
    1.23 +    else:
    1.24 +        raise TypeError
    1.25 +
    1.26 +class integer:
    1.27  
    1.28      "An integer abstraction."
    1.29  
    1.30 -    def __init__(self, number_or_string=None):
    1.31 -
    1.32 -        "Initialise the integer with the given 'number_or_string'."
    1.33 -
    1.34 -        # NOTE: To be implemented.
    1.35 -
    1.36 -        pass
    1.37 -
    1.38      def __hash__(self):
    1.39  
    1.40          "Return a value for hashing purposes."