nonetype

Since when is Python None equal to None?

Since when is Python None equal to None? Question: I always thought that Python nulls are not equal, as is common in many other languages and based on simple logic (if the value is unknown, how can it be equal to another unknown?). However, recently I tried it, and discovered that: Python 3.10.2 >>> None …

Total answers: 3

Beautiful Soup: 'NoneType' object has no attribute 'text'

Beautiful Soup: 'NoneType' object has no attribute 'text' Question: I got this code to work to scrape a table on a webpage, which I’m very happy with. However, on a rare occasion, a title might miss a ‘genre’ or an ‘image URL’ field. As soon as the scraper hits an item in the list that …

Total answers: 1

Queries regarding print() function

Queries regarding print() function Question: print("Line 1") print(">>>") type(print("Hello")) print() print("Line 2") print(">>>") print(print("Hello")) print() print("Line 3") print(">>>") a = print("Hello") b = a print("a:", a, "b:", b) Q1) For Line 1, why is it that type(None) not be executed since print("Hello") returns None ? Q2) I am sort of aware that IIFE is a …

Total answers: 1

None to Empty List

None to Empty List Question: I have to find the sum of two that are equivalent to value s, can’t use dictionaries, only sets, arrays, and lists. If none, then I have to return an empty list. This is my code, I tried to remove None using if statement, but it didn’t work, not sure …

Total answers: 2

NoneType erorr when calling .lower() method on annotated text

NoneType erorr when calling .lower() method on annotated text Question: I have annotated articles in a list (len=488), and I want to apply the .lower() method on the lemmas. I get the following error message AttributeError: ‘NoneType’ object has no attribute ‘lower’. Here’s the code: file = open("Guardian_Syria_text.csv", mode="r", encoding=’utf-8-sig’) data = list(csv.reader(file, delimiter=",")) file.close …

Total answers: 1

What happens "behind the scenes" if I call `None == x` in Python?

What happens "behind the scenes" if I call `None == x` in Python? Question: I am learning and playing around with Python and I came up with the following test code (please be aware that I would not write productive code like that, but when learning new languages I like to play around with the …

Total answers: 2

Attribute Error: 'NoneType' object has no attribute '_next'

Attribute Error: 'NoneType' object has no attribute '_next' Question: I understand that these errors occur when plugging instance methods or any preset functions to None type, but since I’m implementing a singly Linked List I need to assign a None type to the last node. How do I resolve this issue since I can’t change …

Total answers: 2

Webscrapping with bs4: Type Error – 'NoneType' object is not subscriptable

Webscrapping with bs4: Type Error – 'NoneType' object is not subscriptable Question: I am trying to extract "video" from the url and print how many there are in the console. But I get this Error: TypeError: ‘NoneType’ object is not subscriptable Here is my code: import requests from bs4 import BeautifulSoup Web_url = "https://watch.plex.tv/show/hannibal/season/1/episode/9" r …

Total answers: 1

Python.kivy – TypeError: 'NoneType' object is not subscriptable

Python.kivy – TypeError: 'NoneType' object is not subscriptable Question: I’ve faced unknown problem during coding on Python using GUI library Kivy. The problem is that when I execute this code from kivy.app import App from kivy.lang import Builder from kivy.uix.label import Label from kivy.uix.floatlayout import FloatLayout from kivy.uix.scatter import Scatter from kivy.uix.textinput import TextInput from …

Total answers: 1