python,load,python-3.4,nameerror
You cannot use exec() (or eval()) to set local variables; the local namespace is highly optimised. What you are looking at is the locals() dictionary, a one-way reflection of the local namespace; the name was added to that dictionary, but not to the real namespace. Use a dedicated namespace instead:...
python,class,tkinter,nameerror
Your coding style is very confusing. The problem can be solved by sticking to a more common style of coding: move the code into __init__, and save references to the widgets as instance variables. import Tkinter as tk from imaging import * class MainClass: def __init__(self): root = tk.Tk() root.title('Main...
I am gust guessing, but I think the thing with the line break is it - if we do it interactively. So we sit there, staring at the >>>, and enter the code above. At the end, it looks like >>> s = list(raw_input()) print s >>> s ['p', 'r',...
python,graphics,pygame,nameerror
myDisplay is indented, so python thinks it is a part of the Display class. You can't create an instance of a class within the definition of that class. Also, set_icon expects a pygame Surface object, not a path to a file. To fix that, do this: # ... icon =...
num is not actually used in multiply() so there is no reason to pass it in. Instead, declare multiply() without the argument: def multiply(): '''(num1 * num2)''' . . And call it from __main__ like this: if maths == "Multiplication" or "m" or "x": multiply() There seems no point in...
I am guessing you are using Python 2.x , in Python 2.x , input actually tries to evaluate the input before returning the result, hence if you put in some name , it will treat that as a variable and try to get its value causing the issue. Use raw_input()....
In your code, first, you declare the Main function. Then you call the Main function, which calls the AccountInfo function before it's defined. Then you declare the AccountInfo function. Move the AccountInfo function to the top of your code to solve the problem....
Here's a way to do it by creating and using a property of the Road. <Road>: id:label random_colours: [random.randint(11,14)*0.04, random.randint(14,15)*0.4] canvas: Color: r: root.random_colours[0] g: root.random_colours[0] b: root.random_colours[1] a: 1 Rectangle: pos: self.pos size: self.size You'll probably find something like this to be most convenient when working with vertex instructions...
python,python-2.7,kivy,self,nameerror
You've mixed tabs and spaces: When you do that, Python gets confused about how things are supposed to be indented, because it doesn't interpret tabs the same way your editor does. Don't mix tabs and spaces; stick to one or the other, and turn on "show whitespace" in your editor...
You defined the variable work_load inside the __init__ of the class, so you can't access it outside this scope. If you want to have access to work_load, make it an attribute for objects of Work_plan class, and the access it by doing object.work_plan For example: class Work_plan(object): def __init__(self,hours_work,work_len, work_des):...
ruby-on-rails,ruby,class,instance-variables,nameerror
You need to use the @ when setting and when getting an instance variable: class Book def set_title_and_author(title, author) @title = title @author = author end def description puts "#{@title} was written by #{@author}" end end ...
python,windows,nameerror,cloudflare
execfile is a builtin function in Python2, but has been removed in Python 3, To run this program you probably need the correct python version.
The problem here is that msg inside enter() is a local variable: it's created when the enter() function runs, and it ceases to exist when enter() returns. Normally, whenever you set a variable inside a function, you're setting a local variable. If you want to set a global variable, which...
python,variables,nameerror,defined
You're using the wrong operator. = sets the value, while == is the comparison operator for equality. Change cabin == int(raw_input("> ")) to cabin = int(raw_input("> ")) ...
Your Retour() function tries to use the variables PosX and PosY, but never defines them. PosX and PosY are locals in Jeu(), but other functions do not have access to those locals. You'd need to pass them on to other functions if they need them too: def Jouer(PosX, PosY): #...
Yes. The error is telling you that you are calling a function that doesn't exist. You must either define it, or import it from somewhere.
It tries to access a variable from the global scope. def menu(): global option ... The above code should do it. Read more about scopes here Maby try to return that value instead of using a global variable: def menu(): ... return option And turn your conditions accordingly to it....
python,postgresql,flask,nameerror
You have to specify the model class before the column in your filter: Foods.name.like... @app.route('/_search_food') def search_food(): search = request.args.get('search') results = Foods.query.filter(Foods.name.like('%' + search + '%')).all() return jsonify(results) ...
python,class,python-3.x,typeerror,nameerror
You are getting the NameError because in your second file (the one you are importing the Animal class into), you haven't defined your variables. animal = Animal.Animal(animal_type, animal) animal_type and/or animal have not been defined. As for the TypeError, the problem with animal = Animal.Animal() is that you aren't passing...
python,command,command-prompt,nameerror
From your example , I believe you are running the script using - helloworld.py - this would cause Windows to lookup the default application associated with the extension .py and run it. I am guessing in your case when you installed PyCharm, it somehow made Python 2.7.7 the default application...
python,python-2.7,nameerror,def
There's this line in your code: room1 == raw_input(">") Did you mean this? room1 = raw_input(">") ...
python,if-statement,undefined,nameerror
Well, your variable seats_total will be defined only for user_seating == 'economy' or user_seating == 'business'. For the third case, no such variable is defined. To define "seats_total outside of the if-elif-else statements" just set it to zero for example, or some default value.
remove all unnecessary arguments from Person1.__init__: class Person(): def __init__(self, job,fav_food,ethnicity,name,gender): self.job=job self.fav_food=fav_food self.ethnicity=ethnicity self.name=name self.gender=gender class Person1(Person): def __init__(self,job,gender): Person.__init__(self,job,"chips","white",random.shuffle(names)[0],gender) p1=Person1("Plumber", "male") ...
input is equivalent to eval(raw_input). It's completely redundant in your example. Just drop it and keep the raw_input only: hobby = raw_input("what's your favorite hobby?: ") EDIT: To answer the question in the comments, input takes the string and attempts to evaluate it as a python expression (see eval's documentation...
You imported yaml as a local in install_yaml(). You'd have to mark it as a global instead: global yaml inside the function, or better still, move the import out of the function and put it right after calling install_yaml(). Personally, I'd never auto-install a dependency this way. Just fail and...
python,listview,kivy,nameerror
Make your own ListItemLabel subclass in which you add the kv rules. class YourLabel(ListItemLabel): pass Then pass cls=YourLabel in the args converter....
you are getting the error when this condition is not met: if (username==each_username): pass_result=cursor.execute('SELECT PASSWORD from validate where username=?',(each_username,)) set a default value to pass_result, e.g. pass_result = None and then handle it before using, e.g. if pass_result is not None:...
single and multi have no value. They are not defined anywhere in your function or globally. You need to define what they mean before your function will work. If they are just words, you need to wrap them in quotes "single" rather than single....
<% if @skills.blank? %> <p>There are not any skills currently saved in the system.</p> <% else %> <p>These are the current skills saved in our system</p> <ul id="skills"> <% @skills.each do |c| %> <li><%= link_to c.title, {:action => 'show', :id => c.id} -%></li> <% end %> <- **c ends here**...
python,arrays,python-3.x,random,nameerror
+ + is invalid syntax. You should be doing str(something) + ' ' + string(something_else) if you want to add two strings with a space in between. You also need quotes around add, minus and times in the list in order to make them strings.
You're using Python 2. input immediately tries to convert your input into a Python type, which is dangerous and causes problems like the one you are experiencing. Use raw_input instead. In other words, when you type "done", input tries to eval* it, comes up with a non-existent variable named "done",...
python,user-defined-functions,nameerror,def
There's a typo in your program. tax = calc_ftax(retailprice) should be ftax = calc_ftax(retailprice) ...