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. Sorry for the sloppy code so far, I'm really new to Python so it's a steep learning curve for me, I'm by no means a programming numpty and allot of the principles are the same, but the languages I'm used to are more robust and vague so I don't have to define what type of data i'm storing the array and things. Thanks guys, Rob -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Golden Sent: 13 April 2007 13:27 Cc: [EMAIL PROTECTED] Subject: Re: Arrays, Got Me Confused Michael Bentley wrote: > > On Apr 13, 2007, at 7:04 AM, Robert Rawlins - Think Blue wrote: >> #!/usr/bin/python >> >> # Filename: Firewall.py >> class Firewall: >> def __init__(self): >> >> Self.FireArray = array(c) >> >> p = Firewall() >> >> print p >> Throws: >> >> >> >> Traceback (most recent call last): >> >> File "./firewall.py", line 9, in ? >> >> p = Firewall() >> >> File "./firewall.py", line 7, in __init__ >> >> Self.FireArray = array(c) >> >> NameError: global name 'array' is not defined >> >> >> >> How can I solve this problem? > from array import array Well, also the line referencing "Self.FireArray" is not going to work, unless there's some global "Self" knocking around. Python is case-sensitive. More importantly, I suspect, is that the OP's almost certainly looking for a Python *list*, not an array in this case. It's hard to tell, since we've no idea what's in the "c" which is being passed to the array. Robert - can you explain what you're trying to do and/or post a wider fragment of code? TJG -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list