Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Alan Gauld
On 17/03/2023 17:55, Thomas Passin wrote:

>> I used Delphi and Smalltalk/V which both pretty much only exist within
>> their own IDEs and I used their features extensively.
> 
> Back when Delphi first came out, when I first used it, I don't remember 
> any IDE; one just used a text editor.

I think you might be meaning TurboPascal, Delphi's forerunner. It just
had a compiler and text editor. But Delphi from day 1 was an IDE
designed to compete with Visual Basic. Everything was geared around the
GUI builder. You could write code outside the IDE but it was orders of
magnitude more difficult.

The Lazarus open source project is based on Delphi's IDE.

-- 
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: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Weatherby,Gerard
I send ~99% of Python coding time in PyCharm. Likewise, IntelliJ and Clion for 
Java and C++, respectively.

Mostly use:
Tab completion for variable names
Letting PyCharm figure out imports for me, and cleaning up old, unused imports.
Jumping to definitions of symbols.
Tellling me I’ve made a type error before unit testing the code by highlighting 
it in yellow.
   Occasionally I’ll jump through the hoops to connect it to our Postgresql 
database to help verify SQL, but it’s not usually worth the trouble.

For templating, I have two Python programs for starting new work. One generates 
a standalone Python program with the Python shebang, a __main__ which calls def 
main(), and logging and argparser intialization. The other generates a 
pyproject.toml  /setup.cfg directory structure with a main.py referenced as a 
console script. from setup.cfg


From: Python-list  on 
behalf of dn via Python-list 
Date: Thursday, March 16, 2023 at 6:59 PM
To: 'Python' 
Subject: Friday finking: IDE 'macro expansions'
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

It is a long, long, time since I've thrown one of these into the
maelstrom of our musings.
(have the nightmares receded?)


Do you make use of your IDE's expansionist tendencies, and if-so, which
ones?


NB this is where vi/emacs enthusiasts start chuckling (polite term for
'insane cackling'). Hence the question's limitation to IDEs, cf 'editors'!
Also: I'm talking 'PyCharm' because of the story, but others use Codium,
Sublime Text, etc - which presumably offer equivalent features.


Was helping a friend install PyCharm. Jumped into the Settings. Isn't it
incredible how many there are?

Idly noted that there are two short-cut or macro-expansion types of
facilities:
- Postfix Completion, (nothing to do with email or polish notation) and
- Live Templates (again, we're not talking about jinja2)


With both, one types an abbreviated-name and the IDE will expand it into
appropriate code. For (LiveTemplate) example, typing compli and pressing
Tab induces PyCharm to add the following to the program[me]:

 [ ! for ! in !drop-down menu! if ! ]

It offers further typo-saving through the drop-down menu which lists a
bunch of likely (iterable) candidates from amongst previously-written
code. The action continues after selecting from the menu, by inviting
completion of the other ("!") placeholders, in-turn.


I haven't made use of such a tool, to-date - OK, yes, I have practised a
high typing-speed (and accuracy). Puff, puff...

Also, at the time, I'm thinking in 'code', rather than about what tool
might implement said ideas.


Do you make use of such expansionist-tendencies?

Do you make use of other powerful features within the IDE, or are its
editor functionalities employed at pretty-much the NotePad level?



Web.Refs:
https://urldefense.com/v3/__https://www.jetbrains.com/help/pycharm/settings-postfix-completion.html__;!!Cn_UX_p3!l5XlkM7xExYMxpwFOxIvLPLSWPm_iu_aRv0WpnvCW2353FzsFjuJKfOYr-rCsnE915Rk59u6F4CgKPuF7fWLqicNTA$
https://urldefense.com/v3/__https://www.jetbrains.com/help/pycharm/using-live-templates.html*live_templates_types__;Iw!!Cn_UX_p3!l5XlkM7xExYMxpwFOxIvLPLSWPm_iu_aRv0WpnvCW2353FzsFjuJKfOYr-rCsnE915Rk59u6F4CgKPuF7fUOn2vrzA$
--
Regards,
=dn
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l5XlkM7xExYMxpwFOxIvLPLSWPm_iu_aRv0WpnvCW2353FzsFjuJKfOYr-rCsnE915Rk59u6F4CgKPuF7fUQeq7a_w$
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Peter J. Holzer
On 2023-03-18 08:46:42 +, Alan Gauld wrote:
> On 17/03/2023 17:55, Thomas Passin wrote:
> >> I used Delphi and Smalltalk/V which both pretty much only exist within
> >> their own IDEs and I used their features extensively.
> > 
> > Back when Delphi first came out, when I first used it, I don't remember 
> > any IDE; one just used a text editor.
> 
> I think you might be meaning TurboPascal, Delphi's forerunner. It just
> had a compiler and text editor.

I'd still classify Turbo Pascal as an IDE. It wasn't a standalone
compiler you would invoke on source files you wrote with some other
tool. It was a single program where you would write your code, compile
it, see the errors directly in the source code. I think it even had a
debugger which would also use the same editor window (Turbo C did).


> But Delphi from day 1 was an IDE designed to compete with Visual
> Basic. Everything was geared around the GUI builder.

Turbo Pascal predated GUIs, so it wouldn't have a GUI builder. Also not
everything you develop needs a GUI (in fact I haven't written a real
application (i.e. not a learning project) with a traditional desktop GUI
for 20 years) so the presence or absence of a GUI builder isn't an
essential criterion on whether something is or is not an IDE.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Debugging reason for python running unreasonably slow when adding numbers

2023-03-18 Thread Peter J. Holzer
On 2023-03-15 17:09:52 +, Weatherby,Gerard wrote:
> Sum is faster than iteration in the general case.

I'd say this is the special case, not the general case.

> def sum1():
> s = 0
> for i in range(100):
> s += i
> return s
> 
> def sum2():
> return sum(range(100))

Here you already have the numbers you want to add.

The OP needed to compute those numbers first.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Friday finking: IDE 'macro expansions'

2023-03-18 Thread 2QdxY4RzWzUUiLuE
On 2023-03-18 at 11:49:24 +,
"Weatherby,Gerard"  wrote:

> For templating, I have two Python programs for starting new work. One
> generates a standalone Python program with the Python shebang, a
> __main__ which calls def main(), and logging and argparser
> intialization. The other generates a pyproject.toml /setup.cfg
> directory structure with a main.py referenced as a console
> script. from setup.cfg

You don't describe the process for using those programs, but if you
"have two Python programs," then it sounds like you're *not* using the
IDE/editor for that.

(I'm not judging, I'm trying to relate your answer to dn's original
question.)

For an opposing view, I'm much more likely to copy an old project (at
the command line, often with sed) and then use my editor to morph it
into a new project.  IME, unless there's an imposed process, those
templates and programs tend to experience bitrot, whereas going back to
an old program gives me the chance to keep it up to date w.r.t. what
I've learned more recently, which helps reinforce said learning.

