Re: Too Broad of an exception

2023-10-25 Thread dn via Python-list

On 26/10/2023 04.49, rsutton via Python-list wrote:

On 10/25/2023 11:06 AM, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

outer quotation marks) prints some prominent exception types. After

...


   "Manually removing" above was meant to be a fast first pass,
   where I only excluded exception types that were obviously
   inappropriate. It is now to be followed by a search for the
   appropriate exception types among those exception types left.



@Rene & @Stefan,
I really appreciate the guidance provided.  By replacing Exception with 

...


It would appear that (at least one message) did not make it to email - 
neither to the list-archive.


People wishing to learn are unable to benefit a response, if it is not 
sent to the list!


--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


RE: Question(s)

2023-10-25 Thread AVI GROSS via Python-list
Just want to add that even when you can prove that an algorithm works 
absolutely positively, it will often fail on our every finite computers. 
Consider families of algorithms that do hill climbing to find a minimum and 
maximum and are guaranteed to get ever closer to a solution given infinite 
time. In real life, using something like 64 bit or 128 bit floating point 
representations, you can end up with all kinds of rounding errors and 
inexactness on some inputs so it goes into a loop of constantly bouncing back 
and forth between the two sides and never gets any closer to the peak. It may 
work 99.99% of the time and then mysteriously lock up on some new data.

Or consider an algorithm some use in places like Vegas that is absolutely 100% 
guaranteed to win. If you bet $1 and lose, simply double your bet as many times 
as needed and eventually, you should win. Of course, one little problem is that 
all you ever win is $1. And you might lose 50 times in a row and spend hours 
and risk ever larger amounts to just win that dollar. Sure, you could just 
start betting a larger amount like a million dollars and eventually win a 
million dollars but how long can anyone keep doubling before they have to stop 
and lose it all. After enough doublings the vet is for billions of dollars and 
soon thereafter, more than the worth of everything on the planet.

The algorithm is mathematically sound but the result given other realities is 
not.

A last analogy is the division by zero issue. If your algorithm deals with 
infinitesimally smaller numbers, it may simply be rounded or truncated to 
exactly zero. The next time the algorithm does a division, you get a serious 
error. 

So perhaps a PROOF that a real computer program will work would require quite a 
few constraints. Python already by default supports integers limited only in 
size by available memory. This can avoid some of the overflow problems when all 
you are allowed is 64 bits but it remains a constraint and a danger as even a 
fairly simple algorithm you can PROVE will work, will still fail if your 
program uses these large integers in ways that make multiple such large 
integers on machines not designed to extend their memory into whole farms of 
machines or generates numbers like Googolplex factorial divided by googolplex 
raised to the log(Googolplex ) power.

Some problems like the above are manageable as in setting limits and simply 
returning failure without crashing. Many well-designed programs can be trusted 
to work well as long as certain assumptions are honored. But often it simply is 
not true and things can change. 

Python actually is a good choice for quite a bit and often will not fail where 
some other environment might but there are few guarantees and thus people often 
program defensively even in places they expect no problems. As an example, I 
have written programs that ran for DAYS and generated many millions of files as 
they chugged along in a simulation and then mysteriously died. I did not bother 
trying to find out why one program it called failed that rarely to produce a 
result. I simply wrapped the section that called the occasional offender in the 
equivalent try/catch for that language and when it happened, did something 
appropriate and continued. The few occasional errors were a bug in someone 
else's code that should have handled whatever weird data I threw at it 
gracefully but didn't, so I added my overhead so I could catch it. The rare 
event did not matter much given the millions that gave me the analysis I 
wanted. But the point is even if my code had been certified as guaranteed to be 
bug free, any time I stepped outside by calling code from anyone else in a 
library, or an external program, it is no longer guaranteed.

We are now spending quite a bit of time educating someone who seems to have 
taken on a task without really being generally knowledgeable about much outside 
the core language and how much of the answer to making the code as reliable as 
it can be may lie somewhat outside the program as just seen by the interpreter. 

And unless this is a one-shot deal, in the real world, programs keep getting 
modified and new features ofteh added and just fixing one bug can break other 
parts so you would need to verify things over and over and then freeze.


-Original Message-
From: Python-list  On 
Behalf Of Michael F. Stemper via Python-list
Sent: Wednesday, October 25, 2023 9:34 AM
To: python-list@python.org
Subject: Re: Question(s)

On 24/10/2023 18.15, o1bigtenor wrote:


> What is interesting about this is the absolute certainty that it is impossible
> to program so that that program is provably correct.

Not entirely true. If I was to write a program to calculate Fibonacci
numbers, or echo back user input, that program could be proven correct.
But, there is a huge set of programs for which it is not possible to
prove correctness.

In fact, there is a huge (countably infinite) set of programs 

[Python-announce] ANN: pyftpdlib 1.5.9 released

2023-10-25 Thread Giampaolo Rodola'
Hello all,
I'm glad to announce the release of pyftpdlib 1.5.9:
https://github.com/giampaolo/pyftpdlib

About
=

Python FTP server library provides a high-level portable interface to
easily write very efficient, scalable and asynchronous FTP servers with
Python.

What's new
==

**Enhancements**

- #611: use `ruff` code style checker instead of flake8 + isort (much
faster +
  makes many more code quality checks).

**Bug fixes**

- #604: client connection may be reset in PASV/EPSV mode during TLS
handshake.
  (patch by Benedikt McMullin)
- #607: possible infinite wait in Epoll  (patch by @stat1c-void)
- #607: possible infinite traceback printing in DTPHandler (patch by
  @stat1c-void)
- #613: (CRITICAL) bugfix for TLS disconnect causing 100% CPU usage. (patch
by
  @hakai)
- #614: close connection on SSL EOF error, instead of erroneously replying
with
  "226 Transfer completed."

Links
=

- Home page: https://github.com/giampaolo/pyftpdlib
- Download: https://pypi.python.org/pypi/pyftpdlib
- Documentation: http://pyftpdlib.readthedocs.io
- What's new: https://github.com/giampaolo/pyftpdlib/blob/master/HISTORY.rst

--

Giampaolo - https://gmpy.dev/
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


Re: Question(s)

2023-10-25 Thread Jim Schwartz via Python-list
   Does this link help?  It seems to have a Linux package here.

   [1]Eclipse Packages | The
   Eclipse Foundation - home to
   a global community, the
   Eclipse IDE, Jakarta EE and  [2]favicon.ico
   over 350 open source
   projects...
   eclipse.org

   Sent from my iPhone

 On Oct 25, 2023, at 7:55 AM, o1bigtenor via Python-list
  wrote:

 On Wed, Oct 25, 2023 at 7:00AM Dieter Maurer 
 wrote:

   o1bigtenor wrote at 2023-10-25 06:44 -0500:

 On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer 
 wrote:

 ...

   There are different kinds of errors.

   Some can be avoided by using an integrated development environment

   (e.g. misspellings, type mismatches, ...).

 Haven't heard of a python IDE - - - doesn't mean that there isn't
 such - -

 just that I haven't heard of such. Is there a python IDE?

   There are several.

   Python comes with "IDLE".

 Interesting - - - started looking into this.

   There are several others,

   e.g. "ECLIPSE" can be used for Python development.

 Is 'Eclipse' a Windows oriented IDE?
 (Having a hard time finding linux related  information on the
 website.)

   Search for other alternatices.

 Will do.
 Thanks for the assistance.
 --
 https://mail.python.org/mailman/listinfo/python-list

