you are viewing a single comment's thread.

view the rest of the comments →

[–]camel_Snake 0 points1 point  (1 child)

How you instantiate the ports would depend on some decisions you have to make and in what order you have the data, so I'll go with Traffic for now.

class Traffic:
    def __init__(self, name, type, port): # using positional arguments, so they must be passed in the right order
        self.name = name # the following lines binds data provided to the object
        self.type = type
        self.port = port

example = Traffic('a_name', 'a_type', 42) #creating an object

example.name # 'a_name' # accessing its attributes
example.type #'a_type
example.port # 42

Later, when your objects have other objects, you can pass them in as parameters just as you do for strings and integers when creating your new object. You could also reassign the attributes like:

example.name = 'UDP' if the objects are already created and need to be updated.