[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-3000
Subject:    [Python-3000] range vs. int.__getslice__
From:       vys () renet ! ru (Vladimir 'Yu' Stepanov)
Date:       2006-07-04 17:07:43
Message-ID: 44AAA05F.7040605 () renet ! ru
[Download RAW message or body]

Diogo Kollross wrote:
>> It is how much possible to understand slice in Python language is a
>> reception of a range of values with the certain step. By default this
>> step is equal to 1 for objects of any type. It is possible to assume,
>> that the similar behaviour can be at types float, decimal, long and
>> other. As the method __getslice__ till now is not involved by any
>> image for numbers.
>>     
>
> How the following case should work?
>
> class even(int):
> .. "Only the even integers..."
>
> for i in even[:100]:
> .. do something

This method should not be accessible through the inherited classes.
Ambiguity from the point of view of the user (you have already resulted
an example) will be shown differently. It will be probably necessary
to add one more METH_* an option. For example METH_NOEXPORT. Besides
optimization should be not worse existing range, that is impossible
without adaptation of a method under concrete type of data.

The method __getslice__ cannot be set for type with option METH_CLASS
or METH_STATIC. I expect occurrence of the syntax, satisfying to needs
of the given method. Recently it was discussed parametrization of types.
In this connection, how it will be realized __getitem__ for work with
classes ? The similar design could be used and for alternative
realization of syntax `range':

    http://mail.python.org/pipermail/python-3000/2006-May/002149.html

That it would be possible is high-grade to work and with other types of
data, except for int and long, it is required that PEP-357 has been
completed:

    http://www.python.org/dev/peps/pep-0357/



Thanks.

--
Vladimir

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic