Global name 'debug' not defined
-
07-07-2021 - |
Question
I'm trying to write a script that authenticates to AD. Here's my problem:
import sys
sys.stdout = open('output.csv', 'w')
def ad_dict(ldapobj,attr_dict={},recurse=0,auth=1,filter=()):
if ldapobj.find(',')==-1: ldapobj='cn='+ldapobj+','+Ad.ldap_main_loc
if auth: #setup authenticated connections
if debug: print 'auth'
When I run it, it gets as far as this and says that "Global name 'debug' is not defined. I thought that debug was built in here, why wouldn't it be defined?. If it helps, I'm using ActivePython for this script.
Solution
Why don't you just define a global variable called debug if you need this functionality? (or use logging.debug() )
OTHER TIPS
The built-in global constant is called __debug__
not debug
.
I don't use ActivePython, said that. debug is not a built in regular Python. You can take a look at python documentation, to see all the built ins.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow