recnac-itna / python_tricks

Summary about advanced techniques, patterns and philosophy of Python. What's more, collect many inspirational examples to enlighten you how and where to use.

Home Page:https://www.pluralsight.com/guides/python-tricks-basic-part-1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Tricks

Description

"life is short, you need python"

Python Tricks here you can understand them as something like advanced techniques, patterns or philosophy of Python. (Some are indeed tricks, by the way☺)

Currently, it mainly contains three parts: basic, iterable and black magic.

The most valuable part is Inspiration. Even though you already knew this trick, but you rarely use it, because you don't know where to use, and Inspiration part will enlighten you.

Many example codes come from LeetCode, I have tried my best to make a brief problem description, useful enough for most case, actually you can only focus on the trick. If you are also interested in problem, and want to go deep, you can visit LeetCode for more information.

Further Elaboration of Python

Python is a high-level, interpreted, and dynamic programming language. Python offers a great compromise between development and execution time. It improves development efficiency within acceptable performance loss. With the simplicity of grammar, high-level language features, and rich extensive support libraries, Python helps you to focus more on your own logic.

Python used to be a glue or scripting language to increase productivity. Now Python has a complete technology stack, community ecology, and supporting tools and frameworks. On the strength of conciseness, readability and interactivity, python also play an important role in the field of data science and artificial intelligence.

Why should use tricks?

To make code concise, elegant and high-quality. (also efficient enough)

In my opinion, it obeys Python's philosophy: trading maybe a little bit performance for readability, usability, coding efficiency, and reducing possibility of bugs.

Or you simply want to play and have fun with Python.

Attention

Like I said here: https://stackoverflow.com/q/55684960/11263560

Discussion about whether should use python tricks like ~:

In my opinion, If it is a code maintained by yourself, you can use any trick to avoid potential bug or achieve goal easier, because of maybe a high readability and usability. But in team work, avoid using 'too clever' code, may bring troubles to your co-workers.

In Python Tricks, not all tricks are tricky, and not all tricks are suitable in your scenario. So It is you to decide which tricks should use, and which are not.

Actually I have added extra comments about the defect of tricks, to help you decide.

Who is this for?

  1. If you have mastered basic python skills or transferring from another language, and you want to enhance your python skills, to write a more pythonic-style code, here you can learn how to and where to use these advanced python tricks.

  2. If you want to write more cool or hackish python code, or just have a fun with python, here you will be enlightened and enjoy it.

Who isn't this for?

This is not for Python beginners. I try to make it short and refined, just pick the most valuable tricks.

So it not includes all the advanced Python features, and I will not give a complete tutorial, either. Maybe you need to refer to other materials to help you understand.

Environment

Version

Python 3.6 or Above. But some examples have no version restrictions.

Development Environment

In the learning and debugging stage, it is recommended to use an interactive development environment such as Jupyter Notebook.

Future work

Currently, it mainly contains three parts: basic, iterable and black magic. I will continuously update once I dig a gold.

Maybe I will add the advanced usages and black magic of standard library, such as cool operator overloading, and also pick cool ideas from extra python tools.

Maybe I will add more design patterns and philosophy of Python.

Thanks to

  • Special thanks to Stefan Pochmann. Many enlightening codes come from Stefan. I really learned a lot from him.
  • Thanks to Stack Overflow for the great questions and answers.
  • Thanks to LeetCode for the algorithm problems. Moreover, LeetCode has a great OJ platform. It is very suitable for functional and performance tests.
  • Many templates and tricks are enlightened by discussions in LeetCode. Thanks to all the code masters.
  • Thanks to many other articles and code snippets that I have referred to.

MIT License

Feel free to use, copy, modify, merge or publish. just add a reference, please.

If it helps you or you like it, you can star or share it. thanks : )

I'm glad if you want to contribute to make it better.

Source

This project is the practical part of a series of Pluralsight Guides.

Contact

recnac@foxmail.com

About

Summary about advanced techniques, patterns and philosophy of Python. What's more, collect many inspirational examples to enlighten you how and where to use.

https://www.pluralsight.com/guides/python-tricks-basic-part-1

License:MIT License


Languages

Language:Jupyter Notebook 100.0%