Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread Barry via Python-list


> On 18 May 2024, at 16:27, Peter J. Holzer via Python-list 
>  wrote:
> 
> I don't think Linux users have to deal with venvs

Modern debian (ubuntu) and fedora block users installing using pip.
You must use a venv to pip install packages from pypi now.
This is implemented in python and pip and enabled by the distros.

There are ways to turn off the blocking, but it’s strongly discouraged
by the distros.

Barry



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issues with uninstalling python versions on windows server

2024-05-03 Thread Barry via Python-list


> On 3 May 2024, at 17:43, Tripura Seersha via Python-list 
>  wrote:
> 
> Hi Team,
> 
> I am working on an automation related to uninstalling and installing python 
> versions on different windows servers.
> 
> I have observed that uninstallation is working only with the account/login 
> using which the python version is installed. But for automation, we are not 
> aware which account is being used for installation on different machines.

I would guess that this is because you installed for the user not for all-users.
If true fix your install to do it for all-users and you should be able to 
uninstall as any user.

But this will require admin privs for both install and uninstall. As assume you 
can find out how to bet the admin priv required for your automation.

Barry

> 
> Also, with the approach of using msiexec.exe to uninstall different 
> components of python version, though all the components are uninstalled 
> successfully but still an entry for this version shows in the control panel 
> with the options: Modify, repair and uninstall. I am unable to identify which 
> component has still remained as a part of the installer.
> 
> Could you please help me resolve these issues.
> 
> Thanks,
> Tripura
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making 'compiled' modules work with multiple python versions on Linux

2024-04-02 Thread Barry via Python-list


> On 1 Apr 2024, at 18:14, Left Right via Python-list  
> wrote:
> 
> It sounds weird that symbols from Limited API are _missing_ (I'd
> expect them to be there no matter what library version you link with).

You have to specify the version of the limited API that you want to use.
Each release adds more symbols to the limited API.
So if you compile against 3.10 version it works with 3.10, 3.11, 3.12 etc,
but not with 3.9.

My pycxx project has test code that I use to verify pycxx’s use of python API.
You could check out the source and run my tests to see how things work.
It is on https://sourceforge.net/projects/cxx/

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to use pyinstaller under python 3.11, and, recently started receiving error message about specific module/distribution

2024-04-02 Thread Barry via Python-list


> On 1 Apr 2024, at 15:52, Jacob Kruger via Python-list 
>  wrote:
> 
> Found many, many mentions of errors, with some of the same keywords, but, no 
> resolutions that match my exact issue at all.

Try asking the pyinstaller developers. I think there is a mailing list.

Barry
> 
> 
> As in, most of them are mentioning older versions of python, and, mainly 
> different platforms - mac and linux, but, various google searches have not 
> mentioned much of using it on windows, and having it just stop working.
> 
> 
> Now did even try shifting over to python 3.12, but, still no-go.
> 
> 
> If launch pyinstaller under python 3.10 on this exact same machine, 
> pyinstaller runs - just keep that older version hovering around for a couple 
> of occasional tests, partly since some of my target environments are still 
> running older versions of python, but anyway.
> 
> 
> Also, not really relevant, but, cx_freeze is perfectly able to generate 
> executables for this same code, but, then not combining all output into a 
> single file - will stick to that for now, but, not always as convenient, and, 
> still wondering what changed here.
> 
> 
> Jacob Kruger
> +2782 413 4791
> "Resistance is futile!...Acceptance is versatile..."
> 
> 
>> On 2024/03/31 14:51, Barry wrote:
>> 
>>>> On 31 Mar 2024, at 13:24, Jacob Kruger via Python-list 
>>>>  wrote:
>>> 
>>> pkg_resources.DistributionNotFound: The 'altgraph' distribution was not 
>>> found and is required by the application
>> I think I have seen this error being discussed before…
>> 
>> A web search for pyinstaller and that error leads to people discussing why 
>> it happens it looks like.
>> 
>> Barry
>> 
>> 
> --
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying to use pyinstaller under python 3.11, and, recently started receiving error message about specific module/distribution

2024-03-31 Thread Barry via Python-list


> On 31 Mar 2024, at 13:24, Jacob Kruger via Python-list 
>  wrote:
> 
> pkg_resources.DistributionNotFound: The 'altgraph' distribution was not found 
> and is required by the application

I think I have seen this error being discussed before…

A web search for pyinstaller and that error leads to people discussing why it 
happens it looks like.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making 'compiled' modules work with multiple python versions on Linux

2024-03-29 Thread Barry Scott via Python-list


> On 29 Mar 2024, at 16:09, Olivier B.  
> wrote:
> 
> It is not a symlink on my system, where i built python myself, but a
> 15KB so file. But it seems to lack lots of python symbols.
> 
> Maybe what i should do is actually make libpython.so a physical copy
> of libpyton311.so before linking to it, so now on any system the
> module would look to load libpython.so, which could be pointing to any
> version. I'll try that next

You do not link against the .so at all. All the symbols you need are defined in 
the
python process that loads the extension. Try without the -lpython and it should
just work.

Barry


> 
> Le ven. 29 mars 2024 à 10:10, Barry  a écrit :
>> 
>> 
>> 
>>> On 28 Mar 2024, at 16:13, Olivier B. via Python-list 
>>>  wrote:
>>> 
>>> But on Linux, it seems that linking to libpython3.so instead of
>>> libpython3.11.so.1.0 does not have the same effect, and results in
>>> many unresolved python symbols at link time
>>> 
>>> Is this functionality only available on Windows?
>> 
>> Python limited API works on linux, but you do not link against the .so on 
>> linux I recall.
>> 
>> You will have missed that libpython3.so is a symlink to libpython3.11.so.10.
>> 
>> Windows build practices do not translate one-to-one to linux, or macOS.
>> 
>> Barry
>> 
>> 
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Making 'compiled' modules work with multiple python versions on Linux

2024-03-29 Thread Barry via Python-list



> On 28 Mar 2024, at 16:13, Olivier B. via Python-list  
> wrote:
> 
> But on Linux, it seems that linking to libpython3.so instead of
> libpython3.11.so.1.0 does not have the same effect, and results in
> many unresolved python symbols at link time
> 
> Is this functionality only available on Windows?

Python limited API works on linux, but you do not link against the .so on linux 
I recall.

You will have missed that libpython3.so is a symlink to libpython3.11.so.10.

Windows build practices do not translate one-to-one to linux, or macOS.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: EmPy 4.1 -- a powerful, robust and mature templating system for Python

2024-03-25 Thread Barry via Python-list
You should considered also announcing on https://discuss.python.org/ which is a 
lot more active then this list.

Barry