References

   Visible links
   1. https://www.eclipse.org/downloads/packages/
   2. https://www.eclipse.org/downloads/packages/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Dan Purgert via Python-list
On 2023-10-25, o1bigtenor wrote:
> On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer  wrote:
>> [...]
>> There are several others,
>> e.g. "ECLIPSE" can be used for Python development.
>
> Is 'Eclipse' a Windows oriented IDE?
> (Having a hard time finding linux related  information on the
> website.)

Not at all.  As I recall, it's entirely written in Java, so basically
entirely platform-independent already.


-- 
|_|O|_|
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1  E067 6D65 70E5 4CE7 2860
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Too Broad of an exception

2023-10-25 Thread Thomas Passin via Python-list

On 10/25/2023 11:49 AM, rsutton via Python-list wrote:

On 10/25/2023 11:06 AM, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

outer quotation marks) prints some prominent exception types. After
manually removing those that do not seem to apply, I am left with:
"AssertionError",
"ChildProcessError",

...

   "Manually removing" above was meant to be a fast first pass,
   where I only excluded exception types that were obviously
   inappropriate. It is now to be followed by a search for the
   appropriate exception types among those exception types left.



@Rene & @Stefan,
I really appreciate the guidance provided.  By replacing Exception with 
RuntimeError, pylint seems happy!  More specificity, I guess.  I know 
that I could have ignored the pylint exceptions, but I want to use this 
as a learning experience.  I looks like I have a lot of reading to do on 
exception handling. IMO all of the try/except code looks quite clumsy to 
me.  It may be excellent for some tasks but to me, it looks quite 
inelegant.  Like I said, I have a lot to learn.


In this particular case you could probably just handle the return result 
from robocopy right there.  Of course, it depends on the rest of the 
code.  It probably doesn't really need an exception, and if you want to 
handle it in the calling function, you could just return the result as a 
boolean:


return p.returncode < 8  # Reversed the test since a return of "True"
 # would make more sense as a return code


Thank you both for your guidance.

Richard



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


Re: Question(s)

2023-10-25 Thread Thomas Passin via Python-list

On 10/25/2023 9:20 AM, Michael F. Stemper via Python-list wrote:

On 24/10/2023 17.50, Thomas Passin wrote:


   The programming team for the Apollo moon mission developed a system 
which,> if you would write your requirements in a certain way, could 
generate correct

C code for them.
Since the last Apollo mission was in 1972, when C was first being 
developed, I

find this hard to believe.


Yes, sorry, see my previous post.  It's the current-day evolution of the 
tools that can output C.


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


Re: Too Broad of an exception

2023-10-25 Thread Kushal Kumaran via Python-list
On Wed, Oct 25 2023 at 11:49:12 AM, rsutton  wrote:
> On 10/25/2023 11:06 AM, Stefan Ram wrote:
>> r...@zedat.fu-berlin.de (Stefan Ram) writes:
>>> outer quotation marks) prints some prominent exception types. After
>>> manually removing those that do not seem to apply, I am left with:
>>> "AssertionError",
>>> "ChildProcessError",
>> ...
>>"Manually removing" above was meant to be a fast first pass,
>>where I only excluded exception types that were obviously
>>inappropriate. It is now to be followed by a search for the
>>appropriate exception types among those exception types left.
>> 
> @Rene & @Stefan,
> I really appreciate the guidance provided.  By replacing Exception
> with RuntimeError, pylint seems happy!  More specificity, I guess.  I
> know that I could have ignored the pylint exceptions, but I want to
> use this as a learning experience.  I looks like I have a lot of
> reading to do on exception handling. IMO all of the try/except code
> looks quite clumsy to me.  It may be excellent for some tasks but to
> me, it looks quite inelegant.  Like I said, I have a lot to learn.
>

>From what you've described of your problem, it seems like a small-ish
utility program you're writing for your own use.  You don't need any
`try`...`except` blocks in such code.  You just let the exception stop
your program.

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


Re: Question(s)

2023-10-25 Thread Thomas Passin via Python-list

On 10/25/2023 8:50 AM, o1bigtenor via Python-list wrote:

On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer  wrote:


o1bigtenor wrote at 2023-10-25 06:44 -0500:

On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer  wrote:
...

There are different kinds of errors.

Some can be avoided by using an integrated development environment
(e.g. misspellings, type mismatches, ...).


Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
just that I haven't heard of such. Is there a python IDE?


There are several.

Python comes with "IDLE".


Interesting - - - started looking into this.


There are several others,
e.g. "ECLIPSE" can be used for Python development.


Is 'Eclipse' a Windows oriented IDE?
(Having a hard time finding linux related  information on the
website.)


Search for other alternatices.


Will do.

Thanks for the assistance.


Pyzo is one possibility - https://pyzo.org

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


Re: Question(s)

2023-10-25 Thread Alan Gauld via Python-list
On 25/10/2023 12:44, o1bigtenor via Python-list wrote:

> Haven't heard of a python IDE - - - doesn't mean that there isn't such - -

There are literally dozens with varying degrees of smartness.
The big 4 all have Python plugins/environments:
Eclipse, Netbeans, VisualStudio, IntelliJ

And of course the Apple XCode toolset has a python environment.

There are also several Python specific IDEs around too.
Most of them are multi-platform:

https://www.simplilearn.com/tutorials/python-tutorial/python-ide

gives a small sample

And of course the old favourites vi/vim and emacs both have
comprehensive Python support.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list

On 25/10/2023 05.45, o1bigtenor wrote:

On Tue, Oct 24, 2023 at 8:35 PM Chris Angelico via Python-list
 wrote:



3. Catch the failure before you commit and push. Unit tests are great for this.


Where might I find such please.


You don't "find" unit tests; you write them. A unit test tests
a specific function or program.

Ideally, you write each unit test *before* you write the function
that it tests.

For instance, suppose that you were writing a function to calculate
the distance between two points. We know the following things about
distance:
1. The distance from a point to itself is zero.
2. The distance between two distinct points is positive.
3. The distance from A to B is equal to the distance from B to A.
4. The distance from A to B plus the distance from B to C is at
   least as large as the distance from A to C.

