[IronPython] more pythonic than python

Fuzzyman fuzzyman at voidspace.org.uk
Tue Jun 20 16:08:55 CEST 2006


fernando moreira wrote:

> 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.
>
Preventing you from setting attributes on objects would be very
annoying. On the other hand there are several tricks with
``__setattr__``, metaclasses, and ``__slots__`` that can all be used to
achieve what you want.

>
>
>
> ################################
>
>
>
>>>> str = "abc"
>>>> str[0] = "z"
>>>
> Traceback (most recent call last):
>  File , line 0, in <stdin>##14
> AttributeError: 'str' object has no attribute '__setitem__'
>
Strings are immutable. Writing a simple class that does what you want
(in most situations) is not very difficult.

Having the core string datatype as mutable would have all sorts of nasty
consequences (like not being able to use them as dictionary keys because
they would no longer be hashable).

All the best,

Michael Foord


>
> 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
>
>------------------------------------------------------------------------
>
>_______________________________________________
>users mailing list
>users at lists.ironpython.com
>http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>  
>




More information about the Ironpython-users mailing list