Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: API design an choice
Post: RE: API design an choice

One suggestion could be like this,so here wait live in a none blocking way using asyncio import asyncio from pathlib import Path async def file_exists(file_path: Path) -> bool: """Asynchronou...
snippsat News and Discussions 4 191 Yesterday, 04:05 PM
    Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...

(Apr-27-2024, 04:57 PM)Pedroski55 Wrote: Is there a good reason why we should not pass the dictionary we want modified by name?Can do something like this,but think how this solution would look if ad...
snippsat General Coding Help 8 364 Apr-27-2024, 09:59 PM
    Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...

As i mention this task can be better to solve with with eg @dataclass By using default_factory=dict,a new dictionary is created each time an instance of the dataclass is created, ensuring that each i...
snippsat General Coding Help 8 364 Apr-27-2024, 02:31 PM
    Thread: ModulNotFoundError matplotlib
Post: RE: ModulNotFoundError matplotlib

You have two Python versions on your Pc. This on mean that you have installed a Microsoft python 3.12 app version : Requirement already satisfied: matplotlib in c:\users\richb\appdata\local\packages\p...
snippsat General Coding Help 9 281 Apr-26-2024, 05:38 PM
    Thread: ModulNotFoundError matplotlib
Post: RE: ModulNotFoundError matplotlib

(Apr-26-2024, 12:05 AM)WicardBohnam Wrote: I'm new to Python and have installed Python 3.12.3 with idle on Windows 10Here a addition to deanhystad answers. Start to test that all work from command l...
snippsat General Coding Help 9 281 Apr-26-2024, 05:07 PM
    Thread: Why am I getting this error from Dave Beazly's programme?
Post: RE: Why am I getting this error from Dave Beazly's...

Should never ever run parallel/asynchronous code in Idle shell or Editor, always from command line so thread/process don't interfere with what Idle/Editors use. The reason why it works in IDLE and no...
snippsat General Coding Help 4 177 Apr-26-2024, 11:42 AM
    Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...

(Apr-26-2024, 08:16 AM)akbarza Wrote: but i asked why after production(or creation) the clothes_shop_list dictionary in line 39, the dictionary changes when line 40 is runed and the dictionary elect...
snippsat General Coding Help 8 364 Apr-26-2024, 09:26 AM
    Thread: using mutable in function defintion as optional paramter
Post: RE: using mutable in function defintion as optiona...

You mix in example of bad version and the correct one,so it get confusing when look your code for this. The blog post show many different version of not correct ways,and explain why. To sum it up and...
snippsat General Coding Help 8 364 Apr-25-2024, 10:10 AM
    Thread: Using xml.parsers.expat I can't get parser.ParseFile(f) to work
Post: RE: Using xml.parsers.expat I can't get parser.Par...

(Apr-24-2024, 05:33 AM)Pedroski55 Wrote: What does xmlparser.ParseFile(f) want for f? Is the module too old?Still work with some changes over to Python 3,as mention bye Gribouillis need 'rb' # coe...
snippsat General Coding Help 3 197 Apr-24-2024, 07:15 AM
    Thread: Right way to open files with different encodings?
Post: RE: Right way to open files with different encodin...

(Apr-23-2024, 08:49 AM)Winfried Wrote: Some of the files could be Windows (latin1, iso9959-1, cp1252), others could be utf-8.As these are .html some advice if you are making or saving this these fi...
snippsat General Coding Help 2 255 Apr-23-2024, 05:50 PM
    Thread: Loop through all files in a directory?
Post: RE: Loop through all files in a directory?

(Apr-23-2024, 06:17 AM)Gribouillis Wrote: You could also write a generator and also you can have it produce Path instances if you want import os from pathlib import Path def somefunc(root): fo...
snippsat General Coding Help 10 456 Apr-23-2024, 08:11 AM
    Thread: What does .flush do? How can I change this to write to the file?
Post: RE: What does .flush do? How can I change this to ...

Also for fun as this is written to be like tail -f which is command line tool. Then can write to be a command line tool,eg i think Typer is cool. So Typer is tool like eg argparse in standard library....
snippsat General Coding Help 3 248 Apr-22-2024, 01:15 PM
    Thread: What does .flush do? How can I change this to write to the file?
Post: RE: What does .flush do? How can I change this to ...

Can also write it like this,updatet for Python 3. log_sim.py: import time import random ips = [ '99.167.100.246', '74.6.23.48', '77.91.224.3', '67.176.147.11', '84.237.120.134', '64.92.161.13...
snippsat General Coding Help 3 248 Apr-22-2024, 11:40 AM
    Thread: yield from
Post: RE: yield from

def my_join(*iterables, my_joiner=None): if not iterables: return #yield from iterables[0] # The same as the loop under for item in iterables[0]: yield item for it...
snippsat General Coding Help 4 316 Apr-19-2024, 02:44 PM
    Thread: Hide CMD call window
Post: RE: Hide CMD call window

When i test your code no cmd window pop up. This correct and normal behavior,what are you using to schedule code every hour? If you run code from command line python arp_code.py,dos still cmd window p...
snippsat General Coding Help 8 331 Apr-15-2024, 08:31 PM
    Thread: Seeking advice on dask distributed
Post: RE: Seeking advice on dask distributed

(Apr-13-2024, 09:36 PM)sawtooth500 Wrote: I've never used dask before, but my understanding is that each function needs to be passed a dask dataframe. I could convert the pandas dataframe to a dask ...
snippsat General Coding Help 4 293 Apr-15-2024, 11:17 AM
    Thread: Stuck on installing PyQt5-tools
Post: RE: Stuck on installing PyQt5-tools

I tried with Python 3.12 and it did work. So may not ready for Python 3.12 yet,if try 3.11 it works. Also could use pyqt6-tools now. # Make environment with Python 3.11 G:\div_code λ py -3.11 -m venv ...
snippsat General Coding Help 1 270 Apr-11-2024, 03:40 PM
    Thread: please help
Post: RE: please help

Can also use Polars to speed things up. So for 1-GB file .csv Pandas use ca 13.5 seconds versus 350 milliseconds in Polars. In pandas your could be like this. Then if this is slow use Polars or and ...
snippsat General Coding Help 6 425 Apr-10-2024, 10:54 AM
    Thread: Advice needed on how to approach this problem...
Post: RE: Advice needed on how to approach this problem....

(Apr-04-2024, 02:37 AM)sawtooth500 Wrote: How can I code this more efficiently? There has to be a better way..You should post code of have done do,our least as sample of the stock dataset input and ...
snippsat General Coding Help 1 279 Apr-06-2024, 01:55 PM
    Thread: argparse io issue
Post: RE: argparse io issue

(Apr-02-2024, 10:24 AM)pyDream Wrote: So this part not only defines how the script would read a dictionary, but also how it will write to the console, correct? Just to be clear.No,the error happens ...
snippsat General Coding Help 8 710 Apr-02-2024, 12:01 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020