Arrays, Got Me Confused

rishi pathak mailmaverick666 at gmail.com
Fri Apr 13 08:24:56 EDT 2007


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 <robert.rawlins at thinkbluemedia.co.uk>
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070413/0ab570a7/attachment.html>


More information about the Python-list mailing list