You would write unit tests that generate random points and apply
your distance function to them, checking that each of these
conditions is satisfied. You'd also write a few tests of hard-coded
points,such as:
- Distance from (0,0) to (0,y) is y
- Distance from (0,0) to (x,0) is x
- Distance from (0,0) to (3,4) is 5
- Distance from (0,0) to (12,5) is 13

The python ecosystem provides many tools to simplify writing and
running unit tests. Somebody has already mentioned "unittest". I
use this one all of the time. There are also "doctest", "nose",
"tox", and "py.test" (none of which I've used).

--
Michael F. Stemper
Life's too important to take seriously.

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


Re: Too Broad of an exception

2023-10-25 Thread rsutton via Python-list

On 10/25/2023 11:06 AM, Stefan Ram wrote:

r...@zedat.fu-berlin.de (Stefan Ram) writes:

outer quotation marks) prints some prominent exception types. After
manually removing those that do not seem to apply, I am left with:
"AssertionError",
"ChildProcessError",

...

   "Manually removing" above was meant to be a fast first pass,
   where I only excluded exception types that were obviously
   inappropriate. It is now to be followed by a search for the
   appropriate exception types among those exception types left.



@Rene & @Stefan,
I really appreciate the guidance provided.  By replacing Exception with 
RuntimeError, pylint seems happy!  More specificity, I guess.  I know 
that I could have ignored the pylint exceptions, but I want to use this 
as a learning experience.  I looks like I have a lot of reading to do on 
exception handling. IMO all of the try/except code looks quite clumsy to 
me.  It may be excellent for some tasks but to me, it looks quite 
inelegant.  Like I said, I have a lot to learn.


Thank you both for your guidance.

Richard

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


[Python-announce] SQLObject 3.10.3

2023-10-25 Thread Oleg Broytman
Hello!

I'm pleased to announce version 3.10.3, the 3rd bugfix release of branch
3.10 of SQLObject.


What's new in SQLObject
===

The contributors for this release are
Igor Yudytskiy and shuffle (github.com/shuffleyxf).
Thanks!

Bug fixes
-

* Relaxed aliasing in ``SQLRelatedJoin`` introduced in 3.10.2 - aliasing
  is required only when the table joins with itself. When there're two
  tables to join aliasing prevents filtering -- wrong SQL is generated
  in ``relJoinCol.filter(thisClass.q.column)``.

Drivers
---

* Fix(SQLiteConnection): Release connections from threads that are
  no longer active. This fixes memory leak in multithreaded programs
  in Windows.

  ``SQLite`` requires different connections per thread so
  ``SQLiteConnection`` creates and stores a connection per thread.
  When a thread finishes its connections should be closed.
  But if a program doesn't cooperate and doesn't close connections at
  the end of a thread SQLObject leaks memory as connection objects are
  stuck in ``SQLiteConnection``. On Linux the leak is negligible as
  Linux reuses thread IDs so new connections replace old ones and old
  connections are garbage collected. But Windows doesn't reuse thread
  IDs so old connections pile and never released. To fix the problem
  ``SQLiteConnection`` now enumerates threads and releases connections
  from non-existing threads.

* Dropped ``supersqlite``. It seems abandoned.
  The last version 0.0.78 was released in 2018.

Tests
-

* Run tests with Python 3.12.

CI
--

* GHActions: Ensure ``pip`` only if needed

  This is to work around a problem in conda with Python 3.7 -
  it brings in wrong version of ``setuptools`` incompatible with Python 3.7.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is a free and open-source (LGPL) Python object-relational
mapper.  Your database tables are described as classes, and rows are
instances of those classes.  SQLObject is meant to be easy to use and
quick to get started with.

SQLObject supports a number of backends: MySQL/MariaDB (with a number of
DB API drivers: ``MySQLdb``, ``mysqlclient``, ``mysql-connector``,
``PyMySQL``, ``mariadb``), PostgreSQL (``psycopg2``, ``PyGreSQL``,
partially ``pg8000`` and ``py-postgresql``), SQLite (builtin ``sqlite``,
``pysqlite``); connections to other backends
- Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB) - are less
debugged).

Python 2.7 or 3.4+ is required.


Where is SQLObject
==

Site:
http://sqlobject.org

Download:
https://pypi.org/project/SQLObject/3.10.3

News and changes:
http://sqlobject.org/News.html

StackOverflow:
https://stackoverflow.com/questions/tagged/sqlobject

Mailing lists:
https://sourceforge.net/p/sqlobject/mailman/

Development:
http://sqlobject.org/devel/

Developer Guide:
http://sqlobject.org/DeveloperGuide.html


Example
===

Install::

  $ pip install sqlobject

Create a simple class that wraps a table::

  >>> from sqlobject import *
  >>>
  >>> sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
  >>>
  >>> class Person(SQLObject):
  ... fname = StringCol()
  ... mi = StringCol(length=1, default=None)
  ... lname = StringCol()
  ...
  >>> Person.createTable()

Use the object::

  >>> p = Person(fname="John", lname="Doe")
  >>> p
  
  >>> p.fname
  'John'
  >>> p.mi = 'Q'
  >>> p2 = Person.get(1)
  >>> p2
  
  >>> p is p2
  True

Queries::

  >>> p3 = Person.selectBy(lname="Doe")[0]
  >>> p3
  
  >>> pc = Person.select(Person.q.lname=="Doe").count()
  >>> pc
  1

Oleg.
-- 
Oleg Broytmanhttps://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


SQLObject 3.10.3

2023-10-25 Thread Oleg Broytman via Python-list
Hello!

I'm pleased to announce version 3.10.3, the 3rd bugfix release of branch
3.10 of SQLObject.


What's new in SQLObject
===

The contributors for this release are
Igor Yudytskiy and shuffle (github.com/shuffleyxf).
Thanks!

Bug fixes
-

* Relaxed aliasing in ``SQLRelatedJoin`` introduced in 3.10.2 - aliasing
  is required only when the table joins with itself. When there're two
  tables to join aliasing prevents filtering -- wrong SQL is generated
  in ``relJoinCol.filter(thisClass.q.column)``.

Drivers
---

* Fix(SQLiteConnection): Release connections from threads that are
  no longer active. This fixes memory leak in multithreaded programs
  in Windows.

  ``SQLite`` requires different connections per thread so
  ``SQLiteConnection`` creates and stores a connection per thread.
  When a thread finishes its connections should be closed.
  But if a program doesn't cooperate and doesn't close connections at
  the end of a thread SQLObject leaks memory as connection objects are
  stuck in ``SQLiteConnection``. On Linux the leak is negligible as
  Linux reuses thread IDs so new connections replace old ones and old
  connections are garbage collected. But Windows doesn't reuse thread
  IDs so old connections pile and never released. To fix the problem
  ``SQLiteConnection`` now enumerates threads and releases connections
  from non-existing threads.

