I am using a piece of code and am trying to debug it.
But something weird is happening.
In one part, I have this line:
vals = find(A)
But it gives me this error :
global name 'find' is not defined
I thought find was like an inbuilt function in python??
Clearly I am mistaken.
But just want to check.. in case I am forgetting to include anything.
find is a string method:
'python'.find('y') # gives 1
The real answer is:
look in this page:
http://docs.python.org/genindex.html
Why thinking to search with Google and not in an official doc ? Did you think that Python hadn't documentation ?
Related
I tried to run the code
pcp.get_compounds('CC', searchtype='superstructure', listkey_count=3)
but, it didn't work.
This code is exactly the same as one shown in the documentation ("https://pubchempy.readthedocs.io/en/latest/guide/searching.html#advanced-search-types").
Another code such as pcp.get_compounds('Aspirin', 'name', record_type='3d') which is shown in the same page worked.
Please give me some advice about how to fix this error.
It appears that the example in the PubChemPy advanced search documentation is missing a parameter. The example does not identify how to search, i.e., by SMILES. Substituting the following statement for the one in the example should give you the desired result.
pcp.get_compounds('CC', 'smiles', searchtype='superstructure', listkey_count=3)
I am trying to test a Zapier field with python code block to see if it ends with .mov. If so, I want to remove the .mov. If not, just return the field as is. The code I have works, but I have added a .lower() to make it work and don't understand why it behaves that way.
I have tried multiple variations but the only one that seems to work is adding string formatting .lower() in the variable.
formatted_str = input_data['text']
if formatted_str.endswith('.mov'):
formatted_str = formatted_str[:-4]
return {'formatted_str':formatted_str.lower()}
I would like to return the results without having to change it to all lower case. I know it is possible, but I am not having any luck. Thank you so much!
With the help of Zapier folks, I figured out my issue. Thank you!
formatted_str = input_data['text']
if formatted_str.endswith('.mov'):
formatted_str = formatted_str[:-4]
return {'text':formatted_str}
So when I call the nonLinear function with pymel and save it in a variable like this:
flare = pm.nonLinear(objName, type="flare")
and I want to get the name of the flare1 Input like this:
print flare[0]
I get this warning:
Warning: pymel.core.general : Could not create desired MFn. Defaulting to MFnDependencyNode.
Everything works fine and it doesn't break anything.
I have also searched for it but I didn't really get what the actual problem is or how to get rid of it.
Thanks to everyone looking into it.
I ran this example code with 2 polyCubes in scene.
import pymel.core as pymel
pymel.select('pCube1', 'blinn1')
print pymel.ls(sl = True)
print pymel.ls(sl = True)[0]
and this is my output
[nt.Transform(u'pCube1'), nt.Blinn(u'blinn1')]
pCube1
I know the elements inside this list are PyNodes, but printing them gives out a string type name of the node. Is there anyway to access the PyNode directly from this list?
Found the answer myself.
So apparently the Script Editor returns a representation of PyNode when we print it. Like it's an overloaded str. It is still a PyNode but looks like a string only in Maya's Script Editor. To make it actually appear like a PyNode, we have to use repr() or enclose in back-ticks (`)
Here is the link where I found the answer.
: http://download.autodesk.com/us/maya/2011help/pymel/tutorial.html
Formatting: Read Me First to Avoid Confusion section
If you run the following code:
from flask import Flask
import unittest
dir(Flask(__name__).test_client())
The following is output to terminal:
There are a number of names returned that I cannot find documentation on (all of the names that are not surrounded by double underscores).
I have found indirect reference to post here (if you search for 'self.app.post' you'll see it referenced). Note: this link describes using .post with the following keywords: data and follow_redirects. It does not mention that you can also use the keywords content_type and headers. Perhaps the only reason that these keyword options are not intuitively obvious to me is because I'm new to this...
Does anyone know where documentation on these names resides? (I can't find it in flask/python/unittest documentation anywhere - perhaps I am looking in the wrong place?)
edit: with the help of the answers, I found this documentation.
For any Python Module, Class, Method (all of these in Python are object indeed), you can view the doc by:
>>> a_module.__doc__
>>> a_class.__doc__
>>> a_method.__doc__
To see more detailed documents, you can use help command:
>>> help(a_method)
You can always check the docstring of the method - comments that developers left when they wrote the code. You can check any object or method you need. For example:
Flask.__doc__
unittest.__doc__
dir.__doc__
dir.__doc__.__doc__
You can also query
Flask(__name__).test_client().post.__doc__
Flask(__name__).test_client().preserve_context.__doc__
But you'll notice that not all methods would be documented. For example:
Flask(__name__).test_client().open.__doc__
For more about this you can also see http://legacy.python.org/dev/peps/pep-0257/
Using help() gives you the same information but formatted, e.g.:
help(Flask)
help(unittest)
help(dir)
help(dir.__doc__)