[IronPython] more pythonic than python

Dino Viehland dinov at exchange.microsoft.com
Tue Jun 20 17:22:43 CEST 2006


You can actually enforce the 1st one by using __slots__ on a new-style class:

Class __Verbs(object):
        __slots__ = ['annoy', 'bother']
        def __init__(self):
                self.annoy = 'argh'
                self.bother = 'bargh'

v = __Verbs()
v.mother = "throws attribute error"

This is now enforced in IP Beta 8 (previously we would ignore __slots__ and use a dictionary for storage anyway).

Immutable strings are a good thing - they enable a more sane security model (imagine if you had to copy a string everytime before you could validate it), they enable a better optimization model (imagine if you couldn't rely on checking the length once in a loop, and instead got bounds checking on every access because another thread could mutate the string), and they make things like interning viable.

Our goal for IronPython is to try and make Python run great on .NET so we'll leave the great Python clean-up to Python 3000. :)

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of fernando moreira
Sent: Tuesday, June 20, 2006 6:55 AM
To: users at lists.ironpython.com
Subject: [IronPython] more pythonic than python

Hello !

First of all, thanks for the great job you are doing !

Second, as newbie programmer i would like  to ask if you have in mind after finnish IP, to create a completely pythonic language - like python should be without its warts and gotchas. I think it would not be hard for you to do the cleaning in the language ( the PEPs are too slow and shy ;(  ).

Below come 2 examples that bother me and i did not find in the python´s gotchas/warts pages in internet.

Thanks ;)





>>>class __Verbs:
...     def __init__(self):
...             annoy = "argh"
...             bother = "bargh"
...
>>>v = __Verbs()
>>>v.mother = "we should have an error here (i mistyped the variable's
>>>name)"


I think this is an excessive flexibility of the language, error prone.




################################



>>>str = "abc"
>>>str[0] = "z"
Traceback (most recent call last):
  File , line 0, in <stdin>##14
AttributeError: 'str' object has no attribute '__setitem__'


Although this useful feature appears in pnuts language. This time the language was not flexible and simple enough for my taste.

_________________________________________________________________
MSN Messenger: instale grátis e converse com seus amigos.
http://messenger.msn.com.br




More information about the Ironpython-users mailing list