> On 25 Mar 2024, at 04:13, Erik Max Francis via Python-list 
>  wrote:
> 
> I'm pleased to announce the release of EmPy 4.1.
> 
> The 4._x_ series is a modernization of the software and a revamp of
> the EmPy system to update its feature set and make it more consistent
> with the latest Python versions and practices.  EmPy 4._x_ was also
> relicensed to BSD.
> 
> The 4._x_ series adds new markups, including inline comments,
> backquote literals, chained if-then-else extended expression,
> functional expressions, support for modern Pythonic controls,
> stringized and multiline significators, named escapes, diacritics,
> icons, and emojis.
> 
> It adds support for configuration objects (replacing options
> dictionaries); native support for Unicode, file buffering, reference
> counted `sys.stdout` proxies and error dispatchers and handlers; fixes
> several serious bugs; has a set of full unit and system tests, an
> extensive builtin help system; and the online documention has been
> rewritten and expanded.
> 
> Attempts have been made to make EmPy 4._x_ as backward compatible as
> is practical.  Most common markup has not changed; the only changes
> being removal of `repr` (in favor of backquote literals) as well as
> literal close parenthesis, bracket and brace markup; in-place markup
> has changed syntax (to make way for emojis); and custom markup is now
> parsed more sensibly.
> 
> Most backward-incompatible changes are in the embedding interface.
> The `Interpreter` constructor and global `expand` function now require
> keyword arguments to prevent further backward compatibility problems,
> though effort has been made to make the behavior as backward
> compatible as possible.  The supported environment variables have
> changed, as well as the filter, diversion and hook APIs, and options
> dictionaries no longer exist (in deference to configurations).
> 
> For a comprehensive list of changes from 3._x_ to 4._x_, see:
> <http://www.alcyone.com/software/empy/ANNOUNCE.html#changes>
> 
> 
> ## Introduction:  Welcome to EmPy!
> 
> [EmPy](http://www.alcyone.com/software/empy/) is a powerful, robust and mature
> templating system for inserting Python code in template text.  EmPy
> takes a source document, processes it, and produces output.  This is
> accomplished via expansions, which are signals to the EmPy system
> where to act and are indicated with markup.  Markup is set off by a
> customizable prefix (by default the at sign, `@`).  EmPy can expand
> arbitrary Python expressions, statements and control structures in
> this way, as well as a variety of additional special forms.  The
> remaining textual data is sent to the output, allowing Python to be
> used in effect as a markup language.
> 
> EmPy also supports hooks, which can intercept and modify the behavior
> of a running interpreter; diversions, which allow recording and
> playback; filters, which are dynamic and can be chained together; and
> a dedicated user-customizable callback markup.  The system is highly
> configurable via command line options, configuration files, and
> environment variables.  An extensive API is also available for
> embedding EmPy functionality in your own Python programs.
> 
> EmPy also has a supplemental library for additional non-essential
> features (`emlib`), a documentation building library used to create
> this documentation (`emdoc`), and an extensive help system (`emhelp`)
> which can be queried from the command line with the main executable
> `em.py` (`-h/--help`, `-H/--topics=TOPICS`).  The base EmPy
> interpreter can function with only the `em.py`/`em` file/module
> available.
> 
> EmPy can be used in a variety of roles, including as a templating
> system, a text processing system (preprocessing and/or
> postprocessing), a simple macro processor, a frontend for a content
> management system, annotating documents, for literate programming, as
> a souped-up text encoding converter, a text beautifier (with macros
> and filters), and many other purposes.
> 
> 
> ### Markup overview
> 
> Expressions are embedded in text with the `@(...)` notation;
> variations include conditional expressions with `@(...?...!...)`  and
> the ability to handle thrown exceptions with `@(...$...)`.  As a
> shortcut, simple variables and expressions can be abbreviated as
> `@variable`, `@object.attribute`, `@sequence[index]`,
> `@function(arguments...)`, `@function{markup}{...}` and
> combinations.  Full-fledged statements are embedded with `@{...}`.
> Control flow in terms of conditional or repeated expansion is
> available with `@[...]`.  A 

Re: the name ``wheel''

2024-03-24 Thread Barry via Python-list


> On 22 Mar 2024, at 20:28, Mats Wichmann via Python-list 
>  wrote:
> 
> pip is still a separate package in the .rpm world. which makes sense on a 
> couple of levels:

Yes it’s a separate package, but it’s always installed. At least on Fedora.
I agree it makes sense to package it separately, which is inline with Fedora’s
policy of not vendoring code into a package.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the name ``wheel''

2024-03-22 Thread Barry via Python-list


> On 22 Mar 2024, at 15:25, Gilmeh Serda via Python-list 
>  wrote:
> 
>> Many if not most Linux distributions do not include pip by default.
> 
> Really? It came with Manjaro.

Debian and Ubuntu require you to install pip as a separate package.
Also puts venv in its own package.

Fedora leaves all the batteries intact and rhel I assume.

Barry





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-16 Thread Barry via Python-list


> On 15 Mar 2024, at 19:51, Thomas Passin via Python-list 
>  wrote:
> 
> I've always like writing using the "or" form and have never gotten bit

I, on the other hand, had to fix a production problem that using “or” 
introducted.
I avoid this idiom because it fails on falsy values.

Barry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Barry via Python-list


> On 10 Mar 2024, at 14:49, Thomas Passin via Python-list 
>  wrote:
> 
> That and there's a registry setting:
> 
> https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
> 
Yep that and rules about size of parts of the path.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pathlib.Path.is_file vs os.path.isfile difference

2024-03-10 Thread Barry via Python-list



> On 8 Mar 2024, at 23:19, Thomas Passin via Python-list 
>  wrote:
> 
> We just learned a few posts back that it might be specific to Linux; I ran it 
> on Windows.

Depending on the exact win32 api used there is a 257 limit on windows.
The 257 includes 2 for the device, C:, and 255 for the path part that will use 
1 for the leading \. Getting an error for a name that is 255 is not surprising.

Other api allow for 65535 limit, not sure on its additional limits.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem resizing a window and button placement

2024-02-24 Thread Barry via Python-list



> On 24 Feb 2024, at 04:36, Steve GS via Python-list  
> wrote:
> 
> How do I extract the values
> from args?

You can look up the args in documentation.
You can run the example code MRAB provided and see what is printed to learn 
what is in the args.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Feature proposal: unittest.mock.NAN

2024-01-24 Thread Barry Scott via Python-list
Python ideas are discussed here these days: https://discuss.python.org/
Suggest you raise this there in the Ideas category.

Barry


> On 24 Jan 2024, at 17:11, Kerrick Staley via Python-list 
>  wrote:
> 
> I think we should define a unittest.mock.NAN constant that can be used with
> Mock.assert_called_with() to assert that an argument passed to a Mock was
> NaN. NaNs are special in that math.nan != math.nan, so you can't just do
> assert_called_with(math.nan). The naming is meant to parallel
> unittest.mock.ANY.
> 
> Here is a reference implementation:
> 
> class _EqNaN:
>def __eq__(self, other):
>return math.isnan(other)
> 
> NAN = _EqNaN()
> 
> The alternative is that users can just define this EqNaN class themselves
> as needed in test code. I encountered the need to test for a NaN argument
> today and was surprised to find that (as far as I can tell) there is no
> pre-built solution to this in unittest or pytest. It feels like it should
> be included in some standard library.
> 
> - Kerrick
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-16 Thread Barry via Python-list


> On 16 Jan 2024, at 17:11, Sibylle Koczian via Python-list 
>  wrote:
> 
> while the new Windows 11 machine finds the Microsoft stub

You can turn off the stub in windows settings. The magic windows jargon is
“App Execution Aliases”. Once you find it in settings you can turn off
the python and python3 aliases.

Barry




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about garbage collection

2024-01-16 Thread Barry via Python-list



> On 16 Jan 2024, at 12:10, Frank Millman via Python-list 
>  wrote:
> 
> My problem is that my app is quite complex, and it is easy to leave a 
> reference dangling somewhere which prevents an object from being gc'd.

What I do to track these problems down is use gc.get_objects() then summerize 
the number of each type. Part 2 is to print the delta after an interval of a 
2nd summary.
Leaks of objects show up as the count of a type increasing every time you 
sample.


Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about garbage collection

2024-01-16 Thread Barry via Python-list



> On 16 Jan 2024, at 13:17, Thomas Passin via Python-list 
>  wrote:
> 
> The usual advice is to call deleteLater() on objects derived from PyQt 
> classes.  I don't know enough about PyQt to know if this takes care of all 
> dangling reference problems, though.

It works well and robustly.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about garbage collection

2024-01-16 Thread Barry via Python-list



> On 16 Jan 2024, at 03:49, Thomas Passin via Python-list 
>  wrote:
> 
> This kind of thing can happen with PyQt, also.  There are ways to minimize it 
> but I don't know if you can ever be sure all Qt C++ objects will get deleted. 
> It depends on the type of object and the circumstances.

When this has been seen in the past it has been promptly fixed by the 
maintainer.

Barry




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-09 Thread Barry Scott via Python-list



> On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list 
>  wrote:
> 
> Oh, and the two Windows and Python versions are on two different computers.
> 
> Will remove the "/env" from my shebang lines, even if I don't understand 
> what's happening.

Thanks for the details.

Only thing I can think of is that "python" may be defaulting to mean python 2.
If you use "#!/usr/bin/env python3" it may work on both.

Did you creates a py.ini file to configure py.exe?

See if you have %userappdata%\py.ini on either windows 10 or windows 11.
If so what is its contents?

I've tried with and without a py.ini and cannot duplicate what you see.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-03 Thread Barry Scott via Python-list



> On 2 Jan 2024, at 17:24, Thomas Passin via Python-list 
>  wrote:
> 
> You might learn about this if you happen to read and remember the right part 
> of the Python docs.  Otherwise you have no idea what py.exe is up to nor how 
> it does it.  I would say that most people don't know there's an ini file, let 
> alone what it can do.  Of course this situation isn't unique to py.exe!

On discuss.python.org we will share the link to the python windows docs and
often to this specific section: 
https://docs.python.org/3/using/windows.html#python-launcher-for-windows

To create a py.ini does require a user to understand what %localappdata% means.
Some windows users, reasonable, do not use the CLI and know about that syntax 
for environment variables.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-01 Thread Barry via Python-list



> On 1 Jan 2024, at 11:14, Sibylle Koczian via Python-list 
>  wrote:
> 
> But in all this thread I didn't see a single explanation for my current 
> situation: one and the same shebang line works on Windows 10 / Python 3.11 
> and doesn't work on Windows 11 / Python 3.12. I suspect Windows, because a 
> change in the way Python 3.12 uses shebang lines should be visible in the 
> documentation.

See my earlier reply with info on ftype etc output.
What do you see on your windows 10 vs windows 11?

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: mypy question

2023-12-30 Thread Barry via Python-list



> On 30 Dec 2023, at 15:11, Karsten Hilbert via Python-list 
>  wrote:
> 
> queries = [{'SQL': 'SELECT %(value)s', 'args': {'value': 1}}]
> 
> and
> 
> run_queries(conn, queries:list[str|dict[str, Any]]):

In cases like this I often use a wrapper class in place of a simple str.
If you have a class SqlString then your type becomes list[SqlString].

You may find that SqlString gains interesting methods over time.

 Barry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-24 Thread Barry via Python-list



> On 24 Dec 2023, at 00:54, rbowman via Python-list  
> wrote:
> 
> Does that work with virtualenv or conda? I'm slowly getting up to speed
> with those.

Conda is its own thing, not need for py.exe.

Once you have created the venv you do not need py.exe as you will have 
pythob.exe in the venv bin folder.

Barry



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is Install-Paths-To in WHEEL file?

2023-12-24 Thread Barry via Python-list



> On 24 Dec 2023, at 00:58, Left Right via Python-list  
> wrote:
> 
> I'm trying to understand the contents of Wheel files

There are lots of packaging experts that hang out on 
https://discuss.python.org/ you are likely to get a response there if not here 
replies.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread Barry Scott via Python-list



> On 23 Dec 2023, at 03:01, Thomas Passin via Python-list 
>  wrote:
> 
> Not on my system. It may depend on whether Python gets installed to Program 
> Files or to %USERPROFILE%/AppData/Local/Programs/Python.  Python 3.9 is the 
> last verson I installed to Program Files, and that's the version that Windows 
> thinks it should use to run Python files.
> 
> Run the little test program I posted.  That will tell you which version of 
> Python the system wants to use.

I always install for all users and this what I get on my Windows 10 and 11 
systems.
As you can see the shebang lines do what is expected based on the config of 
py.exe.

Maybe it works differently if you install for a single user only,
I do not have such a setup to test with.

Windows 10 output.

K:\shebang>py -0 
 -V:3.13  Python 3.13 (64-bit)
 -V:3.13-32   Python 3.13 (32-bit)
 -V:3.12 *Python 3.12 (64-bit)
 -V:3.12-32   Python 3.12 (32-bit)
 -V:3.11  Python 3.11 (64-bit)
 -V:3.11-32   Python 3.11 (32-bit)
 -V:3.10  Python 3.10 (64-bit)
 -V:3.10-32   Python 3.10 (32-bit)
 -V:3.9   Python 3.9 (64-bit)
 -V:3.9-32Python 3.9 (32-bit)
 -V:3.8   Python 3.8 (64-bit)
 -V:3.8-32Python 3.8 (32-bit)
 -V:3.7   Python 3.7 (64-bit)
 -V:3.7-32Python 3.7 (32-bit)
 -V:3.6   Python 3.6 (64-bit)
 -V:3.6-32Python 3.6 (32-bit)
 -V:3.5   Python 3.5
 -V:3.5-32Python 3.5-32
 -V:3.4   Python 3.4
 -V:3.4-32Python 3.4-32
 -V:2.7   Python 2.7
 -V:2.7-32Python 2.7-32

K:\shebang>type shebang_py2.py 
#!/usr/bin/python2
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

K:\shebang>py shebang_py2.py 
I am python sys.version_info(major=2, minor=7, micro=17, releaselevel='final', 
serial=0)

K:\shebang>shebang_py2.py
I am python sys.version_info(major=2, minor=7, micro=17, releaselevel='final', 
serial=0)

K:\shebang>type shebang_py3.py 
#!/usr/bin/python3
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

K:\shebang>py shebang_py3.py 
I am python sys.version_info(major=3, minor=12, micro=1, releaselevel='final', 
serial=0)

K:\shebang>shebang_py3.py
I am python sys.version_info(major=3, minor=12, micro=1, releaselevel='final', 
serial=0)

K:\shebang>type shebang_env_py3.py 
#!/usr/bin/env python3
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

K:\shebang>py shebang_env_py3.py 
I am python sys.version_info(major=3, minor=12, micro=1, releaselevel='final', 
serial=0)

K:\shebang>shebang_env_py3.py
I am python sys.version_info(major=3, minor=12, micro=1, releaselevel='final', 
serial=0)

K:\shebang>type shebang_env_py3_10.py 
#!/usr/bin/env python3.10
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

K:\shebang>py shebang_env_py3_10.py 
I am python sys.version_info(major=3, minor=10, micro=11, releaselevel='final', 
serial=0)

K:\shebang>shebang_env_py3_10.py
I am python sys.version_info(major=3, minor=10, micro=11, releaselevel='final', 
serial=0)

K:\shebang>assoc .py 
.py=Python.File

K:\shebang>ftype Python.File 
Python.File="C:\WINDOWS\py.exe" "%L" %*


Windows 11 output


: 11:52:10.36 K:\shebang
: \\BARNSTONE\barry> py -0 
 -V:3.12 *Python 3.12 (64-bit)
 -V:3.12-32   Python 3.12 (32-bit)
 -V:3.11  Python 3.11 (64-bit)
 -V:3.11-32   Python 3.11 (32-bit)
 -V:3.10  Python 3.10 (64-bit)
 -V:3.9   Python 3.9 (64-bit)
 -V:3.9-32Python 3.9 (32-bit)
 -V:3.8   Python 3.8 (64-bit)
 -V:3.8-32Python 3.8 (32-bit)

: 11:52:10.40 K:\shebang
: \\BARNSTONE\barry> type shebang_py2.py 
#!/usr/bin/python2
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

: 11:52:10.41 K:\shebang
: \\BARNSTONE\barry> py shebang_py2.py 
No suitable Python runtime found
Pass --list (-0) to see all detected environments on your machine
or set environment variable PYLAUNCHER_ALLOW_INSTALL to use winget
or open the Microsoft Store to the requested version.

: 11:52:10.47 K:\shebang
: \\BARNSTONE\barry> type shebang_py3.py 
#!/usr/bin/python3
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

: 11:52:10.49 K:\shebang
: \\BARNSTONE\barry> py shebang_py3.py 
I am python sys.version_info(major=3, minor=12, micro=0, releaselevel='final', 
serial=0)

: 11:52:10.52 K:\shebang
: \\BARNSTONE\barry> shebang_py3.py
I am python sys.version_info(major=3, minor=12, micro=0, releaselevel='final', 
serial=0)

: 11:52:10.58 K:\shebang
: \\BARNSTONE\barry> type shebang_env_py3.py 
#!/usr/bin/env python3
from __future__ import print_function
import sys
print('I am python %r' % (sys.version_info,))

: 11:52:10.60 K:\sheba

Re: making your own DirEntry.

2023-12-23 Thread Barry Scott via Python-list



> On 23 Dec 2023, at 09:48, Antoon Pardon via Python-list 
>  wrote:
> 
> Because I have functions with DirEntry parameters.

I would duck-type a class I control to be my DirEnrry in this situation.
Would also help you when debugging as you can tell injected DirEntry from 
"real" DirEntry.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Barry via Python-list



> On 23 Dec 2023, at 00:15, Thomas Passin via Python-list 
>  wrote:
> 
> In neither case is the shebang line used.

As i understand it, not in front of my windows box to check.
The handler for .py file extension is set to be the py.exe
It is py.exe that understands shebang lines.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Barry via Python-list



> On 22 Dec 2023, at 14:58, Christian Buhtz via Python-list 
>  wrote:
> 
> On Windows 11 it usually is the "Terminal" which is different from cmd.exe.

In terminal app you can run cmd.exe or powershell, so it is basically the same.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Barry via Python-list



> On 22 Dec 2023, at 14:29, Sibylle Koczian  wrote:
> 
> #!/usr/bin/env/python

That was what i thought you had and it will not work.

The BOM suggestion is worth trying.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Barry via Python-list


> On 22 Dec 2023, at 12:39, Sibylle Koczian via Python-list 
>  wrote:
> 
> Hello,
> 
> I always install Python on Windows in the same manner:
> 
> - Python is not on the path,
> - it is installed for all users,
> - the Python Launcher is installed for all users,
> - the file types .py, .pyw etc. are associated with Python.
> 
> My shebang line is usually "#!/usr/bin/env python3".
> 
> This has always worked well. I could run Python scripts in a console
> window entering just the script name, by double clicking in the explorer
> or using WIN+r; the two last variants for GUI or for scripts with
> something like "input('Leave with Enter')" at the end.
> 
> Now I've got a new computer with Windows 11 and I've installed Python
> 3.12.1. On my older machine it's Windows 10 and Python 3.11.5. Reading
> the Python documentation it seems my shebang lines should work as before
> - but they don't. The error message:
> 
> "Unable to create process using 'C:\usr\bin\env\python
> "C:\Eigen\Src\launcher_versuche.py" ': Das System kann die angegebene
> Datei nicht finden."
> 
> Without the "env" in the shebang line and only without it everything
> works as expected - but that's contrary to the documentation, isn't it?

This suggests a typo in the shebang line. Is there a space between env and 
python?

Barry


> 
> Thank you for information,
> Sibylle
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Barry Scott via Python-list



> On 6 Dec 2023, at 09:32, Chris Green via Python-list  
> wrote:
> 
> My requirement is *slightly* more complex than just key value pairs,
> it has one level of hierarchy, e.g.:-
> 
>KEY1:
>  a: v1
>  c: v3
>  d: v4
>KEY2:
>  a: v7
>  b: v5
>  d: v6
> 
> Different numbers of value pairs under each KEY.

JSON will allow you to nest dictionaries.

{
'KEY1': {
'a': v1
'c': v3
'd': v4
}
'KEY2': {
 'a': v7
 'b': v5
 'd': v6
}
}

Personally I would not use .ini style these days as the format does not include 
type of the data.

Also I would not use the ast.literal_eval as it makes debugging errors in the 
data harder.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Barry Scott via Python-list



> On 5 Dec 2023, at 14:37, Chris Green via Python-list  
> wrote:
> 
> Are there any Python modules aimed specifically at this sort of
> requirement?

I tend to use JSON for this type of thing.
Suggest that you use the options to pretty print the json that is saved so that 
a human can read it.

For example:

import json

config = {
'key2': 42,
'key1': 'value 1',
}

print(json.dumps(config, indent=4, separators=(', ', ': '), sort_keys=True))


% python $T/a.py
{
"key1": "value 1",
"key2": 42
}

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request: inspect: signature & getfullargspec & getcallargs

2023-12-04 Thread Barry Scott via Python-list



> On 4 Dec 2023, at 02:29, Dom Grigonis via Python-list 
>  wrote:
> 
> Hello,
> 
> I have a request.
> 
> Would it be possible to include `follow_wrapper_chains` and `skip_bound_arg` 
> arguments to higher level functions of `inspect` module?
> 
> Would exposing them, but setting defaults to what they currently are, be 
> possible?
> 
> I sometimes need:
>   * `getcallargs`, but without `bound_arg`
>   * `getfullargspec` to `follow_wrapper_chains`
>   * `signature` to include `bound_arg`.

I suspect that you need to raise this as an idea on https://discuss.python.org/ 
to get the attention of the core devs.

Barry

> 
> 
> Regards,
> DG
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xor operator

2023-11-13 Thread Barry via Python-list



> On 13 Nov 2023, at 17:48, Dom Grigonis  wrote:
> 
> Short circuiting happens, when:
> xor([True, True, False, False], n=1)
> At index 1 it is clear that the answer is false.

Can you share an example with 4 values that is true?
And explain why it is xor.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: No current way to just compile flet code into truly native packages for smart phones, etc.?

2023-11-13 Thread Barry via Python-list


> On 13 Nov 2023, at 17:21, Jacob Kruger via Python-list 
>  wrote:
> 
> Had a look at the following bit of introduction to using python and flet to 
> build cross-platform flutter-based apps using same python code, and, while it 
> seems to work alright if tell it to run as under GUI here on windows desktop, 
> and, while can get it to fire up PWA version as well, that's not really 
> stand-alone since will still require code to be running in background, and, 
> in terms of, for example, android, it seems like it will need to then be 
> running via the native android flet interpreter for it to work as such?
> 
> 
> https://flet.dev/docs/
> 
> 
> Flet PWA deployment 
> <https://flet.dev/docs/guides/python/deploying-web-app/progressive-web-apps/>

flet looks interesting. It seems from the road map there is lots missing today.
Also the people that know flet are on discord. You may find someone here.

Barry

> 
> --
> 
> Jacob Kruger
> +2782 413 4791
> "Resistance is futile!...Acceptance is versatile..."
> 
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: xor operator

2023-11-13 Thread Barry via Python-list



> On 13 Nov 2023, at 15:16, Dom Grigonis via Python-list 
>  wrote:
> 
> I think it could be useful to have `xor` builtin, which has API similar to 
> the one of `any` and `all`.

I do not understand how xor(iterator) works.
I thought xor takes exactly 2 args.

I also do not understand how xor can be short circuited.
For AND or OR only looking at the first arg works.
But that does not work for xor right?

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-24 Thread Barry via Python-list



> On 24 Oct 2023, at 18:25, o1bigtenor via Python-list  
> wrote:
> 
> Is there a way to verify that a program is going to do what it is
> supposed to do

In the general case not proven to be not possible.
Have a read about the halting problem 
https://en.wikipedia.org/wiki/Halting_problem

It is common to simulate hardware that does not exist yet and run software in 
the simulated environment.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Barry via Python-list
 On 2 Oct 2023, at 16:02, Jen Kris via Python-list
  wrote:

 Iwant to write a list of 64-bit integers to a binary file.  Everyexample
 I have seen in my research convertsit to .txt, but I want it in binary.
  I wrote this code,based on some earlier work I have done:
 buf= bytes((len(qs_array)) * 8)

   buf is not writable so cannot be used by pack_into. I think you need to
   use bytesarray not bytes.

 foroffset in range(len(qs_array)):
 item_to_write= bytes(qs_array[offset])
 struct.pack_into(buf,"https://mail.python.org/mailman/listinfo/python-list

References

   Visible links
   1. Permalink to this definition
https://docs.python.org/3/library/struct.html#struct.pack_into
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type annotation vs working code

2023-10-01 Thread Barry via Python-list



> On 1 Oct 2023, at 19:36, Richard Damon via Python-list 
>  wrote:
> 
> Perhaps a better method would be rather than just using the name and catching 
> the exception, use a real already_initialized flag (set to True when you 
> initialize), and look it up with getattr() with a default value of False.
I would use a class variable not an instance variable.

class OnlyOne:
   sole_instance = None
   def __init__(self):
  assert OnlyOne.sole_instance is None
  OnlyOne.sole_instance = self

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: venv --upgrade 3.12.0rc2 --> 3.12.0rc3 failure

2023-09-28 Thread Barry via Python-list



> On 27 Sep 2023, at 12:50, Robin Becker via Python-list 
>  wrote:
> 
> Attempting venv upgrade  3.12.0rc2 --> 3.12.0rc3 I find pyvenv.cfg changes, 
> but the virtual python doesn't.
> I guess this ought to be a bug.

You must delete and then recreate the venv if the version of python changes.
It is not a bug in python.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: `time.perf_counter_ns` always a 64-bit int?

2023-09-16 Thread Barry via Python-list


> On 15 Sep 2023, at 23:00, rmlibre--- via Python-list  
> wrote:
> 
> I'd like to capture the output of `time.perf_counter_ns()` as an 8-byte
> timestamp.
> 
> I'm aware that the docs provide an undefined start value for that clock.
> I'm going to assume that means it can't be expected to fit within 8
> bytes. However, it would be rather convenient if it could. Does anyone
> know if any such platform agnostic assumption could be made for any
> fixed number of bytes, even if it isn't exactly 8 bytes?

If you read the source code the value is stored in a 64 bit int for unix and 
windows.

There is a comment that it covers the range of +-232 years.

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding good documentation for gpiod

2023-09-03 Thread Barry via Python-list
E

> On 3 Sep 2023, at 22:49, Chris Green via Python-list  
> wrote:
> 
> Mostly I am managing to get things to work as I want but better
> documentation of gpiod would be a great help.

Ask the author? https://github.com/aswild/python-gpiod

Maybe read the source code for hints?

Barry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-18 Thread Barry via Python-list


> On 17 Aug 2023, at 15:01, c.buhtz--- via Python-list  
> wrote:
> 
> I want to display one string in its original source (untranslated) version 
> and in its translated version site by site without duplicating the string in 
> the python source code?
> It wouldn't be a big deal if it is only one word.

The key to solving this to separate the parsing of the string into the .po file 
and its translation.

def i18n(s):
  return s

msg = i18n(‘my message’)

print(_(msg))
print(msg)

Now you tell the xgettex, pygettext etc, to parse to use “i18n” to find strings 
to translate.

This is covered in the docs at 
https://docs.python.org/3/library/gettext.html#localizing-your-module

Barry





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where is the error?

2023-08-07 Thread Barry via Python-list



> On 7 Aug 2023, at 05:28, Cameron Simpson via Python-list 
>  wrote:
> 
> Used to use a Pascal compiler once which was uncannily good at suggesting 
> where you'd missing a semicolon.

Was that on DEC VMS? It was a goal at DEC for its compilers to do this well.
They could output the errors in a machine readable format to allow editors to 
auto fix.

I am learning rust and it is very good at suggesting fixes.
There is a command to apply fixes automatically, cargo fix.

Barry




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Canonical list of Python security vulnerabilities

2023-07-14 Thread Barry via Python-list


> On 14 Jul 2023, at 19:14, Bob Kline via Python-list  
> wrote:
> 
> Can someone point me to the official catalog of security vulnerabilities in
> Python (by which I mean cpython and the standard libraries)? I found
> https://www.cvedetails.com/vulnerability-list/vendor_id-10210/product_id-18230/Python-Python.html
> but that isn't maintained by python.org. I also found
> security-annou...@python.org, but there hasn't been anything posted there
> in over a year as far as I can tell, and even before that it's pretty thin.
> 
> If there's a better place to ask, please advise.

Where do you get your python from?

You may find that the organisation that packages python that you use has such a 
list.

Barry
> 
> Thanks.
> 
> -- 
> Bob Kline
> https://www.rksystems.com
> mailto:bkl...@rksystems.com
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Should NoneType be iterable?

2023-06-20 Thread Barry via Python-list



> On 20 Jun 2023, at 01:57, Greg Ewing via Python-list  
> wrote:
> 
> I would question the wisdom of designing an API that
> can return either a sequence or None.

I have some APIs that do return None or a list.
The None says that a list is not available and that the caller is
responsible with dealing in a application-domain specific with
with that situation.

In other cases I have API that returns a default list, often [].

It all depends on the design needs.

Barry



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation

2023-06-07 Thread Barry via Python-list


> On 7 Jun 2023, at 16:39, Florian Guilbault via Python-list 
>  wrote:
> 
> Dear Python Technical Team,
> 
> I hope this email finds you well. I am reaching out to you today to seek
> assistance with an issue I am facing regarding the installation of 'pip'
> despite my numerous attempts to resolve the problem.
> 
> Recently, I performed installation, uninstallation, and even repair
> operations on Python 3.10 on my computer. However, I have noticed that
> 'pip' has never been installed successfully. When I check via the command
> prompt, I receive the following error: "'pip' is not recognized as an
> internal or external command, operable program, or batch file."
> 
> I have tried several approaches to resolve this issue. I have verified that
> the PATH environment variable is correctly configured to include the path
> to the Python Scripts directory. I have also attempted to run the
> 'get-pip.py' installation script from the command line, but it did not work
> either.
> 
> I am aware that 'pip' is typically installed automatically with Python, but
> I am encountering this persistent difficulty. Therefore, I would like to
> request your assistance and expertise in resolving this 'pip' installation
> issue. I would like to be able to use 'pip' to manage my Python packages
> efficiently.
> 
> I am open to any suggestions and steps you can provide to help me resolve
> this problem. Please note that I am a user on the Windows operating system.
> 
> Thank you sincerely for your attention and support. I eagerly await your
> guidance to resolve this situation.

You can run pip like this, that works with needing to mess with your PATH.

py -m pip

Barty


> 
> Best regards,
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: complaint

2023-05-30 Thread Barry


> On 30 May 2023, at 21:10, Daniel Ifechukwude Dibie  
> wrote:
> 
> i tried to uninstall the python 3.11.3 program from my machine so that i
> can re-install it is showing successful but it is ligerning on the program
> and features

Maybe what you are seeing is the microsoft app store stubs for python?
The python.org uninstall always works in my experience, but is not related to 
the app store stubs.

Also why do you think you need to reinstall python?
It would be very unusual that that would be necessary.

Barry
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does IDLE use a subprocess?

2023-05-30 Thread Barry


> On 30 May 2023, at 21:10, James Schaffler via Python-list 
>  wrote:
> 
> Originally posted to idle-dev, but thought this might be a better place. Let 
> me know if it isn't.
> 
> Hi,
> 
> I was curious about the internals of IDLE, and noticed that IDLE uses 
> executes user code in a "subprocess" that's separate from the Python 
> interpreter that is running IDLE itself (which does tasks such as making the 
> window and coloring the text).
> 
> As far as I understand, IDLE runs a modified version of 
> code.InteractiveInterpreter by sending user code through a socket. Even the 
> IDLE documentation says that without a subprocess, "user code is not isolated 
> from IDLE itself." However, some minimal testing of InteractiveInterpreter 
> leads me to believe that the Interpreter object has its own view of 
> local/global variables and therefore shouldn't be able to affect the calling 
> interpreter (please correct me if I'm wrong).
> 
> So my question is a combination of "Why does IDLE use a subprocess?" and "Why 
> is InteractiveInterpreter not secureuldenough?" What possible security 
> vulnerabilities exist if one uses IDLE without the subprocess? If anyone 
> knows (or could point me to information on) why IDLE is designed this way, 
> I'd really appreciate it. Thank you!

I don’t think it security but robustness that needs the subprocess.

You can crash idle with bugs in the code that you are developing.
By running your code in a subprocess idle protects itself, and your edits from 
bugs in your code.

Also if your code use tk then it would conflict with idle’s use of tk.

That is my assumption on why the subprocess is required.

Barry

> 
> Jim
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Barry Scott



> On 19 May 2023, at 07:44, Grizzy Adams via Python-list 
>  wrote:
> 
> Morning All
> 
> I'm working through the tutorial and running / saving work that I wish to 
> keep 
> and build on, most times I can save and (re)import later with no difference 
> to 
> when typed in console or editor and run with F5 (which saves before it can 
> run) 
> 
> 
> But sometimes saved work (albeit small) when imported does not work any longer
> 
> I assume I have missed something, any pointers to what/how/why please

reimport is not 100% reliable, in simple cases it will work, but as your
code gets more complex it can break.

I rarely use reimport. Usually just exit python and start again.

If you are working on scripts then just run them from the Terminal
will work well with any need to use reimport.

Barry

> 
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Barry
 On 18 May 2023, at 13:56, Jason Qian  wrote:

 
 Hi Barry,
 void handleError(const char* msg)
 {
 ...
 PyErr_Fetch(, , );
 PyErr_NormalizeException(, , );

 PyObject* str_value = PyObject_Repr(pyExcValue);
 PyObject* pyExcValueStr = PyUnicode_AsEncodedString(str_value, "utf-8",
 "Error ~");
 const char *strErrValue = PyBytes_AS_STRING(pyExcValueStr);
 //where   strErrValue   = "ImportError('Error: Reinit is forbidden')"
 ...
 }
 What we imported is a Python file which import some pyd libraries.

   Please do not top post replies.
   Ok so assume the error is correct and hunt for the code that does the
   reimport.
   You may need to set break points in you C code to find tnw caller.
   Barry

 Thanks 
 Jason 
 On Thu, May 18, 2023 at 3:53 AM Barry <[1]ba...@barrys-emacs.org> wrote:

   > On 17 May 2023, at 20:35, Jason Qian via Python-list
   <[2]python-list@python.org> wrote:
   >
   >  Hi,
   >
   >   I Need some of your help.
   >
   > I have the following C code to import *Import python.*   It works
   99% of
   > the time, but sometimes  receives  "*ImportError('Error: Reinit is
   > forbidden')*". error.
   > **We run multiple instances of the app parallelly.
   >
   > *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51)
   [MSC
   > v.1914 64 bit (AMD64)]
   >
   > PyObject * importPythonModule(const char* pmodName)
   > {
   >    const char* errors = NULL;
   >     int nlen = strlen(pmodName);
   >     PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
   >     PyObject *pModule = *PyImport_Import*(pName);
   >     Py_DECREF(pName);
   >     if (pModule == NULL) {
   >     if (*PyErr_Occurred*()) {
   >            handleError("PyImport_Import()");
   >      }
   >   }
   > }
   > void handleError(const char* msg)
   > {
   >  ...
   >  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
   > }

   You do not seem to printing out msg, you have assumed it means reinit
   it seems.
   What does msg contain when it fails?

   Barry
   >
   >
   > Thanks
   > Jason
   > --
   > [3]https://mail.python.org/mailman/listinfo/python-list
   >

References

   Visible links
   1. mailto:ba...@barrys-emacs.org
   2. mailto:python-list@python.org
   3. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on ImportError('Error: Reinit is forbidden')

2023-05-18 Thread Barry


> On 17 May 2023, at 20:35, Jason Qian via Python-list  
> wrote:
> 
>  Hi,
> 
>   I Need some of your help.
> 
> I have the following C code to import *Import python.*   It works 99% of
> the time, but sometimes  receives  "*ImportError('Error: Reinit is
> forbidden')*". error.
> **We run multiple instances of the app parallelly.
> 
> *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC
> v.1914 64 bit (AMD64)]
> 
> PyObject * importPythonModule(const char* pmodName)
> {
>const char* errors = NULL;
> int nlen = strlen(pmodName);
> PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
> PyObject *pModule = *PyImport_Import*(pName);
> Py_DECREF(pName);
> if (pModule == NULL) {
> if (*PyErr_Occurred*()) {
>handleError("PyImport_Import()");
>  }
>   }
> }
> void handleError(const char* msg)
> {
>  ...
>  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
> }

You do not seem to printing out msg, you have assumed it means reinit it seems.
What does msg contain when it fails?

Barry
> 
> 
> Thanks
> Jason
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pip Error

2023-05-17 Thread Barry


> On 17 May 2023, at 17:26, Aysu Mammadli  wrote:
> 
> I encountered an error while attempting to install pip using the terminal.
> The exact error message I received is:
> 
> "An error occurred during configuration: option use-feature: invalid
> choice: '2020-resolver' (choose from 'fast-deps', 'truststore',
> 'no-binary-enable-wheel-cache')"
> 
> Here are the steps I followed and the context of my system:
> 
> Operating System: Windows 11 Python Version: 3.11.3 I executed the command
> in the terminal to install pip, but it resulted in the aforementioned error
> message. This error specifically references the '2020-resolver' choice
> within the 'use-feature' option. An error occurred during configuration:
> option use-feature: invalid choice: '2020-resolver' (choose from
> 'fast-deps', 'truststore', 'no-binary-enable-wheel-cache')
> 
> I have already attempted the following troubleshooting steps without
> success:
> 
> Checked my internet connectivity to ensure it was stable and not causing
> any issues. Verified that I have the latest version of pip installed, as
> well as the latest version of Python. Tried using alternative commands,
> such as using the --upgrade flag or specifying a specific pip version, but
> the error persists. Looked for any recent system updates or changes that
> could have caused this issue, but found none. I'm uncertain about the cause
> of this error and how to resolve it. Any insights or suggestions would be
> greatly appreciated.
> 
> Thank you in advance for your assistance!

Pip is installed by default with the python.org kits.
I am not sure what the situation is for the app store python.

Can you run python it self?

Does one of these work for you?

py -m pip
python -m pip

If so you have pip installed.

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PythonPath / sys.path

2023-05-15 Thread Barry


> On 15 May 2023, at 05:39, Thomas Passin  wrote:
> 
> On 5/14/2023 11:08 PM, Chris Angelico wrote:
>>> On Mon, 15 May 2023 at 12:07, Thomas Passin  wrote:
>>> Well, no, why would you assume that?  I started to use Linux - in VMs -
>>> because I had to make sure that my cross-platform java/jython Tomcat
>>> program would work right on Linux.  Why, for example, would I think to
>>> install Idle from the package manager when it, or things like that, were
>>> always in my experience installed with pip? For that matter, "sudo
>>> apt-get install pip" won't install pip.  You need to use a different
>>> name, and it may or may not be different for different distros.
>> If you EVER had to install something other than a Python package, you
>> would have had to make use of the system package manager. You're
>> right, there are multiple obvious ways to install Idle, but that
>> doesn't mean that the package manager isn't one of them.
> 
> Yes, after a while I came to realize that missing Python pieces might be 
> available from the package manager.  That doesn't mean it's obvious, or easy 
> to discover just what names to use.  And sometimes one has to add a new 
> external repository.  Personally, I don't find it easy to scroll through 
> hundreds of lines in the synaptics search results looking for something whose 
> name I can only partly guess at.  If I know the command line equivalent for a 
> search, I could do a grep and that would probably be more focused.  But 
> trying to work with a dozen different distros because various clients might 
> use them - it's hard to keep details straight.
> 
> Anyway, there's no point in trying to convince me that I could have 
> understood everything at the start that I may have learned later.  I'm just 
> interested in passing on things I've learned along that way that a newcomer 
> to Python in Linux may not realize.

Being a Fedora user i needed to learn how to install missing pieces of pyrhon 
on ubuntu.

We searches for:
ubuntu install pip
Ubuntu install idle

Both provide lots of answers. Did your searches fail to turn up answers?

Barry


> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PythonPath / sys.path

2023-05-14 Thread Barry


> On 14 May 2023, at 16:32, Grizzy Adams via Python-list 
>  wrote:
> 
> Hi All
> 
> My first post (repeated)
> 
> I am having a problem with PythonPath / sys.path
> 
> I have a dir where I keep all my current work, but I can't seem to add it to 
> PythonPath / sys.path
> 
> When I try to import one of my modules I see
> 
>>>> import My_Working_File
> Traceback (most recent call last):
>  File "", line 1, in 
>import My_Working_File
> ImportError: No module named 'My_Working_File'
> 
> I have tried adding my dir in registry to the existing PythonPath 
> 
> [HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\PythonPath]
> @="D:\\Shades\\Tools\\Python\\Lib;D:\\Shades\\Tools\\Python\\DLLs"
> 
> that did not help, 
> 
> I tried adding PYTHONPATH as an enviramental variable, that also had no effect
> 
> (I did re-boot after these two tests)
> 
> If I go to the editor window and run (F5) any of my modules then I can 
> 
>>>>  RESTART 
>>>> 
>>>> import My_Working_File
>>>> 
> 
> without error
> 
> I can also (from a fresh start) 
> 
>>>> import sys
>>>> sys.path.append(r'D:\Shades\Tools\Python\MyWork')
>>>> print(sys.path)
> ['', 'D:\\Shades\\Tools\\Python\\Lib\\idlelib', 
> 'D:\\Shades\\Tools\\Python\\python34.zip', 'D:\\Shades\\Tools\\Python\\DLLs', 
> 'D:\\Shades\\Tools\\Python\\lib', 'D:\\Shades\\Tools\\Python', 
> 'D:\\Shades\\Tools\\Python\\lib\\site-packages', 
> 'D:\\Shades\\Tools\\Python\\MyWork']
>>>> import My_Working_File
>>>> 
> 
> I don't really want to go this route every time I start work, and more to the 
> point I will need (to learn how) to add dir's to the path at times
> 
> I did search the net for an answer but only got what I had already tried
> 
> any pointers what I'm doing wrong (other than using windows '->) 

