1

I am trying to dive deep into Python's data model, and notably the famous "Everything in Python is object". I have come across a post claiming that there are objects in Python that have neither attributes nor methods, and there are also objects that are not subclassable. Could anyone help me with examples of such objects?

I am asking this question in an attempt to understand what exactly is an object in Python.

The link is here: Is everything an object in Python like Ruby?

Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121
  • 4
    "Everything is an object" means that in Python (unlike many other languages) classes, functions, modules, packages are objects just like e.g. integers (so, you can write e.g. `x = SomeClass`). That has nothing to do with how many methods or attributes such an object has, or whether a class is subclassable or not. – zvone Jan 10 '21 at 20:54
  • See also [pep 0591](https://www.python.org/dev/peps/pep-0591/) about the `final` decorator – zvone Jan 10 '21 at 21:14
  • @zvone, What you are saying is that objects are defined as first-class citizens. But my question is about ecamples of objects that are not subclassable or that have meither props nor methods – Edgar Navasardyan Jan 10 '21 at 21:21
  • I do not know of any objects without any methods. What makes you think there are such? As for not being subclassable, with some effort that can be implemented by adding an assertion that the class has not been subclasses. Do see also the pep link in my previous comment. – zvone Jan 10 '21 at 21:24

0 Answers0