Arrays, Got Me Confused

Carsten Haese carsten at uniqsys.com
Fri Apr 13 09:09:03 EDT 2007


On Fri, 2007-04-13 at 13:50 +0100, Robert Rawlins - Think Blue wrote:
> Hello Guys,
> 
> Wider fragments of code don't really exists at this moment in time :-D this
> is just a bit of a 'tester' class for me to get used to the methods.
> Basically I'm trying to create a class that contains an array of MAC
> address, these look something like this 'FD:E4:55:00:FG:A9. I want the class
> to have the following methods for easy manipulation of the array.
> 
> addDevice(Address) - Pass in the MAC address and have it add it to the
> array.
> 
> removeDevice(Address) - Finds a device with that address in the array and
> removes it.
> 
> isFirewalled(Address) - looks for that address in the array and returns
> true/false dependant on whether it finds it.
> 
> Clear() - empty the array of all its contents.

Unless your class is going to grow more hair than what you specify
above, such as the ability to specify ranges of addresses, I think
you'll want to use a set. See http://docs.python.org/lib/types-set.html

HTH,

Carsten.





More information about the Python-list mailing list