* Dropped ``supersqlite``. It seems abandoned.
  The last version 0.0.78 was released in 2018.

Tests
-

* Run tests with Python 3.12.

CI
--

* GHActions: Ensure ``pip`` only if needed

  This is to work around a problem in conda with Python 3.7 -
  it brings in wrong version of ``setuptools`` incompatible with Python 3.7.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is a free and open-source (LGPL) Python object-relational
mapper.  Your database tables are described as classes, and rows are
instances of those classes.  SQLObject is meant to be easy to use and
quick to get started with.

SQLObject supports a number of backends: MySQL/MariaDB (with a number of
DB API drivers: ``MySQLdb``, ``mysqlclient``, ``mysql-connector``,
``PyMySQL``, ``mariadb``), PostgreSQL (``psycopg2``, ``PyGreSQL``,
partially ``pg8000`` and ``py-postgresql``), SQLite (builtin ``sqlite``,
``pysqlite``); connections to other backends
- Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB) - are less
debugged).

Python 2.7 or 3.4+ is required.


Where is SQLObject
==

Site:
http://sqlobject.org

Download:
https://pypi.org/project/SQLObject/3.10.3

News and changes:
http://sqlobject.org/News.html

StackOverflow:
https://stackoverflow.com/questions/tagged/sqlobject

Mailing lists:
https://sourceforge.net/p/sqlobject/mailman/

Development:
http://sqlobject.org/devel/

Developer Guide:
http://sqlobject.org/DeveloperGuide.html


Example
===

Install::

  $ pip install sqlobject

Create a simple class that wraps a table::

  >>> from sqlobject import *
  >>>
  >>> sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
  >>>
  >>> class Person(SQLObject):
  ... fname = StringCol()
  ... mi = StringCol(length=1, default=None)
  ... lname = StringCol()
  ...
  >>> Person.createTable()

Use the object::

  >>> p = Person(fname="John", lname="Doe")
  >>> p
  
  >>> p.fname
  'John'
  >>> p.mi = 'Q'
  >>> p2 = Person.get(1)
  >>> p2
  
  >>> p is p2
  True

Queries::

  >>> p3 = Person.selectBy(lname="Doe")[0]
  >>> p3
  
  >>> pc = Person.select(Person.q.lname=="Doe").count()
  >>> pc
  1

Oleg.
-- 
Oleg Broytmanhttps://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Question(s)

2023-10-25 Thread AVI GROSS via Python-list
I am replying to this which is heading into another topic:

"(Tongue in cheek) Except doesn't one make more  when software in
hidden in an unreadable state? (That forces the user to go back to the
original dev or group - - yes?)"

Like some of us, I come from a time when much software was compiled. Sure, you 
could play interactively with the BASIC interpreter, but much else could be 
delivered to you as an executable and it was not easy to know what it did 
without trying it and certainly it was not easy to make changes to it and 
resell it as your own.

Where does python fit in?

On the one hand, it is completely visible as the software and modules you use 
tend to be stored on the machine being used in a readable state. If you come up 
with some nifty algorithm, it is there for anyone to see and copy or even alter 
if they have permissions. You can freely search a corpus of code to pick up 
interesting tidbits and that can be a plus but if your livelihood is based on 
selling your code or services, ...

So do some people do things to make that harder? Can you deliver only files 
already converted to bytecode, for example? Could you have an interpreter that 
has special changes such as being able to take encrypted code and decrypt 
before using or perhaps have read privileges that normal users will not have?

Obviously if your code is on a server that users can only access indirectly and 
in a controlled manner, this is not as much of an issue. 

I will skip the anecdotes, but point out how sometimes compiled code may have a 
whole bunch of other problems, including when a user can sneak in your office 
and modify the source code behind your back or when a virus can insert itself.

So to return to the main point, not that I am selling anything, what do 
developers using Python do to try to make sure they get properly paid and 
others do not just use their work without permission?

-Original Message-
From: o1bigtenor  
Sent: Wednesday, October 25, 2023 6:59 AM
To: avi.e.gr...@gmail.com
Cc: Chris Angelico ; python-list@python.org
Subject: Re: Question(s)

On Tue, Oct 24, 2023 at 9:36 PM AVI GROSS via Python-list
 wrote:
>
> Agreed, Chris. There are many methods way better than the sort of RAID
> architecture I supplied as AN EXAMPLE easy to understand. But even so, if a
> hard disk or memory chip is fried or a nuclear bomb takes out all servers in
> or near a city, you would need  some truly crazy architectures with info not
> only distributed across the globe but perhaps also to various space
> satellites or servers kept ever further out and eventually in hyperspace or
> within a black hole (might be write-only, alas).
>
> The point many of us keep saying is there can not easily or even with great
> difficult, any perfect scheme that guarantees nothing will go wrong with the
> software, hardware, the people using it and so on. And in the real world, as
> compared to the reel world, many programs cannot remain static. Picture a
> program that includes many tax laws and implementations that has to be
> changed at least yearly as laws change. Some near-perfect code now has to
> either be patched with lots of errors possible, or redesigned from scratch
> and if it takes long enough, will come out after yet more changes and thus
> be wrong.
>
> A decent question you can ask is if the language this forum is supposed to
> be on, is better in some ways to provide the kind of Teflon-coated code he
> wants. Are there features better avoided? How do you make sure updates to
> modules you use and trust are managed as they may break your code. Stuff
> like that is not as abstract.

The above are very interesting questions - - - - anyone care to tackle
one, or some?
>
> In my view, one consideration can be that when people can examine your
> source code in the original language, that can open up ways others might
> find ways to break it, more so than a compiled program that you only can
> read in a more opaque way.
>
(Tongue in cheek) Except doesn't one make more  when software in
hidden in an unreadable state? (That forces the user to go back to the
original dev or group - - yes?)

TIA

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


Re: Question(s)

2023-10-25 Thread Michael Torrie via Python-list
On 10/25/23 05:51, o1bigtenor via Python-list wrote:
> Looks like I have another area to investigate. (grin!)
> Any suggestions?

Seems to me you're trying to run before you have learned to walk.

Slow down, go to the beginning and just learn python, write some code,
see if it runs.  Go through the tutorial at
https://docs.python.org/3/tutorial/index.html

Your first and most basic tool is the python interpreter.  It will tell
you when you try to run your code if you have syntax errors.  It's true
that some errors the linters will catch won't show up as syntax errors,
but cross the bridge when you get to it.  Once you have a basic grasp of
Python syntax, you can begin using some of the tools Python has for
organizing code: Functions and modules (eventually packages).
Eventually when your logic is placed neatly into functions, you can then
write other python programs that import those functions and feed
different parameters to them and test that the output is what you
expect. That is known as a test.