I take it you have business reasons to use an obsolete version python.
Where did you get your version of python from?

You seem to be doing the right thing with setting an environment variable.
Useless shades is an app that embeds python.

Try starting cmd.exe and using the set command to liat all of the environment.
Do you see your PYTHONPATH variable?
Does it contain what you expect?
If it does start python and check that sys.path has your folder in it.
Also check what is on os.environ dirctionary.

Barry
> 
> Grizz
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip module not found

2023-05-12 Thread Barry


> On 12 May 2023, at 21:59, Thomas Passin  wrote:
> 
> On 5/12/2023 2:42 AM, David John wrote:
>> Hi,
>> I recently have been experiencing issues with the pip installation module.
>> I have python version 3.11 installed. I've checked the directory installed
>> in the systems variables window and nothing is amiss. Kindly assist.
> 
> It would be useful if you told us what operating system you are using and how 
> you installed Python.
> 
> Many if not most Linux distributions do not include pip by default. Usually 
> the package manager as a version to install.

From what i see the fedora/redhat/centos world includes the batteries.
The debian/ubuntu world take batteries out.



>  On systems based on Debian, you can install pip with:
> 
> sudo apt install python3-pip
> 
> On others, you will have to look around in the package manager or search on 
> line.
> 
> As a last resort, if you cannot find an OS package manager way to install 
> pip, you find out how from here:
> 
> https://pip.pypa.io/en/stable/installation/
> 
> As the link says, you can run from a command line:
> 
>  -m ensurepip --upgrade
> 
> NOTE: instead of , use the command that launches the right version of 
> python on your system  On Windows, this is usually py.  On Linux, it is 
> usually python3.
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip module not found

