Re: on floating-point numbers

2021-09-08 Thread Hope Rouselle
Joe Pfeiffer  writes:

> Hope Rouselle  writes:
>> Christian Gollwitzer  writes:
>>>
>>> I believe it is not commutativity, but associativity, that is
>>> violated. 
>>
>> Shall we take this seriously?  (I will disagree, but that doesn't mean I
>> am not grateful for your post.  Quite the contary.)  It in general
>> violates associativity too, but the example above couldn't be referring
>> to associativity because the second sum above could not be obtained from
>> associativity alone.  Commutativity is required, applied to five pairs
>> of numbers.  How can I go from
>>
>>   7.23 + 8.41 + 6.15 + 2.31 + 7.73 + 7.77
>>
>> to 
>>
>>   8.41 + 6.15 + 2.31 + 7.73 + 7.77 + 7.23?
>>
>> Perhaps only through various application of commutativity, namely the
>> ones below. (I omit the parentheses for less typing.  I suppose that
>> does not create much trouble.  There is no use of associativity below,
>> except for the intented omission of parentheses.)
>>
>>  7.23 + 8.41 + 6.15 + 2.31 + 7.73 + 7.77
>>= 8.41 + 7.23 + 6.15 + 2.31 + 7.73 + 7.77
>>= 8.41 + 6.15 + 7.23 + 2.31 + 7.73 + 7.77
>>= 8.41 + 6.15 + 2.31 + 7.23 + 7.73 + 7.77
>>= 8.41 + 6.15 + 2.31 + 7.73 + 7.23 + 7.77
>>= 8.41 + 6.15 + 2.31 + 7.73 + 7.77 + 7.23.
>
> But these transformations depend on both commutativity and
> associativity, precisely due to those omitted parentheses.  When you
> transform
>
> 7.23 + 8.41 + 6.15 + 2.31 + 7.73 + 7.77
>
> into
>
> 8.41 + 6.15 + 2.31 + 7.73 + 7.77 + 7.23.
>
> it isn't just assuming commutativity, it's also assuming associativity
> since it is changing from
>
> (7.23 + 8.41 + 6.15 + 2.31 + 7.73) + 7.77
>
> to
>
> (8.41 + 6.15 + 2.31 + 7.73 + 7.77) + 7.23.
> 
> If I use parentheses to modify the order of operations of the first line
> to match that of the last, I get
> 7.23 + (8.41 + 6.15 + 2.31 + 7.73 + 7.77)
>
> Now, I get 39.61 evaluating either of them.

I need to go slow.  If I have just two numbers, then I don't need to
talk about associativity: I can send 7.23 to the rightmost place with a
single application of commutativity.  In symbols,

  7.23 + 8.41 = 8.41 + 7.23.

But if I have three numbers and I want to send the leftmost to the
rightmost place, I need to apply associativity

7.23 + 8.41 + 6.15
  = (7.23 + 8.41) + 6.15  -- clarifying that I go left to right
  = 7.23 + (8.41 + 6.15)  -- associativity
  = (8.41 + 6.15) + 7.23  -- commutativity

I see it.  Cool.  Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: on writing a while loop for rolling two dice

2021-09-08 Thread charles hottel

On 9/7/2021 9:20 PM, Avi Gross wrote:

Greg,

Yes, a smart person may come up with such tricks but a really smart person,
in my view, adjusts. With some exceptions, such as when trying to port
existing code to a new language quickly, someone who is not too obsessive
will try to pick up the goals and spirit of a new language and use them when
it seems reasonable. And, a smart person, if they see nothing new, might
just go back to their old language or ...

Pick a language that easily supports regular expressions and object creation
and functional programming and so on, like python, and ask why you might
want to use it to simulate a really old version of BASIC when you can just
use BASIC.

Admittedly, most people are not flexible. I find that with human languages
too that some learn another language just enough to recognize words but not
to use the changed grammar or the different idioms and never become fluent.

I am amused though at the fact that python, by using indentation rather than
things like curly braces, would make some of the games like shown below
quite a bit more difficult.

-Original Message-
From: Python-list  On
Behalf Of Greg Ewing
Sent: Tuesday, September 7, 2021 9:08 PM
To: [email protected]
Subject: Re: on writing a while loop for rolling two dice

On 8/09/21 2:53 am, Grant Edwards wrote:

#define IF if (
#define THEN ) {
#define ELSE } else {
#define ENDIF }
...


I gather that early versions of some of the Unix utilities were written by
someone who liked using macros to make C resemble Algol.