> From: Python-list  on 
> behalf of dn via Python-list 
> Date: Thursday, March 16, 2023 at 6:59 PM
> To: 'Python' 
> Subject: Friday finking: IDE 'macro expansions'
> *** Attention: This is an external email. Use caution responding, opening 
> attachments or clicking on links. ***
> 
> It is a long, long, time since I've thrown one of these into the
> maelstrom of our musings.
> (have the nightmares receded?)
> 
> 
> Do you make use of your IDE's expansionist tendencies, and if-so, which
> ones?

[...]

-- 
I can eat glass, it does not hurt me.
Dan Sommers, http://www.tombstonezero.net/dan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Thomas Passin

On 3/18/2023 4:46 AM, Alan Gauld wrote:

On 17/03/2023 17:55, Thomas Passin wrote:


I used Delphi and Smalltalk/V which both pretty much only exist within
their own IDEs and I used their features extensively.


Back when Delphi first came out, when I first used it, I don't remember
any IDE; one just used a text editor.


I think you might be meaning TurboPascal, Delphi's forerunner. It just
had a compiler and text editor. But Delphi from day 1 was an IDE
designed to compete with Visual Basic. Everything was geared around the
GUI builder. You could write code outside the IDE but it was orders of
magnitude more difficult.


Maybe my memory has faded too much!  I remember porting some of my 
TurboPascal code to Delphi and wrapping it with the Delphi-Windows GUI 
instead of my own, pre-Delphi one.  The details are hazy, though ...




The Lazarus open source project is based on Delphi's IDE.



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


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Thomas Passin

On 3/18/2023 8:15 AM, Peter J. Holzer wrote:

On 2023-03-18 08:46:42 +, Alan Gauld wrote:

On 17/03/2023 17:55, Thomas Passin wrote:

I used Delphi and Smalltalk/V which both pretty much only exist within
their own IDEs and I used their features extensively.


Back when Delphi first came out, when I first used it, I don't remember
any IDE; one just used a text editor.


I think you might be meaning TurboPascal, Delphi's forerunner. It just
had a compiler and text editor.


I'd still classify Turbo Pascal as an IDE. It wasn't a standalone
compiler you would invoke on source files you wrote with some other
tool. It was a single program where you would write your code, compile
it, see the errors directly in the source code. I think it even had a
debugger which would also use the same editor window (Turbo C did).


Yes, TurboPascal was a brilliant product for its time.  And it was much 
cheaper than getting, say, a complete C compiler package, and way easier 
and faster to use.





But Delphi from day 1 was an IDE designed to compete with Visual
Basic. Everything was geared around the GUI builder.


Turbo Pascal predated GUIs, so it wouldn't have a GUI builder. Also not
everything you develop needs a GUI (in fact I haven't written a real
application (i.e. not a learning project) with a traditional desktop GUI
for 20 years) so the presence or absence of a GUI builder isn't an
essential criterion on whether something is or is not an IDE.

 hp




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


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Roel Schroeven




Peter J. Holzer schreef op 18/03/2023 om 13:15:

On 2023-03-18 08:46:42 +, Alan Gauld wrote:
> On 17/03/2023 17:55, Thomas Passin wrote:
> >> I used Delphi and Smalltalk/V which both pretty much only exist within
> >> their own IDEs and I used their features extensively.
> > 
> > Back when Delphi first came out, when I first used it, I don't remember 
> > any IDE; one just used a text editor.
> 
> I think you might be meaning TurboPascal, Delphi's forerunner. It just

> had a compiler and text editor.

I'd still classify Turbo Pascal as an IDE. It wasn't a standalone
compiler you would invoke on source files you wrote with some other
tool. It was a single program where you would write your code, compile
it, see the errors directly in the source code. I think it even had a
debugger which would also use the same editor window (Turbo C did).


