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
I'm studying 'inheritance' in Pycharm.
I just followed tutorial. And it doesn't work. What's the problem
##Chef.py##
class Chef:
def make_chicken(self):
print("The chef makes a chicken")
def make_salad(self):
print("The chef makes a salad")
def make_special_dish(self):
print("The chef makes bbq ribs")
##another.py##
from Chef import Chef
class another(Chef):
##app.py##
from another import another
a = another()
a.make_salad()
run>>>
error message :
Traceback (most recent call last):
File "C:/Users/NEWS1/PycharmProjects/exc/app.py", line 1, in <module>
from another import another
File "C:\Users\NEWS1\PycharmProjects\exc\another.py", line 9
^
SyntaxError: unexpected EOF while parsing
Process finished with exit code 1
What is the problem....
The issue is in your 'another' class, there's nothing following the colon. You can either add methods to the class or just a 'pass' like so
##another.py##
from Chef import Chef
class another(Chef):
# other content
pass
Related
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've tried to using this code:
def tw_list(text):
tw_list['text'] = tw_list['text'].str.lower()
print('Case Folding Result : \n')
print(tw_list['text'].head(5))
print('\n\n\n')
But when I run it, I get the error:
Case Folding Result :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-27-c3ee7c744c13> in <module>
6
7 print('Case Folding Result : \n')
----> 8 print(tw_list['texts'].head(5))
9 print('\n\n\n')
TypeError: 'function' object is not subscriptable
i dont know why, can someone help me?
tw_list is the name of your function.
You are trying to access the function as a dict.So it throws error
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
So, here I am, playing around with the ipfsapi in python and yesterday, to start somewhere, I ran some code from the following blogpost that connects to the local node: https://medium.com/python-pandemonium/getting-started-with-python-and-ipfs-94d14fdffd10
Last night it worked perfectly, but today when I began a new project where I would actually use this method and rewrote the code, I got an invalid syntax error in the except statement. Right now the code looks like this
if __name__ == '__main__':
try:
api = ipfshttpclient.connect('127.0.0.1', 5001)
print(api)
except: ipfshttpclient.exceptions.ConnectionError as ce: #the invalid syntax error is marked at as
print(str(ce))
Traceback:
File "/home/", line 17
except: ipfshttpclient.exceptions.ConnectionError as ce:
^
SyntaxError: invalid syntax
The odd thing is that I'm getting an invalid syntax error on the as. I've changed ipfsapi due to deprecation warning to ipfshttpclient, but it doesn't work with either now, same erreor. How is that even possible? Am I just not seeing something I should? Is my brain smoothing out? Sorry if it's a dumb issue and thanks in advance!
Python 3.7.4 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Linux 5.5.10-arch1-1
You should remove the colon : after the except.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
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.
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.
Improve this question
I'm new in python and I'm trying to add an attribute to a maya light shape. The script should works like that: for each light.shape I've selected add a 'mtoa_constant_lightGroup' attribute:
import maya.cmds as pm
lightSelect= pm.ls (sl=True, dag=True, leaf=True)
for elem in lightSelect:
pm.addAttr (elem, ln='mtoa_constant_lightGroup', at=long, dv=0)
pm.setAttr (e=True, keyable=True, elem +'.mtoa_constant_lightGroup')
But when I run the script I've got this error:
Error: line 1: non-keyword arg after keyword arg
Any suggestions please.
In the following line from your code you have a positional argument after a keyword argument, which does not make sense.
pm.setAttr (e=True, keyable=True, elem +'.mtoa_constant_lightGroup')
# ---- here ----------------------^
fix it!
so as Martin said I had to move the keyword arguments to the end
then for the error " # Error: line 1: RuntimeError: file line 6: Type specified for new attribute is unknown." I needed to set at=long as a string, e.g.
`pm.addAttr (elem, ln='mtoa_constant_lightGroup', at="long", dv=0)`
The final scripts is this:
import maya.cmds as pm
lightSelect= pm.ls (sl=True, dag=True, leaf=True)
for elem in lightSelect:
pm.addAttr (elem, ln='mtoa_constant_lightGroup', at="long", dv=0)
pm.setAttr(elem +'.mtoa_constant_lightGroup', e=True, keyable=True)
thanks for all your helps
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
def add_to_receivers(receivers): # make sure they are unique
for receiver in receivers:
name, email = receiver
if email not in [u'', None]: # empty receiver pairs are possible
#print email
if email not in msg_receivers and email is not None:
msg_receivers.append(email.lower())
msg_receivers = []
add_to_receives(msg_to)
add_to_receives(msg_cc)
add_to_receives(msg_bcc) # in essence, we don’t care how the message was received
#add_to_receives(msg_delivered_to)
please help me with fixing this error
Traceback (most recent call last):
File "metadata.py", line 309, in worker
add_to_receives(msg_to)
NameError: global name 'add_to_receives' is not defined
full code you can see at http://brage.bibsys.no/xmlui/handle/11250/198551
I think the problem is that the function is called add_to_receiversand you are calling add_to_receives (without the 'r')
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 8 years ago.
Improve this question
I am writing a Python script that will print out a random value from a list I have written,
from random import randint
class_list=[0,1,2,3,4,5,5,6,7,8,9,10,11,12]
people_called=[]
randomized_number = random.randint(0,12)
print "debug number" + str(randomized_number)
print "The student is" + str(class_list[randomized_number])
class_list[randomized_number].append(people_called)
However when I run this file I get I get
Traceback (most recent call last):
File "./Code/class list.py", line 4, in <module>
number = random.randint(0,12)
NameError: name 'random' is not defined
from random import randint imports randint from random module. That is, you can just use it as randint. If you would import it as import random, you'd have to use random.randint instead.
When importing using just import random, you must call the function with random.randint().
When using from random import randint, Python lets you call the function with just randint()