Nothing wrong with geany as an editor.  However, you might find the
Python Idle IDE useful (it usually installs with Python), as it lets you
work more interactively with your code, inspecting and interacting with
live python objects in memory.  It also integrates debugging
functionality to let you step through your code one line at a time and
watch variables and how they change.

When you encounter isses with your code (syntax or logical) that you
can't solve, you can come to the list, show your code and the full
output of the interpreter that shows the complete error message and back
trace and I think you'll get a lot of helpful responses.
-- 
https://mail.python.org/mailman/listinfo/python-list


Too Broad of an exception

2023-10-25 Thread rsutton via Python-list

Hi all,
I am fairly new to python (ie < 2 years).  I have a question about 
pylint.  I am running on windows 10/11, python 3.10.11.


Here's what I'm trying to do:
I am using robocopy to to copy a set of files to/from a LAN location and 
my desktop(s).  Here is the partial code:


p = subprocess.run(["robocopy.exe",
STORE_LOCATION, NEWS_LOCATION,
"/NFL", "/NDL", "/NJH", "/NJS", "/NP", "/XF", 
"msgFilterRules.dat",

"xmsgFilterRules.dat"], check=False)

# this is necessary because Windows Robocopy returns
# various return codes for success.
if p.returncode >= 8:
raise Exception(f'Invalid result: {p.returncode}')

It actually runs fine.  But pylint is not having it.  I get:

win_get_put_tb_filters.py:61:12: W0719: Raising too general exception: 
Exception (broad-exception-raised)


But the code I have written does exactly what I want.  If the returncode 
is 7 or less, then I have success.  If the returncode is 8 or above 
there is a failure and I want to see what the returncode is.


Trying to read the python Exception docs is mind bending.  Any help 
would be appreciated.


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


Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list

On 24/10/2023 18.15, o1bigtenor wrote:



What is interesting about this is the absolute certainty that it is impossible
to program so that that program is provably correct.


Not entirely true. If I was to write a program to calculate Fibonacci
numbers, or echo back user input, that program could be proven correct.
But, there is a huge set of programs for which it is not possible to
prove correctness.

In fact, there is a huge (countably infinite) set of programs for which it
is not even possible to prove that the program will halt.

Somebody already pointed you at a page discussing "The Halting Problem".
You really should read up on this.


Somehow - - - well - - to me that sounds that programming is illogical.

If I set up a set of mathematical problems (linked) I can prove that the
logic structure of my answer is correct.


Exactly the same situation. There are many (again, countably infinite)
mathematical statements where it is not possible to prove that the statement
is either true or false. I want to be clear that this is not the same as
"we haven't figured out how to do it yet." It is a case of "it is mathematically
possible to show that we can't either prove or disprove statement ."

Look up Kurt Gödel's work on mathematical incompleteness, and some of the
statements that fall into this category, such as the Continuum Hypothesis
or the Parallel Postulate.

As I said at the beginning, there are a lot of programs that can be
proven correct or incorrect. But, there are a lot more that cannot.

--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.

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


Re: Too Broad of an exception

2023-10-25 Thread Rene Kita via Python-list
rsutton  wrote:
> Hi all,
> I am fairly new to python (ie < 2 years).  I have a question about 
> pylint.  I am running on windows 10/11, python 3.10.11.
[...]
> if p.returncode >= 8:
> raise Exception(f'Invalid result: {p.returncode}')
> 
> It actually runs fine.  But pylint is not having it.  I get:
> 
> win_get_put_tb_filters.py:61:12: W0719: Raising too general exception: 
> Exception (broad-exception-raised)

pylint is just a linter, ignore it if the code works and you like it the
way it is.

pylint complains because you use Exception. Use e.g. RuntimeException to
silence it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list

On 24/10/2023 17.50, Thomas Passin wrote:



   The programming team for the Apollo moon mission developed a system which,> 
if you would write your requirements in a certain way, could generate correct
C code for them.

Since the last Apollo mission was in 1972, when C was first being developed, I
find this hard to believe.

--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.

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


Re: Question(s)

2023-10-25 Thread Dan Purgert via Python-list
On 2023-10-24, o1bigtenor wrote:
> On Tue, Oct 24, 2023 at 5:28 PM Rob Cliffe  wrote:
>>
>> There is no general way to prove that a program is "correct".  Or even
>> whether it will terminate or loop endlessly.
>> [...]
>> When you come to run your program "for real", and you have to
>> troubleshoot it (as in real life you probably will), you will have
>> eliminated simple bugs in your program, and can concentrate on the more
>> likely sources of problems (e.g. misbehaving hardware).
>>
> Interesting - - - hopefully taken in the same vein as your second
> statement - - I sorta sounds like programmers keep running around in
> the forest looking for trees. (Grin!)

No, you tend to know what parts of the spec are "wrong(tm)" (either in
the language you're working in, or the hardware). 

If it comes to working with customers (as mentioned in one response),
you start to learn the questions to get at what they really want (but
that's better left to the architect :) )

>
> So how does one test software then?

You write unit tests (usually scripts or other software that can
interact with the main program to twiddle the knobs and such, and ensure
it's doing what was specified).  Alternatively, you have to program your
hardware and test directly on that.


-- 
|_|O|_|
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1  E067 6D65 70E5 4CE7 2860
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 08:29 -0500:
> ...
>It would appear that something has changed.
>
>Went to the Eclipse download page, downloaded and verified (using sha-512).
>Expanded software to # opt .
>There is absolutely NO mention of anything python - - - java, c and
>its permutations,
>'scientific computing', and some others but nothing python.
>
>I may be missing something due to an extreme lack of knowledge.
>
>Please advise as to where I might find the 'python' environment in eclipse.

I entered "eclipse python download" in my favorite search engine
(=> "ecosia.org") and the second hit gave:
"https://marketplace.eclipse.org/content/pydev-python-ide-eclipse;.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Thomas Passin via Python-list

On 10/25/2023 9:21 AM, Thomas Passin wrote:

On 10/25/2023 8:50 AM, o1bigtenor via Python-list wrote:
On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer  
wrote:


o1bigtenor wrote at 2023-10-25 06:44 -0500:
On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer  
wrote:

...

There are different kinds of errors.

Some can be avoided by using an integrated development environment
(e.g. misspellings, type mismatches, ...).


Haven't heard of a python IDE - - - doesn't mean that there isn't 
such - -

just that I haven't heard of such. Is there a python IDE?


There are several.

Python comes with "IDLE".


Interesting - - - started looking into this.


There are several others,
e.g. "ECLIPSE" can be used for Python development.


Is 'Eclipse' a Windows oriented IDE?
(Having a hard time finding linux related  information on the
website.)


Search for other alternatices.


Will do.

Thanks for the assistance.


Pyzo is one possibility - https://pyzo.org


The Leo editor is excellent, as long as you are prepared for a steep 
learning curve - https://github.com/leo-editor/leo-editor


It's installable via pip (though there can be fixable install glitches 
on some Linux distros).




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


Re: Question(s)

2023-10-25 Thread Grant Edwards via Python-list
On 2023-10-25, o1bigtenor via Python-list  wrote:

> Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
> just that I haven't heard of such. Is there a python IDE?

Seriously?  Now you're just trolling.

google.com/search?q=python+ide=python+ide

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Wed, Oct 25, 2023 at 7:56 AM Dieter Maurer  wrote:
>
> o1bigtenor wrote at 2023-10-25 07:50 -0500:
> >> There are several others,
> >> e.g. "ECLIPSE" can be used for Python development.
> >
> >Is 'Eclipse' a Windows oriented IDE?
>
> No.
> ==> "https://en.wikipedia.org/wiki/Eclipse_(software)"

It would appear that something has changed.

Went to the Eclipse download page, downloaded and verified (using sha-512).
Expanded software to # opt .
There is absolutely NO mention of anything python - - - java, c and
its permutations,
'scientific computing', and some others but nothing python.

I may be missing something due to an extreme lack of knowledge.

Please advise as to where I might find the 'python' environment in eclipse.

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


Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 07:50 -0500:
>> There are several others,
>> e.g. "ECLIPSE" can be used for Python development.
>
>Is 'Eclipse' a Windows oriented IDE?

No.
==> "https://en.wikipedia.org/wiki/Eclipse_(software)"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer  wrote:
>
> o1bigtenor wrote at 2023-10-25 06:44 -0500:
> >On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer  wrote:
> > ...
> >> There are different kinds of errors.
> >>
> >> Some can be avoided by using an integrated development environment
> >> (e.g. misspellings, type mismatches, ...).
> >
> >Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
> >just that I haven't heard of such. Is there a python IDE?
>
> There are several.
>
> Python comes with "IDLE".
>
Interesting - - - started looking into this.

> There are several others,
> e.g. "ECLIPSE" can be used for Python development.

Is 'Eclipse' a Windows oriented IDE?
(Having a hard time finding linux related  information on the
website.)

> Search for other alternatices.

Will do.

Thanks for the assistance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 06:44 -0500:
>On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer  wrote:
> ...
>> There are different kinds of errors.
>>
>> Some can be avoided by using an integrated development environment
>> (e.g. misspellings, type mismatches, ...).
>
>Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
>just that I haven't heard of such. Is there a python IDE?

There are several.

Python comes with "IDLE".

There are several others,
e.g. "ECLIPSE" can be used for Python development.
Search for other alternatices.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Wed, Oct 25, 2023 at 6:20 AM Chris Angelico via Python-list
 wrote:
>
> On Wed, 25 Oct 2023 at 21:46, o1bigtenor  wrote:
> > > 2. Catch the failure as you save. We have a lot of tools that can help
> > > you to spot bugs.
> >
> > Tools like this for python please.
>
> Various ones. Type checkers like MyPy fall into this category if you
> set your system up to run them when you save. Some editors do basic
> syntax checks too.

I have been using geany as a plain text editor for some time. Searching for
suggestions for error checking in python I find listed Pylint,
Pyflakes and Pycodestyle.

Looks like I have another area to investigate. (grin!)
>
> > > 3. Catch the failure before you commit and push. Unit tests are great for 
> > > this.
> >
> > Where might I find such please.
>
> The same tools, but run as a pre-commit hook.
>
> Any tool that can help you find bugs has the potential to be of value.
> It's all a question of how much time it saves with earlier detection
> of bugs versus how much it costs you in pacifying the tool. Some are
> better than others.
>
Any suggestions?

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


Re: Question(s)

2023-10-25 Thread Chris Angelico via Python-list
On Wed, 25 Oct 2023 at 22:46, o1bigtenor via Python-list
 wrote:
>
> On Wed, Oct 25, 2023 at 6:24 AM Dieter Maurer  wrote:
> >
> > o1bigtenor wrote at 2023-10-24 07:22 -0500:
> > > ...
> > >Is there a way to verify that a program is going to do what it is
> > >supposed to do even
> > >before all the hardware has been assembled and installed and tested?
> >
> > Others have already noted that "verify" is a very strong aim.
>
> I have worked in environments where everything was 100% tested. Errors
> were either corrected or one's attendance was uninvited. Powerful impetus
> to do a good job.

Or powerful impetus to deny that the error was yours.

Remember, 100% test coverage does NOT mean the code is perfect. It
just means it's tested.

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Wed, Oct 25, 2023 at 6:24 AM Dieter Maurer  wrote:
>
> o1bigtenor wrote at 2023-10-24 07:22 -0500:
> > ...
> >Is there a way to verify that a program is going to do what it is
> >supposed to do even
> >before all the hardware has been assembled and installed and tested?
>
> Others have already noted that "verify" is a very strong aim.

I have worked in environments where everything was 100% tested. Errors
were either corrected or one's attendance was uninvited. Powerful impetus
to do a good job.
>
> There are different kinds of errors.
>
> Some can be avoided by using an integrated development environment
> (e.g. misspellings, type mismatches, ...).

Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
just that I haven't heard of such. Is there a python IDE?
>
> Some can be found via tests.
> Look at Python's "unittest" package for learn how to write tests.
> "unittest.mock" can help you to mockup hardware you do not yet have.

Thanks - - -more to look into.

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Wed, Oct 25, 2023 at 6:25 AM Chris Angelico via Python-list
 wrote:
>
> On Wed, 25 Oct 2023 at 21:53, o1bigtenor  wrote:
> >
> > Hmm - - - - now how can I combine 'Hamming codes'
> > and a raid array?
> >
> > TIA
>
> Normally you wouldn't. But let's say you're worried that a file might
> get randomly damaged. (I don't think single-bit errors are really a
> significant issue with mass storage, as you'd be more likely to have
> an entire sector unreadable, but this can certainly happen in
> transmission.) What you do is take a set of data bits, add an error
> correction code, and send them on their way. The more data bits per
> block, the more efficient, but if there are too many errors you will
> lose data. So there's a tradeoff.
>
>
Thank you Mr Chris!
Cogent explanation that makes sense.
So - - - no change needed to my storage systems.
Great!

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


Re: Simple webserver

2023-10-25 Thread Dieter Maurer via Python-list
Frank Millman wrote at 2023-10-25 09:57 +0200:
> ...
>Based on this, I am considering the following -
>
>1. Replace my HTTP handler with Uvicorn. Functionality should be the
>same, but performance should be improved.
>
>2. Instead of running as a stand-alone server, run my app as a
>reverse-proxy using Nginx. I tested this a few years ago using Apache,
>and it 'just worked', so I am fairly sure that it will work with Nginx
>as well. Nginx can then provide the additional functionality that Dieter
>has mentioned.

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


Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-24 07:22 -0500:
> ...
>Is there a way to verify that a program is going to do what it is
>supposed to do even
>before all the hardware has been assembled and installed and tested?

Others have already noted that "verify" is a very strong aim.

There are different kinds of errors.

Some can be avoided by using an integrated development environment
(e.g. misspellings, type mismatches, ...).

Some can be found via tests.
Look at Python's "unittest" package for learn how to write tests.
"unittest.mock" can help you to mockup hardware you do not yet have.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Chris Angelico via Python-list
On Wed, 25 Oct 2023 at 21:53, o1bigtenor  wrote:
>
> Hmm - - - - now how can I combine 'Hamming codes'
> and a raid array?
>
> TIA

Normally you wouldn't. But let's say you're worried that a file might
get randomly damaged. (I don't think single-bit errors are really a
significant issue with mass storage, as you'd be more likely to have
an entire sector unreadable, but this can certainly happen in
transmission.) What you do is take a set of data bits, add an error
correction code, and send them on their way. The more data bits per
block, the more efficient, but if there are too many errors you will
lose data. So there's a tradeoff.

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


Re: Question(s)

2023-10-25 Thread Chris Angelico via Python-list
On Wed, 25 Oct 2023 at 21:46, o1bigtenor  wrote:
> > 2. Catch the failure as you save. We have a lot of tools that can help
> > you to spot bugs.
>
> Tools like this for python please.

Various ones. Type checkers like MyPy fall into this category if you
set your system up to run them when you save. Some editors do basic
syntax checks too.

> > 3. Catch the failure before you commit and push. Unit tests are great for 
> > this.
>
> Where might I find such please.

The same tools, but run as a pre-commit hook.

Any tool that can help you find bugs has the potential to be of value.
It's all a question of how much time it saves with earlier detection
of bugs versus how much it costs you in pacifying the tool. Some are
better than others.

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Tue, Oct 24, 2023 at 9:36 PM AVI GROSS via Python-list
 wrote:
>
> Agreed, Chris. There are many methods way better than the sort of RAID
> architecture I supplied as AN EXAMPLE easy to understand. But even so, if a
> hard disk or memory chip is fried or a nuclear bomb takes out all servers in
> or near a city, you would need  some truly crazy architectures with info not
> only distributed across the globe but perhaps also to various space
> satellites or servers kept ever further out and eventually in hyperspace or
> within a black hole (might be write-only, alas).
>
> The point many of us keep saying is there can not easily or even with great
> difficult, any perfect scheme that guarantees nothing will go wrong with the
> software, hardware, the people using it and so on. And in the real world, as
> compared to the reel world, many programs cannot remain static. Picture a
> program that includes many tax laws and implementations that has to be
> changed at least yearly as laws change. Some near-perfect code now has to
> either be patched with lots of errors possible, or redesigned from scratch
> and if it takes long enough, will come out after yet more changes and thus
> be wrong.
>
> A decent question you can ask is if the language this forum is supposed to
> be on, is better in some ways to provide the kind of Teflon-coated code he
> wants. Are there features better avoided? How do you make sure updates to
> modules you use and trust are managed as they may break your code. Stuff
> like that is not as abstract.

The above are very interesting questions - - - - anyone care to tackle
one, or some?
>
> In my view, one consideration can be that when people can examine your
> source code in the original language, that can open up ways others might
> find ways to break it, more so than a compiled program that you only can
> read in a more opaque way.
>
(Tongue in cheek) Except doesn't one make more  when software in
hidden in an unreadable state? (That forces the user to go back to the
original dev or group - - yes?)

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
On Tue, Oct 24, 2023 at 8:43 PM Chris Angelico via Python-list
 wrote:
>
> On Wed, 25 Oct 2023 at 12:20, AVI GROSS via Python-list
>  wrote:
> > Consider an example of bit rot. I mean what if your CPU or hard disk has a 
> > location where you can write a byte and read it back multiple times and 
> > sometimes get the wrong result. To be really cautions, you might need your 
> > software to write something in multiple locations and when it reads it back 
> > in, check all of them and if most agree, ignore the one or two that don't 
> > while blocking that memory area off and moving your data elsewhere. Or 
> > consider a memory leak that happens rarely but if a program runs for years 
> > or decades, may end up causing an unanticipated error.
> >
>
> True, but there are FAR more efficient ways to do error correction :)
> Hamming codes give you single-bit correction and two-bit detection at
> a cost of log N bits, which is incredibly cheap - even if you were to
> go for a granularity of 64 bytes (one cache line in a modern Intel
> CPU), you would need just 11 bits of Hamming code for every 512 bits
> of data and you can guarantee to fix any single-bit error in any cache
> line. The "if most agree, ignore the one or two that don't" design
> implies that you're writing to an absolute minimum of three places,
> and in order to be able to ignore two that disagree, you'd probably
> need five copies of everything - that is to say, to store 512 bits of
> data, you would need 2560 bits of storage. But with a Hamming code,
> you need just 523 bits to store 512 reliably.
>
> Here's a great run-down on how efficiently this can be done, and how
> easily. https://www.youtube.com/watch?v=X8jsijhllIA
>
> Side note: If we assume that random bit flips occur at a rate of one
> every X storage bits, having redundant copies of data will increase
> the chances of a failure happening. For example, using a naive and
> horrendously wasteful "store 256 copies of everything" strategy, you
> would be 256 times more likely to have a random bitflip, which is
> insane :) You would also be able to guarantee detection of up to 128
> random bitflips. But as you can see, this puts a maximum on your
> storage ratio.
>