2023-05-12 Thread Barry


> On 12 May 2023, at 18:31, Thomas Passin  wrote:
> 
> On 5/12/2023 11:18 AM, Thomas Passin wrote:
>>> On 5/12/2023 2:42 AM, David John wrote:
>>> Hi,
>>> I recently have been experiencing issues with the pip installation module.
>>> I have python version 3.11 installed. I've checked the directory installed
>>> in the systems variables window and nothing is amiss. Kindly assist.
>> It would be useful if you told us what operating system you are using and 
>> how you installed Python.
>> Many if not most Linux distributions do not include pip by default. Usually 
>> the package manager as a version to install.  On systems based on Debian, 
>> you can install pip with:
>> sudo apt install python3-pip
>> On others, you will have to look around in the package manager or search on 
>> line.
>> As a last resort, if you cannot find an OS package manager way to install 
>> pip, you find out how from here:
>> https://pip.pypa.io/en/stable/installation/
>> As the link says, you can run from a command line:
>>  -m ensurepip --upgrade
>> NOTE: instead of , use the command that launches the right version 
>> of python on your system  On Windows, this is usually py.  On Linux, it is 
>> usually python3.
> 
> On Linux, if you want tkinter, you may have to install it with the package 
> manager too.  On Debian-related systems:
> 
> sudo apt-get install python3-tk
> 
> For the Yum package manager:
> 
> yum install tkinter
> 
> You may also need to install ImageTk:
> 
> sudo apt-get install python3-pil.imagetk  (Debian-based)
> 
> On Centos/Red Hat derived systems, you will also need to install
> 
> python3-pillow
> python3-pillow-tk
> 

PIP not PIL is the topic right?

We still need OP to tell us which OS and where python came from.

Barry

> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is npyscreen still alive?

2023-04-21 Thread Barry


> On 21 Apr 2023, at 22:00, Grant Edwards  wrote:
> 
> I recently googled across the ncurses application framework npyscreen,
> and was thinking about giving it a try for a small but real project
> (something that would be distributed to customers), but I'm a bit
> concerned that npyscreen no longer "alive".
> 
> The pypi page says the homepage is http://www.npcole.com/npyscreen/,
> which then points to a Google Code page at 
> https://code.google.com/archive/p/npyscreen/.
> 
> That page says the official repo is at https://bitbucket.org/npcole/npyscreen
> which returns a 404.
> 
> There seems to be a copy in Github at 
> https://github.com/npcole/npyscreen/commits/master,
> but the last commit was almost 4 years ago.
> 
> Maybe it "just works" and is suitable for production?

Maybe this, recently lwn.net article, https://textual.textualize.io/
I was planning to check it out.

Barry
> 
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for a 'good python'

2023-04-13 Thread Barry


