| Line 6: |
Line 6: |
| | ===Arithmetic=== | | ===Arithmetic=== |
| | <nowiki>+ Addition | | <nowiki>+ Addition |
| − | - Substraction
| + | - Substraction |
| − | * Multiplication
| + | * Multiplication |
| − | / Division
| + | / Division |
| − | ** Power
| + | ** Power |
| − | % Reminder
| + | % Reminder |
| − | // Floor division (Reminder is removed)</nowiki>
| + | // Floor division (Reminder is removed)</nowiki> |
| | ===Comparison=== | | ===Comparison=== |
| | <nowiki> | | <nowiki> |
| − | == Equal
| + | == Equal |
| − | != Not equal
| + | != Not equal |
| − | > Greater
| + | > Greater |
| − | >= Greater or equal
| + | >= Greater or equal |
| − | < Smaller
| + | < Smaller |
| − | <= Smaller or equal
| + | <= Smaller or equal |
| − | <> Similar to !=</nowiki>
| + | <> Similar to !=</nowiki> |
| | ===Assignment=== | | ===Assignment=== |
| | <nowiki> | | <nowiki> |
| − | = Simple assignment
| + | = Simple assignment |
| − | += Add and as
| + | += Add and as |
| − | -= Substract and assignment
| + | -= Substract and assignment |
| − | *= Multiply and assignment
| + | *= Multiply and assignment |
| − | /= Divide and assignment
| + | /= Divide and assignment |
| − | %= Modulus and assignment
| + | %= Modulus and assignment |
| − | **= Exponent and assignment
| + | **= Exponent and assignment |
| − | //= Floor Divisionn and assignment</nowiki>
| + | //= Floor Divisionn and assignment</nowiki> |
| | | | |
| | ===Bitwise operators=== | | ===Bitwise operators=== |
| | They perform operations on binary terms. a= 8 → 100; b= 9 → 101; a & b → 100 | | They perform operations on binary terms. a= 8 → 100; b= 9 → 101; a & b → 100 |
| | <nowiki> | | <nowiki> |
| − | $ Binary AND
| + | $ Binary AND |
| − | | Binary OR
| + | | Binary OR |
| − | ^ Binary XOR
| + | ^ Binary XOR |
| − | ~ Binary complement
| + | ~ Binary complement |
| − | << Binary left shift
| + | << Binary left shift |
| − | >> Binary right shift</nowiki>
| + | >> Binary right shift</nowiki> |
| | | | |
| | ===Logic=== | | ===Logic=== |
| | <nowiki> | | <nowiki> |
| − | and
| + | and |
| − | or
| + | or |
| − | not</nowiki>
| + | not</nowiki> |
| | | | |
| | ===Membership operators=== | | ===Membership operators=== |
| Line 311: |
Line 311: |
| | ==Regular Expressions== | | ==Regular Expressions== |
| | <nowiki> | | <nowiki> |
| − | ^ → Matches the beginning of a line
| + | ^ → Matches the beginning of a line |
| − | $ → Matches the end of a line
| + | $ → Matches the end of a line |
| − | . → Matches any character
| + | . → Matches any character |
| − | \s → Matches any whitespace
| + | \s → Matches any whitespace |
| − | \S → Matches any non-whitespace
| + | \S → Matches any non-whitespace |
| − | * → Repeats a character 0 or more times
| + | * → Repeats a character 0 or more times |
| − | *? → Repeats a character 0 or more times (non-greedy)
| + | *? → Repeats a character 0 or more times (non-greedy) |
| − | + → Repeats a character 1 or more times
| + | + → Repeats a character 1 or more times |
| − | +? → Repeats a character 1 or more times (non-greedy)
| + | +? → Repeats a character 1 or more times (non-greedy) |
| − | [aeiou] → Matches a single character in the listed set
| + | [aeiou] → Matches a single character in the listed set |
| − | [^XYZ] → Matches a single character NOT in the listed set
| + | [^XYZ] → Matches a single character NOT in the listed set |
| − | [a-z0-9] → The set of characters can include a range
| + | [a-z0-9] → The set of characters can include a range |
| − | ( → Indicates where string extraction is to start
| + | ( → Indicates where string extraction is to start |
| − | ) → Indicates where string extraction is to end</nowiki>
| + | ) → Indicates where string extraction is to end</nowiki> |
| | \ → Escape character | | \ → Escape character |
| | ===Regular Expression Module=== | | ===Regular Expression Module=== |
| Line 503: |
Line 503: |
| | attributes that start with a __ wont be visible to others<br /> | | attributes that start with a __ wont be visible to others<br /> |
| | | | |
| − | === Subclasing builtins === | + | ===Subclasing builtins=== |
| | | | |
| − | ==== Perfect dict subclass ==== | + | ====Perfect dict subclass==== |
| | <syntaxhighlight lang="python3"> | | <syntaxhighlight lang="python3"> |
| | + | # has a ton of errors: https://stackoverflow.com/questions/3387691/how-to-perfectly-override-a-dict |
| | + | |
| | class LowerDict(dict): | | class LowerDict(dict): |
| | __slots__ = () | | __slots__ = () |
| Line 553: |
Line 555: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | ==== Not so perfect dict like object ==== | + | ====Not so perfect dict like object==== |
| | <syntaxhighlight lang="python3"> | | <syntaxhighlight lang="python3"> |
| | from collections.abc import MutableMapping | | from collections.abc import MutableMapping |
| Line 853: |
Line 855: |
| | nano ~/.pypirc | | nano ~/.pypirc |
| | <nowiki>[distutils] | | <nowiki>[distutils] |
| − | index-servers =
| + | index-servers = |
| − | pypi
| + | pypi |
| − | pypitest
| + | pypitest |
| − |
| + | |
| − | [pypi]
| + | [pypi] |
| − | repository=https://upload.pypi.org/legacy/
| + | repository=https://upload.pypi.org/legacy/ |
| − | username=your_username
| + | username=your_username |
| − | password=your_password
| + | password=your_password |
| − |
| + | |
| − | [pypitest]
| + | [pypitest] |
| − | repository=https://testpypi.python.org/pypi
| + | repository=https://testpypi.python.org/pypi |
| − | username=your_username
| + | username=your_username |
| − | password=your_password</nowiki>
| + | password=your_password</nowiki> |
| | Adjust .pypirc permissions | | Adjust .pypirc permissions |
| | chmod 600 ~/.pypirc | | chmod 600 ~/.pypirc |
| Line 943: |
Line 945: |
| | nano setup.cfg | | nano setup.cfg |
| | <nowiki>[metadata] | | <nowiki>[metadata] |
| − | description-file = README.md</nowiki>
| + | description-file = README.md</nowiki> |
| | | | |
| | nano LICENSE | | nano LICENSE |
| | <nowiki>The MIT License | | <nowiki>The MIT License |
| − |
| + | |
| − | SPDX short identifier: MIT
| + | SPDX short identifier: MIT |
| − |
| + | |
| − | Copyright <YEAR> <COPYRIGHT HOLDER>
| + | Copyright <YEAR> <COPYRIGHT HOLDER> |
| − |
| + | |
| − | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
| + | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| − |
| + | |
| − | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
| + | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| − |
| + | |
| − | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</nowiki>
| + | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</nowiki> |
| | Test and upload | | Test and upload |
| | <source lang="bash">python setup.py register -r pypitest | | <source lang="bash">python setup.py register -r pypitest |
| Line 970: |
Line 972: |
| | nano ~/.pip/pip.conf | | nano ~/.pip/pip.conf |
| | <nowiki>[global] | | <nowiki>[global] |
| − | index-url= http://10.255.0.21/pypi/simple
| + | index-url= http://10.255.0.21/pypi/simple |
| − | trusted-host= 10.255.0.21</nowiki>
| + | trusted-host= 10.255.0.21</nowiki> |
| | | | |
| | ==Using pip behind proxy== | | ==Using pip behind proxy== |
| Line 979: |
Line 981: |
| | Create the file ~/.pypirc | | Create the file ~/.pypirc |
| | <nowiki>[distutils] | | <nowiki>[distutils] |
| − | index-servers =
| + | index-servers = |
| − | pypi
| + | pypi |
| − | pypitest
| + | pypitest |
| − |
| + | |
| − | [pypi]
| + | [pypi] |
| − | repository=https://pypi.python.org/pypi
| + | repository=https://pypi.python.org/pypi |
| − | username=
| + | username= |
| − | password=
| + | password= |
| − |
| + | |
| − | [pypitest]
| + | [pypitest] |
| − | repository=https://test.pypi.org/legacy
| + | repository=https://test.pypi.org/legacy |
| − | username=
| + | username= |
| − | password=
| + | password= |
| − | </nowiki>
| + | </nowiki> |
| | | | |
| | Test | | Test |