Hmm - - - - now how can I combine 'Hamming codes'
and a raid array?

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


Re: Question(s)

2023-10-25 Thread o1bigtenor via Python-list
A post with useful ideas - - - - thanks (it generates some questions!
interleaved)

On Tue, Oct 24, 2023 at 8:35 PM Chris Angelico via Python-list
 wrote:
>
> On Wed, 25 Oct 2023 at 12:11, Thomas Passin via Python-list
>  wrote:
> > This doesn't mean that no program can ever be proven to halt, nor that
> > no program can never be proven correct by formal means.  Will your
> > program be one of those?  The answer may never come ...
>
snip
> So is all hope lost? No. We learn from our mistakes, we add more
> layers. And ultimately, we test until we're reasonably confident, and
> then go with it, knowing that failures WILL happen. Your goal as a
> programmer isn't to prevent failure altogether - if it were, you would
> never be able to achieve anything. Your goal is to catch those
> failures before they cause major issues.
>
> 1. Catch the failure as you're typing in code. Done, fixed, that's
> what the Backspace key is for.
> 2. Catch the failure as you save. We have a lot of tools that can help
> you to spot bugs.

Tools like this for python please.

> 3. Catch the failure before you commit and push. Unit tests are great for 
> this.

Where might I find such please.

> 4. Catch the failure collaboratively. Other developers can help. Or
> you can use automated tests that run on a bot farm, checking your code
> on a variety of different systems (see for example Python's
> buildbots).

