|
Email lists >
Melbourne Python Users Group >
Re: [melbourne-pug] Simple syntactic error? >
Re: [melbourne-pug] Simple syntactic error?
Re: [melbourne-pug] Simple syntactic error?
This post if a part of this thread
|
2008-05-23 00:45:22 |
|
|
Re: Simple syntactic error?
|
|
|
Hi,
Give this a shot in your interpreter
state = None
def set_state(): print "Scope " + state state = "Hello"
set_state() print state
I get: UnboundLocalError: local variable 'state' referenced before assignment
On Fri, May 23, 2008 at 3:36 PM, g sobers < g.forumz  gmail.com" >g.forumz gmail.com> wrote:
Addressing each of your suggestions below with resulting output:
Kevin Littlejohn - Are you certain cb_calling is even being called? Confirming the same. Checked via print statement.
- cb_calling should definitely declare state as global - and for style, I'd want the global declaration in keys() as well Declared: global state in keys() as well as global state in cb_calling. To no avail.
Tennessee Leeuwenburg - The "state" in cb_calling is not the same "state" you declare earlier. You'll need to declare it global inside cb_calling for it to work.
PyS60 documentation confirms "if a variable is defined outsite any function, it belongs automatically to the global scope."
Anthony Briggs
- appuifw is a framework, so your keys function will be called in a different 'context'. Your framework might be using state for something else, or is otherwise messing around with globals. Try changing
'state' to 'foo_state' or similar and see if that helps.
That is indeed correct. However, in the case of the intended functionality, state only becomes relevant when a key is pressed i.e. keys() is called.
Which state are you suggesting being changed?
- And yes, you should have 'global state' in each of your functions, otherwise you'll drive a local variable over the top of your global.
Done.
All of the above attempts have been unsuccessful. Quite perplexing.
Just a brief plain english understanding of the intended functionaity, present results and implemented code:
Canvas receives a key event and passes it to keys(). If the phone's 'yes39; key is pressed, a note stating the event displays correctly. However, when the phone rings and is answered, state is assigned 'EStatusConnected' parameter. At this point, second of the if-statements in keys() should result in a note stating 'yes key is pressed & call active'. But, the note statement of the first if-statement continues to be displayed.
NOTE: The following code, source for this script, works perfectly. http://mindinthewater.blogspot.com/2008/01/recording-phone-calls-on-s60-phone-part.html
Look forward to your suggestion.
Best, wirefree
_______________________________________________
melbourne-pug mailing list
melbourne-pug python.org">melbourne-pug python.org
http://mail.python.org/mailman/listinfo/melbourne-pug
|
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|