Oh yes, Turbo Pascal was definitely an IDE. It was actually pretty 
similar to the GUI applications we have today, even though it was all 
text based. It had a menu bar with pull-down menus, it had popup 
windows. The look and feel is pretty similar to that of Midnight 
Commander (mc) nowadays, for those who know that.


Like you say it had an editor (obviously) and an integrated compiler, 
and indeed an integrated debugger, with watches and all, much like you 
would see in an IDE today. See this screenshot for example: 
https://daynhauhoc.s3.dualstack.ap-southeast-1.amazonaws.com/original/3X/7/8/782423b53bb6531d43c3c2075cb4a00f4ac7a5c0.png


For people too young to have used such semi-graphical applications in 
the past, you can find plenty of screenshots when you do an image search 
for turbo pascal.


Turbo Pascal was obviously not as advanced as the IDEs we have today, 
but it was definitely an IDE, and it had all the basic functions that 
one would expect from an IDE.


--
"Most of us, when all is said and done, like what we like and make up
reasons for it afterwards."
-- Soren F. Petersen

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


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Alan Gauld
On 18/03/2023 12:15, Peter J. Holzer wrote:

>> I think you might be meaning TurboPascal, Delphi's forerunner. It just
>> had a compiler and text editor.
> 
> I'd still classify Turbo Pascal as an IDE. It wasn't a standalone
> compiler you would invoke on source files you wrote with some other

It had both (although I'm not sure when that was introduced, the
original didn't). Mostly you used the IDE/editor but there was a
command line compiler that you could run (and a make-like project
tool too in the later versions). I started with TurboPascal on DOS
at Uni generating COM files then later used TP versions 4, 5.5(with
added OOP!) and 6 professionally, creating EXE file DOS programs.

Up until I switched to a Mac, a year ago, I still had TP6 and used
it to maintain some old TurboVision DOS programs.

But I used Delphi from version 1 through to 7(?) for all my Windows
programming and still have version 3 installed (via VirtualBox on
Linux) to keep some old shareware apps of mine running.

I often think there are a lot of similarities between
Delphi/Object Pascal and Python in the OOP area.

> it, see the errors directly in the source code. I think it even had a
> debugger which would also use the same editor window (Turbo C did).

I think the debugger came in v3, but i could be wrong. I don't
recall there being one at uni...

> Turbo Pascal predated GUIs, so it wouldn't have a GUI builder. 

No, it did have a windowing toolkit(TurboVision) but no visual UI
builder. That was the big new feature of Delphi.

> application (i.e. not a learning project) with a traditional desktop GUI
> for 20 years) so the presence or absence of a GUI builder isn't an
> essential criterion on whether something is or is not an IDE.

Indeed, but it was intrinsic to Delphi (even though you could
write non GUI apps too, but they required extra effort.)
Eclipse et al have GUI builders available as extras, in Delphi
(and Lazurus) it is hard to avoid.

BTW Delphi (v11) and the other Borland tools are still going strong,
albeit at extortionately high prices: $1000~3000 for the pro
versions!  (But there is still a free community version with
just the basics.) See http://www.embarcadero.com
And it's targeted at multi-platforms now: Windows, MacOS, Android, iOS
although it only runs on Windows.

-- 
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


Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

I accidentally used 'argparse' like this in my Python 3.9 program:
  parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
  parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")

instead of:
  parser.add_argument ("-c", "--clean",  dest="clean", action="store_true")
  parser.add_argument ("-n", "--dryrun", dest="dryrun", action="store_true")

So any use of 'my-prog.py -cn' threw an error:
  error: unrecognized arguments: -cn

So is there something that throws an error on this wrong use of
"-c, --clean" instead? Could be useful. Or is "-c, --clean" legit somehow?

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


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote:
> On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote: 
> > On 3/16/2023 8:07 PM, a a wrote: 
> > > Crash report: 
> > > 
> > > Problem Caption: 
> > > Problem Event Name: APPCRASH 
> > > Application name: python.exe 
> > > Application version: 3.8.7150.1013 
> > > Application time signature: 5fe0df5a 
> > > Error module name: _multiarray_umath.cp38-win32.pyd 
> > > Version of the module with the error: 0.0.0.0 
> > > Time signature of the module with the error: 63dfe4cf 
> > > Exception code: c01d 
> > > Exception offset: 000269c9 
> > > Operating system version: 6.1.7601.2.1.0.256.48 
> > > Regional Settings ID: 1045 
> > > Additional information 1: 0a9e 
> > > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > > Additional information 3: 0a9e 
> > > Additional information 4: 0a9e372d3b4ad19135b953a78882e789 
> > This exception has been reported to have many causes, but one 
> > possibility seems to be that your computer may not support an advanced 
> > instruction set that the .pyd was compiled for. I found this one 
> > specifically mentioned on the Internet: Advanced Vector Extensions. If 
> > that were the case, you would either need to find a different version of 
> > the module, or upgrade the computer/OS. 
> > 
> > It would be worth trying to downgrade the multiarray version to an 
> > earlier one and see if that fixes the problem.
> Thank you Thomas 
> for your kind reply. 
> 
> I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
> system 
> but I have visited every social chat support forum on the Internet: from 
> Python to Matplotlib, Numpy, Twitter, Github. 
> 
> As a newbie I am not aware how to downgrade "the multiarray version to an 
> earlier one 
> 
> I simply tried to test Python code from 
> 
> 
> https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/
>  
> 
>  
> # Python program to read .csv file 
> 
> import numpy as np 
> import matplotlib.pyplot as plt 
> import csv 
>  
> 
> "After importing the libraries, we now read the .csv file: 
> 
> with open('accl1.csv', 'r') as f: 
> data = list(csv.reader(f, delimiter=',')) #reading csv file 
> 
>  
> Just read about AVE from Wikipedia 
> 
> https://en.wikipedia.org/wiki/Advanced_Vector_Extensions


