News for hackers. Stuff that matters.
Re:What Pythonistas Think of Ruby by tghw on Wednesday February 03, 2010 @11:57AM (#1098172)
Are you saying this because you can't monkey-patch literals? Because you can very much monkey-patch everything else in Python.
Re:What Pythonistas Think of Ruby by steveklabnik on Wednesday February 03, 2010 @01:07PM (#1098371)
As far as I know, Python doesn't have open classes, right?
Re:What Pythonistas Think of Ruby by tghw on Wednesday February 03, 2010 @03:46PM (#1098816)

  >>> def print_a(inst):
  ... 	print inst.a
  ... 	
  >>> class Foo(object):
  ... 	def __init__(self, a):
  ... 		self.a = a
  ... 		
  >>> Foo.print_my_a = print_a
  >>> f = Foo(5)
  >>> f.print_my_a()
  5
Not sure why my previous post was downvoted, unless maybe your definition of monkey-patching is different than mine.
Re:What Pythonistas Think of Ruby by steveklabnik on Wednesday February 03, 2010 @03:56PM (#1098840)
Well, I didn't downvote it, but you can't do this with _everything_ in Python, like you can in Ruby.

    $ irb
    irb(main):001:0> class Numeric
    irb(main):002:1>   def wtf
    irb(main):003:2>     puts "hey"
    irb(main):004:2>   end
    irb(main):005:1> end
    => nil
    irb(main):006:0> 5.wtf
    hey
    => nil