Collection of less popular features and tricks for the Python programming language
Python
Switch branches/tags
Nothing to show
Clone or download
brennerm Merge pull request #89 from JohnTitor00/master
Switch/Case statments using dictionaries.
Latest commit 03151e4 Mar 9, 2018
Permalink
Failed to load latest commit information.
CONTRIBUTORS Update CONTRIBUTORS Mar 6, 2018
LICENSE.txt Create LICENSE.txt Aug 10, 2017
PyTrickBase.txt initial commit Mar 19, 2015
README.md fix typo Mar 29, 2015
argumentunpacking.py replace sum function with product Mar 21, 2015
boolasint.py added several PyTricks Mar 19, 2015
boolisslow.py add dictdefaultvalue.py and boolisslow.py Dec 12, 2015
cacheproperty.py added contribution of Kzinglzy Mar 21, 2015
calculator.py added contribution of tutoringsteve Mar 21, 2015
chainedcomparison.py initial commit Mar 19, 2015
codetofunction.py Add Code to Function example May 25, 2015
common_seq_method.py Update common_seq_method.py May 9, 2015
concatenatestrings.py added contribution of tutoringsteve Mar 21, 2015
conditionalassignment.py Adds an example of using python's lazy or for assignments Apr 1, 2015
conditionalfunctioncall.py replace sum function with product Mar 21, 2015
contextmanagers.py added context manager examples Oct 6, 2015
controlwhitespaces.py fix comment Mar 21, 2015
copylist.py copy list by typecasting method Jan 10, 2016
deck_as_list.py Changing print to print() May 19, 2015
dictdefaultvalue.py add dictdefaultvalue.py and boolisslow.py Dec 12, 2015
dictionaryget.py initial commit Mar 19, 2015
dictsortbyvalue.py style(dictsortbyvalue.py): PEP8 style Apr 28, 2015
dictswapkeysvalues.py added contribution of tutoringsteve Mar 21, 2015
exec.py added several PyTricks Mar 19, 2015
extendediterableunpacking.py style(extendediterableunpacking): PEP8 style Apr 28, 2015
flattenlist.py style(flattenlist.py): PEP8 style Apr 28, 2015
forelse.py initial commit Mar 19, 2015
ifelsecommentswitch.py ifelse comments switch Feb 1, 2018
keydefaultdict.py style(keydefaultdict.py): PEP8 style Apr 28, 2015
listtocommaseparated.py Added list to comma separated Mar 23, 2015
loopoverlappingdicts.py pep8 style May 10, 2015
maxsplit.py added use of None Mar 22, 2015
merge_dict.py merging two dictionaries Jan 12, 2016
metatable.py pep8 style May 10, 2015
minmaxindex.py pep8 style May 10, 2015
namedformatting.py Adds object string formatting example. Jan 8, 2016
nested_functions.py added isayme's contribution Apr 2, 2015
objgetnamedattribute.py Rename objgetnamedattribute to objgetnamedattribute.py Mar 23, 2015
rawinputintegers.py string of integers to integers list using map Mar 31, 2015
removeduplicatefromlist.py pep8 style May 10, 2015
reverselist.py Merge branch 'master' of https://github.com/NDevox/PyTricks into NDev… Dec 11, 2015
reversestring.py fixed typo Dec 11, 2015
setglobalvariables.py added setglobalvariables.py Mar 21, 2015
setoperators.py fixed accidental deletion Mar 22, 2015
socketmsghandling.py pep8 style May 10, 2015
sortlistkeepindices.py pep8 style May 10, 2015
stepslice.py initial commit Mar 19, 2015
switch_case_statments_with_dict.py Update and rename lightweightswitch.py to switch_case_statments_with_… Mar 8, 2018
transpose.py pep8 style May 10, 2015
tree.py One-liner for Trees in Python Mar 26, 2015
tryelse.py added .py suffix to tryelse, why was it missing? :D Mar 21, 2015
unique_by_attr.py Update unique_by_attr.py Jan 8, 2016
valueswapping.py initial commit Mar 19, 2015
whileelse.py pep8 style May 10, 2015

README.md

Intention

Creating a knowledge base of unpopular Python built-in features to save a lot of unnecessary code.

Contribute

Feel free to use the PyTrickBase.txt as a starting point.

  1. Pull request:

    Send a pull request with your PyTrick, containing example code and a documentation one-liner. Be sure to add yourself to the contributors.

  2. Issue comment:

    Add your Python snippet and your documentation as a comment on Issue#1. I will take care of adding your PyTrick and you as a contributor.

Requirements

  • only use the standard Python library
  • compared to the "general approach":
    • improve readability
    • improve performance
    • implement functionality in a shorter way

Contact

  1. message me at @__brennerm
  2. send an email to xam.rennerb@gmail.com