On Jul 8, 2006, at 9:40 PM, richardun / gmail.com wrote:

> I love Ruby because I can do this:
>
> class Integer
>   def even?
>     ( self % 2 ) == 0
>   end
> end
>
> puts 3.even?
> puts 28.even?

I don't know if that's possible in Python, but apparently I can't  
guess how to do it based on a little previous Python usage:

irb(main):037:0> quit
curi-g5:~ curi$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> Integer
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
NameError: name 'Integer' is not defined
 >>> 3
3
 >>> 3.methods
   File "<stdin>", line 1
     3.methods
             ^
SyntaxError: invalid syntax
 >>> 3.x = 4
   File "<stdin>", line 1
     3.x = 4
       ^
SyntaxError: invalid syntax
 >>> x = 3
 >>> x.x = 4
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
AttributeError: 'int' object has no attribute 'x'
 >>> quit
'Use Ctrl-D (i.e. EOF) to exit.'
 >>>
curi-g5:~ curi$ irb
irb(main):001:0>

I may have typed "quit" on purpose. *ducks*

-- Elliot Temple
http://www.curi.us/blog/