| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| other:python:misc_by_jyp [2024/08/27 14:47] – [String formatting] Improved the section jypeter | other:python:misc_by_jyp [2025/10/31 11:28] (current) – [Using a decorator to log function calls] jypeter |
|---|
| Only **when you have already read all the content of this page several times**, and you are looking for new ideas | Only **when you have already read all the content of this page several times**, and you are looking for new ideas |
| |
| | * [[https://medium.com/data-science/calculating-distance-between-two-geolocations-in-python-26ad3afe287b|Calculating distance between two geo-locations in Python]]: |
| | * ''[[https://github.com/mapado/haversine|haversine]]'', ''[[https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.haversine_distances.html|haversine_distances]] @ scikit-learn'' and [[https://en.wikipedia.org/wiki/Haversine_formula|Haversine formula]] |
| | * Looking at table data with ''pandas'' |
| | * [[https://blog.devgenius.io/data-profiling-in-python-common-ways-to-explore-your-data-part-1-0efd0dedff75|Summary information]] |
| | * [[https://blog.devgenius.io/data-profiling-in-python-common-ways-to-explore-your-data-part-2-396384522e91|More detailed information]] |
| | * [[https://blog.devgenius.io/data-cleansing-in-python-common-ways-to-clean-your-data-3459a256dd85|Table data cleaning]] |
| | * Stats stuff |
| | * [[https://medium.com/@tubelwj/python-outlier-detection-iqr-method-and-z-score-implementation-8e825edf4b32|Python Outlier Detection: IQR Method and Z-score Implementation]] |
| | * [[https://medium.com/pythons-gurus/clean-code-in-python-good-vs-bad-practices-examples-2df344bddacc|Clean Code in Python: Good vs. Bad Practices Examples]] |
| | * [[https://peps.python.org/pep-0008/|PEP 8 – Style Guide for Python Code]] |
| | * [[https://realpython.com/python-pep8/|How to Write Beautiful Python Code With PEP 8]] |
| | * [[https://www.datacamp.com/tutorial/pep8-tutorial-python-code|PEP-8 Tutorial: Code Standards in Python]] |
| | * Some checkers/linters: [[https://docs.astral.sh/ruff/|ruff]], [[https://flake8.pycqa.org/en/stable/|flake8]] |
| * [[https://medium.com/@yaduvanshineelam09/ultimate-python-cheat-sheet-practical-python-for-everyday-tasks-8a33abc0892f|Ultimate Python Cheat Sheet: Practical Python For Everyday Tasks]] | * [[https://medium.com/@yaduvanshineelam09/ultimate-python-cheat-sheet-practical-python-for-everyday-tasks-8a33abc0892f|Ultimate Python Cheat Sheet: Practical Python For Everyday Tasks]] |
| * [[https://medium.com/pythoneers/16-hacks-that-will-take-your-python-skills-to-the-next-level-12e7a9b97421|16 Hacks That Will Take Your Python Skills to the Next Level]] | * [[https://medium.com/pythoneers/16-hacks-that-will-take-your-python-skills-to-the-next-level-12e7a9b97421|16 Hacks That Will Take Your Python Skills to the Next Level]] |
| | * [[https://levelup.gitconnected.com/modular-coding-in-python-finally-solve-your-import-errors-af2fd172fcf7|Modular Coding in Python: Finally Solve your Import Errors]] (understanding and fixing ModuleNotFoundError and ImportError) |
| | * [[https://medium.com/@moraneus/understanding-multithreading-and-multiprocessing-in-python-1ed39bb078d5|Understanding Multithreading and Multiprocessing in Python]] |
| ===== Reading/setting environments variables ===== | ===== Reading/setting environments variables ===== |
| |
| |
| |
| | ===== Using log files (aka logging) ===== |
| | |
| | It is always possible to display information messages using the ''print()'' command, but it is more efficient to use //logging// tools when you want to **display correctly a lot of information about a script progress |
| | ** |
| | * [[https://loguru.readthedocs.io/|Loguru]] is a library which aims to bring enjoyable logging in Python |
| | * See also [[https://betterstack.com/community/guides/logging/loguru/|A Complete Guide to Logging in Python with Loguru]] |
| | * More on [[https://betterstack.com/community/guides/logging/#python|logging with python]] |
| | * The default (but not easy to use) Python ''[[https://docs.python.org/3/library/logging.html|logging]]'' module |
| ===== Stopping a script ===== | ===== Stopping a script ===== |
| |
| </code> | </code> |
| |
| | ===== Debugging... ===== |
| | |
| | Some resources that you can use in the unlikely case that <del>you</del> some AI has introduced <del>features</del> bugs in your code |
| | |
| | ==== Built-in tools ==== |
| | |
| | Read the documentation of: |
| | * [[https://docs.python.org/3/library/pdb.html|pdb, The Python Debugger]] |
| | * and the other built-in [[https://docs.python.org/3/library/debug.html|Debugging and Profiling tools]] |
| | |
| | ==== Using a decorator to log function calls ==== |
| | |
| | Check the example in [[https://blog.devgenius.io/my-lazy-secret-to-cleaner-code-python-decorators-d43d673a1ba2|My Lazy Secret to Cleaner Code: Python Decorators]] |
| | |
| | Note: more about [[#using_log_files_aka_logging|using log files]] |
| |
| /* | /* |