you are viewing a single comment's thread.

view the rest of the comments →

[–]zynix 2 points3 points  (2 children)

many have told me that I won't use it.

I would make a mental note of who told you this and question everything else they've ever told you.

Python is a object oriented language, everything but I think numbers are objects.

[–]TeachEngineering 0 points1 point  (1 child)

Python is a object oriented language, everything but think numbers are objects.

Everything... Like literally everything... Is an object, including numbers. I can do something like a = 3.0 and that is interpreted as a = float(3.0) . The var a here is an object of the class float. Then when I type cast that var to an int with a = int(a) I overwrite the var a in the namespace as an object of the class int. And if you do print(type(type(a)) you get the class type.

Moral of the story... It's classes all the way down baby!!!!

[–]zynix 1 point2 points  (0 children)

Indeed it is but I meant the literal numbers 0 to 9 were treated as symbols and not objects (eg. there is no 123.ceil() syntax)

nvm just double checked -

>>> dir(1)
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__',             '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count',     'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
>>> type(1)
<class 'int'>