Kent:
Thank you for the explanation. This is a subtlety of Python that has
tripped me up before.
Barry
> Date: Mon, 07 Nov 2005 16:26:39 -0500
> From: Kent Johnson <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Namespace Problem
> Cc: "'tutor@python.org'&
Carroll, Barry wrote:
> Bob:
>
> Yes I did mean 'import' and yes there is more to the function. Here is the
> entire program.
>
>
> import socket
> import struct
>
> # data packet flags
> ABC = 1
> DEF = 2
> GHI = 4
> JKL = 8
> seq = 0
>
> buf = 8192 # This is the ma
e 15, in do_stuff
hdr = struct.pack('@2BH',ABC|DEF,seq,len(in_str))
UnboundLocalError: local variable 'seq' referenced before
assignment>>>>>>>>>>>>>>>>>>>>>>>>
I can't figure it out.
Barry
>
At 05:47 PM 11/4/2005, Carroll, Barry wrote:
>I have a function that makes use of several global variables:
>
>##
>Include struct
Did you mean "import"?
>ABC = 1
>DEF = 2
>xyz = 0
>def do_stuff(in_str):
> hdr = struct.pack('@2BH',ABC|DEF,xyz,len(in_str))
> newstr = hdr+in_str
Wor
I have a function that makes use of several global variables:
##
Include struct
ABC = 1
DEF = 2
xyz = 0
# Other variables
def do_stuff(in_str):
hdr = struct.pack('@2BH',ABC|DEF,xyz,len(in_str))
newstr = hdr+in_str
# rest of code snipped
##
When I run the program c