Re: Incomplete sys.path with embeddable python (Windows)!?

2023-04-22 Thread Ralf M.
Am 21.04.2023 um 18:07 schrieb Thomas Passin: On 4/20/2023 5:47 PM, Ralf M. wrote: Hello, when I run a script with a "normally" installed python, the directory the script resides in is automatically added as first element to sys.path, so that "import my_local_module" find

Re: Incomplete sys.path with embeddable python (Windows)!?

2023-04-22 Thread Ralf M.
Am 22.04.2023 um 03:27 schrieb Greg Ewing via Python-list: How are you invoking your script? Presumably you have some code in your embedding application that takes a script path and runs it. Instead of putting the code to update sys.path into every script, the embedding application could do it

Re: Incomplete sys.path with embeddable python (Windows)!?

2023-04-22 Thread Ralf M.
Am 21.04.2023 um 17:31 schrieb Mats Wichmann: On 4/20/23 15:47, Ralf M. wrote: Hello, when I run a script with a "normally" installed python, the directory the script resides in is automatically added as first element to sys.path, so that "import my_local_module" find

Incomplete sys.path with embeddable python (Windows)!?

2023-04-21 Thread Ralf M.
path not in sys.path: sys.path[0:0] = [script_path] import my_local_modul That works, but it's ugly, executing code between imports is frowned upon, and it needs to be added to every script. Does anybody have a better idea? Any help is appreciated. Ralf M. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to replace an instance method?

2022-09-17 Thread Ralf M.
Am 17.09.2022 um 00:35 schrieb Dan Stromberg: On Fri, Sep 16, 2022 at 2:06 PM Ralf M. <mailto:ral...@t-online.de>> wrote: I would like to replace a method of an instance, but don't know how to do it properly. You appear to have a good answer, but...  are you sure this

Re: How to replace an instance method?

2022-09-17 Thread Ralf M.
Am 16.09.2022 um 23:34 schrieb Eryk Sun: On 9/16/22, Ralf M. wrote: I would like to replace a method of an instance, but don't know how to do it properly. A function is a descriptor that binds to any object as a method. For example: >>> f = lambda self, x: self + x &

How to replace an instance method?

2022-09-16 Thread Ralf M.
read next. Any ideas / pointers? Ralf M. -- https://mail.python.org/mailman/listinfo/python-list

Re: .0 in name

2022-05-28 Thread Ralf M.
erent question. I think the OP wondered about the .0 in the local namespace within list comprehensions. Unfortunately I cannot say much about that. Paul Ralf M. -- https://mail.python.org/mailman/listinfo/python-list

Re: "py.ini" question

2021-04-25 Thread Ralf M.
Am 25.04.2021 um 16:30 schrieb Mats Wichmann: On 4/24/21 2:57 PM, Chris Angelico wrote: On Sun, Apr 25, 2021 at 5:57 AM Gisle Vanem wrote: With 'py -3.6' or 'py 3.8' I get the expected. But with 'py -3':     Python 3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit (AMD64)] on

unittest test discovery: regular packages vs. namespace packages

2020-07-10 Thread Ralf M.
Hello, to my last question I got many helpful and enlightening answers. So I try again with a completely different topic. https://docs.python.org/3/library/unittest.html#test-discovery says about test discovery: "Unittest supports simple test discovery. In order to be compatible with test

Enums are Singletons - but not always?

2020-05-23 Thread Ralf M.
other, different instance of En and its members is created. How do I have to change mod1.py to avoid the problem? Currently I have moved main() into a new file script.py. That works, but is not what I wanted. I doubt it's a bug in the enum module, but should that be the case, I'm willing to ope

Re: Spread a statement over various lines

2019-09-19 Thread Ralf M.
Am 18.09.2019 um 22:24 schrieb Alexandre Brault: On 2019-09-18 4:01 p.m., Ralf M. wrote: I don't know the exact rules of Windows wildcards, so there may be even more cases of unexpected behavior. If anyone knows where to find the complete rules (or a python module that implements them), I

Re: Spread a statement over various lines

2019-09-19 Thread Ralf M.
Am 18.09.2019 um 22:22 schrieb Chris Angelico: On Thu, Sep 19, 2019 at 6:20 AM Ralf M. wrote: Am 17.09.2019 um 20:59 schrieb Manfred Lotz: I have a function like follows def regex_from_filepat(fpat): rfpat = fpat.replace('.', '\\.') \ .replace

Re: Spread a statement over various lines

2019-09-18 Thread Ralf M.
Am 17.09.2019 um 20:59 schrieb Manfred Lotz: I have a function like follows def regex_from_filepat(fpat): rfpat = fpat.replace('.', '\\.') \ .replace('%', '.') \ .replace('*', '.*') return '^' + rfpat + '$' As I don't want to have the

Multidimensional dicts

2019-09-06 Thread Ralf M.
Recently I wrote a quick and dirty script to do some counting and statistics. When I re-read it a bit later I noticed that I had been using two different ways to create two-dimensional (default-)dicts. Now I'm wondering whether one of them is "better" or more pythonic than the other. What I