Python has really useful features that make writing code more efficient than ever.
Here are 5 tips for writing better and more compact Python code.





Here are 5 tips for writing better and more compact Python code.






1. Generator
A generator is a special type of function which does not return a single value, instead it returns an iterator object with a sequence of values.
https://www.tutorialsteacher.com/python/python-generator
A generator is a special type of function which does not return a single value, instead it returns an iterator object with a sequence of values.
https://www.tutorialsteacher.com/python/python-generator
2. Decorator
A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure.
https://book.pythontips.com/en/latest/decorators.html
A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure.
https://book.pythontips.com/en/latest/decorators.html
3. Ternary operator
A Ternary operator allows you to quickly test a condition instead of a multiline if statement.
https://book.pythontips.com/en/latest/ternary_operators.html
A Ternary operator allows you to quickly test a condition instead of a multiline if statement.
https://book.pythontips.com/en/latest/ternary_operators.html
4. Setattr and getattr
The setattr function sets the value of the specified attribute of the specified object. The getattr method returns the value of the named attribute of an object.
The setattr function sets the value of the specified attribute of the specified object. The getattr method returns the value of the named attribute of an object.
5. Enumerate
Enumerate adds a counter to an iterable and returns it in a form of enumerate object.
https://www.geeksforgeeks.org/enumerate-in-python/
Enumerate adds a counter to an iterable and returns it in a form of enumerate object.
https://www.geeksforgeeks.org/enumerate-in-python/
You've reached the end of this 
Please RT and
it if you found it helpful, so you can share it with others.

Please RT and