downloaded and run
HWiNFO
and AVE not supported, not greened out
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:
> On 3/16/2023 8:07 PM, a a wrote: 
> > Crash report: 
> > 
> > Problem Caption: 
> > Problem Event Name: APPCRASH 
> > Application name: python.exe 
> > Application version: 3.8.7150.1013 
> > Application time signature: 5fe0df5a 
> > Error module name: _multiarray_umath.cp38-win32.pyd 
> > Version of the module with the error: 0.0.0.0 
> > Time signature of the module with the error: 63dfe4cf 
> > Exception code: c01d 
> > Exception offset: 000269c9 
> > Operating system version: 6.1.7601.2.1.0.256.48 
> > Regional Settings ID: 1045 
> > Additional information 1: 0a9e 
> > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > Additional information 3: 0a9e 
> > Additional information 4: 0a9e372d3b4ad19135b953a78882e789
> This exception has been reported to have many causes, but one 
> possibility seems to be that your computer may not support an advanced 
> instruction set that the .pyd was compiled for. I found this one 
> specifically mentioned on the Internet: Advanced Vector Extensions. If 
> that were the case, you would either need to find a different version of 
> the module, or upgrade the computer/OS. 
> 
> It would be worth trying to downgrade the multiarray version to an 
> earlier one and see if that fixes the problem.

Thank you Thomas
for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
system
but I have visited every social chat support forum on the Internet: from Python 
to Matplotlib, Numpy, Twitter, Github.

As a newbie I am not aware how to downgrade "the multiarray version to an 
 earlier one

I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/


# Python program to read .csv file

import numpy as np
import matplotlib.pyplot as plt
import csv


"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f:
data = list(csv.reader(f, delimiter=',')) #reading csv file


Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions

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


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread a a
On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:
> On 3/16/2023 8:07 PM, a a wrote: 
> > Crash report: 
> > 
> > Problem Caption: 
> > Problem Event Name: APPCRASH 
> > Application name: python.exe 
> > Application version: 3.8.7150.1013 
> > Application time signature: 5fe0df5a 
> > Error module name: _multiarray_umath.cp38-win32.pyd 
> > Version of the module with the error: 0.0.0.0 
> > Time signature of the module with the error: 63dfe4cf 
> > Exception code: c01d 
> > Exception offset: 000269c9 
> > Operating system version: 6.1.7601.2.1.0.256.48 
> > Regional Settings ID: 1045 
> > Additional information 1: 0a9e 
> > Additional information 2: 0a9e372d3b4ad19135b953a78882e789 
> > Additional information 3: 0a9e 
> > Additional information 4: 0a9e372d3b4ad19135b953a78882e789
> This exception has been reported to have many causes, but one 
> possibility seems to be that your computer may not support an advanced 
> instruction set that the .pyd was compiled for. I found this one 
> specifically mentioned on the Internet: Advanced Vector Extensions. If 
> that were the case, you would either need to find a different version of 
> the module, or upgrade the computer/OS. 
> 
> It would be worth trying to downgrade the multiarray version to an 
> earlier one and see if that fixes the problem.


Just reading from search engine:

https://www.bing.com/search?q=how+to+downgrade+_multiarray_umath.cp38-win32.pyd+&form=QBLH&sp=-1&lq=0&pq=how+to+downgrade+_multiarray_umath.cp38-win32.pyd+&sc=1-50&qs=n&sk=
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-18 Thread Peter J. Holzer
On 2023-03-18 16:06:49 +, Alan Gauld wrote:
> On 18/03/2023 12:15, Peter J. Holzer wrote:
> >> I think you might be meaning TurboPascal, Delphi's forerunner. It just
> >> had a compiler and text editor.
> > 
> > I'd still classify Turbo Pascal as an IDE. It wasn't a standalone
> > compiler you would invoke on source files you wrote with some other
> 
> It had both

I didn't mention that because I think it is irrelevant to the question
whether Turbo Pascal as an IDE or not.

What is relevant IMNSHO is that it did indeed provide an "integraded
environment" for "developing", combining all those tools which were
traditionally separate in one user interface.

> Indeed, but it was intrinsic to Delphi (even though you could
> write non GUI apps too, but they required extra effort.)
> Eclipse et al have GUI builders available as extras, in Delphi
> (and Lazurus) it is hard to avoid.

This is starting to sound like "Delphi is the only True™ IDE".

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread Thomas Passin

On 3/17/2023 11:32 AM, a a wrote:

On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:


It would be worth trying to downgrade the multiarray version to an 
earlier one and see if that fixes the problem.


Thank you Thomas for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7,
32-bit system but I have visited every social chat support forum on
the Internet: from Python to Matplotlib, Numpy, Twitter, Github.

I mentioned the "multiarray" just because of its name in the error message:

"Error module name: _multiarray_umath.cp38-win32.pyd "

I assumed that the code you tried to run required an import from a
module or package whose name included "multiarray".  But I didn't try to
actually look for one.  Now I've checked, and I see it's included with
NumPy.


