Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Are there any objects that do not contain the __name__ attribute? Does the object data always comprise the object name?
Are there any objects that do not contain the __name__ attribute?
Of course:
>>> (4).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__name__'
>>> (3.14).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'float' object has no attribute '__name__'
>>> (6+8j).__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'complex' object has no attribute '__name__'
>>> 'hello'.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute '__name__'
>>> [].__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute '__name__'
>>> ....__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'ellipsis' object has no attribute '__name__'
And on and on it goes...
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 3 days ago.
Improve this question
Traceback (most recent call last):
File "c:\Users\samue\test_minimum.py", line 52, in test_case06
self.assertRaises(ValueError,self.calc.min_element([23, '34.56', 67, 33]))
File "c:\Users\samue\minimum1.py", line 16, in min_element
if elements_list[counter]<minimum :
TypeError: '<' not supported between instances of 'str' and 'int'
======================================================================
ERROR: test_case02 (__main__.TestMinimum)
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\Users\samue\test_minimum.py", line 31, in test_case02
self.assertRaises(ValueError,self.calc.min_element([]))
File "C:\Users\samue\AppData\Local\Programs\Python\Python310\lib\unittest\case.py", line 738, in assertRaises
return context.handle('assertRaises', args, kwargs)
File "C:\Users\samue\AppData\Local\Programs\Python\Python310\lib\unittest\case.py", line 201, in handle
callable_obj(*args, **kwargs)
TypeError: 'NoneType' object is not callable
======================================================================
ERROR: test_case06 (__main__.TestMinimum)
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\Users\samue\test_minimum.py", line 52, in test_case06
self.assertRaises(ValueError,self.calc.min_element([23, '34.56', 67, 33]))
File "c:\Users\samue\minimum1.py", line 16, in min_element
if elements_list[counter]<minimum :
TypeError: '<' not supported between instances of 'str' and 'int'
======================================================================
ERROR: test_case07 (__main__.TestMinimum)
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\Users\samue\test_minimum.py", line 57, in test_case07
self.assertRaises(ValueError,self.calc.min_element([23, 'hi', 32, 1]))
File "c:\Users\samue\minimum1.py", line 16, in min_element
if elements_list[counter]<minimum :
TypeError: '<' not supported between instances of 'str' and 'int'
----------------------------------------------------------------------
Ran 9 tests in 0.011s
FAILED (errors=3)
PS C:\Users\samue>
C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\Scripts>python OpenGLTensorGrowth.py
Traceback (most recent call last):
File "C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\Scripts\OpenGLTensorGrowth.py", line 29, in
Dict = Canvas.winfo_pixels(info, 3840_2160),[Self.tk.getint]
File "C:\Users\KrunkCiti\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 1163, in winfo_pixels
return self.tk.getint(
AttributeError: 'function' object has no attribute 'tk'
I already checked all similar thread, but no help.
>>> from nltk import load_parser
>>> parser = load_parser('grammars/book_grammars/drt.fcfg', logic_parser=nltk.sem.drt.DrtParser())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'DrtParser'
code is given at : http://www.nltk.org/book/ch10.html just above 5.2
>>> print nltk.sem.drt
<module 'nltk.sem.drt' from '/usr/local/lib/python2.7/dist-packages/nltk/sem/drt.pyc'>
what can be the issue?
/nltk/sem has drt.py and drt.pyc files
I am trying to generate the help text at runtime and i am not able to use the pydoc command in Windows. When i type
>>> pydoc(atexit)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
I have already set up the environment variables for pydoc.py file. C:\Python33\Lib\pydoc.py.
This also not works like it works for >>help('atexit')
>>> pydoc('atexit')
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
Whats the possible reason for it.
Updates:
>>> import pydoc
>>> pydoc(sys)
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
>>> pydoc('sys')
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
Like any library in Python, you need to import it before you can use it.
Edit What exactly are you trying to achieve? Modules are indeed not callable. pydoc.help is the function you want, although I don't really know why you need it, since as you note the standalone help function does the same thing already.
I'm trying to use PyKDE, PyKDE.kdecore.KStandardDirs to be precise. This method is called with two strings according to the documentation and according to the PyQt4 documentation, I can use standard Python strs instead of QString.
This doesn't work:
>> KStandardDirs.locate()("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): not enough arguments
>>> KStandardDirs.locate("socket", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: KStandardDirs.locate(): argument 1 has unexpected type 'str'
I can't use QString either because it doesn't seem to exist:
>>> from PyQt4.QtCore import QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name QString
>>> from PyQt4.QtCore import *
>>> QString
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'QString' is not defined
What am I doing wrong?
I suspect that PyKDE is not yet Python 3 ready, at least as far as that error message is concerned; try passing in a bytestring instead:
KStandardDirs.locate(b"socket", "foo")