Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python class to tuple

>>> class SquaresTo:
...     def __init__(self, n):
...         self.n = n
...     def __iter__(self):
...         for i in range(self.n):
...             yield i * i
...
>>> s = SquaresTo(5)
>>> tuple(s)
(0, 1, 4, 9, 16)
>>> list(s)
[0, 1, 4, 9, 16]
>>> sum(s)
30
Comment

PREVIOUS NEXT
Code Example
Python :: PHP echo multiple lines example Using Heredoc 
Python :: python chunks iterator 
Python :: COMBINE TWO 2-D NUMPY ARRAYS WITH NP.VSTACK 
Python :: back of list 
Python :: printing multiple input in python 
Python :: python why is it important to check the __name__ 
Python :: Python - Comment préparer la capitalisation 
Python :: Sending Emails 
Python :: pandas ta quick start example 
Python :: merge_sort 
Python :: form is undefined flask 
Python :: send command civil3D 
Python :: how to send one variable to python using xlwings 
Python :: remove cooldown discord python 
Python :: spark group by alias 
Python :: how to register button presses in pysimpleGUI 
Python :: organize order columns dataframe 
Python :: date component 
Python :: set defualt to none django 
Python :: read file python 
Python :: timeplanner-1 
Python :: pandas plot column titles vertical 
Python :: slice in iloc 
Python :: how to multiply two lists in python 
Python :: find length of all G.keys() in dict 
Python :: pip install matplotlib.pyplot 
Python :: sns countplot show only largest 
Python :: assertRaises property 
Python :: get localapplication python 
Python :: df convert dtypes 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =