Python ? Hidden Syntax ?, You’ll be using always from now ?

Ellipsis

Use … (Ellipsis), an alternative to pass.

def main():

if True:

single line return

For single line utility functions use, single line return statement.

def greet(): return “Welcome!”


This content originally appeared on DEV Community and was authored by Rajesh Joshi

Ellipsis

Use ... (Ellipsis), an alternative to pass.

def main():
    ...
if True:
    ...

single line return

For single line utility functions use, single line return statement.

def greet(): return "Welcome!"
def todo(): ...

Document Your Functions

To get proper documented Classes or functions with auto-completion define types of parameters and return types

def rectangle_area(l: float, b: float) -> float:
    area = l * b
    return area

Python ? Hidden Syntax ?, You'll be using always from now ?

Clever use of type() method

Call type function to know default value of any datatype.

>>> type(512)()
0
>>> type(True)()
False

Also, Use for type checking

>>> type('Apple') == str
True
>>> type([1, 2, '3']) == list
True

Thanks and Cheers
RajeshJ3


This content originally appeared on DEV Community and was authored by Rajesh Joshi


Print Share Comment Cite Upload Translate Updates
APA

Rajesh Joshi | Sciencx (2021-09-13T02:35:25+00:00) Python ? Hidden Syntax ?, You’ll be using always from now ?. Retrieved from https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/

MLA
" » Python ? Hidden Syntax ?, You’ll be using always from now ?." Rajesh Joshi | Sciencx - Monday September 13, 2021, https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/
HARVARD
Rajesh Joshi | Sciencx Monday September 13, 2021 » Python ? Hidden Syntax ?, You’ll be using always from now ?., viewed ,<https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/>
VANCOUVER
Rajesh Joshi | Sciencx - » Python ? Hidden Syntax ?, You’ll be using always from now ?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/
CHICAGO
" » Python ? Hidden Syntax ?, You’ll be using always from now ?." Rajesh Joshi | Sciencx - Accessed . https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/
IEEE
" » Python ? Hidden Syntax ?, You’ll be using always from now ?." Rajesh Joshi | Sciencx [Online]. Available: https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/. [Accessed: ]
rf:citation
» Python ? Hidden Syntax ?, You’ll be using always from now ? | Rajesh Joshi | Sciencx | https://www.scien.cx/2021/09/13/python-%f0%9f%a4%ab-hidden-syntax-%f0%9f%a4%ab-youll-be-using-always-from-now-%f0%9f%98%9d/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.