I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/

  # Python program to read .csv file

import numpy as np import matplotlib.pyplot as plt import csv 

"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f: data = list(csv.reader(f,
delimiter=',')) #reading csv file


You don't need numpy just to do this import, so you could remove the
numpy import just to test reading the csv file.  But I imagine you do
need numpy for later steps.



As a newbie I am not aware how to downgrade "the multiarray version
to an earlier one.
I just had to do this myself to work around a change in an import that 
broke one of my programs (not a numpy import).  If you can identify an 
earlier version that work - we will use proglib v 3.72 as an example - 
with pip you would use


python3 -m pip install --upgrade proglib<=3.72

To get exactly version 3.72, you would use "==3.72".

NOTE - no space allowed before the first "=" character!.
NOTE - you may need to type "python" or "py" instead of "python3".  Just 
use the one that runs the version of Python that you want to run.


To find which versions are available:

python3 -m pip install --upgrade proglib==

To find out which version you have installed on your computer:

python3 -m pip show numpy

After you downgrade to an earlier version, you can test it just by 
trying to import numpy.  In an interpreter session, just try to import it:


>>> import numpy

If that succeeds, chances are you will be all set.


 Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions


I have read that there are other instruction set extensions that could 
be missing besides AVE, that could cause that exception code.  The fact 
that you have a relatively old computer suggests that could be the problem.


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


Re: Q: argparse.add_argument()

2023-03-18 Thread Thomas Passin

On 3/18/2023 2:02 PM, Gisle Vanem via Python-list wrote:

I accidentally used 'argparse' like this in my Python 3.9 program:
   parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
   parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")

instead of:
   parser.add_argument ("-c", "--clean",  dest="clean", 
action="store_true")
   parser.add_argument ("-n", "--dryrun", dest="dryrun", 
action="store_true")


So any use of 'my-prog.py -cn' threw an error:
   error: unrecognized arguments: -cn

So is there something that throws an error on this wrong use of
"-c, --clean" instead? Could be useful. Or is "-c, --clean" legit somehow?



Are you trying to troll here?  You just showed how you got an error with 
this construction, so why are you asking how to get an error with this 
construction?


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


Re: Numpy, Matplotlib crash Python 3.8 Windows 7, 32-bit - can you help ?

2023-03-18 Thread Thomas Passin

On 3/17/2023 11:52 AM, a a wrote:

On Friday, 17 March 2023 at 16:32:53 UTC+1, a a wrote:

On Friday, 17 March 2023 at 16:03:14 UTC+1, Thomas Passin wrote:

On 3/16/2023 8:07 PM, a a wrote:

Crash report:

Problem Caption:
Problem Event Name: APPCRASH
Application name: python.exe
Application version: 3.8.7150.1013
Application time signature: 5fe0df5a
Error module name: _multiarray_umath.cp38-win32.pyd
Version of the module with the error: 0.0.0.0
Time signature of the module with the error: 63dfe4cf
Exception code: c01d
Exception offset: 000269c9
Operating system version: 6.1.7601.2.1.0.256.48
Regional Settings ID: 1045
Additional information 1: 0a9e
Additional information 2: 0a9e372d3b4ad19135b953a78882e789
Additional information 3: 0a9e
Additional information 4: 0a9e372d3b4ad19135b953a78882e789

This exception has been reported to have many causes, but one
possibility seems to be that your computer may not support an advanced
instruction set that the .pyd was compiled for. I found this one
specifically mentioned on the Internet: Advanced Vector Extensions. If
that were the case, you would either need to find a different version of
the module, or upgrade the computer/OS.

It would be worth trying to downgrade the multiarray version to an
earlier one and see if that fixes the problem.

Thank you Thomas
for your kind reply.

I am fully aware to be living on an old machine, old OS, Windows 7, 32-bit 
system
but I have visited every social chat support forum on the Internet: from Python 
to Matplotlib, Numpy, Twitter, Github.

As a newbie I am not aware how to downgrade "the multiarray version to an
earlier one

I simply tried to test Python code from


https://www.section.io/engineering-education/reading-and-processing-android-sensor-data-using-python-with-csv-read/


# Python program to read .csv file

import numpy as np
import matplotlib.pyplot as plt
import csv


"After importing the libraries, we now read the .csv file:

with open('accl1.csv', 'r') as f:
data = list(csv.reader(f, delimiter=',')) #reading csv file


Just read about AVE from Wikipedia

https://en.wikipedia.org/wiki/Advanced_Vector_Extensions



downloaded and run
HWiNFO
and AVE not supported, not greened out


That's too bad; you may be out of luck.  It's possible that someone has 
compiled the .pyd library in such a way that it does not need the 
instruction set extensions.  I'm sorry but I don't know how to find out 
except by trying internet searches - or by downgrading to earlier 
versions of Numpy hoping to find one that works and also can be used by 
the other libraries/programs that need to use it.


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


Re: Q: argparse.add_argument()

2023-03-18 Thread Chris Angelico
On Sun, 19 Mar 2023 at 06:09, Thomas Passin  wrote:
>
> On 3/18/2023 2:02 PM, Gisle Vanem via Python-list wrote:
> > I accidentally used 'argparse' like this in my Python 3.9 program:
> >parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
> >parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")
> >
> > instead of:
> >parser.add_argument ("-c", "--clean",  dest="clean",
> > action="store_true")
> >parser.add_argument ("-n", "--dryrun", dest="dryrun",
> > action="store_true")
> >
> > So any use of 'my-prog.py -cn' threw an error:
> >error: unrecognized arguments: -cn
> >
> > So is there something that throws an error on this wrong use of
> > "-c, --clean" instead? Could be useful. Or is "-c, --clean" legit somehow?
>
>
> Are you trying to troll here?  You just showed how you got an error with
> this construction, so why are you asking how to get an error with this
> construction?
>

