0

I am trying to collect data from a log file. The data will collected into records based on policy number. I have created an object describing the data below:

class fwpolicy:
def __init__(self, policy_id, fr_zone, to_zone, src,dest,serv):
self.policy_id = policy_id
self.fr_zone = fr_zone
self.to_zone = to_zone
self.src = src
self.dest = dest
self.serv = serv

The problem I am having is that some of the data , namely src, dest & serv may have multiple entries per policy.

questions:

1. Do I create these data types as lists in the object.
2. how do I add additional record to these dtat types? do i define a function within the fwpolicy class to do this?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by vegaseat
0

For multiple entries you can use lists or tuples. The class as written can add additional records by simply writing code like this external to the class ...

frank = fwpolicy(...your normal record data for Frank here...)
frank.additional_record = 'blah'

It is customary in Python to start a class name with a capital letter.

For Python code on Daniweb:
Please use the [code=python] and [/code] tag pair to enclose your python code. This will preserve your indentations and color highlight the code.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.