3 ms·
> Python’s primitives aren’t actually objects. As an expert Python programmer, I don't understand what is meant by this.
by chrismorgan 13y ago
> Python’s primitives aren’t actually objects.
As an expert Python programmer, I don't understand what is meant by this.
- coolsunglasses 13y agoMight mean __dict__, but it's a silly point to make since underneath that and the rest is *PyObject.
- afandian 13y agoAgreed. Surely all Python objects are (*PyObject)s? Some values, such as integers, are cached in certain cases. But they are all PyObject pointers. Perhaps the author can clarify?
- rmidthun 13y agoThis is just a guess, but in ruby, you can perform methods directly on any value, such as "3.succ", which returns 4. I don't think that works in Python. Ruby allows you to extend any class with more methods, so you could create your own function and apply it directly to a number. In Python, you would need to pass that number into a function. E.g. Ruby: (3.7).round opposed to Python round(3.7)