> On 13 Apr 2023, at 00:19, jak  wrote:
> 
> Barry ha scritto:
>> 
>>>> On 12 Apr 2023, at 18:10, jak  wrote:
>>> Hi everyone,
>>> some time ago I wrote a class to determine if an ipv4 address belonged
>>> to a subnet. Seldom using python I'm pretty sure it's not written in
>>> 'good python' nor too portable. Could you give me some advice to make it
>>> better?
>>> class calcip:
>>>   def __init__(self, psubnet: str):
>>>   ssubnet, scidr = psubnet.replace(' ', '').split('/')
>>>   subnet = int.from_bytes(tuple(
>>> map(lambda n: (int(n)), 
>>> ssubnet.split('.'))),
>>>   'big')
>>>   cidr = int(scidr)
>>>   mask = ((2 ** cidr) - 1) << (32 - cidr)
>>>   self.__network = subnet & mask
>>>   self.__wildcard = ~mask & 0x
>>>   self.__broadcast = (subnet | self.__wildcard) & 0x
>>>   self.__tsubnet = tuple(subnet.to_bytes(4, 'big'))
>>>   self.__tnetwork = tuple(self.__network.to_bytes(4, 'big'))
>>>   self.__tbroadcast = tuple(self.__broadcast.to_bytes(4, 'big'))
>>>   self.__tmask = tuple(mask.to_bytes(4, 'big'))
>>>   self.__twildcard = tuple(self.__wildcard.to_bytes(4, 'big'))
>>>   self.__host_min = tuple((self.__network + 1).to_bytes(4, 'big'))
>>>   self.__host_max = tuple((self.__broadcast - 1).to_bytes(4, 'big'))
>>>   @staticmethod
>>>   def __to_str(val: tuple):
>>>   return '.'.join(str(v) for v in val)
>>>   @property
>>>   def subnet(self):
>>>   return self.__to_str(self.__tsubnet)
>>>   @property
>>>   def network(self):
>>>   return self.__to_str(self.__tnetwork)
>>>   @property
>>>   def broadcast(self):
>>>   return self.__to_str(self.__tbroadcast)
>>>   @property
>>>   def mask(self):
>>>   return self.__to_str(self.__tmask)
>>>   @property
>>>   def wildcard(self):
>>>   return self.__to_str(self.__twildcard)
>>>   @property
>>>   def host_min(self):
>>>   return self.__to_str(self.__host_min)
>>>   @property
>>>   def host_max(self):
>>>   return self.__to_str(self.__host_max)
>>>   @property
>>>   def hosts_num(self):
>>>   return self.__wildcard - 1
>>>   @property
>>>   def net_class(self):
>>>   tst = (self.__tnetwork[0] & 0xf0) >> 4
>>>   if (tst & 0x8) == 0:
>>>   clx = 'A'
>>>   elif (tst & 0xc) == 0x8:
>>>   clx = 'B'
>>>   elif (tst & 0xe) == 0xc:
>>>   clx = 'C'
>>>   elif (tst & 0xf) == 0xe:
>>>   clx = 'D'
>>>   elif (tst & 0xf) == 0xf:
>>>   clx = 'E'
>>>   return clx
>>>   def __contains__(self, item):
>>>   ret = True
>>>   row_hdr = None
>>>   try:
>>>   row_hdr = int.from_bytes(tuple(map(lambda n: (int(n)), 
>>> item.split('.'))), 'big')
>>>   except:
>>>   ret = False
>>>   if ret:
>>>   if not self.__network < row_hdr < self.__broadcast:
>>>   ret = False
>>>   return ret
>>> def main():
>>>   sn = calcip('10.0.0.0/26')
>>>   print(f"subnet: {sn.subnet}")
>>>   print(f"network: {sn.network}")
>>>   print(f"broadcast: {sn.broadcast}")
>>>   print(f"mask: {sn.mask}")
>>>   print(f"wildcard: {sn.wildcard}")
>>>   print(f"host_min: {sn.host_min}")
>>>   print(f"host_max: {sn.host_max}")
>>>   print(f"Avaible hosts: {sn.hosts_num}")
>>>   print(f"Class: {sn.net_class}")
>>>   tst_hdr = '10.0.0.31'
>>>   is_not = 'is '
>>>   if not tst_hdr in sn:
>>>   is_not = 'is NOT '
>>>   print("hdr %s %sin range %s - %s" %
>>> (tst_hdr, is_not, sn.host_min, sn.host_max))
>>> if __name__ == '__main__':
>>>   main()
>> There is this https://docs.python.org/3/howto/ipaddress.html if you just 
>> want a solution.
>> Or are you after code review feedback?
>> Barry
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
> 
> 
> Thank you too. I had seen this library but I always try not to use
> libraries outside the standard ones. Now I don't remember why I was
> convinced that this wasn't part of it, perhaps because it was like that
> at the time or because I got confused. Only now I realized that it is
> not necessary to install it. Now I'm considering whether to use
> 'ipaddress' or 'socket'. What is certain is that this one you have
> suggested is really comfortable. Thanks again for the report.

Ipaddress was developed outside of the std lib and later added i recall.

Barry
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for a 'good python'

2023-04-12 Thread Barry



> On 12 Apr 2023, at 18:10, jak  wrote:
> Hi everyone,
> some time ago I wrote a class to determine if an ipv4 address belonged
> to a subnet. Seldom using python I'm pretty sure it's not written in
> 'good python' nor too portable. Could you give me some advice to make it
> better?
> 
> class calcip:
>def __init__(self, psubnet: str):
>ssubnet, scidr = psubnet.replace(' ', '').split('/')
>subnet = int.from_bytes(tuple(
>  map(lambda n: (int(n)), ssubnet.split('.'))),
>'big')
>cidr = int(scidr)
>mask = ((2 ** cidr) - 1) << (32 - cidr)
>self.__network = subnet & mask
>self.__wildcard = ~mask & 0x
>self.__broadcast = (subnet | self.__wildcard) & 0x
>self.__tsubnet = tuple(subnet.to_bytes(4, 'big'))
>self.__tnetwork = tuple(self.__network.to_bytes(4, 'big'))
>self.__tbroadcast = tuple(self.__broadcast.to_bytes(4, 'big'))
>self.__tmask = tuple(mask.to_bytes(4, 'big'))
>self.__twildcard = tuple(self.__wildcard.to_bytes(4, 'big'))
>self.__host_min = tuple((self.__network + 1).to_bytes(4, 'big'))
>self.__host_max = tuple((self.__broadcast - 1).to_bytes(4, 'big'))
> 
>@staticmethod
>def __to_str(val: tuple):
>return '.'.join(str(v) for v in val)
> 
>@property
>def subnet(self):
>return self.__to_str(self.__tsubnet)
> 
>@property
>def network(self):
>return self.__to_str(self.__tnetwork)
> 
>@property
>def broadcast(self):
>return self.__to_str(self.__tbroadcast)
> 
>@property
>def mask(self):
>return self.__to_str(self.__tmask)
> 
>@property
>def wildcard(self):
>return self.__to_str(self.__twildcard)
> 
>@property
>def host_min(self):
>return self.__to_str(self.__host_min)
> 
>@property
>def host_max(self):
>return self.__to_str(self.__host_max)
> 
>@property
>def hosts_num(self):
>return self.__wildcard - 1
> 
>@property
>def net_class(self):
>tst = (self.__tnetwork[0] & 0xf0) >> 4
>if (tst & 0x8) == 0:
>clx = 'A'
>elif (tst & 0xc) == 0x8:
>clx = 'B'
>elif (tst & 0xe) == 0xc:
>clx = 'C'
>elif (tst & 0xf) == 0xe:
>clx = 'D'
>elif (tst & 0xf) == 0xf:
>clx = 'E'
>return clx
> 
>def __contains__(self, item):
>ret = True
>row_hdr = None
>try:
>row_hdr = int.from_bytes(tuple(map(lambda n: (int(n)), 
> item.split('.'))), 'big')
>except:
>ret = False
>if ret:
>if not self.__network < row_hdr < self.__broadcast:
>ret = False
>return ret
> 
> 
> def main():
>sn = calcip('10.0.0.0/26')
> 
>print(f"subnet: {sn.subnet}")
>print(f"network: {sn.network}")
>print(f"broadcast: {sn.broadcast}")
>print(f"mask: {sn.mask}")
>print(f"wildcard: {sn.wildcard}")
>print(f"host_min: {sn.host_min}")
>print(f"host_max: {sn.host_max}")
>print(f"Avaible hosts: {sn.hosts_num}")
>print(f"Class: {sn.net_class}")
> 
>tst_hdr = '10.0.0.31'
>is_not = 'is '
>if not tst_hdr in sn:
>is_not = 'is NOT '
>print("hdr %s %sin range %s - %s" %
>  (tst_hdr, is_not, sn.host_min, sn.host_max))
> 
> if __name__ == '__main__':
>main()

There is this https://docs.python.org/3/howto/ipaddress.html if you just want a 
solution.

Or are you after code review feedback?

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows installer from python source code without access to source code

2023-04-04 Thread Barry


> On 4 Apr 2023, at 16:28, Jim Schwartz  wrote:
> 
> Where can I download that cl program?  I've used gcc before, but I hear that 
> cl can use a setup.py program to run the compile and link and create a 
> windows .msi installer.  Is that true?  

It is part of visual studio C++.
Once you have that installed there are bat files that setup environment in the 
terminal.
Then you can use cl, nmake etc

