15.04.2013 Views

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

Core Python Programming (2nd Edition)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C.__*rshift__(self, obj) Right shift; >> operator<br />

C.__*and__(self, obj) Bitwise AND; & operator<br />

C.__*or__(self, obj) Bitwise OR; | operator<br />

C.__*xor__(self, obj) Bitwise XOR; ^ operator<br />

Numeric Types: Unary Operators<br />

C.__neg__(self) Unary negation<br />

C.__pos__(self) Unary no-change<br />

C.__abs__(self) Absolute value; abs() built-in<br />

C.__invert__(self) Bit inversion; ~ operator<br />

Numeric Types: Numeric Conversion<br />

C.__complex__(self, com) Convert to complex; complex() built-in<br />

C.__int__(self) Convert to int; int() built-in<br />

C.__long__(self) Convert to long; long() built-in<br />

C.__float__(self) Convert to float; float() built-in<br />

Numeric Types: Base Representation<br />

(String)<br />

C.__oct__(self) Octal representation; oct() built-in<br />

C.__hex__(self) Hexadecimal representation; hex() built-in<br />

Numeric Types: numeric coercion<br />

C.__coerce__(self, num) Coerce to same numeric type; coerce() built-in<br />

[g] Coerce alternate numeric type to integer if/when<br />

C.__index__(self)<br />

necessary (e.g., for slice indexes, etc.)<br />

Sequence Types [e]<br />

C.__len__(self) Number of items in sequence<br />

C.__getitem__(self, ind) Get single sequence element<br />

C.__setitem__(self, ind, val) Set single sequence element<br />

C.__delitem__(self, ind) Delete single sequence element<br />

Special Method Description<br />

Sequence Types [e]<br />

C.__getslice__(self, ind1, ind2) Get sequence slice<br />

C.__setslice__(self, i1, i2, val) Set sequence slice<br />

C.__delslice__(self, ind1, ind2) Delete sequence slice

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!