HI, You will have to import Numeric module Add from Numeric import * to the script For the second question: Suppose you wrote the code for your class in firewall.py and your main script is main.py Put the file firewall.py in the directory where you have main.py Then in main.py do : import firewall.py
To create an object of class Firewall firewallDemo=firewall.Firewall() May be this will help On 4/13/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote:
Hello Guys, I'm struggling to get my head into arrays in python, I've used them plenty in other languages but I'm struggling to find any decent documentation for them in python. I'm looking to build a list of network MAC address's into an array, which will probably be used for logging and firewalling and things. I've build the basic class, the idea is that the class represents the firewall, and I have functions for the firewall like addDevice() and isFirewalled() where I pass in the address and it returns a value or updates the array. However I'm getting an error when trying to create an empty array on the init. #!/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 what I've seen writing I can't see anything wrong with my syntax, perhaps you can shed some light on the situation. Whilst I'm writing there is also another question I would like to pose briefly. How do a create an object from an external file? Obviously in my one above all I need do is call Firewall() and it creates an instance, but I'm used to creating my class's as separate files, how do I create them as an object in my main application? Thanks, Rob -- http://mail.python.org/mailman/listinfo/python-list
-- Regards-- Rishi Pathak National PARAM Supercomputing Facility Center for Development of Advanced Computing(C-DAC) Pune University Campus,Ganesh Khind Road Pune-Maharastra
-- http://mail.python.org/mailman/listinfo/python-list