I'm pretty sure that a similar thing can be done in Python. Never tried, though.
And the idea that there is only one way to do it disturbs me.
Because then the language would be really boring and restrictive. Different methods of doing things can provide different functionality.I did not say that there should be only one way to do it. But, right now Python limits how I can do it. I can do like in Python with Ruby though:Code:[vince@vincent: ~/prog/python]% python Python 2.1.1 (#1, Nov 11 2001, 18:19:24) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> a = 'Jello' >>> a[0] = 'H' Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: object doesn't support item assignment >>>
And can you tell me how to get a random number with Python please?Code:[vince@vincent: ~/prog/python]% irb irb(main):001:0> a = "Jello" "Jello" irb(main):002:0> a = "H" + a[1..-1] "Hello" irb(main):003:0>


Reply With Quote
Bookmarks