I guess you can get away with that sort of thing if you're a Really Smart
Person.

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



So what do yoy think or feel about a language like RATFOR (Rational 
FORTRAN) which was implemented as macros?  Should they instead have 
simply adapted themselves to FORTRAN?

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


combine multiple xlsx files which include dropdown columns in them.

2021-09-08 Thread [email protected]
I've some xlsx files which include dropdown columns in them. I want to know 
whether I can combine all the lines into one xlsx file. Any hints for doing 
this job with python programmatically will be highly appreciated.

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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Grant Edwards
On 2021-09-08, charles hottel  wrote:

> So what do yoy think or feel about a language like RATFOR (Rational 
> FORTRAN) which was implemented as macros?  Should they instead have 
> simply adapted themselves to FORTRAN?

That's an interesting question. If the langauge is complete,
well-defined, and well-documented then it's not that much different
than any other source language than gets translated into a lower level
language (e.g. C -> assembly). My recollection of RATFOR was that it
provided enough signifcant "features" that weren't available in the
underlying FORTRAN to make it worthwhile.

That seems to me to be qualitatively different than a set of macros
that simply make one language look (somewhat) like a different
language with a similar level of abstraction -- without providing
anything other than cosmetic changes.

--
Grant

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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Grant Edwards
On 2021-09-08, charles hottel  wrote:

> So what do yoy think or feel about a language like RATFOR (Rational 
> FORTRAN) which was implemented as macros?

The RATFOR implementations I've seen weren't done using macros. It was
a preprocessor, yes. But it generates code for the various structured
statement types (while, for, if/then/else) and source structures
(open/close brace) the way a compiler does, even though the generated
code is FORTRAN66 rather than assembly or bytecode or whatever.

> Should they instead have simply adapted themselves to FORTRAN?


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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Dennis Lee Bieber
On Wed, 8 Sep 2021 00:24:44 +0100, Alan Gauld via Python-list
 declaimed the following:

>
>That was quite common in C before it became popular(early/mid 80s).
>I've seen Pascal, Algol and Coral macro sets in use.
>You could even download pre-written ones from various
>bulletin boards (remember them?!) for a while.

And if one wants to expose themselves to real horror -- look at the
output of one of those "structured FORTRAN" preprocessors (RATFOR, TEXTFOR,
others) that were cropping up in the late 70s to generate FORTRAN-IV from
code written with block IF, WHILE, etc.

I spent close to 20 years (80s-90s) maintaining the /output/ of such a
preprocessor. The software had apparently originated with a sub-contractor,
and we did not have access to their preprocessor (and/or no one ported it
to the VAX-11 from PDP-11). 

At first my practice was to study a file in detail, and then rewrite it
using F77 with separately compiled subroutines (the preprocessor was "one
file per program" and implemented BASIC-style GOSUB, relying on shared
variables and ASSIGNed GOTO for the return address -- I had to move the
shared variables to COMMON blocks to make separate subroutines usable).

By the end of those decades, I'd been exposed to the preprocessor
enough to hand-write smaller patches within its style. The only good thing
is that is left the structured source as comments, and tended to
right-justify the F-IV output, so easy to locate...



-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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


Re: combine multiple xlsx files which include dropdown columns in them.

2021-09-08 Thread Dennis Lee Bieber
On Tue, 7 Sep 2021 22:05:58 -0700 (PDT), "[email protected]"
 declaimed the following:

>I've some xlsx files which include dropdown columns in them. I want to know 
>whether I can combine all the lines into one xlsx file. Any hints for doing 
>this job with python programmatically will be highly appreciated.

I don't recall ANY Python Excel reader/writer that can handle embedded
scripting. They all only read the last value active in a cell, not the code
behind the cell. They mostly just bypass the need to convert to/from
CSV/TSV.

Presuming you are doing this on Windows, you might be able to use
either the pywin32/win32py extension library, or ctypes, to invoke the
Excel COM interface -- which may allow you to read the underlying script
and/or form objects.

If this is a one-time operation, it may be faster to just open the
files and use cut&paste  Or write a large VBA script in Excel.

This appears to be the current "favored" package from Python:
https://openpyxl.readthedocs.io/en/stable/

You may still have problems: 
"""
keep_vba controls whether any Visual Basic elements are preserved or not
(default). If they are preserved they are still not editable.
"""
If not editable, you won't be able to copy from one file to another.
Also:
"""
openpyxl does currently not read all possible items in an Excel file so
images and charts will be lost from existing files if they are opened and
saved with the same name.
"""
It does, however, grant access to the formulas in cells, rather than
just last value; along with style information...



