passing lists

Earl Eiland eee at nmt.edu
Thu Mar 3 08:33:55 EST 2005


This message contains the responses to two previous messages:

In response to Steven B.,the statements
	Raw_packet_queue = enqueue(..., Raw_packet_queue, ...)	
	print 'Sort 1 Raw_packet_queue is', Raw_packet_queue
produce the output
Sort 1 Raw_packet_queue is [[(<Pkthdr object at 0x4341d7d0>,
'\x00\x00\xd1\xf0\x
15\xe1\x00\x051\x0bh\x00\x08\x00E\x00\x004\x96\xc2@\x007\x06\xfc\xff\x89N\xa2j\x
81\x8a\x02\xbf\xb1\x13\x00\x16\xe5/\xd5\xa7vu\x0e\x08\x80\x10\xf8\xe0\x8a[\x00\x
00\x01\x01\x08\n\x15\xb7\x13\xba\x8e\x91\x9a\xfd'), ['E\x00\x004',
'@\x00', '\x0
6',
'\x89N\xa2j\x81\x8a\x02\xbf\xb1\x13\x00\x16\xe5/\xd5\xa7vu\x0e\x08\x80\x10\x
f8\xe0\x8a[\x00\x00\x01\x01\x08\n\x15\xb7\x13\xba\x8e\x91\x9a\xfd']]]

This consists of two lists [[pcap packet header, pcap packet body], [a
list of selected IP header fields]].  Raw_packet_queue[0][0][1] should
return the 'pcap packet body' list element.


In response to Steve H., the traceback is
Traceback (most recent call last):
  File "../Devel_2.py", line 125, in ?
    Inbound_Results = Parser.Sort(Inb_sequence,
"Inbound-dump-"+Run_ID+"-Dropped
.dmp", "Inbound-dump-"+Run_ID+"-Created.dmp")
  File
"/home/earl/ResearchProjects/IntrusionResistance/NewPhasee2/Parser.py",
l
ine 291, in Sort
    if Raw_packet_queue[ctr][1] == Passed_IP: Last_Passed, Last_Dropped,
Raw_pac
ket_queue = Match(Created, Passed, Raw_packet_queue, Raw, False,
Last_Passed, La
st_Dropped, First_Created, ctr)
  File
"/home/earl/ResearchProjects/IntrusionResistance/NewPhasee2/Parser.py",
l
ine 132, in Match
    Last_Passed = Raw_packet_queue[0][0][1]
TypeError: unsubscriptable object

On Wed, 2005-03-02 at 15:34, Steve Holden wrote:
> Earl Eiland wrote:
> > def Match(..., Raw_packet_queue, ...):
> > 	...
> > 	print 'in Match, Raw_Packet_queue is', Raw_packet_queue # this returns
> > 'Reader object at 0xaaa'
> > 	...
> > 	return [Last_Passed, Last_Dropped, Raw_packet_queue] # this causes
> > 'unsubscriptable object'error message
> > 
> > #*************************************************
> > def Main(...):
> > 	Raw_packet_queue = []
> > 	...
> > 	Raw_packet_queue = enqueue(..., Raw_packet_queue, ...) # this works
> > 	...	
> > 	if Raw_packet_queue[ctr][1] == Passed_IP: Last_Passed, Last_Dropped,
>                             ^^^^^^^^
>                               oops!
> > Raw_packet_queue = Match(..., Raw_packet_queue, ...) # the problem
> > starts here
> > 	...
> > 
> Rule one: ALWAYS include the actual traceback, rather than providing 
> your interporetation of what it means (though you are then free to do 
> that, too).
> 
> What makes you think it's the Match() call that's causing the problem?
> 
> I'd be willing to bet money it's the double-subscripting of 
> Raw_packet_queue - if item [ctr] on the Raw_packet_queue isn't a list or 
> a dict then subscripting it by [1] will give you the error message that 
> you quote.
> 
> But if you had included the traceback you would have made it unnecessary 
> for me to use my psychic powers :-)
> 
> regards
>   Steve
> 
> > On Wed, 2005-03-02 at 14:09, Bill Mill wrote:
> > 
> >>Earl,
> >>
> >>Please post the smallest snippet of code you can which illustrates
> >>your problem. No list is an unsubscriptable object, so you seem to be
> >>passing something that is not a list to your function.
> >>
> >>As it stands, you don't give enough information to give an actual answer.
> >>
> >>Peace
> >>Bill Mill
> >>bill.mill at gmail.com
> > 
> > 
> >>
> >>On Wed, 02 Mar 2005 14:05:18 -0700, Earl Eiland <eee at nmt.edu> wrote:
> >>
> >>>I have a program in which I'm passing a list to functions.  When I
> >>>reference an element in a function to which it is passed, I get the
> >>>error message "unsubscriptable object".  When printing the list contents
> >>>in that same function, I get "xxx is <Reader object at 0xyyyy>".  How do
> >>>I pass a list?
> >>>
> >>>Earl Eiland
> >>>
> >>>--
> >>>http://mail.python.org/mailman/listinfo/python-list
> >>>
> > 
> > 
> -- 
> Meet the Python developers and your c.l.py favorites March 23-25
> Come to PyCon DC 2005                      http://www.pycon.org/
> Steve Holden                           http://www.holdenweb.com/




More information about the Python-list mailing list