Name : python3-baseconv
| |
Version : 1.2.2
| Vendor : obs://build_opensuse_org/home:bmwiedemann
|
Release : lp155.2.1
| Date : 2023-07-21 13:01:01
|
Group : Development/Languages/Python
| Source RPM : python-baseconv-1.2.2-lp155.2.1.src.rpm
|
Size : 0.02 MB
| |
Packager : https://www_suse_com/
| |
Summary : A generic base-conversion library for Python
|
Description :
h2. What is baseconv?
baseconv is a generic _base conversion_ library for Python. It allows you to convert any number between binary, hexadecimal, decimal, octal or any other base you can define. A base is a method of representing numbers; using two or more different _words_ you can represent any conceivable number using an ordered combination of those words. For example, the _decimal_ base is made up of 10 words: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. _Binary_ uses only 0 and 1.
h2. Usage
h3. Installation
To install baseconv, simply pull the repository using AATTgitAATT (for more info consult the \"github documentation\":http://github.com/guides), AATTcdAATT into the directory and run the following command as root:
python setup.py install
This will copy AATTbaseconv.pyAATT to Python\'s AATTsite-packagesAATT directory, and you can then import the library in your code via AATTimport baseconvAATT.
h3. Using the Library In Your Code
In order to carry out the most common features of base conversion, the library comes equipped with the pre-defined bases AATTDECIMALAATT, AATTBINARYAATT, AATTHEXADECIMALAATT, AATTOCTALAATT, AATTALPHA\\_LOWERAATT, AATTALPHA\\_UPPERAATT and AATTALPHAAATT. This means you can, out of the box, convert between all of these bases. An example usage case is shown below; note that numbers are held as instances of the AATTbaseconv.NumberAATT class, and bases as AATTbaseconv.BaseAATT instances. The attributes AATTdecimalAATT, AATTbaseAATT, AATTvaluesAATT and AATTindicesAATT are all Python _descriptors_; setting or otherwise changing one will cause the number\'s other attributes to update. The following code sample shows how you might use the library in a basic way:
>>> from baseconv import \\* >>> num = BINARY(\'1010011010\') # Create a number >>> num # Show the representation of a number Number(BINARY, \'1010011010\') >>> num.decimal 666 >>> num.decimal = 423 # Change a number\'s decimal value >>> num # The number\'s binary value has changed automatically Number(BINARY, \'110100111\') >>> num.base = HEXADECIMAL # Change a number\'s base >>> num Number(HEXADECIMAL, \'1A7\') >>> print num # Print a number as a string; also accessible via str(num) 0x1A7 >>> num.values # The sequence of base-words that this number represents \'1A7\' >>> num.values = \'FFC0DE\' # Set this numbers values list >>> num # Number has changed accordingly Number(HEXADECIMAL, \'FFC0DE\') >>> num.indices # The decimal value of each word in this number [15, 15, 12, 0, 13, 14] >>> num.indices = [1, 10, 7] # Set this number\'s indices attribute >>> num Number(HEXADECIMAL, \'1A7\')
h2. About the Author
My name is Zachary Voase, and you can get to my personal home page (which has links to all my other pages) \"here\":http://biga.mp.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/home:/bmwiedemann:/ipfs/15.5/noarch |