-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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


RE: on writing a while loop for rolling two dice

2021-09-08 Thread Avi Gross via Python-list
Charles,

This forum is for python discussions so I will clarify that there is nothing
wrong with making up a new language, including by bootstrapping an old
language. But why not call it new and do not try to confuse people using the
old.

Python has grown and added much over the years and even had a fairly
negative experience in a transition from versions 2 to 3 as some people
complain their old software no longer works. 

If you look at a language like C which was remade into C++, guess what? It
has a new name and makes no claims to be fully compatible. 

If RATFOR was a more pleasant programming environment for some people and
purposes, fine.

I note Python has many modules that for some people become the most used
parts even when the base language might allow some similar functionality.
Someone who learns python but has never experienced those, may feel a bit
lost. And you can customize Python to a point where it does things in fairly
hidden ways too. There are no promises of purity.

What this particular discussion began with was much lower level and about
various ways of writing a while loop within very basic Python and seems to
be heading away into discussions of other languages. I happen to enjoy
learning and contrasting lots of languages but doubt many others do and most
people want to learn just a few good tools and use them to get their job
done. My point was if you have a tool you like and you try another you
don't, then rather than trying to force the new one, just use what works and
leave others that like it alone. Make your own religion and let others keep
theirs.

However, improvements and increased functionality may be more welcome, than
examples where the interface was changed with no benefits.

-Original Message-
From: Python-list  On
Behalf Of charles hottel
Sent: Tuesday, September 7, 2021 11:31 PM
To: [email protected]
Subject: Re: on writing a while loop for rolling two dice



So what do yoy think or feel about a language like RATFOR (Rational
FORTRAN) which was implemented as macros?  Should they instead have simply
adapted themselves to FORTRAN?
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Grant Edwards
On 2021-09-08, Dennis Lee Bieber  wrote:

> I spent close to 20 years (80s-90s) maintaining the /output/ of such
> a preprocessor.

Ouch. I hope it paid well. ;)

Back when I did a lot of TeX/LaTeX stuff on VMS, I used to make
occasional fixes and add (very minor) features to one of the dvi
handling executables (I don't remember if it was the VT2xx previewer,
or the laser-printer "driver") using the VMS "PATCH" utility. I also
can't remember how we ended up without source code for that piece of
the toolchain when we build all of the reset of it from source.

> The software had apparently originated with a sub-contractor, and we
> did not have access to their preprocessor

Allowing that to happen is definitely a major management F*%k-up for
which somebody should have had their career ended.

> (and/or no one ported it to the VAX-11 from PDP-11).

I would have though that would have been pretty trivial compared to
maintaining the output source for 20 years.

--
Grant




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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Dennis Lee Bieber
On Wed, 8 Sep 2021 14:46:28 - (UTC), Grant Edwards
 declaimed the following:

>On 2021-09-08, charles hottel  wrote:
>
>> So what do yoy think or feel about a language like RATFOR (Rational 
>> FORTRAN) which was implemented as macros?  Should they instead have 
>> simply adapted themselves to FORTRAN?
>
>That's an interesting question. If the langauge is complete,
>well-defined, and well-documented then it's not that much different
>than any other source language than gets translated into a lower level
>language (e.g. C -> assembly). My recollection of RATFOR was that it
>provided enough signifcant "features" that weren't available in the
>underlying FORTRAN to make it worthwhile.
>

Primarily providing block structured IF/ELSE and loops -- in a language
that only really provided IF/GOTO...

My college tried using one of these (for some reason the name TextFOR
sticks with me)... The experiment only lasted one term. The preprocessor
ate CPU and I/O time -- with the result that the FORTRAN class used two or
three times the times of the COBOL class! (The native compilers were
designed as re-entrant, allowing multiple compiles to share one in-core
image; the preprocessor no doubt ran as one image per compile, triggering
lots of page swapping to disk)


-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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


Re: on writing a while loop for rolling two dice

2021-09-08 Thread Dennis Lee Bieber
On Wed, 8 Sep 2021 16:32:45 - (UTC), Grant Edwards
 declaimed the following:

>On 2021-09-08, Dennis Lee Bieber  wrote:
>
>> I spent close to 20 years (80s-90s) maintaining the /output/ of such
>> a preprocessor.
>
>Ouch. I hope it paid well. ;)

