nameerror

Newbie inquiry about NameError

a 夏天 提交于 2020-11-30 02:04:41
问题 Total Newbie question for which I have searched the site. I am running a really simple program in Chapter 2 of Automate the Boring Stuff and I keep getting a NameError. The first line is if name == 'Alice': And it results in NameError: name 'name' is not defined Any thoughts on this. Cannot find this NameError in the index or any sites. Thanks 回答1: In the book you missed this comment above the code: " (Pretend name was assigned some value earlier.) ". So you need to do that. For example

global name 'get_user_model' is not defined

£可爱£侵袭症+ 提交于 2020-07-09 06:39:09
问题 NameError at /project/reset_password_confirm/MTQ-4c8-65d880f1c28996091226/ global name 'get_user_model' is not defined Request Method: POST Django Version: 1.9.1 Exception Type: NameError Exception Value: global name 'get_user_model' is not defined Exception Location: /root/django/studie/project/views.py in post, line 770 Python Executable: /usr/bin/python Python Version: 2.7.9 views.py from django.contrib.auth.models import User line 770: def post(self, request, uidb64=None, token=None, *arg

NameError: name 'one' is not defined python 3.4 error

感情迁移 提交于 2020-05-14 13:19:34
问题 a=str(input("Enter num To Start FunctionOne")) if(a == '1'): one() elif (a == '2'): tow() def one(): print('Good') def tow(): print('Very Good') Error Enter numper To Start FunctionOne1 Traceback (most recent call last): File "C:/Users/Hacker/Desktop/complex program.py", line 3, in <module> one() NameError: name 'one' is not defined 回答1: You need to define the functions before calling them: def one(): print('Good') def tow(): print('Very Good') a=str(input("Enter num To Start FunctionOne"))

NameError: name 'one' is not defined python 3.4 error

一笑奈何 提交于 2020-05-14 13:15:31
问题 a=str(input("Enter num To Start FunctionOne")) if(a == '1'): one() elif (a == '2'): tow() def one(): print('Good') def tow(): print('Very Good') Error Enter numper To Start FunctionOne1 Traceback (most recent call last): File "C:/Users/Hacker/Desktop/complex program.py", line 3, in <module> one() NameError: name 'one' is not defined 回答1: You need to define the functions before calling them: def one(): print('Good') def tow(): print('Very Good') a=str(input("Enter num To Start FunctionOne"))

NameError in a Discord bot program

自古美人都是妖i 提交于 2020-01-25 07:39:17
问题 I started writing my first Discord bot, but I ran into a little problem. Why is my code not working ? @bot.command() async def msg(user : str, text : str): s = message.server await bot.send_message(s.get_member_named(name = user), text) On the idea this command writes to users of the server on behalf of the bot Error: ================== RESTART: C:/Users/Roman-PC/Desktop/t2.py ================== Logged in as FiveStar Role Play 470014458215792641 ------ Ignoring exception in command msg

'Tk' is not defined [duplicate]

耗尽温柔 提交于 2020-01-06 08:14:06
问题 This question already has an answer here : idle-python3.2 not starting: complains of NameError: name 'Tk' is not defined (1 answer) Closed 5 years ago . I am new to Python. I downloaded Spyder 2.3.1 and am running Python 2.7 on my Mac. I tried this sample program: from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop() When I run, I get the error message: NameError: name 'Tk' is not defined If I look in the file Tkinter.py, it has the following lines

NameError: name 'Frame' is not defined (Python)

余生长醉 提交于 2020-01-04 05:50:10
问题 I have constructed a messaging application, but it seems to have incorrect syntax: from tkinter import messagebox from AESEncDec import * from MD5Hashing import * from RSAEncDec import * color = 'lightblue' #color our background class Application(Frame): def __init__(self, root=None): Frame.__init__(self, root) self.frame_width = 700 self.frame_height = 400 # Set configuration our frame self.config(width = self.frame_width, height = self.frame_height, bg = color) self.pack() # Create textBox

Python can't catch overridden NameError

血红的双手。 提交于 2020-01-04 04:26:05
问题 How can you explain this: This code is supposed to override the NameError and then catch it. OldNameError = NameError class NameError(OldNameError): pass try: ccc except NameError as e: print "hi" Does not print "hi". Instead, the output is: Traceback (most recent call last): File "try.py", line 6, in <module> ccc NameError: name 'ccc' is not defined But this code: OldNameError = NameError class NameError(OldNameError): pass try: raise NameError("oo") except NameError: print "hi" Gives the