Re: AttributeError: 'NoneType' object has no attribute 'get'
On Fri, Jan 7, 2022 at 8:47 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-01-06 at 14:21:48 -0700, > Mats Wichmann wrote: > > > And at a more meta level: many functions in the Python world return > > None as an indication that the operation did not succeed. It's useful > > because in many circumstances None is an "out of band" value - one > > that could not happen naturally - and thus returning it provides an > > easy way for the caller to check for success or failure. > > Errors should never pass silently. > > Unless explicitly silenced. > > https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/ > Python is not C, and returning None is not the same as returning a null pointer. Also, I dispute that null pointers are the "billion-dollar mistake" described there, but of course, everyone loves to talk about figures like that. Returning None is most definitely not a flaw. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: AttributeError: 'NoneType' object has no attribute 'get'
On 2022-01-06 at 14:21:48 -0700, Mats Wichmann wrote: > And at a more meta level: many functions in the Python world return > None as an indication that the operation did not succeed. It's useful > because in many circumstances None is an "out of band" value - one > that could not happen naturally - and thus returning it provides an > easy way for the caller to check for success or failure. Errors should never pass silently. Unless explicitly silenced. https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/ Exceptions aren't perfect, but when something fails, I'd much rather have an exception raised and thrown at me than to get back None. An exception is immediate,¹ but None often ends up causing trouble far away¹ from where the actual failure occurred. ¹ in space and in time -- https://mail.python.org/mailman/listinfo/python-list
Re: AttributeError: 'NoneType' object has no attribute 'get'
On 1/6/22 11:02, Kushal Kumaran wrote: > On Tue, Jan 04 2022 at 11:34:20 PM, NArshad wrote: >> How to correct what is written below: >> >> Exception in Tkinter callback >> Traceback (most recent call last): >> File "C:\Users\Dani Brothers\Anaconda3\lib\tkinter\__init__.py", line >> 1705, in __call__ >> return self.func(*args) >> File "D:/Python/Book Bank/New folder/PyCharm/Final/Excel.py", line 57, in >> SaveBook >> e_pissue.get(), >> AttributeError: 'NoneType' object has no attribute 'get' >> >> Process finished with exit code 0 > > The error means that e_pissue is None, so your code cannot call the get > method on it. You need to fix the code so that e_pissue is not None and > is instead referring to an object that has a suitable get method. And at a more meta level: many functions in the Python world return None as an indication that the operation did not succeed. It's useful because in many circumstances None is an "out of band" value - one that could not happen naturally - and thus returning it provides an easy way for the caller to check for success or failure. However... if that is the case, you have to actually do that check. If you just proceed as if a vaild value had come back, you're defeating the purpose - and are sure to fall into a hole like the one you've encountered. -- https://mail.python.org/mailman/listinfo/python-list
Re: AttributeError: 'NoneType' object has no attribute 'get'
On Tue, Jan 04 2022 at 11:34:20 PM, NArshad wrote: > How to correct what is written below: > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Users\Dani Brothers\Anaconda3\lib\tkinter\__init__.py", line 1705, > in __call__ > return self.func(*args) > File "D:/Python/Book Bank/New folder/PyCharm/Final/Excel.py", line 57, in > SaveBook > e_pissue.get(), > AttributeError: 'NoneType' object has no attribute 'get' > > Process finished with exit code 0 The error means that e_pissue is None, so your code cannot call the get method on it. You need to fix the code so that e_pissue is not None and is instead referring to an object that has a suitable get method. Without looking at the rest of your code, it is not possible to get any more specific. Looking at the path of the file, it looks like you may be following some programming exercises from a book. If so, perhaps you need to look up the section about understanding exception tracebacks. -- regards, kushal -- https://mail.python.org/mailman/listinfo/python-list
AttributeError: 'NoneType' object has no attribute 'get'
How to correct what is written below: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Dani Brothers\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "D:/Python/Book Bank/New folder/PyCharm/Final/Excel.py", line 57, in SaveBook e_pissue.get(), AttributeError: 'NoneType' object has no attribute 'get' Process finished with exit code 0 -- https://mail.python.org/mailman/listinfo/python-list