New submission from David:

when I do anything like this:

import flask ...



try:
    current_user
except NameError:
    global current_user
    current_user = User(request.form['parameter1'], request.form['parameter2'], 
'')


I get the error that the_user was 'used' before the global declaration. The try 
... except ... is so when the user enters this route / function the first time, 
a class instance is instantiated, but if they return the second time, the 
existing class instance is updated in lines of code downstream rather than 
declared again with the same name, and therefore overwritten.

----------
components: Interpreter Core, macOS
messages: 298012
nosy: Davidt, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: Syntax checking confuses Try: class_instance_name as ... is used before 
glabal declaration
type: compile error
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30887>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to