Greetings
(Sorry for a nebulous subject but dunno how to have a short title for
a complex question.)
[...]
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?
Consider an example of bit rot. I mean what if your CPU or hard disk has alocation 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
On 2023-10-24, o1bigtenor wrote:
Greetings
(Sorry for a nebulous subject but dunno how to have a short title for
a complex question.)
[...]
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?
In short, no.
Reality is a mess, and even if you've programmed/perfectly/ to the
datasheets (and passed our unit-tests that are also based on those datasheets), a piece of hardware may not actually conform to what's
written. Maybe the sheet is wrong, maybe the hardware is faulty, etc.
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?
On 24 Oct 2023, at 15:22, o1bigtenor via Python-list <python-list@python.org> wrote:
Greetings
(Sorry for a nebulous subject but dunno how to have a short title for
a complex question.)
I have been using computers for a long time but am only beginning my
foray into the
galaxy of programming. Have done little to this point besides
collection of information
on sensors and working on the logic of what I wish to accomplish. Have
been reading code that accompanies other's projects in the process of
self development.
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?
(Many years ago I remember an article (if not an issue) in Byte magazine about
mathematically proven constructs a.k.a. programs - - - this idea is
what I'm pursuing.
The concept is that in non-trivial programs there are plenty of places where a
poorly placed symbol or lack of a character will result in at best an inaccurate
result and at worst - - - no result. This is the kind of thing
(correct code) that I'm
hoping to accomplish - - - to rephrase the question - - - how do I
test for that?)
TIA
--
https://mail.python.org/mailman/listinfo/python-list
On 24 Oct 2023, at 18:25, o1bigtenor via Python-list <python-list@python.org> wrote:
Is there a way to verify that a program is going to do what it is
supposed to do
On 2023-10-24, Dan Purgert via Python-list <python-list@python.org> wrote:
On 2023-10-24, o1bigtenor wrote:
Greetings
(Sorry for a nebulous subject but dunno how to have a short title for
a complex question.)
[...]
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?
In short, no.
Reality is a mess, and even if you've programmed/perfectly/ to the datasheets (and passed our unit-tests that are also based on those datasheets), a piece of hardware may not actually conform to what's written. Maybe the sheet is wrong, maybe the hardware is faulty, etc.
And the specified customer requirements are usually wrong too. Sure,
the customer said it is supposed to do X, but what they actually
needed was Y.
And the protocol spec isn't quite right either. Sure, it says "when A
is received reply with B", but what everybody really does is slighty different, and you need to do what everybody else does, or the widget
you're talking to won't cooperate.
And floating point doesn't really work the way you think it
does. Sometimes it does, close-enough, for the test-cases you happened
to choose...
On 2023-10-24, Thomas Passin via Python-list <python-list@python.org> wrote:
Something less ambitious than a full proof of correctness of an
arbitrary program can sometimes be achieved. 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.
Er, what?
C didnt' exist until after the Apollo program was done.
FORTRAN, perhaps?
Greetings
(Sorry for a nebulous subject but dunno how to have a short title for
a complex question.)
I have been using computers for a long time but am only beginning my
foray into the
galaxy of programming. Have done little to this point besides
collection of information
on sensors and working on the logic of what I wish to accomplish. Have
been reading code that accompanies other's projects in the process of
self development.
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?
(Many years ago I remember an article (if not an issue) in Byte magazine about
mathematically proven constructs a.k.a. programs - - - this idea is
what I'm pursuing.
The concept is that in non-trivial programs there are plenty of places where a
poorly placed symbol or lack of a character will result in at best an inaccurate
result and at worst - - - no result. This is the kind of thing
(correct code) that I'm
hoping to accomplish - - - to rephrase the question - - - how do I
test for that?)
TIA
There is no general way to prove that a program is "correct". Or even whether it will terminate or loop endlessly.
These are of course theoretical statements of computer science. But
they can be rigorously proven. (Sorry if I'm just saying this to show
what a smart-ass I am. 🙂)
In practice, of course, there is often a great deal that can be done to "verify" (a word whose meaning I intentionally leave vague) a program's correctness.
In your case, it sounds as if you should
Write programs or functions to simulate each piece of hardware and generate random, but reasonably realistic, data. (Python and most other programming languages provide means of generating random or
pseudo-random data.)
In your main program:
Replace the bits of code that accept data from the hardware by
bits of code that accept data from these simulation programs/functions.
Write the decisions it makes to a log file (or files).
Run the program as long as you can or until your patience is
exhausted, and check from the log file(s) that it is behaving as you
would expect.
This is not guaranteed to catch all possible errors. (Nothing is.) E.g.
The original code to accept data from the hardware (code that you
remove in your test version of the program) might be wrong. Duh!
There might be specific sets of input data that happen not to arise
in your testing, but that your program logic does not cope with.
Nonetheless, this sort of testing (if done diligently) can give you a
high degree of confidence in your program.
And it is a good idea to do it.
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).
By now you have read many responses that basically say that you cannot
prove that a given program has no errors, even apart from the hardware question. Even if it could be done, the kind of specification that you
would need would in itself be difficult to create, read, and understand,
and would be subject to bugs itself.
Something less ambitious than a full proof of correctness of an
arbitrary program can sometimes be achieved. 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.
You won't be doing that.
Here I want to point out something else. You say you are just getting
into programming. You are going to be making many mistakes and errors,
and there will be many things about programming you won't understand
until you get some good solid experience. That's not anything to do
with you personally, that's just how it will play out.
So be prepared to learn from your mistakes and bugs. They are how you
learn the nuts and bolts of the business of programming.
Something less ambitious than a full proof of correctness of an
arbitrary program can sometimes be achieved. 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.
So how does one test software then?
And the specified customer requirements are usually wrong too. Sure,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?
the customer said it is supposed to do X, but what they actually
needed was Y.
So how does one test software then?
On Tue, Oct 24, 2023 at 6:09 PM Thomas Passin via Python-list <python-list@python.org> wrote:
snip
By now you have read many responses that basically say that you cannot
prove that a given program has no errors, even apart from the hardware
question. Even if it could be done, the kind of specification that you
would need would in itself be difficult to create, read, and understand,
and would be subject to bugs itself.
Something less ambitious than a full proof of correctness of an
arbitrary program can sometimes be achieved. 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. >>
You won't be doing that.
Here I want to point out something else. You say you are just getting
into programming. You are going to be making many mistakes and errors,
and there will be many things about programming you won't understand
until you get some good solid experience. That's not anything to do
with you personally, that's just how it will play out.
So be prepared to learn from your mistakes and bugs. They are how you
learn the nuts and bolts of the business of programming.
I am fully expecting to make mistakes (grin!).
I have a couple trades tickets - - - I've done more than a touch of technical learning so mistakes are not scary.
What is interesting about this is the absolute certainty that it is impossible
to program so that that program is provably correct.
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.
That's what I'm looking to do with the programming.
(Is that different than the question(s) that I've asked - - - dunno.)
Stimulating interaction for sure (grin!).
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 inmultiple 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
By now you have read many responses that basically say that you cannot
prove that a given program has no errors, even apart from the hardware question. Even if it could be done, the kind of specification that you
would need would in itself be difficult to create, read, and understand,
and would be subject to bugs itself.
Something less ambitious than a full proof of correctness of an
arbitrary program can sometimes be achieved. 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.
You won't be doing that.
Here I want to point out something else. You say you are just getting
into programming. You are going to be making many mistakes and errors,
and there will be many things about programming you won't understand
until you get some good solid experience. That's not anything to do
with you personally, that's just how it will play out.
So be prepared to learn from your mistakes and bugs. They are how you
learn the nuts and bolts of the business of programming.
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 ...
Hmmmmmmmmmm - - - - now how can I combine 'Hamming codes'
and a raid array?
TIA
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.
On Tue, Oct 24, 2023 at 5:28 PM Rob Cliffe <rob.cliffe@btinternet.com> wrote:
Interesting - - - hopefully taken in the same vein as your second
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).
statement - - I sorta sounds like programmers keep running around in
the forest looking for trees. (Grin!)
So how does one test software then?
...
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?
On Wed, 25 Oct 2023 at 12:11, Thomas Passin via Python-list <python-list@python.org> 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 ...
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.
3. Catch the failure before you commit and push. Unit tests are great for this.
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).
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.
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".
Eff up like it's your job. https://thedailywtf.com/articles/eff-up-like-it-s-your-job
On Wed, 25 Oct 2023 at 12:20, AVI GROSS via Python-list <python-list@python.org> wrote: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
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
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.
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.
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.
On Wed, 25 Oct 2023 at 21:53, o1bigtenor <o1bigtenor@gmail.com> wrote:
Hmmmmmmmmmm - - - - 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.
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.
On Wed, Oct 25, 2023 at 6:24 AM Dieter Maurer <dieter@handshake.de> 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.
On Wed, 25 Oct 2023 at 21:46, o1bigtenor <o1bigtenor@gmail.com> 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.
On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer <dieter@handshake.de> 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 others,
e.g. "ECLIPSE" can be used for Python development.
Is 'Eclipse' a Windows oriented IDE?
"https://en.wikipedia.org/wiki/Eclipse_(software)"
o1bigtenor wrote at 2023-10-25 06:44 -0500:
On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer <dieter@handshake.de> 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.
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)"
The programming team for the Apollo moon mission developed a system which,> if you would write your requirements in a certain way, could generate correctSince the last Apollo mission was in 1972, when C was first being developed, I find this hard to believe.
C code for them.
What is interesting about this is the absolute certainty that it is impossible
to program so that that program is provably correct.
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.
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?
On 10/25/2023 8:50 AM, o1bigtenor via Python-list wrote:
On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer <dieter@handshake.de>
wrote:
Interesting - - - started looking into this.
o1bigtenor wrote at 2023-10-25 06:44 -0500:
On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer <dieter@handshake.de>
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.
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
...
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.
"ecosia.org") and the second hit gave:"https://marketplace.eclipse.org/content/pydev-python-ide-eclipse".
On Tue, Oct 24, 2023 at 8:35 PM Chris Angelico via Python-list <python-list@python.org> wrote:
3. Catch the failure before you commit and push. Unit tests are great for this.
Where might I find such please.
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.
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.
Looks like I have another area to investigate. (grin!)
Any suggestions?
Haven't heard of a python IDE - - - doesn't mean that there isn't such - -
On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer <dieter@handshake.de> wrote:
Interesting - - - started looking into this.
o1bigtenor wrote at 2023-10-25 06:44 -0500:
On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer <dieter@handshake.de> 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.
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.
On 24/10/2023 17.50, Thomas Passin wrote:
The programming team for the Apollo moon mission developed a systemSince the last Apollo mission was in 1972, when C was first being
which,> if you would write your requirements in a certain way, could
generate correct
C code for them.
developed, I
find this hard to believe.
On Wed, Oct 25, 2023 at 7:00 AM Dieter Maurer <dieter@handshake.de> 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.)
What is interesting about this is the absolute certainty that it is impossible
to program so that that program is provably correct.
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.
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".
On 25/10/2023 05.45, o1bigtenor wrote:
On Tue, Oct 24, 2023 at 8:35 PM Chris Angelico via Python-list <python-list@python.org> 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).
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.
--
Does this link help? It seems to have a Linux package here.related.
Eclipse Packages | The Eclipse Foundation - home to a global community,
the Eclipse IDE, Jakarta EE and over 350 open source projects... <https://www.eclipse.org/downloads/packages/>
eclipse.org <https://www.eclipse.org/downloads/packages/>
[image: favicon.ico] <https://www.eclipse.org/downloads/packages/> <https://www.eclipse.org/downloads/packages/>
I was looking at this page and absoulutely couldn't find anything python
On Wed, Oct 25, 2023 at 9:10 AM Dieter Maurer <dieter@handshake.de> wrote:
o1bigtenor wrote at 2023-10-25 08:29 -0500:
...I entered "eclipse python download" in my favorite search engine
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. >>
"ecosia.org") and the second hit gave:"https://marketplace.eclipse.org/content/pydev-python-ide-eclipse".
Using Duckduckgo I had tried eclipse + python which I would have
thought should have spit out something useful - - - but that just took
me to the general page and the download - - - well it did NOT offer
any python anything!
Thank you for the tip!
By the way you definitely can step
through MicroPython code one line at a time with a remote debugger, say
with Visual Studio Code.
Interesting - - - - ". . . see if it runs." - - - that's the issue!
When the code is accessing sensors there isn't an easy way to
check that the code is working until one has done the all of the
physical construction. If I'm trying to control a pulsation system
using square waves with distinct needs for timing etc I hadn't
seen any way of 'stepping through the code' (phrase you use later).
I have been following this list for some time. Don't believe that I've ever seen anything where anyone was referred to 'Idle'. In reading other user group threads I have heard lots about java and its ide - - - don't remember, again, any re: an ide for python.
Even in maker threads - - - say for arduino - - its 'use this cut and
paste method
of programming' with no mention of any kind of ide when it was microPython - -
although being a subset of python it Idle may not work with it.
Oh well - - - I am working on things!
On 10/26/23 10:41, Michael Torrie wrote:Even here - - - I now have a first step and a direction!
By the way you definitely can step
through MicroPython code one line at a time with a remote debugger, say with Visual Studio Code.
I meant to edit that bit out. After doing a bit more research, it
appears remote debugging with MicroPython may not be possible or easy.
But the MicroPython lists and forums will know more about that than I
do. But there are some nice IDEs for developing code in MicroPython and deploying it to devices.
--
On 10/26/23 06:34, o1bigtenor wrote:
Interesting - - - - ". . . see if it runs." - - - that's the issue!
When the code is accessing sensors there isn't an easy way to
check that the code is working until one has done the all of the
physical construction. If I'm trying to control a pulsation system
using square waves with distinct needs for timing etc I hadn't
seen any way of 'stepping through the code' (phrase you use later).
Having dabbled in embedded electronics, all I can say is you will just
have to build it and try to get it working. Failure is always an
option. If I understand you correctly, this is for a hobby interest, so
go at it and have fun.
Stepping through code is a basic part of debugging in any language.
They all have tools for it. Google for python debugging.
"distinct needs for timing?" Did you forget to tell us you need to use MicroPython? Certainly MicroPython running on a microcontroller with
help from hardware timers certainly can do it, but this mailing list is
not the place to ask about it. Instead you'll have to visit a forum on MicroPython or CircuitPython. By the way you definitely can step
through MicroPython code one line at a time with a remote debugger, say
with Visual Studio Code.
I have been following this list for some time. Don't believe that I've ever seen anything where anyone was referred to 'Idle'. In reading other user group threads I have heard lots about java and its ide - - - don't remember,
again, any re: an ide for python.
Idle has been mentioned on several occasions, but probably more on the python-tutor list. I find it hard to believe that searching for Python
IDEs really came up blank. There are even IDEs for MicroPython and
embedded devices. I found a nice list with a quick search.
Even in maker threads - - - say for arduino - - its 'use this cut and
paste method
of programming' with no mention of any kind of ide when it was microPython - -
although being a subset of python it Idle may not work with it.
You keep dropping little details that, had you included them in the
first post, would have helped avoid a lot of answers that ultimately
aren't going to be useful to you. Are you working MicroPython or with regular Python on a PC? That makes a big difference in where you go to
get help and what kind of help we can provide here.
Oh well - - - I am working on things!
That is good. I wish you success.
On Wed, Oct 25, 2023 at 10:19 AM Michael Torrie via Python-list
<python-list@python.org> wrote:
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
Interesting - - - - ". . . see if it runs." - - - that's the issue!
When the code is accessing sensors there isn't an easy way to
check that the code is working until one has done the all of the
physical construction. If I'm trying to control a pulsation system
using square waves with distinct needs for timing etc I hadn't
seen any way of 'stepping through the code' (phrase you use later).
[...]
Even in maker threads - - - say for arduino - - its 'use this cut and
paste method of programming' with no mention of any kind of ide when
it was microPython - - although being a subset of python it Idle may
not work with it.
[...]
My problem is that I'm needing to move quite quickly from 'hello, world' to something quite a bit more complex. Most of the instruction stuff I've run into assumes that one is programming only for the joy of learning to
program where I've got things I want to do and - - - sadly - - - they're
not sorta like the run of the mill stuff.
On Thu, Oct 26, 2023 at 11:43 AM Michael Torrie via Python-list <python-list@python.org> wrote:
On 10/26/23 06:34, o1bigtenor wrote:
Interesting - - - - ". . . see if it runs." - - - that's the issue!
When the code is accessing sensors there isn't an easy way to
check that the code is working until one has done the all of the
physical construction. If I'm trying to control a pulsation system
using square waves with distinct needs for timing etc I hadn't
seen any way of 'stepping through the code' (phrase you use later).
Having dabbled in embedded electronics, all I can say is you will just
have to build it and try to get it working. Failure is always an
option. If I understand you correctly, this is for a hobby interest, so
go at it and have fun.
Stepping through code is a basic part of debugging in any language.
They all have tools for it. Google for python debugging.
"distinct needs for timing?" Did you forget to tell us you need to use
MicroPython? Certainly MicroPython running on a microcontroller with
help from hardware timers certainly can do it, but this mailing list is
not the place to ask about it. Instead you'll have to visit a forum on
MicroPython or CircuitPython. By the way you definitely can step
through MicroPython code one line at a time with a remote debugger, say
with Visual Studio Code.
Its one of the reasons to use micropython - - - it is a subset of python.
I didn't think I was asking about micropython here though. The project with the square wave stuff has lots going on so its more likely that regular python
will be used. Part of the challenge is trying to figure out if I need to be running a real time kernel or even a real time OS. Independent information
is quite hard to find - - - seems like most of the information is by someone with skin in the game and then without a background its hard to figure out
if what they're saying tells enough so that I can make a good decision or not.
I am not one for IDLE worship, Tenor. But if you have been getting a message here, it is that there are an amazing number of programs that support your use of python during the development phase and perhaps later. I actually often use an environmentcalled RSTUDIO (now part of a new name of POSIT) because it has been expanded beyond supporting R and supports Python and a growing number of other languages or combos that combine word processing with inserts from multiple languages.
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.
--
I am not one for IDLE worship, Tenor. But if you have been getting amessage here, it is that there are an amazing number of programs that
Thomas,
It looks like much of our discussion and attempts at help are not going to
be that helpful to Tenor as we may be way off bass about what he wants to do and certainly RSTUDIO and quite a few other suggestions may not be available in his microcontroller.
As I see it, some of his objective involves sampling a sensor in real time.
I have not heard what he wants to do with the data gathered and this may be an example of where code needs to be running fast enough to keep up. Proving the code will work, especially if you add logging or print statements or run it in a monitored mode so you can follow what it is doing, presents special challenges.
Now if he ever wants to read in a .CSV file and analyze the data and make graphs and so on, I might chime in. For now, I am dropping out.
Avi
-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of Thomas Passin via Python-list
Sent: Thursday, October 26, 2023 6:50 PM
To: python-list@python.org
Subject: Re: Question(s)
On 10/26/2023 6:36 PM, AVI GROSS via Python-list wrote:
I am not one for IDLE worship, Tenor. But if you have been getting amessage here, it is that there are an amazing number of programs that
support your use of python during the development phase and perhaps later. I actually often use an environment called RSTUDIO (now part of a new name of POSIT) because it has been expanded beyond supporting R and supports Python and a growing number of other languages or combos that combine word processing with inserts from multiple languages.
Excellent! I didn't know about this development.
[snip]
Error correcting memory, redundant systems, and human
monitoring, plus the ability to rewrite the guidance software on the
fly if they needed to.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 546 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 28:53:35 |
| Calls: | 10,390 |
| Calls today: | 1 |
| Files: | 14,064 |
| Messages: | 6,417,082 |