nameerror

NameErrors and functions in python

橙三吉。 提交于 2019-12-12 06:17:01
问题 I'm constantly getting a NameError Although I already defined a term, The problem is with "day" on line 28. def today(): day = input("What day is it?") if "sunday" in day: day = 0 elif "monday" in day: day = 1 elif "tuesday" in day: day = 2 elif "wednesday" in day: day = 3 elif "thursday" in day: day = 4 elif "friday" in day: day = 5 elif "saturday" in day: day = 6 else: today() today() days_on_vacation = int(input("How many days will you be on vacation? ")) days_to_add_to_day = days_on

Sinatra: NameError at '/route', undefined local variable or method

旧街凉风 提交于 2019-12-12 02:21:45
问题 I'm trying to build an admin backend for a cms website. this is the structure of my application ├── app.rb ├── Gemfile ├── models │ └── models.rb ├── routes │ └── routes.rb └── views ├── categories.erb ├── # ... other view files app.rb require 'sinatra' require 'data_mapper' require 'dm-core' require 'dm-migrations' require 'digest' enable :sessions DataMapper.setup(:default, 'mysql://username:password@localhost/database') require './models/models.rb' require './routes/routes.rb' DataMapper

windows Python Name error

旧时模样 提交于 2019-12-12 01:54:01
问题 I am getting name error for this code. error message: Traceback (most recent call last): File "D:\injection.py", line 16, in opts, args = getopt.getopt(argv, "h", ["help", "target="]) NameError: name 'argv' is not defined #!/usr/bin/python import sys import getopt import urllib # define hexEncode function hexEncode = lambda x:"".join([hex(ord(c))[2:].zfill(2) for c in x]) def main(argv): # set defaults target = None # parse command line options try: opts, args = getopt.getopt(argv, "h", [

name error not defined in python [duplicate]

不问归期 提交于 2019-12-11 16:54:52
问题 This question already has an answer here : What is this odd colon behavior doing? (1 answer) Closed last year . So this is the basic string (the text is in hungarian before you are wondering): >>> nev=input("add meg a neved: ") add meg a neved: Kristóf >>> print("Üdvözöllek, " + nev) Üdvözöllek, Kristóf >>> print("egy út előtt állsz") egy út előtt állsz >>> print("elindulsz rajta") elindulsz rajta >>> arany: 0 >>> print("Most" + str(arany)+ "aranyad van") Traceback (most recent call last):

WeBrick does not bootup, gives an error white accessing new rails app

馋奶兔 提交于 2019-12-11 09:18:17
问题 I'm getting an error when I try to boot up WeBrick. When I type rails server , I get the following error: C:\Users\xxxx\Documents\Sites\simple_cms>rails s => Booting WEBrick => Rails 4.2.4 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server Exiting C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:40:in `<module:Helpers>': uninitialized constant ActionView::Helpers:

Warning of NameError for wireType in ABAQUS

久未见 提交于 2019-12-11 05:18:27
问题 I tried to connect points through wires using script. A warning regarding the NameError occurred. the code i tried to run in abaqus: a = mdb.models['Model-1'].rootAssembly v11 = a.instances['r-mesh-2'].vertices v12 = a.instances['s-mesh-1'].vertices v13 = a.instances['r-mesh-1'].vertices v14 = a.instances['s-mesh-1-lin-2-1'].vertices a.WirePolyLine(points=((v11.findAt(coordinates=(2.595, 0.22, -35.7)), v12.findAt(coordinates=(2.595, 0.2, -35.7))), (v11.findAt(coordinates=( 2.445, 0.22, -35.7)

NameError: name 'now' is not defined [duplicate]

假装没事ソ 提交于 2019-12-10 19:54:25
问题 This question already has answers here : error in python d not defined. [duplicate] (3 answers) Closed 5 years ago . From this source code: def numVowels(string): string = string.lower() count = 0 for i in range(len(string)): if string[i] == "a" or string[i] == "e" or string[i] == "i" or \ string[i] == "o" or string[i] == "u": count += 1 return count print ("Enter a statement: ") strng = input() print ("The number of vowels is: " + str(numVowels(strng)) + ".") I am getting the following error

Python: NameError name '[input]' is not defined [duplicate]

柔情痞子 提交于 2019-12-10 19:04:11
问题 This question already has answers here : input(): “NameError: name 'n' is not defined” [duplicate] (2 answers) Closed 6 years ago . I'm trying to make a simple little tool for converting inches to centimeters and am stuck at trying to take a user input ('y' or 'n') for deciding whether to do another conversion or terminate. Here's what I've done: import time def intro(): print "Welcome! This program will convert inches to centimeters for you.\n" convert() def convert(): input_cm = input((

Python3.3 type=file NameError

荒凉一梦 提交于 2019-12-10 15:44:27
问题 import sys import argparse parser = argparse.ArgumentParser(description='blah blah') parser.add_argument('reference_file', type=file, help='blah blah') args = parser.parse_args() When I run the above script I get the following error. NameError: name 'file' is not defined I don't know what's wrong. Is this not allowed in Python 3.3? Please help. 回答1: file was an alias for open , which has been removed in Python 3. You can use open instead, but argparse has a better option: the [ FileType()

python NameError: name '<anything>' is not defined (but it is!)

泄露秘密 提交于 2019-12-09 18:20:27
问题 Note: Solved. It turned out that I was importing a previous version of the same module. It is easy to find similar topics on StackOverflow, where someone ran into a NameError. But most of the questions deal with specific modules and the solution is often to update the module. In my case, I am trying to import a function from a module that I wrote myself. The module is named InfraPy, and it is definitely on sys.path. One particular function (called listToText) in InfraPy returns a NameError,