Design Q: Changing the indexing of a list

M

Matt

Hello, I was wondering if anyone could suggest a way of doing the
following in Python: I'm writing a class to handle strings of bits,
and I often need to number the bits in different ways, e.g. from the
left starting at zero, or from the right starting at one, and so
forth. I'd quite like to be able to dynamically change how
subscripting works for individual objects, and maybe have that
behaviour transferred to any further objects that that individual
creates (e.g. a new bit string that's the logical negation of the
original). There's actually a couple of other things like that as
well, such as being able to set whether the "+" operation means
concatenation or addition for an object.

This might sound like a horrible thing to want to do, given that it
would then be hard to know what indexing or addition would do in any
given context, but it would be very convenient in the application I'm
looking at. Any suggestions on how I might go about this would be much
appreciated,

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top