[Python-3000] enhanced descriptors, part 2
tomer filiba
tomerfiliba at gmail.com
Tue Jun 13 19:48:25 CEST 2006
> f.position -- used to access the current position
> f.position = x -- seek to an absolute position (may be relative to end)
> f.seek_by(x) -- seek by a relative amount
>
> Properties are nice, but there's nothing wrong with methods either. If
> we went with the second approach, people might foolishly use
> "f.position += 4" where they intended "f.seek_by(x)" and it would still
> work fine, it just wouldn't be optimized. That's really not so bad.
okay, i'm fine with that. but i'm not happy with the fact it's not *possible*
to implement such things in python. perhaps with time more use-cases
will show it's needed. until then... ;)
-tomer
On 6/13/06, Michael Chermside <mcherm at mcherm.com> wrote:
> tomer writes:
> > there really is a need for "enhanced descriptors", or something like
> > that. i'm having serious trouble implementing the position property,
> > as python is currently limited in this area.
>
> No, this doesn't necessarily imply that we need "enhanced descriptors",
> an alternative solution is to change the intended API for file
> positions. After all, the original motivation for using a property
> was that it was (a) nice to use, (b) easy to read, and (c) possible to
> implement. If (c) isn't true then perhaps we rethink the API.
>
> After all, how bad would it be to use the following:
>
> f.position -- used to access the current position
> f.seek_to(x) -- seek to an absolute position (may be relative to end)
> f.seek_by(x) -- seek by a relative amount
>
> Or even go half-way:
>
> f.position -- used to access the current position
> f.position = x -- seek to an absolute position (may be relative to end)
> f.seek_by(x) -- seek by a relative amount
>
> Properties are nice, but there's nothing wrong with methods either. If
> we went with the second approach, people might foolishly use
> "f.position += 4" where they intended "f.seek_by(x)" and it would still
> work fine, it just wouldn't be optimized. That's really not so bad.
>
> -- Michael Chermside
>
>
More information about the Python-3000
mailing list