Arrays, Got Me Confused

Tim Golden mail at timgolden.me.uk
Fri Apr 13 08:26:58 EDT 2007


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



More information about the Python-list mailing list