Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Learning Python, please go easy
I have removed all other methods defined in this class, here is the skeleton of whats left :
from random import randint
class CreditCardNumberGenerator:
def __init__(self):
print "Hello World"
pass
if __name__ == "__main__":
o = CreditCardNumberGenerator()
Error
Traceback (most recent call last):
File "del.py", line 3, in <module>
class CreditCardNumberGenerator:
File "del.py", line 11, in CreditCardNumberGenerator
o = CreditCardNumberGenerator()
NameError: name 'CreditCardNumberGenerator' is not defined
i have checked name, typecase and all possible SO thread, no help....can some one please advice??
I am pretty sure, its something very obvious which i am missing here!!! :\
if __name__ == "__main__":
o = CreditCardNumberGenerator()
is too much indented - make it aligned to the same column as class and it should be OK.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
Traceback (most recent call last): File "/home/Budget.py", line 11, in response = client.create_budget(parent="billingAccounts/"+billingAccountId, budget=budgets_v1.Budget(display_name=displayName, budget_filter=budgets_v1.Filter({"projects":str(budgetFilter)}), amount=budgets_v1.BudgetAmount(specified_amount=budgetAmount), threshold_rule=budgets_v1.ThreshholdRule(threshold_percent=thresholdPercent))) NameError: name 'client' is not defined
This is my response when I ran the py script
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am trying to use kafka-python to stream csv data but while importing kafka, I'm getting below error. The funny thing is it was working last night and since morning its giving this error all of sudden.
NameError Traceback (most recent call last)
<ipython-input-13-c237685c7217> in <module>
----> 1 import kafka
~/TweetStream/kafka.py in <module>
29 "id": "interior-tolerance",
30 "metadata": {
---> 31 "scrolled": true
32 },`enter code here`
33 "outputs": [
NameError: name 'true' is not defined
Are you sure you don't have a file named kafka (or perhaps a class or def) that could be overriding the default kafka-python module? If so, I would change its name or -- well, just change the name or put it in a subdirectory, as it'll get quite confusing and error-prone otherwise.
It seems in your file you have a true on line 31 where it should be the python builtin True instead.
~/TweetStream/kafka.py in <module>
---> 31 "scrolled": true
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
test.py
import telebot
import config
bot = telebot.Telebot(config.TOKEN)
#bot.message_handler(content_types=['text'])
def lalala(message):
bot.send_message(message.chat.id, message.text)
bot.polling(non_stop=True)
config.py
TOKEN='1030045171:AAFPptKPt0a7xcoev9ryIMb6jXEIck5QfOs'
gives error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\telegram\test.py", line 4, in <module>
bot = telebot.Telebot(config.TOKEN)
AttributeError: module 'telebot' has no attribute 'Telebot'
You misspelled TeleBot
import telebot
bot = telebot.TeleBot("TOKEN")
From the docs
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I am getting an IndentationError when trying to run my program in a Python Interpreter:
line 127
global map
^
IndentationError: expected an indented block
I am using python version 2.7
What's wrong with the following code?:
def make_map():
global map
Python expects 4 spaces or a tab to indent and align code - similar to Java expecting curly {} brackets are the start of a loop, method or class etc.
def some_function():
somecode
morecode
...
should be formatted as
def some_function():
somecode
morecode
...
It appears that your code throws an exception on line 127, so check this and indent the code as required.
def some_code():
for i in range(1, some_value):
some_method()
if need_more_indent:
indent_code()
do_this_after_indent_code()
this_runs_after_for_loop()
return 'lol'
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am new to tensorflow. Following is the program I was trying to run.
import numpy as np
import tensorflow as tf
with tf.Session() as sess:
x=tf.placeholder("float",[1,3])
relu_out=x
num_layers=2
for layer in range(num_layers):
w=tf.Variable(tf.random_normal([3,3]))
b=tf.Variable(tf.zeros([1,3]))
relu_out=tf.nn.relu(tf.matmul(relu_out,w)+b)
softmax_w=tf.Variable(tf.random_normal([3,3]))
softmax_b=tf.Variable(tf.zeros([1,3]))
logit=tf.matmul(relu_out,softmax_w)+softmax_b
softmax=tf.nn.softmax(logit)
answer=np.array([[0.0,1.0,0.0]])
labels=tf.placeholder("float",[1,3])
cross_entropy=tf.nn.softmax_cross_entropy_with_logits(relu_out,labels,name='xentropy')
optimizer=tf.train.GradientDescentOptimizer(0.1)
train_op=optimizer.minimize(cross_entropy)
sess.run(tf.initialize_all_vraiables())
for step in range(10):
sess.run(train_op,feed_dict={x:np.array([[1.0,2.0,3.0]]),labels:answer})
It is showing following error:
Traceback (most recent call last):
File "/home/nilay/gdrive/REU/summer_exp/tf_tut/tf_add_layers.py", line 20, in <module>
sess.run(tf.initialize_all_vraiables())
AttributeError: 'module' object has no attribute 'initialize_all_vraiables'
Please help me resolve it.
There's a typo in your code:
is tf.initialize_all_variables not tf.initialize_all_vraiables