Compromise: Datatypes for Reasonable People
Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.
In a world of disagreement, Compromise is everything for everyone. You no longer have to make the tough decisions in life.
>>> l = HalfIndexList('abcde') >>> l[0.5] 'a' >>> l[1.5] 'b' >>> l[-0.5] 'e' >>> l.reverse() >>> l ['e', 'd', 'c', 'b', 'a']
Some may find having a set starting index a bit restrictive. They should use FlexibleList.
>>> l = FlexibleList('abcde') FlexibleList(['a', 'b', 'c', 'd', 'e'], start=0) >>> l.start = 5 >>> l 'c'
SemiMutableSequences can't be changed.
>>> t = SemiMutableSequence(range(5)) >>> t SemiMutableSequence([0, 1, 2, 3, 4]) >>> t = 7 TypeError: SemiMutableSequence object does not support item assignment
Unless you, like, really want to.
>>> t = SemiMutableSequence(range(5)) >>> try: ... t = 7 ... except TypeError: ... pass >>> t = 7 >>> t SemiMutableSequence([0, 7, 2, 3, 4])
Magic Numbers are bad. Who could possibly understand what this means?
>>> feet = yards * 3
These should be replaced by Number instances.
>>> from compromise import THREE >>> feet = yards * THREE
See? Much better. You can make longer numbers with
& and floats with
>>> ONE & ZERO 10 >>> THREE + point(ONE & FOUR) 3.14
They're constant by convention only. Don't change them!
>>> TWO = (ONE & ZERO) / FOUR >>> TWO + TWO 5
Or change them if you want. I don't care.