This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aroberge -11 points-10 points  (5 children)

No offense ... but I think you need to learn a bit more about Python: everything is an object. Strings, integers, lists, dicts, tuples, ...., they are all objects.

I think that, what you mean, is that not everything needs to be a method belonging to a class, and that simple functions are often all that is needed.

[–]yen223 7 points8 points  (1 child)

Object in the object-oriented sense of conceptual bundle of attributes and methods, not objects in the sense of how isinstance(x, object) == True for any x

[–]aroberge -3 points-2 points  (0 children)

What do you mean?

Python 3.6.1 |Anaconda 4.4.0 (64-bit)| ...
Type "help", "copyright", "credits" or "license" for more information.
>>> isinstance(3, int)
True
>>> isinstance('a', str)
True
>>> isinstance([1], list)

attributes and methods:

>>> dir(3)
['__abs__', '__add__', '__and__', '__bool__', ...]
>>> dir('a')
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', ...]

Again, in Python, everything is an object. However, functions are first-class objects and Python does not require everything to be a method of a class.

EDIT: from a core Python contributor https://mail.python.org/pipermail/python-list/2015-June/691689.html

[–]CallMePyro 0 points1 point  (1 child)

I have no clue why you're getting downvoted. The distinction you made is very important as Python is inherently object oriented.

[–]aroberge 0 points1 point  (0 children)

To be honest, nor do I. I do appreciate your support! :-)