There's a small difference in the way that the arguments are passed.
In the accidental example, "-c, --clean" is passed as a single
argument, which is a bug.

The truth is, though, that no program can ever tell you about all of
your bugs. The "-c, --clean" form is technically valid, and will match
an argument that looks exactly like it; I suppose argparse might be
coded to give a warning if there's a space inside an argument, but
that would be extremely annoying to anyone who actually wants it.

Ultimately, the only way to find bugs is to test, and to get good at
noticing expected patterns (for instance, if your editor highlights
strings or quote characters, your brain should expect to see them in
certain places). It's a nice courtesy when a library will help you to
find your own bugs, but there's a limit to what it can do.

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


Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

Thomas Passin wrote:

Are you trying to troll here?  


You just showed how you got an error with this construction, so why are you 
asking how to

get an error with this construction?


I meant (obviously), another error-message besides:
  error: unrecognized arguments: -cn

Perhaps from 'parser.add_argument ("-c, --clean", dest="clean", 
action="store_true")'
  error: "-c, --clean", 2 options are unsupported.

BTW, accusing someone of 'trolling' is rather rude IMHO.
And thanks to ChrisA for a nice and normal answer.

--
--gv

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


Re: Q: argparse.add_argument()

2023-03-18 Thread Chris Angelico
On Sun, 19 Mar 2023 at 06:35, Gisle Vanem via Python-list
 wrote:
>
> Thomas Passin wrote:
>
> > Are you trying to troll here?
> >
> You just showed how you got an error with this construction, so why are you 
> asking how to
> > get an error with this construction?
>
> I meant (obviously), another error-message besides:
>error: unrecognized arguments: -cn
>
> Perhaps from 'parser.add_argument ("-c, --clean", dest="clean", 
> action="store_true")'
>error: "-c, --clean", 2 options are unsupported.
>
> BTW, accusing someone of 'trolling' is rather rude IMHO.
> And thanks to ChrisA for a nice and normal answer.

I suspect the reason you were accused of trolling was that it was
quite unobvious what the difference was. When you ask for help with
something where the distinction is subtle (and you generally know it
was subtle by how long it took you to spot it!), it's often valuable
to pinpoint the exact issue, so people don't gloss over it and think
you posted the same code twice. For example:

"""
I accidentally used 'argparse' like this in my Python 3.9 program:
   parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
   parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")

instead of:
   parser.add_argument ("-c", "--clean",  dest="clean", action="store_true")
   parser.add_argument ("-n", "--dryrun", dest="dryrun", action="store_true")

Instead of having the short and long forms as separate parameters to
add_argument, I mistakenly put them in a single string.
"""

Now everyone can see immediately what your bug was, how easy it is to
make (and how hard to spot if not pointed out), and how likely it is
for this to be actually desired behaviour (in this case: highly
unlikely).

As to the reason you didn't get any other error message - that's
because, technically, what you did was perfectly valid.

>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument ("-c, --clean",  dest="clean", action="store_true")
_StoreTrueAction(option_strings=['-c, --clean'], dest='clean',
nargs=0, const=True, default=False, type=None, choices=None,
required=False, help=None, metavar=None)
>>> parser.add_argument ("-n, --dryrun", dest="dryrun", action="store_true")
_StoreTrueAction(option_strings=['-n, --dryrun'], dest='dryrun',
nargs=0, const=True, default=False, type=None, choices=None,
required=False, help=None, metavar=None)
>>> parser.parse_args(["-c, --clean"])
Namespace(clean=True, dryrun=False)

It's just that the argument needed to make this happen is... a tad
unlikely in the real world. So I do see that there's a problem here,
but I'm not sure what the true solution is. Is it reasonable to
mandate that arguments do not contain spaces? (Dubious.) What if
they're not allowed to contain commas? (Also dubious.) Maybe something
really complicated like ", -" as an entire construct? (Could easily be
confusing.) It's definitely worth opening the conversation on this,
and I'd be curious to know how many other people have made this same
bug.

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


Re: Q: argparse.add_argument()

2023-03-18 Thread Thomas Passin

On 3/18/2023 4:05 PM, Chris Angelico wrote:

On Sun, 19 Mar 2023 at 06:35, Gisle Vanem via Python-list
 wrote:


Thomas Passin wrote:


Are you trying to troll here?


You just showed how you got an error with this construction, so why are you 
asking how to

get an error with this construction?


I meant (obviously), another error-message besides:
error: unrecognized arguments: -cn

Perhaps from 'parser.add_argument ("-c, --clean", dest="clean", 
action="store_true")'
error: "-c, --clean", 2 options are unsupported.

BTW, accusing someone of 'trolling' is rather rude IMHO.
And thanks to ChrisA for a nice and normal answer.


I apologize for putting it that way.  I did have a reason for wondering 
about the post, but another time I wouldn't express it like that. 
Really, this is more general - about how to be more effective when 
asking for help.



