Programming Tip -What is python .. ("dot dot") notation syntax?

in #steemit6 years ago

Programming Tip -What is python .. ("dot dot") notation syntax?

EBOOK_PYTHON_no-name.png


Today i am going to show Programming Tip - How to generate XML from Python dictionary in python with simple code. I hope you will understand this.
If you have any query you can ask.
i hope you will like it.


There is no special .. ("dot dot") notation syntax in python. You can, however, see this in case of floats accessing their properties. For example,

f = 1..__truediv__ # or 1..__div__ for python 2
print(f(8))

This will give the output:

0.125
What we have is a float literal without the trailing zero, which we then access the __truediv__ method of. It's not an operator in itself; the first dot is part of the float value, and the second is the dot operator to access the object's properties and methods. This can also be achieved using:

>>> f = 1.
>>> f
1.0
>>> f.__truediv__


Follow me at : https://steemit.com/@ahmadhassan
=========================================================


Thanks for reading and always welcome your suggestions :) =========================================================

Sort:  

Thanks for sharing this post.

This post has received a 1.09 % upvote from @booster thanks to: @ahmadhassan.