This is very interesting - - - grin - - - almost looks like another rabbit hole
to climb into though.

> 5. Catch the failure in alpha. Release to a small number of willing
> users first. They get rewarded with cool new features before everyone
> else does, in return for having fewer guarantees.

For here its software for use here so I get to wear all the hats.

> 6. If all else fails, catch the failure before it kills someone.
> Design your system so that failures are contained. That's easier for
> some than others, but it's part of why I've been saying "system" here
> rather than "program".

This will not be an issue here - - - at least not yet. This is software for
collecting data to enhance management of things that aren't generally
managed in most like outfits. (Or they utilize the 800# gorillas in the
industries tools which are bloody pricey.)
>
> Eff up like it's your job.
> https://thedailywtf.com/articles/eff-up-like-it-s-your-job
>
Very interesting article - - - thanks!

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


Re: Simple webserver

2023-10-25 Thread Chris Angelico via Python-list
On Wed, 25 Oct 2023 at 19:00, Frank Millman via Python-list
 wrote:
> 2. Instead of running as a stand-alone server, run my app as a
> reverse-proxy using Nginx. I tested this a few years ago using Apache,
> and it 'just worked', so I am fairly sure that it will work with Nginx
> as well. Nginx can then provide the additional functionality that Dieter
> has mentioned.

This, I would recommend. In general, tools like Django and Flask and
such are aimed at the creation of web apps, but not necessarily web
servers; it's convenient to have a high-performance web server like
Nginx or Apache, and then it passes along requests to the application
server. This provides a number of benefits:

1. Static files can be served directly, without involving the app
2. Need to scale horizontally? Run two or more copies of your app and
have the web server share requests among them.
3. App crashed? The web server can return an HTTP 503 error so end
users aren't left wondering what's going on.
4. DOS protection can be done in the web server (although it could
also be done in a firewall, or any other level that's appropriate)

> My main concern is that, if I do release my app, I want it to be taken
> seriously and not dismissed as 'Mickey Mouse'. Do you think the above
> changes would assist with that?

You shouldn't be dismissed as Still-In-Copyright-Decades-Old-Rodent
even if you don't make those changes. I've been hosting a number of
servers, some fairly home-grade, and nobody's ever told me that it
looks bad. If you want to be respected, the main thing is to have
something that people find interesting - everything else is secondary.
But there are a few points to consider:

* Performance. People respect something that's snappy and responsive
more than they respect something where a single HTTP request takes
anywhere from 2.89 seconds to nearly 30 seconds. And no, I'm totally
not still mindblown at having seen this kind of appalling performance
from a published and very expensive API.
* Have your own domain name. https://rosuav.github.io/AntiSocialMedia/
is a toy; https://devicat.art/ is a professional web site. (They're
not related, and the first one really is just a toy that I whipped up
in like half an hour.)
* Have a proper SSL certificate. It looks *really bad* to have a
broken or outdated certificate (or none at all, these days).
LetsEncrypt can do that for you, no charge.
* Put some effort into styling. Yeah, I know, most of my web sites are
ugly, so I shouldn't talk. But things definitely look more
professional if you take the time to style them up a bit.

> When I talk about releasing it, it is already available on Github here -
> https://github.com/FrankMillman/AccInABox.
>
> You are welcome to look at it, but it needs a lot of tidying up before
> it will be ready for a wider audience.

Cool! This is particularly of note to me personally. Back in the 90s,
I was working in the family business, and we used a fairly clunky
piece of professionally-written software (and if you want stories, ask
me about overnight runs of report generation, or Ctrl-Alt-Shift and
old mouse pedal importing, or 32-bit installers for 16-bit
applications, or a bunch of other things). There was, for a while, a
theory of us designing our own accounting system, but it turns out,
that's a really REALLY big job, and it's less effort to keep using the
thing you already have.

Your README, dating from 9 years ago, says that you support/require
Python 3.4 - that's kinda ancient now. If you want to take advantage
of newer features, I think you should be safe bumping that up a long
way. :)

I wouldn't recommend sqlite3 for any production work here, but it's
good for a demo. Postgres is a far better choice if you're going to be
storing your vital information in this.

You can list vital packages in a file called requirements.txt - this
will be recognized by both people and automated tooling.

 huh. I'm listed as a contributor. I'll be quite honest, I do not
remember this, but presumably you shared this previously! Looks like
all I contributed was a minor suggestion and commit, but still, I have
absolutely no memory. LOL.

Looks pretty good there. I don't have time right now to download and
install it for a proper test, but based on flipping through the code,
looks like you have something decent going on.

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


Re: Simple webserver

2023-10-25 Thread Frank Millman via Python-list

On 2023-10-22 7:35 PM, Dieter Maurer via Python-list wrote:


The web server in Python's runtime library is fairly simple,
focusing only on the HTTP requirements.

You might want additional things for an HTTP server
exposed on the internet which should potentially handle high trafic:
e.g.

  * detection of and (partial) protection against denial of service attacks,
  * load balancing,
  * virtual hosting
  * proxing
  * URL rewriting
  * high throughput, low latency

Depending on your requirements, other web servers might be preferable.


Dieter's response was very timely for me, as it provides some answers to 
a question that I was thinking of posting. My use-case is reasonably 
on-topic for this thread, so I won't start a new one, if that is ok.


I am writing a business/accounting application. The server uses Python 
and asyncio, the client is written in Javascript. The project is inching 
towards a point where I may consider releasing it. My concern was 
whether my home-grown HTTP server was too simplistic for production, and 
if so, whether I should be looking into using one of the more 
established frameworks. After some brief investigation into Dieter's 
list of additional requirements, here are my initial thoughts. Any 
comments will be welcome.


I skimmed through the documentation for flask, Django, and FastAPI. As 
far as I can tell, none of them address the points listed above 
directly. Instead, they position themselves as one layer in a stack of 
technologies, and rely on other layers to provide additional 
functionality. If I read this correctly, there is nothing to stop me 
doing the same.


Based on this, I am considering the following -

1. Replace my HTTP handler with Uvicorn. Functionality should be the 
same, but performance should be improved.


2. Instead of running as a stand-alone server, run my app as a 
reverse-proxy using Nginx. I tested this a few years ago using Apache, 
and it 'just worked', so I am fairly sure that it will work with Nginx 
as well. Nginx can then provide the additional functionality that Dieter 
has mentioned.


My main concern is that, if I do release my app, I want it to be taken 
seriously and not dismissed as 'Mickey Mouse'. Do you think the above 
changes would assist with that?


When I talk about releasing it, it is already available on Github here - 
https://github.com/FrankMillman/AccInABox.


You are welcome to look at it, but it needs a lot of tidying up before 
it will be ready for a wider audience.


Frank Millman

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