gah! I hate the new string syntax

Fredrik Lundh fredrik at pythonware.com
Wed Mar 14 17:15:57 EST 2001


Quinn Dunkan wrote:
> Note that in ruby, any time you write
>
> class Foo
>     ...
> end
>
> you are adding to, not overriding, 'Foo'.  Thus,
>
> class String
>     def cap
>         s = (if self[0].betwwen?(97, 122) then
>                 self[0] - 32
>             else
>                 self[0]
>             end).chr
>         s + self[1 .. self.length]
>     end
> end
>
> is perfectly valid ruby that does what he wanted

does all classes live in the same namespace?

Cheers /F





More information about the Python-list mailing list