[frames] | no frames]

# Class WithinPosition

source code

```      object --+
|
int --+
|
object --+   |
|   |
AbstractPosition --+
|
WithinPosition
```

Specify the position of a boundary within some coordinates.

Arguments: - position - The default integer position - left - The start (left) position of the boundary - right - The end (right) position of the boundary

This allows dealing with a position like ((1.4)..100). This indicates that the start of the sequence is somewhere between 1 and 4. Since this is a start coordinate, it should acts like it is at position 1 (or in Python counting, 0).

```>>> p = WithinPosition(10, 10, 13)
>>> p
WithinPosition(10, left=10, right=13)
>>> print(p)
(10.13)
>>> int(p)
10```

Basic integer comparisons and operations should work as though this were a plain integer:

```>>> p == 10
True
>>> p in [9, 10, 11]
True
>>> p < 11
True
>>> p + 10
20```
```>>> isinstance(p, WithinPosition)
True
>>> isinstance(p, AbstractPosition)
True
>>> isinstance(p, int)
True```

Note this also applies for comparison to other position objects, where again the integer behaviour is used:

```>>> p == 10
True
>>> p == ExactPosition(10)
True
>>> p == BeforePosition(10)
True
>>> p == AfterPosition(10)
True```

If this were an end point, you would want the position to be 13:

```>>> p2 = WithinPosition(13, 10, 13)
>>> p2
WithinPosition(13, left=10, right=13)
>>> print(p2)
(10.13)
>>> int(p2)
13
>>> p2 == 13
True
>>> p2 == ExactPosition(13)
True```

The old legacy properties of position and extension give the starting/lower/left position as an integer, and the distance to the ending/higher/right position as an integer. Note that the position object will act like either the left or the right end-point depending on how it was created:

```>>> p.position == p2.position == 10
True
>>> p.extension == p2.extension == 3
True
>>> int(p) == int(p2)
False
>>> p == 10
True
>>> p2 == 13
True```
 Instance Methods

 __repr__(self) Represent the WithinPosition object as a string for debugging. source code

 __str__(self) Return a representation of the WithinPosition object (with python counting). source code

 _shift(self, offset) Return a copy of the position object with its location shifted (PRIVATE). source code

 _flip(self, length) Return a copy of the location after the parent is reversed (PRIVATE). source code

Inherited from `int`: `__abs__`, `__add__`, `__and__`, `__cmp__`, `__coerce__`, `__div__`, `__divmod__`, `__float__`, `__floordiv__`, `__format__`, `__getattribute__`, `__getnewargs__`, `__hash__`, `__hex__`, `__index__`, `__int__`, `__invert__`, `__long__`, `__lshift__`, `__mod__`, `__mul__`, `__neg__`, `__nonzero__`, `__oct__`, `__or__`, `__pos__`, `__pow__`, `__radd__`, `__rand__`, `__rdiv__`, `__rdivmod__`, `__rfloordiv__`, `__rlshift__`, `__rmod__`, `__rmul__`, `__ror__`, `__rpow__`, `__rrshift__`, `__rshift__`, `__rsub__`, `__rtruediv__`, `__rxor__`, `__sub__`, `__truediv__`, `__trunc__`, `__xor__`, `bit_length`, `conjugate`

Inherited from `object`: `__delattr__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

 Static Methods
a new object with type S, a subtype of T
 __new__(cls, position, left, right) Create a WithinPosition object. source code
 Properties
position
Legacy attribute to get (left) position as integer (OBSOLETE).
extension
Legacy attribute to get extension (from left to right) as an integer (OBSOLETE).

Inherited from `int`: `denominator`, `imag`, `numerator`, `real`

Inherited from `object`: `__class__`

 Method Details

### __new__(cls, position, left, right)Static Method

source code
Create a WithinPosition object.
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

### __repr__(self)(Representation operator)

source code
Represent the WithinPosition object as a string for debugging.
Overrides: object.__repr__

### __str__(self)(Informal representation operator)

source code
Return a representation of the WithinPosition object (with python counting).
Overrides: object.__str__

 Property Details

### position

Legacy attribute to get (left) position as integer (OBSOLETE).
Get Method:
unreachable.position(self) - Legacy attribute to get (left) position as integer (OBSOLETE).

### extension

Legacy attribute to get extension (from left to right) as an integer (OBSOLETE).
Get Method:
unreachable.extension(self) - Legacy attribute to get extension (from left to right) as an integer (OBSOLETE).

 Generated by Epydoc 3.0.1 on Fri Jun 22 16:36:05 2018 http://epydoc.sourceforge.net