News for hackers. Stuff that matters.
Re:Python metaclasses by aduitsis on Saturday August 08, 2015 @01:47PM (#10028057)
Tangential question, is there anything similar to Moose (Perl) in the Python world?
Re:Python metaclasses by bcostlow on Saturday August 08, 2015 @06:33PM (#10028833)
Caveat: I haven't written any Perl except for an occasional one-liner in a decade.

But I do a fair amount of Python, and a 20 minute cruise through the Moose docs leads me to believe that the most similar thing to Moose in the Python world is, well, Python.

Re:Python metaclasses by gambogi on Saturday August 08, 2015 @09:49PM (#10029254)
Not quite. One of the biggest features of Moose is it's concept of roles. They're in some senses similar to typeclasses in Haskell and Traits in Rust.

Effectively, they give you access to parametric polymorphism in perl land.

http://modernperlbooks.com/books/modern_perl_2014/07-object-...

Re:Python metaclasses by bcostlow on Sunday August 09, 2015 @10:33AM (#10030370)
True.

Rather than having the kind of parametric polymorphism you get with roles, Python prefers duck typing. And for the practical use of adding some composed, reusable, but orthogonal state and behavior to a class, Python provides multiple inheritance. For type-checking issues where duck typing is not sufficient, Python has Abstract Base Classes.

Now, I am aware that roles are not the same thing as duck typing or multiple inheritance, or ABCs. Not having roles in Python is a design decision. http://legacy.python.org/dev/peps/pep-3133/

But I still think in terms of the ability to use the language to write clean OOP code, Python is closer to Perl5 + Moose, than Perl5 alone is to Perl5 + Moose.

(Not a knock on Perl5 or Moose, between 2002 and 2005, I did a bunch of web and systems programming in Perl, and I wish Moose existed then.)

Re:Python metaclasses by StavrosK on Saturday August 08, 2015 @02:34PM (#10028211)
What's moose?
Re:Python metaclasses by aduitsis on Saturday August 08, 2015 @05:57PM (#10028758)
http://moose.iinteractive.com/en/

TL;DR: Moose is an awesome OO framework for Perl.

Re:Python metaclasses by StavrosK on Saturday August 08, 2015 @07:03PM (#10028915)
I'm afraid that's not enough information for me to understand it, so I can't tell you whether there's something comparable for Python.