python-3.6

How do I get my progress bar to iterate while a script is being executed?

How do I get my progress bar to iterate while a script is being executed? Question: I created a ui that runs a python script on a button click. I included a progress bar to confirm when the script has completed. I’m not sure I have the code correct because when I click the button …

Total answers: 2

Get all required fields of a nested Python Pydantic model

Get all required fields of a nested Python Pydantic model Question: My pydantic nested model is defined as below: from pydantic import BaseModel from typing import Optional class Location(BaseModel): city: Optional[str] state: str country: str class User(BaseModel): id: int name: Optional[str] = "Gandalf" age: Optional[int] location: Location I would like to get all required fields …

Total answers: 1

Numpy loadtxt in python – except some colums

Numpy loadtxt in python – except some colums Question: Is it possible in np.loadtxt to load all columns except the first one, or except some particular ones, please? What does usecols = (0,) mean, please? Is it possible to use sliders? I have 55 columns, and I would like to load all except one. Is …

Total answers: 1

Adding a key value into dictionary of list in python3

Adding a key value into dictionary of list in python3 Question: I have this data: enquiry_metadata = {‘enquiry_id’: ’02e19c4e21d2′, ‘items’: [{‘status’: ‘SUCCESS’, ‘code’: 0, ‘panelId’: ‘0a1702be81bf’, ‘data’: {‘customerId’: 19373, ‘appId’: 30531, ‘zip’: 80124, ‘service_id’: 979869}}, {‘status’: ‘SUCCESS’, ‘code’: 0, ‘panelId’: ‘6e638d5fbb’, ‘data’: {‘customerId’: 30743, ‘appId’: 51808, ‘zip’: 32425, ‘service_id’: 879463}}]} How can I add the …

Total answers: 3

Add role Python Discord Bot

Add role Python Discord Bot Question: Some help if possible please. I am using the below code to achieve adding a role to a member by using the command : @addRole @user knight . But the role isnt being added. Can anyone spot my error ? @ is my prefix and knight is the name …

Total answers: 1

AttributeError: Can't pickle local object '<locals>.<lambda>'

AttributeError: Can't pickle local object '<locals>.<lambda>' Question: I am trying to pickle a nested dictionary which is created using: collections.defaultdict(lambda: collections.defaultdict(int)) My simplified code goes like this: class A: def funA(self): #create a dictionary and fill with values dictionary = collections.defaultdict(lambda: collections.defaultdict(int)) … #then pickle to save it pickle.dump(dictionary, f) However it gives error: AttributeError: …

Total answers: 2

cx_freeze attributeerror: 'windowspath' object has no attribute 'write' error

cx_freeze attributeerror: 'windowspath' object has no attribute 'write' error Question: I got this error while trying to convert my .py file to .exe file with Cx_Freeze: cx_freeze attributeerror: ‘windowspath’ object has no attribute ‘write’ error The file I’m trying to convert: print("Hello!") while True: pass Setup.py file: from cx_Freeze import setup, Executable setup( name = …

Total answers: 1

Return None – scraping p by Python

Return None – scraping p by Python Question: I want to scrap name and number of product in stock but it return None. data_insight = [] for n in range(pagenum): pages_url = f"https://www.insight.com/en_US/search.html?qtype=all&q=tp-link&qsrc=k&pq=%7B%22pageSize%22%3A100%2C%22currentPage%22%3A{n+1}%2C%22shownFlag%22%3Afalse%2C%22priceRangeLower%22%3Anull%2C%22priceRangeUpper%22%3Anull%2C%22cmtStandards%22%3Atrue%2C%22categoryId%22%3Anull%2C%22setType%22%3Anull%2C%22setId%22%3Anull%2C%22shared%22%3Anull%2C%22groupId%22%3Anull%2C%22cmtCustomerNumber%22%3Anull%2C%22groupName%22%3Anull%2C%22fromLicense%22%3Atrue%2C%22licenseContractIds%22%3Anull%2C%22assortmentIds%22%3Anull%2C%22controller%22%3Anull%2C%22fromcs%22%3Afalse%2C%22searchTerms%22%3A%7B%22TP-LINK%2520TECHNOLOGY%22%3A%7B%22field%22%3A%22field%22%2C%22value%22%3A%22A-HYBRIS-ManufacturerId~0007045098%22%7D%7D%2C%22sortBy%22%3A%22BestMatch%22%7D" driver.get(pages_url) WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, ‘[class="prod-section-container"]’))) html = driver.page_source soup = Soup(html) soup for item in soup.select(‘[class="prod-section-container"]’): data_insight.append({ ‘title’ : item.find("a", class_="select-prod").text, ‘name’ : …

Total answers: 1

Can returned attributes be forced into lowercase

Can returned attributes be forced into lowercase Question: Changes on our LDAP Server have changed the case of the attributes returned from search. For example, "mailroutingaddress" is now "mailRoutingAddress". The searches themselves are case insensitive, but the python code processing the returned ldap object is attempting to reference attributes in all lower case and failing. …

Total answers: 2