I suspect the reason you were accused of trolling was that it was
quite unobvious what the difference was. When you ask for help with
something where the distinction is subtle (and you generally know it
was subtle by how long it took you to spot it!), it's often valuable
to pinpoint the exact issue, so people don't gloss over it and think
you posted the same code twice.


I did notice the difference, although I had to read it carefully a few 
times.  What I picked up on was that the OP wrote


"So is there something that throws an error on this wrong use..."

immediately after writing

"So any use of 'my-prog.py -cn' threw an error..."

To me that reads "using 'cn' as a parameter gave an error.  Is there 
something that will give this error?".  The question doesn't make sense 
that way - the OP *already* has "something" that gives the error.  So 
either the OP meant something else - and why should I need to guess what 
it was? - or ... [troll, maybe? :)].


So please, try to think out how your questions will seem to the reader, 
and be clear about what you are asking.  You may not know the 
terminology that some other people use, but don't let that stop you from 
being clear about what you really need to find out.  Including more 
context is likely to be helpful, too.  Don't leave it to the readers to 
infer what you were thinking of.


Perhaps some people who ask for help do not realize it, but to 
understand clearly what a situation and question are, and to work out 
and write (and edit) a helpful reply, perhaps with some code that needed 
to be checked first - that takes time and care.



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


Re: Friday finking: IDE 'macro expansions'

2023-03-18 Thread dn via Python-list

On 19/03/2023 01.27, 2qdxy4rzwzuui...@potatochowder.com wrote:

On 2023-03-18 at 11:49:24 +,
"Weatherby,Gerard"  wrote:


For templating, I have two Python programs for starting new work. One
generates a standalone Python program with the Python shebang, a
__main__ which calls def main(), and logging and argparser
intialization. The other generates a pyproject.toml /setup.cfg
directory structure with a main.py referenced as a console
script. from setup.cfg


You don't describe the process for using those programs, but if you
"have two Python programs," then it sounds like you're *not* using the
IDE/editor for that.

(I'm not judging, I'm trying to relate your answer to dn's original
question.)


It is a good example of a facility or 'power' of an IDE - even if 
there's room for more information...



The team I'm currently assisting has decided to use Poetry.

PyCharm will create a new project, populating basic files, more-or-less 
as @George described. In the same way, if one prefers a venv (etc) 
instead of a Poetry structure, PyCharm will set things up similarly.


Accordingly, it saves a lot of time, fiddling-about creating a bunch of 
(basically) empty files and sub-dirs.


(that said, there a plenty of operations which have a blank-project 
template which can be copied-in and renamed...)



Continuing the story, let's say the project calls for a PyPi-based* 
library, eg more_itertools, or there's a team 'standard', eg pytest; 
then these can be selected from a PyCharm-provided list (no need to go 
to PyPi to download) AND that operation will also be reflected in the 
pyproject.toml file.


* cf one from the PSL

In other words, the build file has been created and 
continually-maintained, by the IDE, ready for when the project is to be 
uploaded to a library or exported to target-machines; cf the 'tradition' 
of an extra, last, and not looked-forward-to, step in the process!




For an opposing view, I'm much more likely to copy an old project (at
the command line, often with sed) and then use my editor to morph it
into a new project.  IME, unless there's an imposed process, those
templates and programs tend to experience bitrot, whereas going back to
an old program gives me the chance to keep it up to date w.r.t. what
I've learned more recently, which helps reinforce said learning.


Yes...
(guilty as charged!)

Equally, may promulgate old habits and a lower-quality (related to the 
depth of learning, back-then cf 'now').


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


Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-18 Thread John O'Hagan
On Tue, 2023-03-14 at 21:54 +1100, John O'Hagan wrote:

[...]

> Here is minimal code that demonstrates the problem in the subject
> line:
> 
> import cv2
> from tkinter import *
> 
> images=['a.jpg', 'b.jpg', 'c.jpg'] #change to image paths
> 
> cv2.namedWindow('W', cv2.WND_PROP_FULLSCREEN)
> cv2.setWindowProperty('W', cv2.WND_PROP_FULLSCREEN, 
> cv2.WINDOW_FULLSCREEN)
> counter=[0]
> def show():
>cv2.imshow('W', cv2.imread(images[counter[0] % len(images)]))
>cv2.waitKey(1)
>counter[0] += 1
> 
> root=Tk()
> root.wm_attributes("-topmost", 1)
> Button(root, text=' Show ', command=show).pack()
> mainloop()
> 
> It works up to a point - I can cycle through the images by clicking
> the button - but if I mouse-click on the displayed image (e.g. to use
> the zooming and panning features of cv2), nothing happens, and a few
> seconds later the image greys out and a popup appears saying
> "'Unknown' is not responding" and giving the option of waiting or
> forcing close (but sometimes these options are greyed out too).
> Clicking "wait", if available, closes the popup but it comes back a
> few seconds later. If I then click on the tkinter window titlebar,
> the popup changes to "'Tk' is not responding". Clicking on the button
> still works and after a few clicks the popup closes.
> 
[...]

For anyone interested (and there are a lot of questions about this type
of issue out there), here's the nearest I came to a satisfactory
solution. In the real code I put a method like:

def window_thread():
   cv2.namedWindow('W') #window properties omited
   while 1: # really a flag for clean exit
  cv2.imshow('W', self.image)
  cv2.waitKey(40)