Only if one ignores the bloody cost of apartments (given the rent paid
over the 30 years I spent in that 1BR 680sq.ft. unit I should have owned
it, if not half the facility )
>
>> The software had apparently originated with a sub-contractor, and we
>> did not have access to their preprocessor
>
>Allowing that to happen is definitely a major management F*%k-up for
>which somebody should have had their career ended.
>
For all I know, someone might have... Back when the application was
running on PDP-11 (I joined the program early 80s, when the "mission
planning" software was being ported to the VAX-11).

Most of the "mission planning" software was local-grown, so was DEC
FORTRAN (may have started as F-IV, and developed F77 during maintenance and
the porting to the VAX). Not the part I maintained -- which drove a Ramtek
9300 graphics engine (only one engine could be installed into a VAX, it was
that archaic). It got to the point where I think Ramtek service was
recycling the parts when ever we had a service call. Eventually I proposed
that a VAXstation (DECWindows) and GKS could replace most of the display
side. We weren't approved to rewrite the application to directly display --
but rewriting the Ramtek library to send the plotting data to a separate
program, which managed the display window, was in the budget.

>
>I would have though that would have been pretty trivial compared to
>maintaining the output source for 20 years.

I'm not so sure -- that "one file per executable" would have led to
long compile times (first for the preprocessor, then for the generated F-IV
output), vs my rewrites into multiple files, where only isolated changes
needed to be recompiled.

Humorously, the graphics application suite was known as "MESS" (I can't
go deeper into the acronym without violating security classification).


-- 
Wulfraed Dennis Lee Bieber AF6VN
[email protected]://wlfraed.microdiversity.freeddns.org/

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


Re: combine multiple xlsx files which include dropdown columns in them.

2021-09-08 Thread Kushal Kumaran
On Tue, Sep 07 2021 at 10:05:58 PM, "[email protected]" 
 wrote:
> I've some xlsx files which include dropdown columns in them. I want to
> know whether I can combine all the lines into one xlsx file. Any hints
> for doing this job with python programmatically will be highly
> appreciated.
>

The dropdown is *probably* implemented using Excel's data validation
mechanism.  openpyxl's documentation says it can read[1]/write Excel
files and also mentions data validation[2].  You might be able to use it
to read the existing files, combine the rows and write to a different
file.

[1] 
https://openpyxl.readthedocs.io/en/stable/usage.html#read-an-existing-workbook
[2] https://openpyxl.readthedocs.io/en/stable/validation.html

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


Problems with running Python in Npp

2021-09-08 Thread Ricardo
   Hey Python and crew I'm having difficulties installing and running Python
   on my computer. I've seen plenty YouTube videos on how to set it up, but
   none of them have worked. Any help or guidance will be greatly
   appreciated.



   Sincerely,

   Ricardo



   Sent from [1]Mail for Windows



References

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


Re: combine multiple xlsx files which include dropdown columns in them.

2021-09-08 Thread [email protected]
On Thursday, September 9, 2021 at 9:15:23 AM UTC+8, Kushal Kumaran wrote:
> On Tue, Sep 07 2021 at 10:05:58 PM, "[email protected]"  
> wrote: 
> > I've some xlsx files which include dropdown columns in them. I want to 
> > know whether I can combine all the lines into one xlsx file. Any hints 
> > for doing this job with python programmatically will be highly 
> > appreciated. 
> >
> The dropdown is *probably* implemented using Excel's data validation 
> mechanism. openpyxl's documentation says it can read[1]/write Excel 
> files and also mentions data validation[2]. You might be able to use it 
> to read the existing files, combine the rows and write to a different 
> file. 
> 
> [1] 
> https://openpyxl.readthedocs.io/en/stable/usage.html#read-an-existing-workbook
>  
> [2] https://openpyxl.readthedocs.io/en/stable/validation.html 

Thank you for your comments. For a related discussion on this topic, please 
refer to [1].

[1] https://groups.google.com/g/openpyxl-users/c/k2xnPZS2kbo/m/m2YmEO9ZBgAJ

Regards,
HY

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


Change the display style of the text on the STACKLINE.

2021-09-08 Thread [email protected]
I'm using the following code in my forked project [1]:

percol.view.STACKLINE = 'Fold:F1,F2,F3 Push:C-p Pop:M-p Script:M-s Dir:M-d 
Dircmd:M-b'

I would like to change the display style of the text mentioned above, for 
example, to underline some characters in it, as shown below:

_D_ir:M-d

How to achieve this purpose? 

[1] 
https://github.com/hongyi-zhao/ariadne/blob/838179bb4275ac85f5342d9e7d086d6ade3be1de/rc.py#L55

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