Linked Questions
36 questions linked to/from Is everything an object in Python like Ruby?
0
votes
1
answer
7k
views
Is Python a pure object-oriented language [duplicate]
I use Ruby on a daily basis and know it is a purely object oriented language. As far as I know, pure object oriented languages' distinguishable characteristic is that all variables are objects, even ...
2
votes
0
answers
54
views
Int, float - classes? [duplicate]
Little question: are int, float, bool, list, str, etc. actual classes in python? For example, if we write x = 5 we create an instance of a class int and assign this instance to a variable x. Am I ...
829
votes
26
answers
1.8m
views
How to print a date in a regular format?
This is my code:
import datetime
today = datetime.date.today()
print(today)
This prints: 2008-11-22 which is exactly what I want.
But, I have a list I'm appending this to and then suddenly everything ...
155
votes
9
answers
67k
views
What is boxing and unboxing and what are the trade offs?
I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome.
60
votes
15
answers
31k
views
Can you monkey patch methods on core types in Python?
Ruby can add methods to the Number class and other core types to get effects like this:
1.should_equal(1)
But it seems like Python cannot do this. Is this true? And if so, why? Does it have something ...
9
votes
6
answers
2k
views
Has Python changed to more object oriented?
I remember that at one point, it was said that Python is less object oriented than Ruby, since in Ruby, everything is an object. Has this changed for Python as well? Is the latest Python more object ...
15
votes
8
answers
31k
views
What is an Object in Python?
I am surprised that my question was not asked (worded like the above) before. I am hoping that someone could break down this basic term "object" in the context of a OOP language like Python. ...
21
votes
2
answers
38k
views
assigning value in python dict (copy vs reference)
I understand that in python every thing, be it a number, string, dict or anything is an object. The variable name simply points to the object in the memory. Now according to this question,
>> ...
3
votes
4
answers
6k
views
In python what does it mean by everything is an object [duplicate]
I have started learning about python, reading some tutorials, and i have seen the sentence that Everything is an object in Python, what does it actually mean?
5
votes
3
answers
7k
views
hasattr on class names
hasattr documentation says that it takes an object and an attribute name and lets you know if that attribute exists on that object.
I have discovered that it seems to work on class names too (i.e. ...
0
votes
4
answers
4k
views
Can hasattr work on a Module?
I'm adding dynamically attribute to a module, before using it I want to verify that the added attribute exist (in the module).
hasattr signature is:
hasattr(object, name)
module is not an object, ...
3
votes
3
answers
6k
views
Appropriate Python error type for argument type mismatches
I am looking for the equivalent of PHPs InvalidArgumentException to use in case a function gets an argument that has an incorrect type. I'm working with Python 3. (And I am quite new to Python.)
...
7
votes
1
answer
619
views
Understanding Self Internally in Python
I fully understand what is being passed to self in this example. I'm very confused on how it is being passed to self internally. Could someone help me understand?
class Cars:
def __init__(self,...
3
votes
5
answers
738
views
Everything in Python is an object, why operators are not?
Everything in Python is an object
We all know this sentence and all Pythonistas (including me) loving it. In that regard, it is interesting to look at operators. They seem to be no objects, e.g.
>&...
2
votes
5
answers
2k
views
What does "Everything" mean when someone says "Everything in Python is an object."?
I constantly see people state that "Everything in Python is an object.", but I haven't seen "thing" actually defined. This saying would lead me to believe that all tokens of any kind are also ...