[PYTHON] Receives and processes n objects in a list

I wanted to receive an unknown number of instances at once and handle members.

ObjList.py


class object:
  def __init__(self, value):
    self.L = value

def integral(ObjList):
  L = 0.0
  for obj in ObjList:
    L += obj.L
  return L

def main():
  obj1 = object(2.0)
  obj2 = object(3.0)

  L = integral([obj1, obj2])
  print(L)

if __name__ == '__main__':
  main()

I was able to write it surprisingly neatly. It's supposed to be used for different purposes, but it can be used to implement to-do lists and Gantt charts.

Recommended Posts

Receives and processes n objects in a list
Difference between list () and [] in Python
[python] Manage functions in a list
Assignments and changes in Python objects
When creating a matrix in a list
How to compare lists and retrieve common elements in a list
Display a list of alphabets in Python 3
Change the list in a for statement
Difference between append and + = in Python list
Extract every n elements from an array (list) in Python and Ruby
Organize python modules and packages in a mess
How to clear tuples in a list (Python)
I wrote a class in Python3 and Java
Make a copy of the list in Python
A memo created in a package and registered in PyPI
Get only the subclass elements in a list
View drug reviews using a list in Python
Y / n processing in bash, python and Go
Sort list elements in a specified order in Python
[Python] Manipulating elements in a list (array) [Sort]
Differences in behavior between append () and "+ =" operators when adding data to a list in Python
list and sum
list and numpy
The simplest Python memo in Japan (classes and objects)
Extract and list personal names and place names in the text
A list of stumbling blocks in Django's image upload
Implemented List and Bool in Python and SQLite3 (personal note)
Delete 1000 objects stored in AWS S3 at a time.
Things to note when initializing a list in Python
[Python] How to sort dict in list and instance in list
Group by consecutive elements of a list in Python
Output a binary dump in binary and revert to a binary file
Get a participant's username and screen name in Slack
(For myself) Flask_2 (list and for, extends, and a little more)
[Golang] Command to check the supported GOOS and GOARCH in a list (Check the supported platforms of the build)
Spit out a list of file name, last modified date and character code in python3
[Python] How to delete rows and columns in a table (list of drop method options)
Recursively get the Excel list in a specific folder with python and write it to Excel.
Parse the Researchmap API in Python and automatically create a Word file for the achievement list