Live data from Hacker News

Metaclasses in Python

stackoverflow.com

1–10 of 32 posts

Re: Metaclasses in Python

#3
post #2

Python is a very cool language. I wonder if using __metaclass__ in some fashion would allow for javascript-like prototyping.

Jonathan Fine gave a talk on this at Europython this year.

Looks like there's a video available at http://ep2011.europython.eu/conference/talks/javascript-for-....

Re: Metaclasses in Python

#7
post #5
post #2

Python is a very cool language. I wonder if using __metaclass__ in some fashion would allow for javascript-like prototyping.

What prototyping stuff is missing in Python?

Well in JS you could do String.prototype.fnName = function(){}; to add fnName as a method to all strings even if they are already instantiated, is that possible with Python?

Re: Metaclasses in Python

#8
post #7
post #5

Earlier quoted context omitted.

What prototyping stuff is missing in Python?

Well in JS you could do String.prototype.fnName = function(){}; to add fnName as a method to all strings even if they are already instantiated, is that possible with Python?

Of course.

http://codepad.org/3fWweqje

Re: Metaclasses in Python

#9
post #8
post #7

Earlier quoted context omitted.

Well in JS you could do String.prototype.fnName = function(){}; to add fnName as a method to all strings even if they are already instantiated, is that possible with Python?

Of course. http://codepad.org/3fWweqje

[deleted]

Re: Metaclasses in Python

#10
post #8
post #7

Earlier quoted context omitted.

Well in JS you could do String.prototype.fnName = function(){}; to add fnName as a method to all strings even if they are already instantiated, is that possible with Python?

Of course. http://codepad.org/3fWweqje

Can it be done for built-in types?
Post reply on HN