Re: Searching for a file

2025-05-28 Thread Roland Mueller via Python-list
ke 28.5.2025 klo 1.45 Thomas Passin (li...@tompassin.net) kirjoitti:

> On 5/27/2025 10:41 AM, Roland Mueller via Python-list wrote:
> > To get a list of files in a given directory one can use glob.glob and
>
> The OP had a different problem.  He wanted to find a config file of
> known name that could be in one of several locations.
>

This can be done by replacing the star wildcard  the join(dir, '*') with a
filename or filename glob pattern.
>>> tmp_files = []
>>> for dir in ['/tmp', '/var/tmp']:
... tmp_files += [f for f in glob(join(dir, filename_to_find))  if
isfile(f) ]


>
> > os.path.isfile
> >
>  from os.path import isfile
>  from glob import glob
>  files_in_var_tmp = [f for f in glob('/var/tmp/*') if isfile(f) ]
> >
> > For several directories iterate over the dirs and add the resulting list
> of
> > files.
> >
>  tmp_files = []
>  for dir in ['/tmp', '/var/tmp']:
> > ... tmp_files += [f for f in glob(dir + '/*')  if isfile(f) ]
> >
> >
> > ti 27.5.2025 klo 17.05 Peter J. Holzer (hjp-pyt...@hjp.at) kirjoitti:
> >
> >> On 2025-05-24 17:18:11 -0600, Mats Wichmann wrote:
> >>> On 5/23/25 16:05, Rob Cliffe via Python-list wrote:
>  On 23/05/2025 18:55, Mats Wichmann wrote:
> > On 5/22/25 21:04, Rob Cliffe via Python-list wrote:
> >> It occurs to me that it might be useful if Python provided a
> >> function to search for a file with a given name in various
> >> directories (much as the import.import_lib function searches for
> >> a module in the directories in sys.path).
> >> This function would perhaps be best placed in the os.path or os
> >> modules.
> >> To start the ball rolling, I offer this version:
> > consider: os.walk, glob.glob, Path.glob
> >
> >
>  I have.  None of these are appropriate.
>  os.walk iterates *recursively* over a *single* directory and its
>  subdirectories.
>  pathlib.Path.glob so far as I can make out (I have never used pathlib)
>  does much the same.
>  glob.glob (so far as I can make out) does a *wildcard* search for
>  directories matching a *single* pattern.
>  My suggestion needs a *non-recursive* search for a *file* in a *list*
> >> of
>  *non-wildcarded* directories.
> >>>
> >>> They don't give you "search in a list of directories" intrinsically,
> but
> >>> that's simple loop, bailing out on a match, no?
> >>
> >> But they all read directories. For Rob's purpose this isn't necessary.
> >> He just needs to test a fixed number of locations. Reading even one
> >> directory (muss less recursively scanning a whole tree like os.walk
> >> does) is just pointless extra work.
> >>
> >>  hjp
> >>
> >> --
> >> _  | Peter J. Holzer| Story must make more sense than reality.
> >> |_|_) ||
> >> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> >> __/   | http://www.hjp.at/ |   challenge!"
> >> --
> >> https://mail.python.org/mailman3//lists/python-list.python.org
> >>
>
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


Re: Searching for a file

2025-05-28 Thread Peter J. Holzer
On 2025-05-28 10:59:16 +0300, Roland Mueller via Python-list wrote:
> ke 28.5.2025 klo 1.45 Thomas Passin (li...@tompassin.net) kirjoitti:
> > On 5/27/2025 10:41 AM, Roland Mueller via Python-list wrote:
> > > To get a list of files in a given directory one can use glob.glob and
> >
> > The OP had a different problem.  He wanted to find a config file of
> > known name that could be in one of several locations.
> >
> 
> This can be done by replacing the star wildcard  the join(dir, '*') with a
> filename or filename glob pattern.
> >>> tmp_files = []
> >>> for dir in ['/tmp', '/var/tmp']:
> ... tmp_files += [f for f in glob(join(dir, filename_to_find))  if
> isfile(f) ]

But then the glob is useless.

Just try to open the file as Chris already demonstrated.

hjp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


magic-wormhole 0.19.0

2025-05-28 Thread meejah
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512


Greetings,

Wizards have foretold that May 28, 2025 marks the release of Magic
Wormhole version 0.19.0.

Magic Wormhole is a Python library and CLI tool to securely get
arbitrary data from one computer to another using short, one- time,
human- pronounceable codes and end-to-end encryption.

The library allows use of the lower-level protocol for things besides
file-transfer.

In this release are the following changes since 0.18.2:

* Add a "status" feedback API for Dilation (#591, @meejah)
* use new Status API to notify a sending user when a code is consumed (#575, 
@shapr + @meejah)
* add support for Ping/Pong timeouts in Dilation, improving re-connection speed 
(#590 @meejah)
* documentation improvements (#614, #615 @shapr + @meejah)
* improve Dilation version negotiation (#606, #611 @shapr + @meejah)
* convert test-suite to pytest (#603, #610 @shapr + @meejah)
* resize progress bar properly (#622 @shapr)
* Drop support for Python 3.9, upgrade github-actions (#596 @meejah)
* add a contribution guide (#597 @meejah)
* INCOMPAT: "sdist" files move to an underscore, so the source-package name is
  now "magic_wormhole-0.19.0.tar.gz" (the wheel files always had an underscore).
  This is because setuptools v69.3.0 in 2024 implemented PEP 625 from 2020.

You can find the release on PyPI:

   https://pypi.org/project/magic-wormhole/

More information can be found:

   https://magic-wormhole.readthedocs.io/en/latest/welcome.html
   https://github.com/magic-wormhole/magic-wormhole


thanks,

meejah


-BEGIN PGP SIGNATURE-

iQFFBAEBCgAvFiEEnVor1WiOy4id680/wmAoAxKAaacFAmg33IURHG1lZWphaEBt
ZWVqYWguY2EACgkQwmAoAxKAaaeUtQgAqtR8OfDXclj6YoeLc/Q594uI/ds0fvzA
OCzetbLzUZF0fkFIfyFCHPLvNBD+TYXLYfo0E/pbRPklGxrMcntrgmYFERet2ZA3
p7oUxc79ylEm7Pp9Z5p/1YhYsz8PtrsZd7QPlip9OdBnKC9JAiZWv/F+8BHnNtvg
OTfzK8to2wnPWR/XizFvk4X54p5PkczIo6nWOvscZ3FbtJErqZVTgSrfL9jNFFed
V/GLHU/V1HhkY7zITvwL8+q1reJwymkf2oznJ6/ezgTRYyR3ISwhf5jOHhTlwRl5
SgNwNwlQU2pX4uXWsdTyTcWYMctlHKIcnYxUtiNHpHVgQ+TOTOnxhw==
=wEqZ
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman3//lists/python-list.python.org


Re: Python tutor mailing list?

2025-05-28 Thread Mats Wichmann

On 5/27/25 18:00, Alan Gauld via Python-list wrote:

On 28/05/2025 00:32, Alan Gauld via Python-list wrote:


The archives are still there and the sign-up page seems to
work, but it doesn't recognise me. I tried signing up as
a new member with a different address and that seems to work(ie no
errors) but I still don;t see any list activity.


I sent a test message and it sent a response saying my
message was in a queue waiting for the moderator. But
since that's me and it won't let me in, I can't approve
anything, So I assume there will be a bunch of stuff
just sitting in a queue waiting for a non-existent moderator.

I guess this proves the list is still there in some form!
Back to the postmaster to see how I get this fixed...

I do notice we seem to have moved to Mailman3 as a server,
perhaps it has something to do with the migration? It would
have been nice to be told though.


Interesting - list transitions from 2->3 are supposed to be quite 
difficult, it's really a different piece of software that happens to 
still be called Mailman, not a simple version transition. When I've 
asked about other lists (hosted elsewhere on a "free to open source 
projects" basis), been told pretty much "ain't gonna happen".  I'm 
surprised python.org would have made such a move without letting anyone 
know, though I'm not surprised there was some motivation since Mailman 2 
is pinned forever to the slightly out-of-date (sic) Python 2



--
https://mail.python.org/mailman3//lists/python-list.python.org


Re: Searching for a file

2025-05-28 Thread Mats Wichmann

On 5/28/25 03:29, Peter J. Holzer wrote:

On 2025-05-28 10:59:16 +0300, Roland Mueller via Python-list wrote:

ke 28.5.2025 klo 1.45 Thomas Passin (li...@tompassin.net) kirjoitti:

On 5/27/2025 10:41 AM, Roland Mueller via Python-list wrote:

To get a list of files in a given directory one can use glob.glob and


The OP had a different problem.  He wanted to find a config file of
known name that could be in one of several locations.



This can be done by replacing the star wildcard  the join(dir, '*') with a
filename or filename glob pattern.

tmp_files = []
for dir in ['/tmp', '/var/tmp']:

... tmp_files += [f for f in glob(join(dir, filename_to_find))  if
isfile(f) ]


But then the glob is useless.

Just try to open the file as Chris already demonstrated.

 hjp




Indeed - a simple loop over the possible dirs each concatenated with the 
known file name is quick and easy.


Was only responding on the glob/pathlib stuff as there seemed to be 
information missing, not to claim it was  necessarily a better solution 
for this need (could still be used, though).

--
https://mail.python.org/mailman3//lists/python-list.python.org


Re: Python tutor mailing list?

2025-05-28 Thread Marc Nicole via Python-list
Being a user of that list i've also noticed that only recently. hope that
this list is good enough to take on all python questions. Are there any
other alternative lists? Thx

On Wed, 28 May 2025, 01:35 Alan Gauld via Python-list, <
python-list@python.org> wrote:

> I am the moderator of the python tutor mailing list.
> Or at least I was. It seems the tutor list has been deleted.
> I came back from vacation to find that I can't access it.
>
> Nobody told me anything in advance. I've tried emailing
> postmaster but got no response.
>
> I wonder if anyone here has any idea of what happened and why?
> The list had quietened down a lot since its heyday but
> there were still a few messages per month going to it.
>
> The archives are still there and the sign-up page seems to
> work, but it doesn't recognise me. I tried signing up as
> a new member with a different address and that seems to work(ie no
> errors) but I still don;t see any list activity.
>
> So, is it just the case that the admins have unsubscribed
> everyone on the list (again, this happened a few years ago)?
>
> Puzzled,
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
> --
> https://mail.python.org/mailman3//lists/python-list.python.org
>
-- 
https://mail.python.org/mailman3//lists/python-list.python.org