and call this as a thread from __init__. This updates the image every
40 ms regardless of whether it has been changed or not, in the manner
of a video feed. Seems unnecessary, but surprisingly it doesn't seem to
use any significant resources and seems to be the only way to keep both
the tkinter GUI and the cv2 window responsive. What I'd really like is
cv2.wait(until_i_say_so()) - i.e. to wait for a flag that can be set
programatically, but it doesn't seem to be available in cv2.

Thanks to those who replied.

> --
> 
> John
> 
> 

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


Re: Packing Problem

2023-03-18 Thread Rob Cliffe via Python-list



On 02/03/2023 19:40, Weatherby,Gerard wrote:

Haven’t look at it all in detail, but I’d replace the list comprehensions with 
a loop:
CopyOfWords = list(Words)
 Words = [(w[1:] if w[0] == ch else w) for w in Words]
 Words = [w for w in Words if w != '']
 nextWords = []
 for w in CopyOfWords:
 if w[0] != ch:
 nextWords.append(w)
 elif len(w) > 1:
 nextWords.append(w[1:])
 assert Words == nextWords

Why?
Rob Cliffe


From: Python-list  on behalf of 
Rob Cliffe via Python-list 
Date: Thursday, March 2, 2023 at 2:12 PM
To: python-list@python.org 
Subject: Re: Packing Problem
*** Attention: This is an external email. Use caution responding, opening 
attachments or clicking on links. ***

Slightly improved version (deals with multiple characters together
instead of one at a time):

# Pack.py
def Pack(Words):
  if not Words:
  return ''
  # The method is to build up the result by adding letters at the
beginning
  # and working forward, and by adding letters at the end, working
backwards,
  # meanwhile shrinking the words in the list.
  Words = list(Words) # Don't mutate the original
  Initial = ''
  Final = ''
  while True:
  # It is safe to add an initial letter (of one or more of the
words) if
  # EITHERThere is no word that contains it as
  # a non-initial letter but not as an initial letter.
  #  OR   All words start with it.
  while True:
  FirstLetters = set(w[0] for w in Words)
  FirstLettersSafe = sorted(ch for ch in FirstLetters if
  all(w[0]==ch for w in Words)
  or not any(ch in w[1:] and w[0]!=ch for w in Words))
  # sorted() to make the answer deterministic
  # (not dependent on set ordering)
  if not FirstLettersSafe:
  break
  AnyProgress = True
  Initial += ''.join(FirstLettersSafe)   # Build up the
answer from the beginning
  Words = [ (w[1:] if w[0] in FirstLettersSafe else w) for w
in Words ]
  Words = [ w for w in Words if w != '']
  if not Words:
  return Initial + Final
  # It is safe to add a final letter (of one or more of the words) of
  # EITHERThere is no word that contains it as
  # a non-final letter but not as a final letter.
  #  OR   All words end with it.
  while True:
  LastLetters = set(w[-1] for w in Words)
  LastLettersSafe = sorted(ch for ch in LastLetters if
  all(w[-1]==ch for w in Words)
  or not any(ch in w[:-1] and w[-1]!=ch for w in Words))
  # sorted() to make the answer deterministic
  # (not dependent on set ordering)
  if not LastLettersSafe:
  break
  Final = ''.join(LastLettersSafe) + Final   # Build up the
answer from the end
  Words = [ (w[:-1] if w[-1] in LastLettersSafe else w) for w
in Words ]
  Words = [ w for w in Words if w != '']
  if not Words:
  return Initial + Final
  if not (FirstLettersSafe or LastLettersSafe):
  break # stuck
  # Try all the possibilities for the next letter to add at the
beginning,
  # with recursive calls, and pick one that gives a shortest answer:
  BestResult = None
  for ch in FirstLetters:
  Words2 = list( (w[1:] if w[0] == ch else w) for w in Words )
  Words2 = [ w for w in Words2 if w != '' ]
  res = ch + Pack(Words2)
  if BestResult is None or len(res) < len(BestResult):
  BestResult = res
  return Initial + BestResult + Final

print(Pack(['APPLE', 'PIE', 'APRICOT', 'BANANA', 'CANDY']))

Rob Cliffe
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!l3ysx0BUPZBdKdwb9F8mw4BAE2UIflvNqWeZLfALY2kjEo9e4KTy6fEYoGCTileOUtYe0yp6nL18ymdOguC3TGagEA$


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


Re: Q: argparse.add_argument()

2023-03-18 Thread Gisle Vanem via Python-list

Thomas Passin wrote:

So please, try to think out how your questions will seem to the reader, and be clear about what you are asking.  You may 
not know the terminology that some other people use, but don't let that stop you from being clear about what you really 
need to find out.  Including more context is likely to be helpful, too.  Don't leave it to the readers to infer what you 
were thinking of.


I'll do that. My post was written in a bit of a hurry
and frustration after struggling with my 'typo' for
30 minutes.

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


Re: Q: argparse.add_argument()

2023-03-18 Thread Thomas Passin

On 3/18/2023 10:52 PM, Gisle Vanem via Python-list wrote:

Thomas Passin wrote:

So please, try to think out how your questions will seem to the 
reader, and be clear about what you are asking.  You may not know the 
terminology that some other people use, but don't let that stop you 
from being clear about what you really need to find out.  Including 
more context is likely to be helpful, too.  Don't leave it to the 
readers to infer what you were thinking of.


I'll do that. My post was written in a bit of a hurry
and frustration after struggling with my 'typo' for
30 minutes.



Been there too :)

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