*
<>if

* False The ones with high probability are put in front
* The slow ones are put in the back
* else Only with the latest if Make a couple
*
<>if…else… simplified method

*
<> Ternary expression

*
<> be good at using sth. or sb. if return

Academies believe that there is only one function return sentence , because return It's the end .

When there are multiple branches , Proper use return You can end the branch in time .

*
<> The internal contents are extracted into functions

When if…else… When the internal code is complex , It can be extracted into functions , about for It's the same thing .

*
<> notes

*
<> Too many comments are not appropriate

*
<> Function names are clear instead of comments

*
<> The necessity of extraction as function

*
<> The code is complex

*
<> It can be used in other places

*
<> Dyslexia

*
<> View function

*
<> Code needs to be concise

*
<> The origin of business logic

*
<> Read source code

*
<> Layered view , Don't worry about it all

*
<> Ternary expression

*
<> original
if r.status_code == 200: if return_json: return r.json() else: return r.text
else: if return_json: return {} else: return ''
*
<> simplify
def func(): if r.status_code != 200: return {} if return_json else '' return r.
json() if return_json else r.text

Technology
©2019-2020 Toolsou All rights reserved,
Final review of database : Summary of comprehensive application questions Laplance operator ( Second derivative ) Simple learning of computer composition principle pyqt Button call python program _PyQt: Link button to function in program How much can you go up once you change jobs ? Today, I saw the ceiling of job hopping python in str Function usage _python in str Usage Summary of built-in functions MySQL trigger web The server nginx---linux Installation and deployment C++ Chapter V polymorphism exercises :( It's coming to an end )python Check built-in functions , How to check python Built in function