Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Waiting for input from serial port, then move on
Post: RE: Waiting for input from serial port, then move ...
(Apr-17-2024, 06:45 AM)feistycavities Wrote: The issue with your while loop not closing is because you have an embedded for loop in your code.
The cause was the condition of while. In the code there... |
|
DeaD_EyE |
General Coding Help |
3 |
999 |
Apr-17-2024, 07:21 AM |
|
|
Thread: python calculate float plus float is incorrect?
Post: RE: python calculate float plus float is incorrect...
I don't know what PHP does to prevent the visible inaccuracy.
In modern programming languages, you don't see the real floating point value inclusive PHP.
An algorithm is used, to show the user a nic... |
|
DeaD_EyE |
General Coding Help |
6 |
250 |
Apr-16-2024, 01:45 PM |
|
|
Thread: Need to get around SSL: CERTIFICATE_VERIFY_FAILED
Post: RE: Need to get around SSL: CERTIFICATE_VERIFY_FAI...
I do not have this problem. I was able to connect to api.polygon.io:443 on Windows 11 with Python 3.12.2 x64.
btw. Python 3.12.3 is out
import socket
import ssl
addr = ("api.polygon.io", 443)
ctx ... |
|
DeaD_EyE |
General Coding Help |
3 |
181 |
Apr-16-2024, 07:50 AM |
|
|
Thread: Hide CMD call window
Post: RE: Hide CMD call window
windows ...
import subprocess
def arp():
"""
Run arp -a and return the stripped output.
Window creation is prevented.
"""
flags = subprocess.CREATE_NO_WINDOW
return sub... |
|
DeaD_EyE |
General Coding Help |
8 |
215 |
Apr-15-2024, 08:56 PM |
|
|
Thread: How do I parse the string?
Post: RE: How do I parse the string?
If you need a path, a Path object is maybe what you want.
Code is based on Gribouillis example:
from urllib.parse import urlparse
from pathlib import PurePosixPath
def url2path(url: str) -> Pure... |
|
DeaD_EyE |
General Coding Help |
4 |
253 |
Apr-10-2024, 10:26 AM |
|
|
Thread: Next/Prev file without loading all filenames
Post: RE: Next/Prev file without loading all filenames
Here as a class with type hints. mypy does not complain :-)
This loads the whole directory content for the first time, and then only if the sort_function has been changed.
The __init__ method makes th... |
|
DeaD_EyE |
General Coding Help |
9 |
460 |
Apr-08-2024, 07:58 AM |
|
|
Thread: a better way to code this to fix a URL?
Post: RE: a better way to code this to fix a URL?
If the url should always start with https even, if only a hostname is given, you could use this:
from urllib.parse import urlsplit, urlunsplit
def conv2(url):
return urlunsplit(("https", *urlsp... |
|
DeaD_EyE |
News and Discussions |
10 |
663 |
Mar-19-2024, 09:15 AM |
|
|
Thread: list.sort() returning None
Post: RE: list.sort() returning None
(Mar-18-2024, 10:39 AM)Pedroski55 Wrote: **smile** **smile** **smile**
Dead_EyE: a very accurate shooter (and reader?)
Quote:You can also use the list.sort() method. It modifies the list in-pla... |
|
DeaD_EyE |
General Coding Help |
8 |
530 |
Mar-18-2024, 08:16 PM |
|
|
Thread: Anyway to stop a thread and continue it?
Post: RE: Anyway to stop a thread and continue it?
Example with a queue:
import time
from random import randint
from queue import Queue
from threading import Thread
def fake_feed():
"""
Generator function which yields
endless values fro... |
|
DeaD_EyE |
General Coding Help |
2 |
322 |
Mar-18-2024, 10:53 AM |
|
|
Thread: Request for Feedback: Python Website Accessibility
Post: RE: Request for Feedback: Python Website Accessibi...
Contact python.org
Buzzwords: Accessibility, Inclusiveness
Perhaps the reference to this document will help to speed up the procedure **lol** :
https://eur-lex.europa.eu/legal-content/...02&from... |
|
DeaD_EyE |
News and Discussions |
2 |
345 |
Mar-18-2024, 10:29 AM |
|
|
Thread: list.sort() returning None
Post: RE: list.sort() returning None
There is no mention in the Documentation, that this method return a None.
But, it returns None and sorts the list in-place.
I guess the expectation comes from str. The str methods always return a new... |
|
DeaD_EyE |
General Coding Help |
8 |
530 |
Mar-18-2024, 10:20 AM |
|
|
Thread: class and runtime
Post: RE: class and runtime
(Mar-15-2024, 08:02 AM)akbarza Wrote: can explain this statement? what is the importance of the creation of a class in runtime? how can a class be modified after creation?
This is not possible with ... |
|
DeaD_EyE |
General Coding Help |
4 |
353 |
Mar-15-2024, 10:25 AM |
|
|
Thread: MCU reboots after opening Serial port when ran from Raspberry PI
Post: RE: MCU reboots after opening Serial port when ran...
(Mar-15-2024, 09:25 AM)zazas321 Wrote: However, the device that I am connecting to reboots. When I try to do this via my Windows machine, it does not reboot. Perhaps anyone know why this could be th... |
|
DeaD_EyE |
General Coding Help |
3 |
428 |
Mar-15-2024, 10:13 AM |
|
|
Thread: Screenshot problem
Post: RE: Screenshot problem
There is a bbox argument.
img = PIL.ImageGrab.grab(bbox=(0, 0, 90, 60))I use X11. It grabs all physical screens, even if all_screens=False.
Maybe the option works on Wayland. If you have only one scr... |
|
DeaD_EyE |
Bar |
7 |
566 |
Mar-11-2024, 08:32 PM |
|
|
Thread: using PowerShell from Python script for mounting shares
Post: RE: using PowerShell from Python script for mounti...
A file is not required to send a script via stdin to powershell.exe.
Example with logging:
import subprocess
import logging
from pathlib import Path
from textwrap import indent
logging.basicConfig(
... |
|
DeaD_EyE |
General Coding Help |
8 |
511 |
Mar-11-2024, 09:11 AM |
|
|
Thread: No Internet connection when running a Python script
Post: RE: No Internet connection when running a Python s...
(Mar-10-2024, 10:11 PM)buran Wrote: It was not installed on YOUR machine. There is no info about OP setup - may or may not be installed, we just don't know
This is why I mentioned, that bare excepts... |
|
DeaD_EyE |
General Coding Help |
8 |
577 |
Mar-10-2024, 10:49 PM |
|
|
Thread: No Internet connection when running a Python script
Post: RE: No Internet connection when running a Python s...
(Mar-10-2024, 07:28 PM)buran Wrote: well, I don't know how you know it is not installed on OP machine
I tested his code and ran into this issue. lxml was not installed. |
|
DeaD_EyE |
General Coding Help |
8 |
577 |
Mar-10-2024, 08:49 PM |
|
|
Thread: No Internet connection when running a Python script
Post: RE: No Internet connection when running a Python s...
import requests
import os
from bs4 import BeautifulSoup
import time
import logging
import smtplib as smtp
try:
import lxml
except ImportError:
raise RuntimeError("Please install lxml")
URL_... |
|
DeaD_EyE |
General Coding Help |
8 |
577 |
Mar-10-2024, 05:53 PM |
|
|
Thread: Screenshot problem
Post: RE: Screenshot problem
Have you tried ImageGrab? It should work now on all Operating Systems. Before only Windows was supported for ImageGrab. It returns a Image object you can work with.
from PIL.ImageGrab import grab
d... |
|
DeaD_EyE |
Bar |
7 |
566 |
Mar-06-2024, 01:32 PM |
|
|
Thread: drawing a table with the status of tasks in each thread
Post: RE: drawing a table with the status of tasks in ea...
Maybe this helps as a start.
Additionally, you should look here: https://rich.readthedocs.io/en/stable/live.html
import time
from collections.abc import Generator
from concurrent.futures import Thre... |
|
DeaD_EyE |
General Coding Help |
3 |
407 |
Feb-29-2024, 09:45 AM |