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
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
Hey so I’m writing a text-adventure game in python and made a typingprint function to make the text look like it was typed out. But when I try to use this function with inputs it will reply with None.
import random
import time
import console
import sound
import sys
def typingPrint(text):
for character in text:
sys.stdout.write(character)
sys.stdout.flush()
time.sleep(0.05)
console.set_color()
typingPrint('Hello! My name is Sawyer and I will be your guide
throughout this game. Heres a helpful hint, every time you enter
room you will have to battle a enemy.')
time.sleep(3)
player_name = input(typingPrint('\nBefore we begin why don\'t
you tell me your name: '))
How can I fix this?
This is because your function doesn't return anything so there is no text in the input prompt. To solve it, you will need to first call your function, then the input -
typingPrint('Hello! My name is Sawyer and I will be your guide throughout this game. Heres a helpful hint every time you enter a room you will have to battle a enemy.')
time.sleep(3)
typingPrint('\nBefore we begin why dont you tell me your name: ')
player_name = input()
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 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
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
So I created this function:
def bs_obj(url, lan="html.parser"):
try:
html = urlopen(url)
bsObj = BeautifulSoup(html, lan)
print(lan)
return bsObj
except HTTPError as e:
print(e)
Now, if I call the function with the next code: object = bs_obj(html, "lxml"), the console prints html.parser. Same goes if the code is object = bs_obj(html, lan="lxml"). What's going on?
EDIT: (SOLVED) I'm ashamed. I was calling bs_obj(html) some lines before the codeline I used as example.
I believe you are running the wrong file. For reference.
def bs_obj(lan="html.parser"):
print(lan)
if __name__ == "__main__":
bs_obj()
bs_obj("lxml")
bs_obj(lan='html5.parser')
Correctly outputs
html.parser
lxml
html5.parser