Nice one :)
By the way you can turn classes into functions too:
def __call__(self, a):
print(f"Calling with a=", a)
foo = Foo()
By the way you can do this:
In : return_hello = lambda *args, **kwargs: 'hello'
In : class Foo(metaclass=return_hello): ...
In : Foo
Great! That's the needed comment to complement this article!
I‘ve written a Python interpreter in Java once where I learned that really everything is an object in python.
I usually ask in job interviews „what’s the difference between Java and Python“ and most candidates say „Java is object-oriented and Python is a scripting language“ :)
you are in language making? really awesome!
Oh no, I only wrote an interpreter that executed precompiled Python code! I did this once as a PoC to run Python on an embedded device. It worked but unfortunately as you might imagine, interpreting Python Byte code in Java which was also interpreted byte code on a slow embedded device was terrible slow.
The point is: I learned how beautifully Python is designed internally.
As you stated: everything’s an object
This is truly amazing!
hum ok, embedded programming is another level for me _
I don't know Abdur.
I understand that you can utilize OOP principles in Python, but if I really want to do OOP AND the scripting lvl I would rather choose Ruby as my language to go. I just hate Python OOP syntax and things associated with the OOP paradigm in Python. Of course, at the end it will work, but I'm really happy to write my scripts without overhead of using OOP in this particular language.
Thanks for the post though, it was good & inspirational :)
ruby i agree is less code, more expressive, but i love the mamothy python
Yep, functions are objects and you can add methods to them. But why would you do that?
to learn more about py i guess
Yeap, that's the coolest reason of all!!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.