simple integer subclass

Stefan Schwarzer sschwarzer at
Thu Aug 5 11:49:48 CEST 2010

Hi Andreas,

On 2010-08-03 12:15, Andreas Pfrengle wrote:
> On 3 Aug., 03:22, Carl Banks <pavlovevide... at> wrote:>
> Thinking about it, it might really be dangerous to coerce always to
> int1, since sometimes I might want a normal int as result (I can't
> tell yet for sure).

Yes, that way your problem may shift from inconvenient to
outright hairy. ;-)

> The application will be a browsergame, and most gamers start counting
> at 1, so they would probably wonder about a "level 0 item" ;-)
> If there didn't already exist lots of code, I would redesign the whole
> data-structure - I think that's "lessons learned" for the next project

What about

    def _index_to_level(index):
        return index + 1

with this or a different name? This admittedly is longer
than writing `something + 1` but in the latter case you
might wonder what the addition is for, i. e. if it's really
a level offset calculation or something else.


More information about the Python-list mailing list