Barry
> 
> -Original Message-
> From: Eryk Sun  
> Sent: Friday, March 31, 2023 12:55 PM
> To: Jim Schwartz 
> Cc: python-list@python.org
> Subject: Re: Windows installer from python source code without access to 
> source code
> 
>> On 3/31/23, Jim Schwartz  wrote:
>> I want a windows installer to install my application that's written in 
>> python, but I don't want the end user to have access to my source code.
> 
> Cython can compile a script to C source code for a module or executable 
> (--embed). The source can be compiled and linked normally.
> For example, the following builds a "hello.exe" executable based on a 
> "hello.py" script.
> 
>> cython -3 --embed hello.py
>> set "PYI=C:\Program Files\Python311\include"
>> set "PYL=C:\Program Files\Python311\libs"
>> cl /I"%PYI%" hello.c /link /libpath:"%PYL%"
>> copy hello.exe embed
>> embed\hello.exe
>Hello, World!
> 
> I extracted the complete embeddable distribution of Python 3.11 into the 
> "embed" directory. You can reduce the size of the installation, if needed, by 
> minimizing the zipped standard library and removing pyd extensions and DLLs 
> that your application doesn't use.
> 
> The generated "hello.c" is large and not particularly easy to read, but here 
> are some snippets [...]:
> 
>[...]
>/* Implementation of 'hello' */
>static PyObject *__pyx_builtin_print;
>static const char __pyx_k_main[] = "__main__";
>static const char __pyx_k_name[] = "__name__";
>static const char __pyx_k_test[] = "__test__";
>static const char __pyx_k_print[] = "print";
>static const char __pyx_k_Hello_World[] = "Hello, World!";
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<<<<<<<<<<<<<
> */
>  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Hello_World);
>if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>  /* "hello.py":1
> * print("Hello, World!") # <<<<<<<<<<<<<<
> */
>  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_,
>  NULL);
>if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
>[...]
>int wmain(int argc, wchar_t **argv) {
>[...]
>if (argc && argv)
>Py_SetProgramName(argv[0]);
>Py_Initialize();
>if (argc && argv)
>PySys_SetArgv(argc, argv);
>[...]
>  m = PyInit_hello();
>[...]
>if (Py_FinalizeEx() < 0)
>return 2;
>[...]
>return 0;
>[...]
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Small lament...

2023-04-03 Thread Barry Warsaw
I heard it on reasonably believable authority that the FLUFL took the year off. 
 Lamentable.

-Barry

> On Apr 1, 2023, at 11:19, Skip Montanaro  wrote:
> 
> Just wanted to throw this out there... I lament the loss of waking up on 
> April 1st to see a creative April Fool's Day joke on one or both of these 
> lists, often from our FLUFL... Maybe such frivolity still happens, just not 
> in the Python ecosystem? I know you can still import "this" or "antigravity", 
> but those are now old (both introduced before 2010). When was the last time a 
> clever easter egg was introduced or an April Fool's Day joke played?
> 
> ¯\_(ツ)_/¯
> 
> Skip
> 
> ___
> Python-Dev mailing list -- python-...@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-...@python.org/message/Q62W2Q6R6XMX57WK2CUGEENHMT3C3REF/
> Code of Conduct: http://python.org/psf/codeofconduct/



signature.asc
Description: Message signed with OpenPGP
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem in using libraries

2023-04-03 Thread Barry


> On 3 Apr 2023, at 17:46, Pranav Bhardwaj  wrote:
> 
> Why can't I able to use python libraries such as numpy, nudenet, playsound,
> pandas, etc in my python 3.11.2. It always through the error "import
> 'numpy' or any other libraries could not be resolved".

You need to provide enough details for people to help you.

Include which OS you are using.
Where you got python from.
How you installed the libraries you are trying to use.
Commands and error messages you are seeing.

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Gui Frontend

2023-04-01 Thread Barry Scott



> On 1 Apr 2023, at 18:47, Igor Korot  wrote:
> 
> I suggest going with wxPython/wxGlade.

I ported all my wxPython code to PyQt and have not regretted it.

wxPython was (its been a while so may not be an issue now) far to
hard to make consistent across OS, my apps run on Linux, macOS and Windows.
I found that PyQt was easier to get working.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python not showing correct version

2023-04-01 Thread Barry Scott



> On 31 Mar 2023, at 22:02, Eryk Sun  wrote:
> 
> 
> The OP installed the standard Python 3.8 distribution, which does
> install the launcher by default. The launcher can run all installed
> versions, including store app installations. By default it runs the
> highest available version, which will probably be the 3.10 store app
> in the OP's case. To make 3.8 the default without having to remove
> 3.10, set the environment variables "PY_PYTHON=3.8" and
> "PY_PYTHON3=3.8" in the user environment.

I find user environment on windows to be less flexible to work with then
adding a py.ini. On my Windows 11 I added %userprofile%\AppData\Local\py.ini.
To make python 3.8 the default that py.exe uses put this in py.ini:

[defaults]
python=3.8-64
python3=3.8-64

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python not showing correct version

2023-03-31 Thread Barry Scott



> On 31 Mar 2023, at 09:33, Sumeet Firodia  wrote:
> 
> Thanks Barry.
> 
> One more thing is that pip --version also refers to python 3.10
> 
> C:\Users\admin>pip --version
> pip 23.0.1 from 
> C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip
>  (python 3.10)

Use this command to ensure that pip matches the python you wish to use:

py -3.8 -m pip --version

Barry

> 
> The issue here is I am trying to use snowpark for which I need python 3.8 but 
> because of this I am not able to proceed with next steps.
> 
> Thanks
> Sumeet
> 
> On Thu, 30 Mar 2023 at 22:45, Barry Scott  <mailto:ba...@barrys-emacs.org>> wrote:
>> 
>> 
>>> On 30 Mar 2023, at 15:17, Sumeet Firodia >> <mailto:ssfiro...@gmail.com>> wrote:
>>> 
>>>> 
>>>> Hi Team,
>>>> 
>>>> I have installed Python 3.8 for Snowpark but when I check the version in
>>>> command prompt it shows me Python 3.10.10.
>>>> 
>>>> C:\Users\admin>python --version
>>>> Python 3.10.10
>> 
>> Try this:
>> 
>> py -3.8
>> 
>> And this to list all version of python installed:
>> 
>> py -0
>> 
>> 
>>>> 
>>>> Also when I try to uninstall 3.10 it says no such version is installed.
>>>> 
>>>> C:\Users\admin>pip uninstall python 3.10.10
>>>> WARNING: Skipping python as it is not installed.
>>>> WARNING: Skipping 3.10.10 as it is not installed.
>> 
>> PIP is for installing python modules not the python program.
>> The python program is installed by running the .exe that you get from 
>> python.org <http://python.org/>, for example.
>> Use the standard Windows method to uninstall a program.
>> Search the web for "windows uninstall software" if you are not sure how to 
>> do this.
>> 
>> Barry
>> 
>>>> 
>>>> Can you please help me here as my snowpark assignment is stuck because of
>>>> this issue.
>>>> 
>>>> Thanks
>>>> Sumeet
>>>> 
>>>> 
>>> -- 
>>> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: built-in pow() vs. math.pow()

2023-03-31 Thread Barry


> On 30 Mar 2023, at 22:30, Chris Angelico  wrote:
> 
> On Fri, 31 Mar 2023 at 08:13, Oscar Benjamin  
> wrote:
>> 
>>> On Thu, 30 Mar 2023 at 17:31, Andreas Eisele  
>>> wrote:
>>> 
>>> I sometimes make use of the fact that the built-in pow() function has an 
>>> optional third argument for modulo calculation, which is handy when dealing 
>>> with tasks from number theory, very large numbers, problems from Project 
>>> Euler, etc. I was unpleasantly surprised that math.pow() does not have this 
>>> feature, hence "from math import *" overwrites the built-in pow() function 
>>> with a function that lacks functionality. I am wondering for the rationale 
>>> of this. Does math.pow() do anything that the built-in version can not do, 
>>> and if not, why is it even there?
>> 
>> It is useful for when you want the pure floating point power which has
>> an approximately fixed computational cost (unlike integer powers).
>> Perhaps it would have been better if it was named fpow similar to fsum
>> vs sum.
>> 
> 
> It's called math.pow. That on its own should be a strong indication
> that it's designed to work with floats.

So long as you know that the math module is provided to give access the C 
math.h functions.

Barry

> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: built-in pow() vs. math.pow()

2023-03-30 Thread Barry Scott



> On 30 Mar 2023, at 18:11, Barry Scott  wrote:
> 
> 
> 
>> On 30 Mar 2023, at 10:15, Andreas Eisele  wrote:
>> 
>> I sometimes make use of the fact that the built-in pow() function has an 
>> optional third argument for modulo calculation, which is handy when dealing 
>> with tasks from number theory, very large numbers, problems from Project 
>> Euler, etc. I was unpleasantly surprised that math.pow() does not have this 
>> feature, hence "from math import *" overwrites the built-in pow() function 
>> with a function that lacks functionality. I am wondering for the rationale 
>> of this. Does math.pow() do anything that the built-in version can not do, 
>> and if not, why is it even there?
> 
> Maybe math.pow() aways using IEEE 754(?) float point via the C runtime math 
> routines.
> pow() will give int answer if called with int args.

And the C version of pow only supports 2 arg call.

SYNOPSIS
 #include 

 double
 pow(double x, double y);

 long double
 powl(long double x, long double y);

 float
 powf(float x, float y);


> 
> Barry
> 
> 
>> Thanks in advance for any enlightening comment on this.
>> Best regards, Andreas
>> -- 
>> https://mail.python.org/mailman/listinfo/python-list
>> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python not showing correct version

2023-03-30 Thread Barry Scott



> On 30 Mar 2023, at 15:17, Sumeet Firodia  wrote:
> 
>> 
>> Hi Team,
>> 
>> I have installed Python 3.8 for Snowpark but when I check the version in
>> command prompt it shows me Python 3.10.10.
>> 
>> C:\Users\admin>python --version
>> Python 3.10.10

Try this:

py -3.8

And this to list all version of python installed:

py -0


>> 
>> Also when I try to uninstall 3.10 it says no such version is installed.
>> 
>> C:\Users\admin>pip uninstall python 3.10.10
>> WARNING: Skipping python as it is not installed.
>> WARNING: Skipping 3.10.10 as it is not installed.

PIP is for installing python modules not the python program.
The python program is installed by running the .exe that you get from 
python.org <http://python.org/>, for example.
Use the standard Windows method to uninstall a program.
Search the web for "windows uninstall software" if you are not sure how to do 
this.

Barry

>> 
>> Can you please help me here as my snowpark assignment is stuck because of
>> this issue.
>> 
>> Thanks
>> Sumeet
>> 
>> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: built-in pow() vs. math.pow()

2023-03-30 Thread Barry Scott



> On 30 Mar 2023, at 10:15, Andreas Eisele  wrote:
> 
> I sometimes make use of the fact that the built-in pow() function has an 
> optional third argument for modulo calculation, which is handy when dealing 
> with tasks from number theory, very large numbers, problems from Project 
> Euler, etc. I was unpleasantly surprised that math.pow() does not have this 
> feature, hence "from math import *" overwrites the built-in pow() function 
> with a function that lacks functionality. I am wondering for the rationale of 
> this. Does math.pow() do anything that the built-in version can not do, and 
> if not, why is it even there?

Maybe math.pow() aways using IEEE 754(?) float point via the C runtime math 
routines.
pow() will give int answer if called with int args.

Barry


> Thanks in advance for any enlightening comment on this.
> Best regards, Andreas
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: found older version of python in my command prompt

2023-03-28 Thread Barry


> On 28 Mar 2023, at 16:44, pranavbhardwaj...@gmail.com wrote:
> 
> 
> 
>
> 
>   Sent from [1]Mail for Windows
> 
>   Dear sir,
> 
> I am Pranav Bhardwaj and I am facing issue regarding python
>   version. When I try to open python in my command prompt, I see there is
>   very older version in it that is python 2.7.13 as a default version. I
>   want to switch my default version to the latest version in my command
>   prompt. Plese help me how can I do this.

Uninstall python 2.7 in the usual windows way.
Download python 3.11 from python.org and run the installer.

In a cmd terminal window run py.exe and you should get the python prompt.

Barry
> 
>
> 
> References
> 
>   Visible links
>   1. https://go.microsoft.com/fwlink/?LinkId=550986
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyGILState_Release called twice in embedded application

2023-03-23 Thread Barry


> On 23 Mar 2023, at 14:34, Arnaud Loonstra  wrote:
> 
> On 23-03-2023 13:33, Barry Scott wrote:
>>>> On 23 Mar 2023, at 08:46, Arnaud Loonstra  wrote:
>>> 
>>> Hi all,
>>> 
>>> I'm running in a crash due to a ResourceWarning (some socket is not closed 
>>> in a used module) after calling PyGILState_Release.
>>> 
>>> I'm running Python in a native thread (so a thread created by C not 
>>> Python). I'm acquiring the GIL through PyGILState_Ensure before doing any 
>>> CPYthon calls and releasing when finished using PyGILState_Release.
>>> 
>>> This has worked fine. But now I'm using a python module (openai) which 
>>> doesn't close its socket correctly which results in a ResourceWarning which 
>>> triggers an assert.
>>> 
>>> In the backtrace  (below) I can see PyGILState_Release is called again. (7) 
>>> while I've already called it (126).
>>> 
>>> I can make the crash go away by adding
>>> 
>>> import warnings
>>> warnings.simplefilter("ignore", ResourceWarning)
>>> 
>>> to my python code. But I'd rather prevent this from happening in the first 
>>> place.
>>> 
>>> Any suggestion very welcomed cause I'm puzzled.
>> What 3rd party C extension are you running with?
>> I'd be surprised if the cpython code was the issue.
>> Barry
> 
> I'm not using any 3rd party extension myself. But the issue is caused by the 
> openai module using the requests module which is not closing sockets:
> 
> https://github.com/openai/openai-python/issues/140
> 
> I'm not aware what C extensions they might use.

In gdb use info shared to see what is loaded.

Leaving a socket open will not cause a logic error as you are encountering.
I expect a bug in C/C++ cod3 that is not part of python itself.
You are using 3rd party code, requests and openai that you name.

Barry

> 
> Btw, I've tested this with python 3.8 and 3.11.2.
> 
> Rg,
> 
> Arnaud
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyGILState_Release called twice in embedded application

2023-03-23 Thread Barry Scott



> On 23 Mar 2023, at 08:46, Arnaud Loonstra  wrote:
> 
> Hi all,
> 
> I'm running in a crash due to a ResourceWarning (some socket is not closed in 
> a used module) after calling PyGILState_Release.
> 
> I'm running Python in a native thread (so a thread created by C not Python). 
> I'm acquiring the GIL through PyGILState_Ensure before doing any CPYthon 
> calls and releasing when finished using PyGILState_Release.
> 
> This has worked fine. But now I'm using a python module (openai) which 
> doesn't close its socket correctly which results in a ResourceWarning which 
> triggers an assert.
> 
> In the backtrace  (below) I can see PyGILState_Release is called again. (7) 
> while I've already called it (126).
> 
> I can make the crash go away by adding
> 
> import warnings
> warnings.simplefilter("ignore", ResourceWarning)
> 
> to my python code. But I'd rather prevent this from happening in the first 
> place.
> 
> Any suggestion very welcomed cause I'm puzzled.

What 3rd party C extension are you running with?
I'd be surprised if the cpython code was the issue.

Barry
 
> 
> Rg,
> 
> Arnaud
> 
> 1   __pthread_kill_implementation  pthread_kill.c   44 
> 0x76fcaccc
> 2   __pthread_kill_internalpthread_kill.c   78 
> 0x76fcad2f
> 3   __GI_raise raise.c  26 
> 0x76f7bef2
> 4   __GI_abort abort.c  79 
> 0x76f66472
> 5   __assert_fail_base assert.c 92 
> 0x76f66395
> 6   __GI___assert_fail assert.c 101 
> 0x76f74df2
> 7   PyGILState_Release pystate.c1742 
> 0x77abcf9f
> 8   tracemalloc_raw_alloc  _tracemalloc.c   779 
> 0x77afa803
> 9   tracemalloc_raw_malloc _tracemalloc.c   789 
> 0x77afa844
> 10  PyMem_RawMallocobmalloc.c   586 
> 0x779dab8d
> 11  decode_current_locale  fileutils.c  472 
> 0x77ada4ab
> 12  _Py_DecodeLocaleEx fileutils.c  598 
> 0x77adafce
> 13  unicode_decode_locale  unicodeobject.c  3970 
> 0x77a13b65
> 14  PyUnicode_DecodeLocale unicodeobject.c  4012 
> 0x77a18c79
> 15  PyErr_SetFromErrnoWithFilenameObjects  errors.c 772 
> 0x77a94178
> 16  PyErr_SetFromErrnoWithFilenameObject   errors.c 750 
> 0x77a942ce
> 17  posix_path_object_errorposixmodule.c1709 
> 0x77ae4201
> 18  path_object_error  posixmodule.c1719 
> 0x77ae420f
> 19  path_error posixmodule.c1737 
> 0x77ae4221
> 20  posix_do_stat  posixmodule.c2565 
> 0x77af42f7
> 21  os_stat_impl   posixmodule.c2897 
> 0x77af4491
> 22  os_statposixmodule.c.h  71 
> 0x77af45e5
> 23  cfunction_vectorcall_FASTCALL_KEYWORDS methodobject.c   443 
> 0x779d2ece
> 24  _PyObject_VectorcallTstate pycore_call.h92 
> 0x7798b579
> 25  PyObject_Vectorcallcall.c   299 
> 0x7798b65e
> 26  _PyEval_EvalFrameDefault   ceval.c  4772 
> 0x77a75453
> 27  _PyEval_EvalFrame  pycore_ceval.h   73 
> 0x77a79887
> 28  _PyEval_Vector ceval.c  6435 
> 0x77a799b1
> 29  _PyFunction_Vectorcall call.c   393 
> 0x7798b215
> 30  _PyObject_VectorcallTstate pycore_call.h92 
> 0x7798b579
> 31  PyObject_CallOneArgcall.c   376 
> 0x7798b6cd
> 32  call_show_warning  _warnings.c  609 
> 0x77a31d24
> 33  warn_explicit  _warnings.c  746 
> 0x77a3223b
> 34  do_warn_warnings.c  947 
> 0x77a3236f
> 35  warn_unicode   _warnings.c  1106 
> 0x77a32414
> 36  _PyErr_WarnFormatV _warnings.c  1126 
> 0x77a32481
> 37  PyErr_ResourceWarning  _warnings.c  1177 
> 0x77a32d38
> 38  sock_finalize  socketmodule.c   5073 
> 0x76840cf3
> 39  PyObject_CallFinalizer object.c 208 
> 0x779d6449
> 40  PyObject_CallFinalizerFromDealloc  object.c 226 
> 0x779d75ac
> 41

Re: Winodws10 Command Prompt unresponsive to .py commands

2023-03-07 Thread Barry


> On 8 Mar 2023, at 05:55, Mike Dewhirst  wrote:
> 
> On 8/03/2023 6:31 am, Thomas Gregg wrote:
>> Hi,  I got python 11 to work with the esptool a few days ago.  However, I
>> must have something wrong, because now, when I enter any command with .py,
>> Windows Command Prompt just returns without doing anything.  Example
>> 
>> C:\Users\gregg>esptool.py version
>> 
>> C:\Users\gregg>
>> 
>> I tried to change the Windows default by filetype. but no luck.  Any
>> ideas?  Thanks
> 
> Prove it works in the command prompt by using the full path to python for 
> example,
> 
> C:\Python311\python C:\Users\gregg>esptool.py version

On windows use the py.exe command rather then python.exe.

Does `py esptool.py version’
> 
> If that works, look at your path environment variables and see where python 
> is sitting. Substitute the real location of Python 3.11 on your machine. 
> Sadly, I think it defaults to C:\Program Files nowadays.
> 
> Once you can get Python working by omitting the path, for example,
> 
> C:\Users\gregg>python esptool.py version
> 
> ... you can then right-click the .py file and choose whichever program you 
> like to open with.

Use py.exe which should in the windows folder to run .py files.

Barry

> I'm inclined to advise you to focus on getting virtual environments working 
> next and leave all that auto-opening to later. You might find you prefer to 
> right click and select every time.
> 
> M
> 
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Your
> email software can handle signing.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug 3.11.x behavioral, open file buffers not flushed til file closed.

2023-03-06 Thread Barry


> On 6 Mar 2023, at 01:42, Greg Ewing via Python-list  
> wrote:
> 
> On 6/03/23 1:02 pm, Cameron Simpson wrote:
>> Also, fsync() need not expedite the data getting to disc. It is equally 
>> valid that it just blocks your programme _until_ the data have gone to disc.
> 
> Or until it *thinks* the data has gone to the disk. Some drives
> do buffering of their own, which may impose additional delays
> before the data actually gets written.

This used to be an issue until Microsoft refused to certify and drive that lied 
about when data was persisted to the medium. WHQL?

That had the effect of stooping driver manufactures having firmware to win 
benchmarking.

Now the OS will use the commands to the drive that allow the OS to know the 
data is safe.

Barry

> 
> -- 
> Greg
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a more efficient threading lock?

2023-02-28 Thread Barry
> Though it's still probably not as useful as you might hope. In C, if I
> can do "int id = counter++;" atomically, it would guarantee me a new
> ID that no other thread could ever have.

C does not have to do that atomically. In fact it is free to use lots of 
instructions to build the int value. And some compilers indeed do, the linux 
kernel folks see this in gcc generated code.

I understand you have to use the new atomics features.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a more efficient threading lock?

2023-02-26 Thread Barry Scott


On 25/02/2023 23:45, Jon Ribbens via Python-list wrote:

I think it is the case that x += 1 is atomic but foo.x += 1 is not.


No that is not true, and has never been true.

:>>> def x(a):
:...    a += 1
:...
:>>>
:>>> dis.dis(x)
 1   0 RESUME   0

 2   2 LOAD_FAST    0 (a)
 4 LOAD_CONST   1 (1)
 6 BINARY_OP   13 (+=)
10 STORE_FAST   0 (a)
12 LOAD_CONST   0 (None)
14 RETURN_VALUE
:>>>

As you can see there are 4 byte code ops executed.

Python's eval loop can switch to another thread between any of them.

Its is not true that the GIL provides atomic operations in python.

Barry

--
https://mail.python.org/mailman/listinfo/python-list


Re: Is there a more efficient threading lock?

2023-02-25 Thread Barry
Re sqlite and threads. The C API can be compiled to be thread safe from my
Reading if the sqlite docs. What I have not checked is how python’s bundled 
sqlite
is compiled. There are claims python’s sqlite is not thread safe.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Barry


> On 23 Feb 2023, at 01:39, Hen Hanna  wrote:
> 
> On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote:
>> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: 
>>>> py bug.py 
>>> Traceback (most recent call last): 
>>> File "C:\Usenet\bug.py", line 5, in  
>>> print( a + 12 ) 
>>> TypeError: can only concatenate str (not "int") to str 
>>> 
>>> 
>>> Why doesn't Python (error msg) do the obvious thing and tell me 
>>> WHAT the actual (offending, arg) values are ? 
>>> 
>>> In many cases, it'd help to know what string the var A had , when the error 
>>> occurred. 
>>>  i wouldn't have to put print(a) just above, to see. 
>>> 
>>> 
>>> 
>>> 
>>> ( pypy doesn't do that either, but Python makes programming (debugging) so 
>>> easy that i hardly feel any inconvenience.)
> 
> 
> i see that my example would be (even)  clearER with this one-line change:
> 
>   py bug.py 
> 
> Traceback (most recent call last): 
> 
>   File "C:\Usenet\bug.py", line 5, in 
> map( Func, fooBar( X, Y, X + Y ))
> 
> TypeError: can only concatenate str (not "int") to str
>attempt to call +  with  'abc'  ,   123.45  
> <--
> 
>> i hope that NOW a few of you can see this as a genuine, (reasonable) 
>> question.
> 
> Python  seems so perfectly  User-friendly that
>   i 'm  so curious (puzzled)  that it doesn't do the very  
> obvious and easy thing 
> of giving me this info:
> 
>attempt to call  + with  'abc'  ,   
> 123.45  <--

It is not easy to do that in a robust and reliable way for any object.
You can end up in the code to generate the error message itself breaking.
For example using unbounded CPU time when attempting to get the string repr of 
the variable.

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Introspecting the variable bound to a function argument

2023-02-22 Thread Barry
please do not use an email address on a public list that cannot be replied to.


> On 22 Feb 2023, at 14:43, Anton Shepelev  wrote:
> 
> Hello, all.
> 
> Does Python have an instrospection facility that can
> determine to which outer variable a function argument is
> bound, e.g.:

There is no requirement for a variable to be used in the call.
It could be an an int or string, 42 “forty two”.

> 
>  v1 = 5;
>  v2 = 5;
> 
>  def f(a):
>  print(black_magic(a)) # or black_magic('a')
> 
>  f(v1) # prints: v1
>  f(v2) # prints: v2

There is the traceback module that lets you find where you are called from.
Also there is the inspect module that also lets tou get at the stack in more 
detail.

Barry

> 
> -- 
> ()  ascii ribbon campaign -- against html e-mail
> /\  www.asciiribbon.org   -- against proprietary attachments
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python: How to use the 'trace' module programmatically?

2023-02-16 Thread Barry


> On 15 Feb 2023, at 17:23, Peter Slížik  wrote:
> 
> Hello,
> 
> I'm trying to analyze complex Python code. For some specific reasons, I
> decided to use tracing instead of a debugger.
> 
> The first thing I tried was:
> 
> python -m trace -t /path/to/file.py
> 
> The output of this command turned out to be completely useless. The reason
> is that there was a thread running in the background, doing some work
> every *0.1
> s* and this generated thousands of lines of tracing information. The useful
> information (a reaction to my interaction with app GUI) scrolled away in a
> blink.
> 
> For this reason, I decided to limit the scope of tracing. I did the
> following.
> 
> The original code:
> 
> def caller():
>print("I'm the caller.")
>callee()
> def callee():
>print("Callee here.")
> 
> Code modified for tracing:
> 
> import trace
> 
> tracer = trace.Tracer(
>count=0,
>trace=1,
> )
> def outer():
>print("I'm the caller.")
>tracer.runfunc(inner)


The docs show that you need to do either add the outfile to trace
or generate and write the report after runfunc returns.

I have not tested this, just read the docs out of curiosity
Here https://docs.python.org/3/library/trace.html

Barry

> def inner():
>print("Callee here.")
> 
> Now I launched the program and the tracer did not generate any output. I
> was hoping that this would provide complete tracing information, but only
> for the limited scope of inner().
> 
> No success with tracer.run() either.
> 
> What I was able to do, when I set count=1, I was able to catch the coverage
> data with tracer.results() and write them to a file. But the tracing
> information was not generated even in this case.
> 
> Am I doing anything wrong?
> 
> Peter
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HTTP server benchmarking/load testing in Python

2023-01-26 Thread Barry


> On 26 Jan 2023, at 17:32, Thomas Passin  wrote:
> 
> On 1/26/2023 11:41 AM, Chris Angelico wrote:
>>> On Fri, 27 Jan 2023 at 03:34, Thomas Passin  wrote:
>>> A nice theory but nothing to do with the real world.  I've had a number
>>> of laptops that overheat (or would, if I let test program continue)
>>> running this test program.
>> Define "overheat". If all you're saying is "the fan began to whine and
>> I got annoyed so I shut off the program", that is absolutely NOT
>> overheating. 
> 
> CPU core temperatures up to 95 deg C and rising rapidly, as reported by a 
> number of utilities including NZXT and CoreTemp.  Max junction temperature is 
> given as 100 deg C, and I don't want to risk reducing the lifetime of my  CPU.

Silicon junctions melt something like 400C ish not 100C.
The max you see is the operating temp of the CPU.

For intel CPU if you go beyond what the slow clocking can deal with the CPU 
turns itself off to prevent damage.

Intel did this to stop people asking for replacement parts when there cooling 
was at fault.

Barry

> 
> Maybe five or ten minutes at or above 100 deg C every few months might not 
> make a noticeable lifetime difference, who knows?  I don't want to make a 
> habit of it.  I wouldn't drive my car very long with a low oil pressure 
> warning active, either.
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: file.read Method Documentation (Python 2.7.10)

2023-01-09 Thread Barry Scott



On 09/01/2023 14:34, Stephen Tucker wrote:

Dear Python-list,

Yes, I know that Python 2.x is no longer supported.

I have found that the documentation for this method is misleading when the
file being read is UTF-8-encoded:

Instead of reading *size* bytes, the method reads *size *UTF-8 byte
*sequences*.

Has this error been corrected in the Python 3.x documentation?


Please read the python 3 docs and let us know if you think its correct now.

Barry

--
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion: Regex string specifier like r and f

2023-01-08 Thread Barry


> On 8 Jan 2023, at 21:16, Raphael Santiago  
> wrote:
> 
> Maybe something like re""
> It should behave exactly like a raw string but would be useful for syntax
> highlighting and debugging. Perhaps also for type hinting expected regex
> input (don't know if this is feasible).

This is unlikely to be implemented. See 
https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740/12
 for related idea discussion.

Barry


> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question.

2023-01-08 Thread Barry


> On 8 Jan 2023, at 21:20, Angitolol36  wrote:
> 
>    Hello, i installed phyton in Windows 10 22H2 and i can’t find the program.
>   I used the repair that doesnt work.

Does this help?

 https://docs.python.org/3/using/windows.html

Barry
> 
>
> 
>
> 
>   Enviado desde [1]Correo para Windows
> 
>
> 
>   [2][IMG] Libre de virus.[3]www.avast.com
> 
> References
> 
>   Visible links
>   1. https://go.microsoft.com/fwlink/?LinkId=550986
>   2. 
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient
>   3. 
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=emailclient
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott



On 03/01/2023 21:24, c.bu...@posteo.jp wrote:

Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de:

logging.getLogger().addHandler( logging.StreamHandler( sys.stdout ))


But I don't want to make all log levels go to stdout. Just DEBUG and 
INFO. But this would be a workaround.


The main question here is why does Python deciecded to make all logs 
go to stderr?
Maybe I totally misunderstood the intention of logging.info()?! Isn't 
this the "usual applicaton output"?


If not, what messages should go into logging.info()? Can you name me 
some examples?


Example:

write an app that prints the contents of a file.

The application output is the contents of the file.

The logging might be this when all is working:

INFO About to open 
INFO Wrote  bytes from 

The logging might be this when there is a problem:

INFO About to open 
ERROR Failed to open  - 

Does that help?

Barry


--
https://mail.python.org/mailman/listinfo/python-list


Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott



On 03/01/2023 21:24, c.bu...@posteo.jp wrote:

Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de:

logging.getLogger().addHandler( logging.StreamHandler( sys.stdout ))


But I don't want to make all log levels go to stdout. Just DEBUG and 
INFO. But this would be a workaround.


The main question here is why does Python deciecded to make all logs 
go to stderr?
Maybe I totally misunderstood the intention of logging.info()?! Isn't 
this the "usual applicaton output"?


If not, what messages should go into logging.info()? Can you name me 
some examples?


It is up to you, the designer of an application, to decide how it works.
You will take into account conventions that your users will expect you 
to follow.


If the logging module helps you then use it, but you are not forced by 
logging to
design your app is a particular way. The default behavior of the logging 
module is
a generally useful default, but its only a default. You are free to 
setup logging to

meet your needs.

Barry


--
https://mail.python.org/mailman/listinfo/python-list


Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott



On 04/01/2023 06:46, Chris Angelico wrote:

I've known some systems to have a trigger of "reading on FD 0 flushes
FD 1"


C++ has this feature:

Quote from https://en.cppreference.com/w/cpp/io/cin

"Once |std::cin| is constructed, std::cin.tie() returns ::cout 
<http://en.cppreference.com/w/cpp/io/cout>, and likewise, 
std::wcin.tie() returns ::wcout 
<http://en.cppreference.com/w/cpp/io/cout>. This means that any 
formatted input operation on |std::cin| forces a call to std::cout 
<http://en.cppreference.com/w/cpp/io/cout>.flush() if any characters are 
pending for output."


Barry

--
https://mail.python.org/mailman/listinfo/python-list


Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott



On 04/01/2023 02:26, Chris Angelico wrote:

Reading/writing the FD is the same as using stdout (technically you'd
write to fd 1 and read from fd 0), but yes, can use /dev/tty to reach
for the console directly.


I think the logic is more like checking that stdin is a tty then using
the tty it to read and write the tty. This works with stdout redirected.
Also stdin is likely only open with read access.

For example the way to prevent ssh-add from prompting in the terminal is 
this:


$ ssh-add ~/.ssh/id_rsa https://mail.python.org/mailman/listinfo/python-list


Re: Possible re bug

2022-12-29 Thread Barry Scott

Please please fix you email client so that your replies stay with the
emails you are replying to.

Barry


On 28/12/2022 19:09, Stefan Ram wrote:

Alexander Richert writes:
|print(re.findall(".*","pattern"))
|yields ['pattern',''] which is not what I was expecting.

   The asterisk is "greedy", so I agree that it should consume
   /everything/ including all the empty strings at the end.
   To work around this, one can use '^.*' (no smiley intended).



--
https://mail.python.org/mailman/listinfo/python-list


Re: Pyserial problem

2022-12-22 Thread Barry


> On 22 Dec 2022, at 17:09, Patrick EGLOFF  wrote:
> 
> Hi all,
> 
> I use Python 3.10.9 and Pyserial 3.5 on a Win10 machine.
> 
> I'm sending datas via an USB port to a device that accept commands in the
> form of  : cmd;
> The device receives and reacts to the commands sent, and it should reply
> with an ACK of the same kind.
> 
> But looking with a COM port sniffer, nothing is sent back.
> 
> I checked that everything is working with PUTTY and even MINITERM, and
> everything is just fine, the device is responding correctly.
> 
> I have set the flow control to different values, as well as setting the RTS
> and DTR high or low with no change.
> Normally, the device works without any flow control, and CTS + DTR high.
> 
> I checked with MINITERM, that the flow control and control lines have the
> same state.
> 
> I'm a bit surprised and stucked.
> Can someone help ?

Please post tour code that you are using to talk to the device.

Barry

> Thanks,
> -- 
> Patrick Egloff
> email : pegl...@gmail.com
> Web page : http://www.egloff.eu
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to enter escape character in a positional string argumentfrom the command line?

2022-12-21 Thread Barry


> On 21 Dec 2022, at 17:06, Chris Angelico  wrote:
> 
> On Thu, 22 Dec 2022 at 03:58, gene heskett  wrote:
>> 
>>> On 12/21/22 11:22, Chris Angelico wrote:
>>> On Thu, 22 Dec 2022 at 03:11, Stefan Ram  wrote:
>>>> 
>>>> Lars Liedtke  writes:
>>>>> Or you could have "native" bash ($SHELL) with WSL.
>>>> 
>>>>   In this newsgroup, it would actually be obvious to use Python.
>>> 
>>> Less obvious than you might think - partly because bash is just so
>>> dang good that it's really really hard to outdo it :) Sure, bash has a
>>> lot of weird and wonky edge cases, but it's an incredibly practical
>>> shell to use.
>>> 
>> When you make a statement like that, Chris, you should also note that
>> every single one of those "wonky edge cases" is documented down to the
>> last dotted i. Bash's docs will kill a good sized pulp tree, needing
>> around a ream of paper to print on a duplex printer. I know, I did it
>> around a decade ago. If you like to write scripts, having a dead tree
>> copy of the docs at your elbow in incredibly useful.  That huge man page
>> does not cover it like the printed docs do.
>> 
> 
> Oh yes, absolutely true. Its wonkiness is dependable and consistent;
> but it is definitely quirky (look at all the different ways to embed
> arguments into things, and the ways that $*, $@, "$*, and "$@" behave
> when put into variables). Not usually a problem, but it does sometimes
> leave you thinking "wow, wouldn't it be easier to just use something
> like Python?". And in the complicated cases, yeah, it can be. But in
> the simple cases? Bash rocks.

I see bash scripts that are 1000’s of line of code at work and its a 
maintenance nightmare.

Knowing when to make the move from “handy bash script” to “this is a production 
application” and needs to be python is what I see people miss.

After a certain point in complexity the python code wins on maintenance.
Personally i set a low bar to move from bash to python.

Barry


> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip/setuptools: Entry points not visible from pkexec-root-environment

2022-12-18 Thread Barry


> On 18 Dec 2022, at 17:57, c.bu...@posteo.jp wrote:
> 
> Hello,
> 
> when I install a package on a GNU/Linux system via "sudo python3 -m pip
> install -e ." that defines entry points in its pyproject.toml the entry
> point starter scripts are located in /usr/locale/bin.
> 
> That folder is in PATH for "regular" root users and by "sudo su" roots
> users.
> 
> But I need to start that entry points via "pkexec".
> But in the environment started by "pkexec" the PATH does not contain
> /usr/local/bin.
> 
> So what can I do?


Why are asking on this list and discuss.python.org?
Lots of people on this list are also on discuss.python.org.

Barry
> 
> I don't need a hack or workaround but an "elegant" solution.
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Barry Scott


> On 11 Dec 2022, at 18:50, Chris Green  wrote:
> 
> My solution in the end was copied from one I found that was much
> simpler and straightforward than most.  I meant to post this earlier
> but it got lost somewhere:-
> 
>import sys, termios, tty
>#
>#
># Read a single character from teminal, specifically for 'Y/N' 
>#
>fdInput = sys.stdin.fileno()
>termAttr = termios.tcgetattr(0)
>#
>#
># Get a single character, setcbreak rather than setraw meands CTRL/C
>etc. still work
>#
>def getch():
>sys.stdout.flush()
>tty.setcbreak(fdInput)
>ch = sys.stdin.buffer.raw.read(1).decode(sys.stdin.encoding)

Will not work for uncode code points above 255.

This is what happened when I typed € key:

:>>> a.getch()
Traceback (most recent call last):
  File "", line 1, in 
  File "/private/var/folders/ll/08dwwqkx6v9bcd15sh06x14wgn/T/a.py", line 
15, in getch
ch = sys.stdin.buffer.raw.read(1).decode(sys.stdin.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 0: 
unexpected end of data

You would need to have a loop that collected all the utf-8 bytes of a single 
code point.
You can to look at the first byte of know if the utf-8 is 1, 2, 3 or 4 bytes 
for a code point.

Barry

>termios.tcsetattr(fdInput, termios.TCSAFLUSH, termAttr)
>sys.stdout.write(ch)
>return ch
>#
>#
># Get a y or n answer, ignore other characters
>#
>def getyn():
>ch = 'x'
>while ch != 'y' and ch != 'n':
>ch = getch().lower()
>return ch
> 
> So getyn() reads a y or an n, ignores anything else and doesn't wait
> for a return key.  Keyboard input operation is restored to normal
> after doing this. Using tty.setcbreak() rather than tty.setraw() means
> that CTRL/C etc. still work if things go really wrong.

> 
> 
> -- 
> Chris Green
> ·
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FTP without username and password

2022-12-07 Thread Barry


> On 7 Dec 2022, at 16:49, ^Bart  wrote:
> 
> 
>>   It's a whole different protocol. TFTP is simplified to the point it
>> will fit on embedded devices which don't need security (the assumption
>> being that one has the embedded device physically present, FTP assumes
>> distributed networks).
>> https://wiki.python.org/moin/tftp
> 
> I never used TFTP so, like what I wrote in another post, I thought it was 
> just a FTP without username and password...
> 
> Thanks to show me the "Python way" to use TFTP! :)
> 
> Have a nice day!
> ^Bart

TFTP server and client tools are standard on linux systems.

Barry
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Contributing to cpython

2022-12-06 Thread Barry


> On 6 Dec 2022, at 20:55, ramvikram singh  wrote:
> 
> Greetings,
> I learnt python this year and visiting the python issue tab for the last
> two months, but there is a problem which I am facing I understand the issue
> after reading the few times but I can't think about how to modify the code
> as per the issue. Could you please help me with this?

no one can help as you have not explained what the issue is.

Barry 

> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Calling pselect/ppoll/epoll_pwait

2022-12-04 Thread Barry
 On 3 Dec 2022, at 13:13, Weatherby,Gerard  wrote:

 

 Signalfd and select could probably be made to work if one codes around
 the race conditions pselect is provided to avoid. I’m not sure if using
 the GIL (for CPython) is sufficient or if a dedicated concurrency
 control (e.g. lock, mutex, semaphore) is necessary.

 An alternative is to call the C library function via a wrapper. I had
 need to use setfsuid on a project a couple of years ago and found this
 example:

 [1]https://gist.github.com/atdt/ebafa299e843a767139b

  

   I read this on SO when researching your question.
   Search for epoll and signal.

   (I would post the link but ipad turns the link into an image…)

   I assume that the lack of pepoll means you can use epoll and

   signalfd without race conditions. The trick seems to be setting

   the signal to ignore.

   Barry

  

 From: Python-list 
 on behalf of Barry 

 Date: Friday, December 2, 2022 at 7:02 PM
 To: Ian Pilcher 
 Cc: python-list@python.org 
 Subject: Re: Calling pselect/ppoll/epoll_pwait

 *** Attention: This is an external email. Use caution responding,
 opening attachments or clicking on links. ***

 > On 2 Dec 2022, at 20:03, Ian Pilcher  wrote:
 >
 > Does Python provide any way to call the "p" variants of the I/O
 > multiplexing functions?
 >
 > Looking at the documentation of the select[1] and selectors[2]
 modules,
 > it appears that they expose only the "non-p" variants.
 >
 > [1]
 
[2]https://urldefense.com/v3/__https://docs.python.org/3/library/select.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_OD5qBjeA$
 > [2]
 
[3]https://urldefense.com/v3/__https://docs.python.org/3/library/selectors.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_MwNjgO8A$

 Can you use signalfd and select/poll/epoll?

 Barry

 >
 > --
 >
 
 > Google  Where SkyNet meets
 Idiocracy
 >
 
 > --
 >
 
[4]https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$
 >

 --
 
[5]https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$

References

   Visible links
   1. https://gist.github.com/atdt/ebafa299e843a767139b
   2. 
https://urldefense.com/v3/__https:/docs.python.org/3/library/select.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_OD5qBjeA$
   3. 
https://urldefense.com/v3/__https:/docs.python.org/3/library/selectors.html__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_MwNjgO8A$
   4. 
https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$
   5. 
https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!hClFFo4XdiwQAhHxDbHA5zFr490Of9uheHSf84V9cREMHyw1kX-baG5HzXWMt-hFLP30q6DpSUb2G_PhasKBfg$
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Calling pselect/ppoll/epoll_pwait

2022-12-02 Thread Barry


> On 2 Dec 2022, at 20:03, Ian Pilcher  wrote:
> 
> Does Python provide any way to call the "p" variants of the I/O
> multiplexing functions?
> 
> Looking at the documentation of the select[1] and selectors[2] modules,
> it appears that they expose only the "non-p" variants.
> 
> [1] https://docs.python.org/3/library/select.html
> [2] https://docs.python.org/3/library/selectors.html

Can you use signalfd and select/poll/epoll?

Barry

> 
> -- 
> 
> Google  Where SkyNet meets Idiocracy
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NEO6 GPS with Py PICO with micropython

2022-11-30 Thread Barry Scott



> On 30 Nov 2022, at 10:58, KK CHN  wrote:
> 
> List,
> 
> Just commented the // gpsModule.readline() in the while loop,  (
> refer the link
> https://microcontrollerslab.com/neo-6m-gps-module-raspberry-pi-pico-micropython/
> )
> 
> 
> while True: # gpsModule.readline() // This line commented out and the "GPS
> not found message disappeared". buff = str(gpsModule.readline()) parts =
> buff.split(',')
> 
> 
> The GPS not found error which appears intermittently in the output python
> console for few seconds ( say 7 to 8 seconds  its printing the lines   "
> GPS data not found" )   now  disappears.
> 
> Any thoughts?  How the above line comment made it vanish the  "GPS data
> not found" error output.

Show the full text of the error that you see. Is it a traceback?

What I would do then is read the code that raised the "GPS data not found"
error and find out why it reports that error.

Barry
p.s. Please reply in line, do not top post.

> 
> Krishane
> 
> On Wed, Nov 30, 2022 at 3:58 AM rbowman  wrote:
> 
>> On Tue, 29 Nov 2022 17:23:31 +0530, KK CHN wrote:
>> 
>> 
>>> When I ran the program I am able to see the output of  latitude and
>>> longitude in the console of thony IDE.  But  between certain intervals
>>> of a few seconds  I am getting the latitude and longitude data ( its
>>> printing GPS data not found ?? ) in the python console.
>> 
>> I would guess the 8 seconds in
>> 
>> timeout = time.time() + 8
>> 
>> is too short. Most GPS receivers repeat a sequence on NMEA sentences and
>> the code is specifically looking for $GPGGA. Add
>> 
>> print(buff)
>> 
>> to see the sentences being received. I use the $GPRMC since I'm interested
>> in the position, speed, and heading. It's a different format but if you
>> only want lat/lon you could decode it in a similar fashion as the $GPGGA.
>> 
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >