[Python-announce] Re: [python-committers] [RELEASE] Python 3.11 release candidate 1 (3.11.0rc1) is available

2022-08-08 Thread Terry Reedy

On 8/8/2022 12:59 PM, Pablo Galindo Salgado wrote:
Python 3.11.0 is almost ready. This release, 3.11.0rc1, is the 
penultimate release preview. You can get it here:


## This is the first release candidate of Python 3.11

https://www.python.org/downloads/release/python-3110rc1/ 



This release, **3.11.0rc1**, is the penultimate release preview.  
Entering the release candidate phase, only reviewed code changes which 
are clear bug fixes are allowed between this release candidate and the 
final release. The second candidate and the last planned release preview 
is currently planned for Monday, 2022-09-05 while the official release 
is planned for Monday, 2022-10-03.


There will be no ABI changes from this point forward in the 3.11 series 
and the goal is that there will be as few code changes as possible.



 Core developers: all eyes on the docs now

* Are all your changes properly documented?
* Did you notice other changes you know of to have insufficient 
documentation?


Pablo, are you going to unlock 3.11 and revert merges you don't like, or 
keep it locked and merge PRs you think are OK?



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


Re: [python-committers] [RELEASE] Python 3.11 release candidate 1 (3.11.0rc1) is available

2022-08-08 Thread Terry Reedy

On 8/8/2022 12:59 PM, Pablo Galindo Salgado wrote:
Python 3.11.0 is almost ready. This release, 3.11.0rc1, is the 
penultimate release preview. You can get it here:


## This is the first release candidate of Python 3.11

https://www.python.org/downloads/release/python-3110rc1/ 



This release, **3.11.0rc1**, is the penultimate release preview.  
Entering the release candidate phase, only reviewed code changes which 
are clear bug fixes are allowed between this release candidate and the 
final release. The second candidate and the last planned release preview 
is currently planned for Monday, 2022-09-05 while the official release 
is planned for Monday, 2022-10-03.


There will be no ABI changes from this point forward in the 3.11 series 
and the goal is that there will be as few code changes as possible.



 Core developers: all eyes on the docs now

* Are all your changes properly documented?
* Did you notice other changes you know of to have insufficient 
documentation?


Pablo, are you going to unlock 3.11 and revert merges you don't like, or 
keep it locked and merge PRs you think are OK?



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


Explaining exec(globals, separate_locals)

2021-09-20 Thread Terry Reedy

The second paragraph of the current exec entry
https://docs.python.org/3.11/library/functions.html#exec
ends with a sentence I wrote.

"If exec gets two separate objects as globals and locals, the code will 
be executed as if it were embedded in a class definition."


Would the following would be clearer?

"If exec gets two separate objects as globals and locals, the code will 
be executed in two namespaces, the same as is done with the suite of a 
class statements."


In either case, does the following help even more?

"(The difference is that the locals for exec is not passed to type() to 
become a class dict.)"


I am asking because the current sentence engenders questions.  Today I 
got a private email with "This behavior seems really peculiar to me, and 
I would love to know if you know about why this behavior was chosen to 
be as it is."


The answer is that the choice is made by the user by what the user 
passes.  Top level code is executed in one namespace serving as both 
globals and locals.  Class definition code is executed in two separate 
namespaces serving the two role.  The populated local namespace is then 
passed to type() to become the __dict__ of the resulting class.  An 
interpreter written in Python could use exec for the two cases.  IDLE, 
for instance, uses exec, with *one* namespace, to execute user code as 
toplevel code.


The third type of code is function code, which executes in 2 *or more* 
namespaces, with peculiar locals behavior, and with 'return', 'yield', 
and 'nonlocal' valid.  It would make no sense to treat the code passed 
to exec as a function suite.


--
Terry Jan Reedy

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


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-13 Thread Terry Reedy

On 9/13/2021 8:46 AM, Mostowski Collapse wrote:

The Standard Python version of Dogelog runtime
is annoyingly slow. So we gave it a try with
andother Python, and it was 6x times faster.

We could test GraalVM. We worked around the missing
match in Python 3.8 by replacing it with if-then-else.
Performance is a little better, we find:

/* Standard Python Version, Warm Run */
?- time(fibo(23,X)).
% Wall 3865 ms, gc 94 ms, 71991 lips
X = 46368.

/* GraalVM Python Version, Warm Warm Run */
?- time(fibo(23,X)).
% Wall 695 ms, gc 14 ms, 400356 lips
X = 46368.

See also:

JDK 1.8 GraalVM Python is 6x faster than Standard Python
https://twitter.com/dogelogch/status/1437395917167112193

JDK 1.8 GraalVM Python is 6x faster than Standard Python
https://www.facebook.com/groups/dogelog


You need to test more than fibonacci to make that claim.  There is a 
benchmark test that times around 40 different similarly small benchmarks.



--
Terry Jan Reedy

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


Re: Friday Finking: Contorted loops

2021-09-10 Thread Terry Reedy

On 9/10/2021 7:38 AM, Alan Gauld via Python-list wrote:


But python complicates this tenet still further by adding an else
clause to its loops. And complicating this still more is that these
else clauses have almost exactly opposite effects.


To the contrary...

if...else
executes the else part if the condition is false.



while...else...

executes the else if the body of the loop does NOT get executed.


IE, executes the else part if the condition is false.
A while statement is, or can be viewed as, an if statement with a goto 
ending the if part.




for...else...

executes the else iff ALL iterations of the for loop DO complete.


IE, executes the else part of the condition is false.
A for loop is, or can be viewed as syntactic sugar for a while loop. 
The condition is that next(iterable) yields a value.


It is possible that the doc could be improved.  I have not looked for a 
while.  Or maybe it needs to be read more.


--
Terry Jan Reedy

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


Re: Friday Finking: Contorted loops

2021-09-09 Thread Terry Reedy

On 9/9/2021 5:36 PM, dn via Python-list wrote:

Why does Python not have a repeat-until loop construct?


1. It is not needed.  You covered that.

2. It is rare useful.  For loops are common.  While loops are occasional 
(nearly an order of magnitude less common than for loops.  Fractional 
loop constructs are rare.  ("loop-and-a-half" is a mislabel since at not 
even one loop is guaranteed.)  "do-while" or "repeat-until is even rarer 
since fractional-loop include this as a special case.


3. Adding 'until' as a keyword *now*, rather than in 1.0 or at least 
several versions ago, has cost so far judged to outweigh the small 
benefit.  The PEP parser makes contextual keywords much more easily 
possible but there is a cost to having a context dependent grammar. 
Consider this 3.10.0 snippet:


>>> match, case = 1, 1
>>> match match:
... case case:
... print('matched')
...
...
matched
>>> match case:
... case match:
... print('matched')
...
...
matched

To me, having a word sometimes be a keyword and sometime not make code 
harder to read.  In IDLE, it is a bit easier as the keyword uses of 
'match' and 'case' above are correctly highlighted as keywords, and the 
non-keywords uses not highlighted.  But this is harder that for 
full-time keywords with sane code that works in an re-based highlighter.


Underscore, not used above, but also a new contextual keyword, is even 
harder.  Three of us could not get all the cases we tested correct and I 
suspect doing so without running the PEG parser may be impossible. 
Since highlighting is redone with each keystroke, I suspect doing the 
latter would add a noticeable and unacceptable lag between keystrokes 
and display.




--
Terry Jan Reedy

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


Re: Problem with python

2021-09-04 Thread Terry Reedy

On 9/4/2021 2:27 PM, Igor Korot wrote:

Hi, ALL,

[code]
igor@WaylandGnome ~/bakefile $ python
Python 3.9.6 (default, Aug  8 2021, 17:26:32)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from distutils import sysconfig


In 3.10, distutils and d.sysconfig are deprecated, with suggestions to 
use setuptools or sysconfig modules instead.



print sysconfig.get_python_inc()

   File "", line 1
 print sysconfig.get_python_inc()
   ^
SyntaxError: invalid syntax


In interactive mode, print is not usually needed.

>>> sysconfig.get_python_inc()
'C:\\Programs\\Python310\\include'


--
Terry Jan Reedy

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


How to include insertion order in dict equality

2021-09-04 Thread Terry Reedy
In https://bugs.python.org/issue45093, Michael Rans suggested adding a 
dict method that would include the insertion order in comparing dicts 
for equality. He wanted this for testing.  The proposal is rejected 
because there are already multiple good methods.  To make them more 
visible and searchable, I list them here.


Steven D'Aprano:
d1 == d2 and all(k1 == k2 for k1, k2 in zip(d1, d2))

Sethiy Storchaka:
list(d1.items()) == list(d2.items())
# When using unittest, produces nicer report on failure.

Raymond Hettinger:
assert OrderedDict(d) == OrderedDict(e)

--
Terry Jan Reedy

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


Re: on writing a while loop for rolling two dice

2021-08-28 Thread Terry Reedy

On 8/28/2021 8:00 AM, Hope Rouselle wrote:

How should I write this?  I'd like to roll two six-sided dice until I
get the same number on both.  I'd like to get the number of times I
tried.  Here's a primitive I'm using:

--8<---cut here---start->8---

x, y = roll()
x

6

y

6 # lucky


x, y = roll()
x

4

y

1 # unlucky
--8<---cut here---end--->8---

Here's my solution:

--8<---cut here---start->8---
def how_many_times():
   x, y = 0, 1
   c = 0
   while x != y:
 c = c + 1
 x, y = roll()
   return c, (x, y)
--8<---cut here---end--->8---

Why am I unhappy?  I'm wish I could confine x, y to the while loop.  The
introduction of ``x, y = 0, 1'' must feel like a trick to a novice.  How
would you write this?  Thank you!


Something like (untested)

c = 0
while True:
c += 1
x, y = roll()
if x == y:
return c, (x,y)

or even better to me, as it will not loop forever if you mess up the 
condition


for i in range(1, 100):
x, y = roll()
if x == y:
return i, (x,y)
# return "The universe ends as the essentially impossible happened"


--
Terry Jan Reedy

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


Re: on the popularity of loops while and for

2021-08-28 Thread Terry Reedy

On 8/28/2021 9:31 AM, Hope Rouselle wrote:

I'd like get a statistic of how often each loop is used in practice.


My guess is that for loops are at least twice as common as while loops.


I was trying to take a look at the Python's standard libraries --- those
included in a standard installation of Python 3.9.6, say --- to see
which loops are more often used among while and for loops.  Of course,
since English use the preposition ``for'' a lot, that makes my life
harder.  Removing comments is easy, but removing strings is harder.  So
I don't know yet what I'll do.


Try something like

fors = 0
for file in files:
for line in file:
if re.match(r"/s*for .* in ", line):
fors += 1

This excludes comprehensions, which have replaced some for loops.

--
Terry Jan Reedy

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


Re: Can't get rid of old version of python

2021-08-13 Thread Terry Reedy

On 8/13/2021 2:32 PM, Ciarán Ó Duibhín via Python-list wrote:

Hi,

On Windows 10, I uninstalled all previous versions of Python and 
installed v3.9.6.


When I use the start menu option Python 3.9 (64-bit), I get the prompt 
"Python 3.9.6" as expected.  The same happens when I type "py" at the 
DOS prompt.


But when I type "python" at the DOS prompt, I get "Python 3.8.10".  I 
don't understand this, as I uninstalled old versions, and I do not see a 
DOS environment variable called "python" anywhere.


The real problem comes when I install a package, e.g. germalemma. Python 
3.8.10 can use it, but Python 3.9.6 can't find it.


If 'py' starts 3.9, then

py -m pip install xyz

will install xyz for 3.9.  (In not, py -3.9 -m pip ... will)

The command 'python' takes one to the MS store unless one has already 
gotten the store python.


--
Terry Jan Reedy


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


Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-13 Thread Terry Reedy

On 8/13/2021 6:53 AM, Umang Goswami wrote:

Hi There, Hope you find this mail in good health.

I am Umang Goswami, a Python developer and student working on a huge
project for automation of music instruments. I am producing the musical
notes using the Beep function of Winsound Module(
https://docs.python.org/3/library/winsound.html) by passing frequency as a
argument to the function.

Now whenever i provide frequency of any note in decimal(for example
277.1826 for C4 note) it shows following error:
Traceback (most recent call last):
   File "C:\Users\Umang Goswami\Desktop\Umang  Goswami\test.py", line 2, in

 winsound.Beep(111.11,11)
TypeError: integer argument expected, got float

Now I have  to round up the frequencies. This is hurting the quality,
accuracy ,authenticity and future of the project. Almost all the notes have
the frequencies  in decimal parts. Rounding up means changing semitones and
quatertones thus whole note itself. This problem is technically making my
program useless.

Its my humble request to you all, I beg you, Please tell me how to overcome
this issue. I have consulted many sources both online and offline but I
remained unsatisfied. I can not make audio files of each note because there
are many many notes and so practically making so many files of different
time length wont help.

Please suggest to me the way to resolve this issue or is there any other
module to produce the sound of decimal frequency.


Without knowing what sources you have already looked at, anything anyone 
might say might be duplication.  However,...


If the builtin hardware sound generator only generates integral 
frequencies, you are stuck unless you get an add-in card that is more 
flexible.  If the Windows interface to the hardware only accepts 
integral frequencies, which I suspect might be true, ditto, unless you 
get custom software.  You could look at pygame and see what its sound 
functions do.  And search pypi for 'sound generator' or 'frequency 
generator'.


--
Terry Jan Reedy

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


Re: some problems for an introductory python test

2021-08-10 Thread Terry Reedy

On 8/10/2021 5:27 PM, Hope Rouselle wrote:

Terry Reedy  writes:


On 8/10/2021 9:15 AM, Hope Rouselle wrote:

2.__add__(3)

SyntaxError: invalid syntax
But then I tried:


(2).__add__(3)

5


Add a space is easier.

2 .__add__(3)

5




Hah.  That's brilliant!  So cool.


Python is a little looser about whitespace than one might expect from 
reading 'normal' code when the result is unambiguous in that it cannot 
really mean anything other than what it does.  Two other examples:


>>> if3: print('yes!')
yes!
>>> [0]  [0]
0





--
Terry Jan Reedy

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


Re: some problems for an introductory python test

2021-08-10 Thread Terry Reedy

On 8/10/2021 9:15 AM, Hope Rouselle wrote:

2.__add__(3)

SyntaxError: invalid syntax

But then I tried:


(2).__add__(3)

5


Add a space is easier.
>>> 2 .__add__(3)
5
>>>

--
Terry Jan Reedy

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


Re: CODING PAGE ACCESS

2021-08-07 Thread Terry Reedy

On 8/6/2021 11:34 PM, MICHAEL J W SMITH via Python-list wrote:

I downloaded python. I selected it from the start menu. I clicked on:-
Python 3-9New


'New' goes away after the first access


I got:-
IDLE (Python 3.9 64-bit)


This is the included editor and enhanced interactive shell for writing 
and testing Python code.  Doc is available on the Help menu and at

https://docs.python.org/3/library/idle.html


Python 3.9 (64-bit)


This is the standard interactive shell.


Python 3.9 Manuals (64-bit)


The online manuals


Python 3.9 Module Docs (64-bit)


The 'help' version of module docs generated from the installed modules.


I wish to access the page where I do coding.I would appreciate help, either 
directly, or with information as to where I can get help.Thank you so much!




--
Terry Jan Reedy

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


Re: Subtle difference between any(a list) and any(a generator) with Python 3.9

2021-07-29 Thread Terry Reedy

On 7/29/2021 5:39 AM, Unknown wrote:

Hello

Reading PEP572 about Python 3.9 assignment expressions,
I discovered a subtle difference between any(a list)
and any(a generator)

see:

 >>> lines = ["azerty", "#qsdfgh", "wxcvbn"]
 >>> any((comment := line).startswith('#') for line in lines)
True
 >>> comment
"#qsdfgh"

 >>> any([(comment := line).startswith('#') for line in lines])


Same as

>>> booleans = [(comment := line).startswith('#') for line in lines]
>>> # comment == last item.
>>> any(booleans) # Iteration though booleans stops at 1st True.

> True
  >>> comment

'wxcvbn'

The two code snippets which seems very similar provide a
different value for "comment".

When "any" deals with a generator, it stops as soon it finds
a True value and returns True.

When "any" deals with a list, the whole list is calculated
first, and then "any" looks for a True.

Before 3.9 and the walrus operator, the two ways always provide
the same result, in a faster way with a generator.


Since the 'two ways' involve the new :=, I have no idea what 'two ways' 
and 'same result' you mean before :=.



With 3.9 and the walrus operator, result can be different




--
Terry Jan Reedy

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


Re: a simple question

2021-07-27 Thread Terry Reedy

On 7/26/2021 6:19 PM, Glenn Wilson via Python-list wrote:

I recently downloaded the latest version of python, 3.9.6. Everything works 
except, the turtle module. I get an error message every time , I use basic 
commands like forward, backward, right and left. My syntax is correct: 
pat.forward(100) is an example. Can you tell me what is wrong.


On Windows, normal install,
C:\Users\Terry>py -3.9 -m turtle
C:\Users\Terry>py -3.9 -m turtledemo
both work.


--
Terry Jan Reedy

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


Re: Python and Ubuntu versions

2021-07-24 Thread Terry Reedy

On 7/23/2021 5:11 PM, Mike Easter wrote:
For those who are following this thread on a conventional news server, 
there are missing parts which came from the python-list mailing list 
instead.


For those who prefer an nntp access to the mailing list, the 
corresponding group on news.gmane.io is gmane.comp.python.general.


Posting there is unconventional.


Huh?  If you read this, posting from gmane works fine!


--
Terry Jan Reedy

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


Re: Python and Ubuntu versions

2021-07-23 Thread Terry Reedy

On 7/23/2021 12:54 AM, אורי wrote:

Hi,

I have a production server with Ubuntu 18.04 LTS (currently upgraded to
Ubuntu 18.04.5 LTS) and I use Python in virtualenv - currently Python
3.6.9. I'm using Django and I read that from Django 4.0, a minimal version
of Python 3.8 will be required. I would like to know how I use the latest
version of Python (3.10 or 3.9) with my production server - do I have to


3.9 is the latest production release.  Others packages should all be 
available.  3.10 is still in beta, and updated versions of some packages 
will not be available for a few months after its release in Sept.


--
Terry Jan Reedy


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


Re: zoneinfo not working properly

2021-07-18 Thread Terry Reedy

On 7/18/2021 1:44 AM, Shashank Jain wrote:

I was using python 3.9.3 then zoneinfo library was working fine without any
issues. but now after installing 3.9.6 there are problems.  Ex.

Using below code there no outputs. and further there are issues while
working with timezones with zoninfo  where I tried same things with pytz
that was giving correct output.

for i in zoneinfo.available_timezones():
 print(i)


https://docs.python.org/3/library/zoneinfo.html#data-sources
starts with "The zoneinfo module does not directly provide time zone 
data, and instead pulls time zone information from the system time zone 
database or the first-party PyPI package tzdata, if available."


Somehow and for some reason, it is no longer getting the data.   So I 
suggest reading the section to see if you can determine why.  If 3.9.6 
is a separate installation from the 3.9.3, rather than an upgrade 
thereof, then maybe you need to install tzdata for the new installation.


Being on Windows, where this is not available, I cannot help further.

--
Terry Jan Reedy

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


Re: Tkinter widgets for desktop database application

2021-07-14 Thread Terry Reedy

On 7/13/2021 4:24 PM, Rich Shepard wrote:

I'm writing a couple of database applications that use tkinter, and not a
web browser, for the UI and I'm still trying to determine the optimal 
way to

do this.

Individual tk and ttk widgets (LineEntry, Combobox, etc.) work for adding


Do you mean Entry?

and modifying individual database table rows but not for displaying 
multiple

rows returned by a SELECT statement. To view all rows returned by the SQL
statement would a pythonReport be used?


ttk.Treeview can be used for read-only hierarchical and table data. 
Search 'python ttk Treeview' and Images for examples.




I'm working on learning to use tksheet as the sole widget because it can
display multiple rows from a database table as well as add new rows and
modify existing ones (one or more columns in each row).


I have not used it but have read some of manual and it seems suitable 
for editing flat table.



--
Terry Jan Reedy

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


Re: Unfindable module: code

2021-07-03 Thread Terry Reedy

On 7/2/2021 5:44 AM, Chris Angelico wrote:

I've just spent half an hour trying to figure out how to mess with the
Python REPL (specifically, how to implement a line-by-line interactive
interpreter within a larger app). It's rather hard to find it, but the
key module is "code".

https://docs.python.org/3/library/code.html

(How did I end up finding it? By searching the CPython source code for
"ps1", since interactive mode looks at sys.ps1/sys.ps2 for its
prompts.)

In the module index, it is listed thus:

Custom Python Interpreters
* code — Interpreter base classes
* codeop — Compile Python code

While this isn't *wrong*, per se, it does hide the fact that this is
where the REPL can be found. IMO it would be helpful to say that in
the summary, but I'm not sure what would be good wording.

What do people think of calling it "Interactive interpreter


I think that would be better.  The module include an console function, 
so it can be used as is.


? and REPL implementation"?

Nah.

I believe codeop is only for interactive code.

--
Terry Jan Reedy


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


Re: IDLE is not working after Python installation .

2021-06-22 Thread Terry Reedy

On 6/22/2021 1:14 AM, Ayaana Soni wrote:

I  have installed python from your site.


For what OS.


After installation my IDLE doesn't work.


How did you try to start it?  Did you read the Using Python doc on the 
website?  Can you start python?



 IDLE is not in my search list.


On Windows and macOS, IDLE is usually started from an installed icon.

--
Terry Jan Reedy

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


Re: Subpixel positioning on Tk canvas

2021-06-19 Thread Terry Reedy

On 6/19/2021 12:42 AM, Christian Gollwitzer wrote:

Am 19.06.21 um 06:26 schrieb George Furbish:
On Saturday, June 19, 2021 at 12:22:31 AM UTC-4, Christian Gollwitzer 
wrote:

Am 19.06.21 um 02:03 schrieb George Furbish:
Does Tk support interpolation/subpixel positioning of canvas 
elements? (e.g. images, text.) I have moving elements on my canvas, 
but the movement isn't very smooth and it's especially obvious when 
I have text moving alongside an image, since the two elements tend 
to jump to the next pixel at different times, creating a little 
judder between the two.

There is an "improved canvas" available, tkpath, which supports
antialiasing on all platforms. It is part of, e.g. undroidwish, if you
want to experiment with it. Last time I tested it had problems on macOS
though.


How can I enable or access the improved canvas via Tkinter?



Probably by writing the wrapper for it ;)

Sorry for that answer, but Tkinter does not support many of the most 
useful extensions for Tcl/Tk, because someone has to write the wrappers. 
It only supports what is provided by base Tk. Among those I consider 
useful and use in almost any application are:


Are these extensions included with the tcl/tk distribution, or otherwise 
available from active state?  Are this extensions included with Linux 
installations of tcl/tk?  Or easily installed?


* TkDnD for native drag'n'drop support (there is an inferior python 
package of the same name which implements local DnD only)


* tablelist - complete widget for displaying trees and tables like 
ttk::treeview, but with almost every feature one could imagine


* pdf4tcl - create a PDF from a canvas content, e.g. for printing


Basically you call Tcl via the eval() method of tkinter; in principle 
you could do



import tkinter as tk
root=tk()

root.eval('package require tkpath')
root.eval('...here comes your tkpath code...')
root.call('.tkp', 'create', 'oval', )


tkpath is described here: https://wiki.tcl-lang.org/page/tkpath

For the wrapping, look at the implementation files of Tkinter, for say, 
the original canvas, and modify accordingly.


 Christian




--
Terry Jan Reedy


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


Re: Tkinter problem

2021-06-19 Thread Terry Reedy

On 6/18/2021 2:28 AM, Liya Ann Sunny wrote:

I am using Colab. How could  solve this problem.
import tkinter as Tk


If you do this, import 'as tk'.


from tkinter import *


The second import overwrites the first since it imports tkinter.Tk as 
'Tk'.  Don't try to do both.



import sys
import os
#create main window
master = Tk()
master.title("tester")
master.geometry("300x100")


#make a label for the window
label1 = tkinter.Label(master, text='Hello')
# Lay out label
label1.pack()

# Run forever!
master.mainloop()
The error shows that :
 in ()
   9
  10 #create main window
---> 11 master = Tk()
  12 master.title("tester")
  13 master.geometry("300x100")

/usr/lib/python3.7/tkinter/__init__.py in __init__(self, screenName, baseName, 
className, useTk, sync, use)
2021 baseName = baseName + ext
2022 interactive = 0
-> 2023 self.tk = _tkinter.create(screenName, baseName, className, 
interactive, wantobjects, useTk, sync, use)
2024 if useTk:
2025 self._loadtk()

TclError: couldn't connect to display ":0.0"




--
Terry Jan Reedy

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


Re: Strange disassembly

2021-06-19 Thread Terry Reedy

On 6/18/2021 8:13 PM, Chris Angelico wrote:

On Sat, Jun 19, 2021 at 9:50 AM Terry Reedy  wrote:

Why are there two separate bytecode blocks for the "raise Exception"?


Because one block must POP_TOP and other must not.


I'd have thought that the double condition would still be evaluated as
one thing, or at least that the jump destinations for both the
early-abort and the main evaluation should be the same.


To reuse the exception block with POP_TOP, could jump over it after the
2nd compare.


Hmm, fair enough I guess. The compiler figured that it'd be faster to
duplicate the executable code rather than have the jump.


I would not assume that any alternative was considered.


It made for a
somewhat confusing disassembly, but I presume it's faster to run.


For the simplest and fasted bytecode, write normal logic and let x be
reloaded instead of duplicated and rotated.

  >>> import dis
  >>> def f(x):
... if x <= 0 or 10 <= x: raise Exception
...
...
  >>> dis.dis(f)
2   0 LOAD_FAST0 (x)
2 LOAD_CONST   1 (0)
4 COMPARE_OP   1 (<=)
6 POP_JUMP_IF_TRUE 8 (to 16)
8 LOAD_CONST   2 (10)
   10 LOAD_FAST0 (x)
   12 COMPARE_OP   1 (<=)
   14 POP_JUMP_IF_FALSE   10 (to 20)
  >>   16 LOAD_GLOBAL  0 (Exception)
   18 RAISE_VARARGS1
  >>   20 LOAD_CONST   0 (None)
   22 RETURN_VALUE
  >>>



Makes sense. I'm not sure if this would actually run faster, but I
can't really justify warping my code around the disassembly :)

Thanks for the explanation. I guess I just assumed the interpreter
would prefer a jump to the duplication, but that's a decision it's
free to take!


--
Terry Jan Reedy

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


Re: Faker package

2021-06-18 Thread Terry Reedy

On 6/18/2021 6:24 PM, Rich Shepard wrote:

I'm trying to use the faker package to generate data to load in a sample
postgres database so I can learn how to use tksheet and psycopg2.

The 8.8.1 documentation shows output on a root shell prompt (#), not a
python prompt (>>>). It also has a description of using faker from 'the
command line', which I assume is the python shell, and I can't get it to
work. I suppose that I can generate one name, address, etc. at a time and
them copy and concatenate them into table data, but I thought that the 
faker

package would do this all for me.

Is there a tool that will let me generate the equivalent of a database row
worth of data? That is, a set of strings of different types that can 
then be

inserted into the testing database?


I would try using the 'given' function/decorator of hypothesis (on pypi) 
to generate random data that conforms to whatever specification.


--
Terry Jan Reedy

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


Re: Strange disassembly

2021-06-18 Thread Terry Reedy

On 6/18/2021 6:04 AM, Chris Angelico wrote:

sys.version

'3.10.0b2+ (heads/3.10:33a7a24288, Jun  9 2021, 20:47:39) [GCC 8.3.0]'

def chk(x):

... if not(0 < x < 10): raise Exception


0 < x < 10 == 0 < x and x < 10, except that 'x' is evaluated once.

not(_) == (not 0 < x) or (not x < 10)
  [== x <= 0 or 10 <= x]


dis.dis(chk)

   2   0 LOAD_CONST   1 (0)
   2 LOAD_FAST0 (x)


stack = 0 x.  Since compare will remove both, must duplicate x and move 
duplicate out of the way.



   4 DUP_TOP
   6 ROT_THREE


stack = x 0 x


   8 COMPARE_OP   0 (<)


test 0 < x, remove both, leaving stack = x


  10 POP_JUMP_IF_FALSE   11 (to 22)


if false, not 0
  12 LOAD_CONST   2 (10)
  14 COMPARE_OP   0 (<)


Raise exception if false, making not x < 10 true
So if true, jump to normal exit at end. Stack is empty.


  16 POP_JUMP_IF_TRUE14 (to 28)
  18 LOAD_GLOBAL  0 (Exception)
  20 RAISE_VARARGS >  >>   22 POP_TOP


Must first remove unneeded duplicate of x!


  24 LOAD_GLOBAL  0 (Exception)
  26 RAISE_VARARGS1
 >>   28 LOAD_CONST   0 (None)
  30 RETURN_VALUE



Why are there two separate bytecode blocks for the "raise Exception"?


Because one block must POP_TOP and other must not.


I'd have thought that the double condition would still be evaluated as
one thing, or at least that the jump destinations for both the
early-abort and the main evaluation should be the same.


To reuse the exception block with POP_TOP, could jump over it after the 
2nd compare.


>   14 COMPARE_OP   0 (<)
>   16 POP_JUMP_IF_TRUE14 (to 28)
18 JUMP(to 24)
20 NOP (#to avoid renumbering)
>  >>   22 POP_TOP
>   24 LOAD_GLOBAL  0 (Exception)
>   26 RAISE_VARARGS1

For the simplest and fasted bytecode, write normal logic and let x be 
reloaded instead of duplicated and rotated.


>>> import dis
>>> def f(x):
... if x <= 0 or 10 <= x: raise Exception
...
...
>>> dis.dis(f)
  2   0 LOAD_FAST0 (x)
  2 LOAD_CONST   1 (0)
  4 COMPARE_OP   1 (<=)
  6 POP_JUMP_IF_TRUE 8 (to 16)
  8 LOAD_CONST   2 (10)
 10 LOAD_FAST0 (x)
 12 COMPARE_OP   1 (<=)
 14 POP_JUMP_IF_FALSE   10 (to 20)
>>   16 LOAD_GLOBAL  0 (Exception)
 18 RAISE_VARARGS1
>>   20 LOAD_CONST   0 (None)
 22 RETURN_VALUE
>>>


--
Terry Jan Reedy

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


Re: How Do I Get A Bug In Multiprocessing Fixed?

2021-06-18 Thread Terry Reedy

On 6/17/2021 5:02 PM, Michael Boom wrote:

The below issue is pretty serious and it is preventing me from using a system I 
wrote on a larger scale.  How do I get this bug fixed?  Thanks.
https://bugs.python.org/issue43329


Reduce your code to the minimum needed to exhibit the problem.  Then run 
it with 3.9.5 and 3.10.0b3.  3.8 only gets security fixes.  To get 
attention, demonstrate that there is a problem with current versions.



--
Terry Jan Reedy

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


Re: tkinter: tksheet

2021-06-16 Thread Terry Reedy

On 6/16/2021 12:31 PM, Rich Shepard wrote:

Reading the doc for tksheet tells me that it allows me to modify cells (or
entire rows) as well as display them. What I don't see is whether I can add
a new row using tksheet


Somewhat sparse doc at
https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data

insert_row()

 and change the column used for sorting (e.g.,

sorting by company number or company name).


I did not see anything about sorting.  tksheet is generic 'table', not a 
database viewer


--
Terry Jan Reedy

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


Re: Behaviour of pop() for dictionaries

2021-06-14 Thread Terry Reedy

On 6/14/2021 5:18 PM, BlindAnagram wrote:

I believe that consistency in how methods common to different types work 
is useful since it adds to the coherence of the language as a whole and 
avoids the need to remember special cases.


Each collection class *is* a special case, and pop has to be adjusted to 
each.  However, you seem to have missed an essential commonality.


Lists and dicts are both subscripted classes.  So the basic API is 
col.pop(sub), which removes and returns the sub item, whereas col[sub] 
leaves and returns.


Lists have a special index, -1, the most commonly used, so that is the 
default.  In fact, when I proposed list.pop(), I only proposed that, as 
I wanted pop to be the inverse of append, so a list could be used as a 
stack.


Bad list subscripts are an error (unless one is slicing), whereas where 
dicts allow a default (when subscripted with the get method).  Hence the 
optional default only for dicts.


At one time, dicts, like sets, were unordered collections (of functional 
item pairs). dict.pop(), with no arg, could have been used to return a 
random 2-ple, but Guido is generally against having return types depend 
on arguments. So a new popxxx name was added.  Note that deques have a 
popleft in addition to pop (right).


--
Terry Jan Reedy

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


Re: curses apps on MS Windows?

2021-06-14 Thread Terry Reedy

On 6/13/2021 1:44 PM, Grant Edwards wrote:


Does windows have a terminfo/termcap subsystem to deal with different
terminal types? 


No. AFAIK


Or do the apps only work with the built-in terminal
windows implemented by command.com/cmd.exe?


The windows console is implemented by separate code.  It is used Command 
Prompt, Powershell, Python, and other test-mode console applications.


I can't answer other questions.  I imagine that *nix-like operations, 
one best use WSL? (Windows Subsystem for Linux?) or a Windows Bash 
imitation (Git bash, for instance).  I believe git bash uses the same 
console as its interface.


--
Terry Jan Reedy

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


Re: Replacement for Mailman

2021-06-08 Thread Terry Reedy

On 6/8/2021 4:36 PM, Jon Ribbens via Python-list wrote:

On 2021-06-08, Grant Edwards  wrote:

On 2021-06-08, Paul Bryan  wrote:

How about Mailman 3.x on Python 3.x?


According to https://www.gnu.org/software/mailman/requirements.html
mailman 3.x still requires Python 2.7 for the archiver and the web UI.


I'm pretty sure that's out of date.


https://pypi.org/project/mailman/
3.3.4 works with 3.6 to 3.9


--
Terry Jan Reedy

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


Re: Replacement for Mailman

2021-06-08 Thread Terry Reedy

On 6/8/2021 3:08 PM, D'Arcy Cain wrote:

Given that mailman still runs under 2.7 and that's being deprecated,


It is not 'deprecated'.  Rather, official python.org support, including 
security fixes, has ended.  The same is true of 3.x up to 3.5, and 3.6 
by the end of the year.  I don't know if RedHat, for instance, followed 
through with plans to extend security fixes for customers paying for 
long-term support releases.  If they have, a patched 2.7 might be safer 
than the last 3.5.


--
Terry Jan Reedy

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


Re: Posting code on stackoverflow

2021-06-05 Thread Terry Reedy

On 6/5/2021 5:36 PM, Rich Shepard wrote:

I tried to post a question on stackoverflow.com which included a bunch of
code (entered after clicking the box 'code'). I noticed that lines were
wrapped but could not find how to expand the input box so they would not
wrap.

SO wouldn't let me post the question because of the wrapped code. As I've
not asked a question ther for a long time, and it didn't involve long lines
of code, I need to learn a) how to enter code if it's not just clicking on
the 'code' box before pasting text


Last time I tried *before*, it did not work.  paste, reselect (a 
nuisance) and click does.


--
Terry Jan Reedy

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


Re: Python app setup

2021-06-01 Thread Terry Reedy

On 5/31/2021 2:20 PM, Murali Pa wrote:

Hi,
I've installed latest version of Python 3.9.5 and downloaded for Windows.
Once I click on the Python app, I'm getting command screen
You are getting the Python interactive interpreter.  This is different 
from the system command line console/terminal in which you enter system 
commands.



and not sure on  the next action.


Enter a Python statement.  See the Python tutorial which explains.


could you please help me to fix this issue.


If you wish to run a python program in a file, you have to enter a 
command line in the system terminal, click on the file, or load the file 
in an IDE such as IDLE and run it from there.  See the chapter of the 
doc Using Python for your system.



Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>


Enter the first line of a statement, or if using IDLE, a complete statement.


Disclaimer: The information in this email is the property of IBM and may
be IBM Confidential and privileged. It is intended solely for the
addressee. Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited. If you receive this message
in error please notify the sender immediately and delete all copies of
this message.


When one sends a message to a mailing list or newsgroup, this is 
complete nonsense.  The 'addressee' is anyone and everyone in the world. 
 Try to avoid it if you can.



--
Terry Jan Reedy

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


Re: python 3.9.5

2021-06-01 Thread Terry Reedy

On 5/31/2021 3:15 AM, said ganoune wrote:

Just installed python 3.9.5 in my HP laptop, cant open it.
Laptop hp I3 running with windows 10.


You have to say a lot more.  How did you install, with what options? 
How do you try to 'open' (start) it?  What happens instead?



--
Terry Jan Reedy

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


Re: Definition of "property"

2021-05-30 Thread Terry Reedy

On 5/30/2021 12:57 PM, Irv Kalb wrote:

I am doing some writing (for an upcoming book on OOP), and I'm a little stuck.

I understand what a "property" is, how it is used and the benefits, but 
apparently my explanation hasn't made the light bulb go on for my editor.  The editor is 
asking for a definition of property.  I've looked at many articles on line and a number 
of books, and I haven't found an appropriate one yet.

I have written some good examples of how it works, but I agree that a 
definition up front would be helpful.  I have tried a number of times, but my 
attempts to define it have not been clear.  Perhaps the best I've found so far 
is from the Python documentation:

A property object has getter, setter, and deleter methods usable as decorators 
that create a copy of the property with the corresponding accessor function set 
to the decorated function.

But I'm hoping that someone here can give me a more concise (one or two sentence) 
definition of the word "property".

(I would like to avoid going through the whole derivation with the property 
function, as that would distract from the points that I am trying to make.)


From a user viewpoint, which is likely close to that of the editor, a 
property is a possibly dynamic class attribute managed by up to 3 hidden 
functions.


A user only needs to know that an attribute is a property when it has 
otherwise surprising dynamic behavior.  For instance, if 'time.now != 
time.now', or if 'time.now = something; print(time.now)' does not print 
'something'.


Note: at least one person says a property *pretends* to be an attribute. 
 I think a more useful view is that it *is* an attribute with a 
particular behind-the-scene implementation.  When a normal attribute is 
converted to a 'property', it effectively still is an attribute.  The 
syntax manipulating the attribute remains the same.  If one can set, 
get, and delete something dotted notation, it is an attribute.


--
Terry Jan Reedy

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


Re: string storage [was: Re: imaplib: is this really so unwieldy?]

2021-05-26 Thread Terry Reedy

On 5/26/2021 12:07 PM, Chris Angelico wrote:

On Thu, May 27, 2021 at 1:59 AM Jon Ribbens via Python-list
 wrote:


On 2021-05-26, Alan Gauld  wrote:

On 25/05/2021 23:23, Terry Reedy wrote:

In CPython's Flexible String Representation all characters in a string
are stored with the same number of bytes, depending on the largest
codepoint.


I'm learning lots of new things in this thread!

Does that mean that if I give Python a UTF8 string that is mostly single
byte characters but contains one 4-byte character that Python will store
the string as all 4-byte characters?


Note that while unix uses utf-8, Windows uses utf-16.


If so, doesn't that introduce a pretty big storage overhead for
large strings?


Memory is cheap ;-)



This is true, but sometimes memory translates into time - either
direction. When the Flexible String Representation came in, it was
actually an alternative to using four bytes per character on ALL
strings (not just those that contain non-BMP characters),


Except on Windows, where CPython used 2 bytes/char + surrogates for 
non-BMP char.  This meant that indexing did not quite work on Windows 
and that applications that allowed astral chars and wanted to work on 
all systems had to have separate code for Windows and unix-based systems.



and it
actually improved performance quite notably, despite some additional
complications.


And it made CPython text manipulation code work on all CPython system.


Performance optimization is a funny science :)



--
Terry Jan Reedy

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


Re: imaplib: is this really so unwieldy?

2021-05-25 Thread Terry Reedy

On 5/25/2021 1:25 PM, MRAB wrote:

On 2021-05-25 16:41, Dennis Lee Bieber wrote:


In Python 3, strings are UNICODE, using 1, 2, or 4 bytes PER 
CHARACTER


This is CPython 3.3+ specific.  Before than, it depended on the OS.  I 
believe MicroPython uses utf-8 for strings.



(I don't recall if there is a 3-byte version).


There isn't.  It would save space but cost time.


If your input bytes are all
7-bit ASCII, then they map directly to a 1-byte per character string.


If your input bytes all have the upper bit 0 and they are interpreted as 
encoding ascii characters then they map to overhead + 1 byte per char


>>> sys.getsizeof(b''.decode('ascii'))
49
>>> sys.getsizeof(b'a'.decode('ascii'))
50
>>> sys.getsizeof(11*b'a'.decode('ascii'))
60


If
they contain any 8-bit upper half character they may map into a 2-byte 
per character string.


See below.


In CPython 3.3+:

U+..U+00FF are stored in 1 byte.
U+0100..U+ are stored in 2 bytes.
U+01..U+10 are stored in 4 bytes.


In CPython's Flexible String Representation all characters in a string 
are stored with the same number of bytes, depending on the largest 
codepoint.


>>> sys.getsizeof('\U0001')
80
>>> sys.getsizeof('\U0001'*2)
84
>>> sys.getsizeof('a\U0001')
84

Bytes in Python 3 are just a binary stream, which needs an 
encoding to produce characters.


Or any other Python object.

Use the wrong encoding (say ISO-Latin-1) when the 
data is really UTF-8 will result in garbage.


So does decoding bytes as text when the bytes encode something else,
such as an image ;-).


--
Terry Jan Reedy


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


Re: Question for potential python development contributions on Windows

2021-05-24 Thread Terry Reedy

On 5/23/2021 10:05 PM, Terry Reedy wrote:

On 5/23/2021 12:20 PM, pjfarl...@earthlink.net wrote:
I asked this question on python-dev last week but did not get an 
answer.  If

anyone here know the answer I would appreciate it.

The Python Developers Guide specifically states to get VS2017 for 
developing

or enhancing python on a Windows system.

Is it still correct to specifically use VS2017 , or is VS2019 also
acceptable?


pjfarley just got answers on pydev.  For anyone else, they are no, not 
only VS2017, and yes, VS2019 is fine.  The same will be true of a 
possible VS2021 as long as the compiler version remain 14.something.


--
Terry Jan Reedy


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


Re: Question for potential python development contributions on Windows

2021-05-23 Thread Terry Reedy

On 5/23/2021 12:20 PM, pjfarl...@earthlink.net wrote:

I asked this question on python-dev last week but did not get an answer.  If
anyone here know the answer I would appreciate it.

The Python Developers Guide specifically states to get VS2017 for developing
or enhancing python on a Windows system.

Is it still correct to specifically use VS2017 , or is VS2019 also
acceptable?

I ask this because I know that the *.vcxproj files and other
build-environment files have changed format pretty dramatically over the
many releases of VS.  If a potential new contribution targeted for current
and future python will require new build environment files, I wouldn’t want
to have to “down release” those files (or expect core dev’s to do it) at or
after submission to the community for approval.  Much better to use the same
setup as core dev’s use than to introduce up-level differences in the build
environment.

IOW, for new releases on Windows are core dev’s still using VS2017 and so
potential contributors should also use that version, or has the core dev’s
process for Windows releases been updated to use VS2019?


I am pretty sure that VS2019 output is binary compatible with with 
output from VS2017 and VS2015.  I believe the only issue would be is one 
were developing a patch to a CPython .c file and one used recent C## 
features not allowed in CPython code.


You could open an issue on bugs.python.org asking that the doc be clarified.


--
Terry Jan Reedy


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


Re: If you have Python Cookbook, 3rd ed.

2021-05-21 Thread Terry Reedy

On 5/19/2021 2:57 PM, Terry Reedy wrote:
can you verify that the Algorithm chapter (near end in 2nd ed.) does 
*NOT* have an introduction by Tim Peters?

(Info needed to verify timeit doc correction
https://github.com/python/cpython/pull/21744)


Thank you to 2 respondents.  I have gone ahead with the patch.

--
Terry Jan Reedy

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


Python at SpaceX

2021-05-21 Thread Terry Reedy

https://stackoverflow.blog/tag/software-in-space/
has 4 links to interviews.  2 specifically mention Python.

https://stackoverflow.blog/2021/05/11/testing-software-so-its-reliable-enough-for-space/
"Python “is for backend test running, build orchestration, and all our 
web servers are python-based. It’s a lot of little scripts and a lot of 
big web services. "


https://stackoverflow.blog/2021/05/11/building-a-space-based-isp/
"Starlink software, both in satellites and on the ground, is written 
almost exclusively in C++, with some prototyping development in Python."


“For development and test of these algorithms, we have a full-scale 
network simulation running in continuous integration on a 
high-performance computing cluster. This simulation is capable of 
running the C++ production code as well as running against prototype 
code written in Python,”


--
Terry Jan Reedy


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


Re: Unexpected Inheritance Problem

2021-05-20 Thread Terry Reedy

On 5/20/2021 2:53 PM, Grant Edwards wrote:

On 2021-05-20, Mats Wichmann  wrote:

On 5/20/21 4:54 AM, Richard Damon wrote:

On 5/20/21 3:24 AM, Peter Otten wrote:

On 20/05/2021 06:00, Richard Damon wrote:


class GedcomHead(Gedcom0Tag):
   """GEDCOM 0 HEAD tag"""
   def ___init___(self, *, parent):


An __init__ with three underscores; you must me joking ;)


Yes, that is what I was missing, too many underscores there, so
GedcomHead didn't have an __init__ so it inherited inherited from it
from its base with the wrong signature.


many fonts squish together repeated underscores in the display so it's
hard to see this visually,


Is it just me, or does it seem foolish to use such fonts for
editing/browsing source code...


Windows 10, at least, has Source Code Pro, and variations, in which 
__init__ has distinct _s with a small space in between (unlike the 
default font here in Thunderbird, or in Firefox).  This is the only 
monospaced TrueType font available in the Windows console with this 
property.



--
Terry Jan Reedy


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


Re: If you have Python Cookbook, 3rd ed.

2021-05-20 Thread Terry Reedy

On 5/20/2021 1:14 PM, boB Stepp wrote:

On Thu, May 20, 2021 at 11:43 AM Terry Reedy  wrote:


can you verify that the Algorithm chapter (near end in 2nd ed.) does
*NOT* have an introduction by Tim Peters?
(Info needed to verify timeit doc correction
https://github.com/python/cpython/pull/21744)


In my 3rd edition copy chapter 1 is "Data Structures and Algorithms".
The only thing comprising an introduction is a brief paragraph that
starts the chapter and has no attribution.


Hmm. 2nd ed starts with 1. Text.  The intro mentioned was for 18. 
Algorithms, starting with removing duplicates from a sequence.


--
Terry Jan Reedy

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


Re: Python install failing. Install log is available.

2021-05-20 Thread Terry Reedy

On 5/20/2021 7:06 AM, jan via Python-list wrote:


This time it's simply not installing correctly when run as
administrator, and not at all when run as non-administrator.

As administrator, it's not installing for other users as I believe it should.

It's certainly not adding the python path correctly *for all users*



C:\WINDOWS\system32>whoami

...

Any thoughts?


On Windows, use the py launcher to launch python.  It was added as the 
solution to problems with adding python paths, including problems with 
multiple installs and those with removing them.



--
Terry Jan Reedy

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


If you have Python Cookbook, 3rd ed.

2021-05-20 Thread Terry Reedy
can you verify that the Algorithm chapter (near end in 2nd ed.) does 
*NOT* have an introduction by Tim Peters?

(Info needed to verify timeit doc correction
https://github.com/python/cpython/pull/21744)
--
Terry Jan Reedy

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


Re: How to build stable 3.9 branch from fork and clone of cpython

2021-05-18 Thread Terry Reedy

On 5/18/2021 3:00 AM, Chris Angelico wrote:

On Tue, May 18, 2021 at 4:33 PM  wrote:


I am following the "Getting Started" section of the Python Developers Guide,
but when I build the first version to verify everything builds, it builds
branch 3.11.



If I want to build and contribute to branch 3.9, how do I set that up
please?



git checkout 3.9

That should switch you to the branch, replacing all the (tracked)
files in the build directory with the corresponding files from 3.9.

Be aware that most development is going to happen on the master branch
(or the main branch, whichever one you have),


It should be 'main' for any python/??? repository.  If one forked and 
cloned before the switch, one should rename 'master' to 'main' both 
locally and on the fork.  Github has directions somewhere.  It might 
provide them if one attempts a PR against 'master'.  There may also be 
something in the devguide.


The only time an initial contribution would be for 3.9 would be for a 
bug that only exists in 3.9, which is very rare.



and branches like 3.9
are going to get backported patches; so any change you're planning to
contribute to 3.9 is going to need to work correctly on both branches.


It must be 'main' for any python/??? repository.  The only time an 
initial contribution would be for 3.9 would be for a bug that only 
exists in 3.9, which is very rare.


--
Terry Jan Reedy

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


Re: Standarize TOML?

2021-05-17 Thread Terry Reedy

On 5/17/2021 4:29 PM, Barry Scott wrote:




On 15 May 2021, at 23:39, Jason C. McDonald  wrote:

During the Steering Committee presentation at PyCon, it was mentioned
that no one has formally proposed TOML be added to the standard library
(emphasis on formal). THe joke went forth that there would be a flood
of proposals to that end.

So, just to kick this off while the thought is still fresh in a bunch of
people's minds: **should we add a TOML parser to the standard library**?

The main reason this matters is to help encourage adoption of the now
PEP-standardized pyproject.toml. A few projects have cited the lack of
a standardized TOML implementation in the standard library as a reason
not to adopt pyproject.toml...and the topic thus became weirdly
political.

I understand that Brett Cannon intends to bring this up at the next
language summit, but, ah, might as well put the community two-cents in
now, hey?

I, for one, feel like this is obvious.


I think the python ideas list is a better place to have this discussion.


I disagree.  Rehashing *opinions* is pretty useless. The issues were 
already discussed on

https://discuss.python.org/t/adopting-recommending-a-toml-parser/4068

There are multiple packages.  There is no consensus on which to pick, 
*if any*. Existing modules apparently include writers, which are 
necessarily opinionated (as is formatting of C, Python, html, ...).  As 
I just noted in the discussion, the stdlib does not have an html writer. 
   So if we want just a parser, maybe we should generate one from the 
grammar.  Then there are broader 'What should be in the stdlib discussions.


If anyone has *new information* about toml, post it there.

--
Terry Jan Reedy

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


Re: Decoratored functions parsed differently by ast stdlib between 3.7 and 3.8

2021-05-03 Thread Terry Reedy

On 4/30/2021 11:07 PM, Mike Lee Williams wrote:

On Friday, April 30, 2021 at 7:55:10 PM UTC-7, Mike Lee Williams wrote:

This trivial bit of code is parsed differently by the ast module between python
3.7 and python 3.8. I'm trying to figure out what changed and why, and once I
know that, if it's possible and desirable to retain the 3.7 behavior for my use
case (which needs to give the same result for this input on 3.7 and 3.8).


Answering my own question: the behavior was changed by 
https://github.com/python/cpython/pull/9731.


Since this patch, Mark Shannon has revised line numbering and tracing 
and replaced the internal lineno data structure. Your example code still 
outputs 2.  So Mark either missed this case or considers it correct.


--
Terry Jan Reedy

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


Re: cant use certain commands, leading to more problems

2021-04-28 Thread Terry Reedy

On 4/28/2021 10:09 AM, Michael Torrie wrote:

On 4/28/21 4:00 AM, Rasig Kosonmontri wrote:

so i heard that the microsoft store's version of python tends to hide
itself. and so i uninstalled it
but when i typed in to a powershell it just directs me to the
mircrosoft store's page
i then disabled it from doing that and install python from python.org
  myself
but for some weird reason this time it doesnt work at all, 'python' is
somehow not recognized as a cmdlet, bash or command. this also happens with
gitbash and cmd


If you installed Python from an installer from python.org, did you tell
it to put itself into your system PATH? If not, try manually adding the
bin folder where it installed to to your system path.


Or check the option to install the py launcher and use that.  No need to 
fuss with PATH.


>py  # run interactive python
>py filename.py  # run python with that file
>py -m module  # run module as a command

--
Terry Jan Reedy

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


Re: Not found in the documentation

2021-04-27 Thread Terry Reedy

On 4/26/2021 7:24 PM, elas tica wrote:


Python documentation doesn't seem to mention anywhere what is the str value of an int: is it right?  the same 
for float, Fraction, complex, etc? Not worth to be documented? Perphaps str(42) returns "forty two" 
or "XLII" or "101010" ...


Python has this thing called interactive mode that makes it possible to 
discover answers even faster than looking in the docs (which can get out 
of date when things change, as they have for floats).


str(12345)
'12345'
repr(12345)
'12345'
str(1+1*j)
Traceback (most recent call last):
  File "", line 1, in 
if True:
NameError: name 'j' is not defined
str(1+1j)
'(1+1j)'
repr(1+1j)
'(1+1j)'
str(.999)
'1.0'
str(0xff34)
'65332'



--
Terry Jan Reedy

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


Re: do ya still use python?

2021-04-22 Thread Terry Reedy

On 4/21/2021 6:07 AM, o1bigtenor wrote:

On Tue, Apr 20, 2021 at 6:26 PM Terry Reedy  wrote:


On 4/20/2021 4:32 AM, Alan Gauld via Python-list wrote:


We see the same trend on the tutor list, traffic has dropped off
by a factor of 3-5 times what it was at its peak. And the questions
are changing too, fewer basic things about loops and writing
functions, more about specific library modules and such.


I suspect that at least some such questions have good answers on
StackOverflow that questioners could profitably read first.


Respectfully - - - - I would disagree.
I am finding when I'm looking for answers that the generalist sites
most often cough up responses - - - - - yes there are responses
- - - but those responses are for software of at best 5 to 6 years
ago and all too often its for software of 15 + years ago.


Alan and I were specifically discussing questions about Python standard 
library modules, which are currently maintained and mostly stable.  Many 
beginner questions are likely to have useful answers tagged , 
, and sometimes something more specific.


Someone on the tutor list could even look on SO for the beginner and 
perhaps answer with a link.  But that is for Alan, etc, to decide.  I 
merely offered that as a suggestion.


--
Terry Jan Reedy

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


Re: do ya still use python?

2021-04-20 Thread Terry Reedy

On 4/20/2021 4:32 AM, Alan Gauld via Python-list wrote:


We see the same trend on the tutor list, traffic has dropped off
by a factor of 3-5 times what it was at its peak. And the questions
are changing too, fewer basic things about loops and writing
functions, more about specific library modules and such.


I suspect that at least some such questions have good answers on 
StackOverflow that questioners could profitably read first.


--
Terry Jan Reedy

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


Re: do ya still use python?

2021-04-20 Thread Terry Reedy

On 4/20/2021 5:44 PM, dn via Python-list wrote:


Are there reasons why someone might prefer StackOverflow to this list?


For programming questions with testable answers, generally yes.  But I 
sometimes advise SO questioners to redirect questions here when more 
appropriate.


Advantages include that questions and answers can be searched within a 
tag, can be commented separately,  and can be edited.  The latter is 
important.  Web forums that imitate mail lists with indelible sequential 
postings are not much better.



Are they more to do with the person, or something the Python Community
should address?


Not the first, nor the second officially.  But many Python Community 
members already answer python-tagged questions.  I specifically monitor 
python-idle questions.  The PSF could set up a imitation site, or 
perhaps sponsor 'Python Pitstop' on stackexchange, but why bother?


--
Terry Jan Reedy

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


Re: Repair Install of 64 bit python

2021-04-17 Thread Terry Reedy

On 4/16/2021 10:15 AM, Cameron Simpson wrote:

On 16Apr2021 13:13, Dan Ciprus (dciprus)  wrote:

Isn't the recommended python3 way of pip-ing stuff:

python3 -m pip install ...

.. just curious.


If there's only one Python 3 installed then "pip3 install ..." _ought_
to be equivalent. However, in the face of virtualenvs etc there may
often be several pip3s.

Using "python3 -m pip install ..." ensures that you are using the pip
which is associated with "python3" (which you can adjust to be whichever
python3 you intend). This is why the "-m pip" form is recommended: it
definitely installs in the Python you'd be running.


It requires that pip itself be installed for pythonx, which can be 
ensured with "pythonx -m ensurepip".



--
Terry Jan Reedy

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


Re: port to PDOS (especially mainframe)

2021-04-17 Thread Terry Reedy

On 4/16/2021 4:02 PM, Paul Edwards wrote:

On Saturday, April 17, 2021 at 5:13:31 AM UTC+10, Paul Rubin wrote:

Paul Edwards  writes:

I have succeeded in producing a Python 3.3 executable despite being
built with a C library that only supports C90.


Not surprising. CPython was restricted to C90 until fairly recently to 
be portable across major systems, including Windows with MS Visual C. 
At least some C99 features are used now and more are being comtemplated.


--
Terry Jan Reedy

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


Re: translating external files type thing

2021-04-13 Thread Terry Reedy

On 4/13/2021 4:53 PM, Avi Gross via Python-list wrote:

https://translate.google.com/?sl=is=en=translate

Or, you could do it the hard way.

Kidding aside, there may be a python module you can hand a file name or
contents to and have it do much of the job using some API that may tap into
the above Google resource.


For one chunk of text under 5000 chars, the website is easiest.


Dan specifically suggested importing googletrans ...


The author reverse engineered the undocumented ticket used by the web 
page.  It will work until Google either bans one's IP address or 
disables googletrans by changing the protocol.  Since Google's paid 
service only charges for chars over 500_000 in a month, Google is likely 
better off leaving the protocol alone and only banning users who would 
actually pay if signed up.




-Original Message-
From: Python-list  On
Behalf Of Quentin Bock
Sent: Tuesday, April 13, 2021 3:16 PM
To: python-list@python.org
Subject: translating external files type thing

okay, so I'm making a translating program, and I have files set to be
translated (they're in Icelandic) and I want all of them to be read in
English but I'm not sure how to open the files and translate them at the
same time. I'm also not even sure how to translate an external file to
English from another language.
I can't show code for this because I don't know if it's possible to do what
I'm asking.
Hopefully, this question is understandable Thanks
--
https://mail.python.org/mailman/listinfo/python-list




--
Terry Jan Reedy

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


Re: googletrans in python

2021-04-12 Thread Terry Reedy

On 4/12/2021 12:48 PM, Quentin Bock wrote:

Can someone explain the basics of googletrans in python?


You most likely want to install
https://pypi.org/project/googletrans/


--
Terry Jan Reedy

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


Re: Style qeustion: Multiple return values

2021-04-12 Thread Terry Reedy

On 4/12/2021 4:29 AM, Steve Keller wrote:

Just a short style question: When returning multiple return values, do
you use parenthesis?

E.g. would you write

 def foo():
 return 1, 2

 a, b = foo()

or do you prefer

 def foo():
 return (1, 2)

 (a, b) = foo()


No.  Parentheses are for grouping (and separation from surrounding code).
 () and (1,) (can be though of as) group(ing) the a zero-width space 
and one-comma pair respectively and separate them from the rest of the code.


--
Terry Jan Reedy

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


Re: PyWin32 : When using Microsoft Word in code , opening it doesn't work

2021-04-08 Thread Terry Reedy

On 4/8/2021 6:35 PM, VISHESH MANGLA wrote:

On Friday, April 9, 2021 at 4:02:37 AM UTC+5:30, Chris Angelico wrote:

On Fri, Apr 9, 2021 at 8:26 AM VISHESH MANGLA
 wrote:


Please help with this .

https://github.com/mhammond/pywin32/issues/1689

Did you follow the instructions in the first line of the issue, saying
how you should seek support?

ChrisA



obviously I did


Not at all obvious that you did so.  People routinely seek help without 
first doing what they should do first.



but their mailing list  > requires them to respond to your email
when they haven't done since I made the request
1 month back.I did that atleast thrice. So I 'm stuck.


Next time, help youself and us and say this ;-).

--
Terry Jan Reedy

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


Re: PyWin32 : When using Microsoft Word in code , opening it doesn't work

2021-04-08 Thread Terry Reedy

On 4/8/2021 6:22 PM, VISHESH MANGLA wrote:

Please help with this .

https://github.com/mhammond/pywin32/issues/1689


Closed by Mark Hammond as a support requrest rather than a bug report or 
feature request.




--
Terry Jan Reedy

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


Re: Yield after the return in Python function.

2021-04-05 Thread Terry Reedy

On 4/5/2021 3:32 PM, Chris Angelico wrote:


On Tue, Apr 6, 2021 at 5:14 AM Terry Reedy  wrote:

Python *could* do the same for expresssions: load 'a' (in this case)
once into a register or stack slot and use that value consistently
throughout the expression.  Replacing the eval with the following exec
has the same effect.


True, but I think that this would be enough of a semantic change that
Python should be very VERY careful about doing it.


I consider it beyond a possibility.


A *programmer* can
choose to do this (and we see it sometimes as an optimization, since
global lookups can be a lot more costly), but the interpreter
shouldn't.


Agreed.  My interest is in elucidating the different between math and 
computing.  The reason some prohibit rebinding bound names within a 
local context is to make code more like math.  But this example should 
that Python code can effectively rebind names 'invisibly'.


Side note: Since a loop is equivalent to a recursive tail call, I think 
rebinding once per loop should be considered to be consistent with 
no-rebinding.  When an compiler or interpreter re-writes tail recursion 
as while looping, the result is the same.  I don't believe in forcing 
people to take the detour of using recursion syntax, which for many is 
harder to write and understand.




exec("tem=a; print(tem and not tem)", Wat(print=print))
# print False

In this example, one could disable the binding with __setitem__
(resulting in printing 0), but python code cannot disable internal
register or stack assignments.



Indeed. That said, though, I think that any namespace in which
referencing the same simple name more than once produces this sort of
bizarre behaviour should be considered, well, unusual. NORMAL code
won't have to concern itself with this. But the language spec doesn't
require us to write normal code..


I believe in the freedom to write 'strange code'.  But my other interest 
is how to talk about Python and 'normal' code.


--
Terry Jan Reedy

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


Re: Yield after the return in Python function.

2021-04-05 Thread Terry Reedy

On 4/5/2021 1:53 PM, Chris Angelico wrote:

On Tue, Apr 6, 2021 at 3:46 AM Terry Reedy  wrote:

*While 'a and not a' == False in logic, in Python it might raise
NameError.  But that would still mean that it is never True, making
'yield 0' still unreachable.


When I wrote that, I knew I might be missing something else.


And even just the lookup can have side effects, if your code is
pathologically stupid.


Or pathologically clever.


class Wat(dict):

... def __missing__(self, key):
... global count
... count -= 1
... return count


'__missing__' is new since I learned Python.  I barely took note of its 
addition and have never used it.  Thanks for the example of what it can 
do.  One could also make it randomly return True or False.



count = 2
eval("print(a and not a)", Wat(print=print))

True

So Python can't afford to treat this as dead code.


This gets to the point that logic and math are usually atemporal or at 
least static (as in a frozen snapshot), while computing is dynamic.  In 
algebra, the canon is that all instances of a variable are replaced by 
the same value.


Python *could* do the same for expresssions: load 'a' (in this case) 
once into a register or stack slot and use that value consistently 
throughout the expression.  Replacing the eval with the following exec 
has the same effect.


exec("tem=a; print(tem and not tem)", Wat(print=print))
# print False

In this example, one could disable the binding with __setitem__ 
(resulting in printing 0), but python code cannot disable internal 
register or stack assignments.


--
Terry Jan Reedy

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


Re: Yield after the return in Python function.

2021-04-05 Thread Terry Reedy

On 4/5/2021 8:25 AM, Bischoop wrote:

The return suspends the function execution so how is it that in below
example I got output: 

def doit():
 return 0
 yield 0
 
print(doit())


*Any* use of 'yield' in a function makes the function a generator 
function.  This is a simple rule that any person, and just as important, 
any automated algorithm, can understand.  If there were a 'dead 
(unreachable) code' exception, a reader or compiler would have to 
analyze each use of 'yield' and decide whether it is reachable or not. 
And we would have to decide whether just 1 or all 'yield's had to be 
reachable.


In the following code, in 3.x, it is also clear that 'yield' is unreachable.

>>> def f():
if False:
yield 0
return 1

>>> f()


But 'False' could be a more complex and less obvious but still 
equivalent expression, such and 'a and  and not a'*.  Is 'log(a) = 
0' tautologically False?


*While 'a and not a' == False in logic, in Python it might raise 
NameError.  But that would still mean that it is never True, making 
'yield 0' still unreachable.


--
Terry Jan Reedy

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


Re: About \033[m

2021-04-04 Thread Terry Reedy

On 4/4/2021 7:40 AM, Skip Montanaro wrote:

Porque quando se usa formatac,ao de cores, o python nao consegue


centralizar dentro da cadeia de 40 caracteres ?


Tive que colocar 54 no parametro pois de alguma forma esta sendo
considerado os caracteres de dentro do comando \033[m



Python doesn't know there is anything special about escape sequences (that
they take up no space on the screen). I think you will have better results
if you place the escape sequences in the format specifier:

  print("\033[7;30;43m{:^40}\033[m".format("Programac,ao Python"))


or
print(f"\033[7;30;43m{"Programac,ao Python":^40}\033[m")

--
Terry Jan Reedy

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


Re: not able to download PyAudio

2021-04-02 Thread Terry Reedy

On 4/2/2021 6:09 AM, Benjamin Schollnick wrote:



On Apr 2, 2021, at 4:40 AM, ᗷᑌᑎᑎY  wrote:

   Hello  everyone
   I am not able to download PyAudio. I tried by typing pip install in
   PyAudio in cmd but it show's no compatible version availbale. What should
   I do? .


There seems to be some confusion, which I can understand…

“No compatible version”, simply means that Pip was unable to find a version of 
 for your version of python.

Please note, that does not mean that a version *EXISTS*, just that it could not 
find a version for your platform.

So go to https://pypi.org  and do a search.


https://pypi.org/project/PyAudio/#files shows that the latest version on 
pypi is for 3.6, uploaded 4 years ago.


https://www.lfd.uci.edu/~gohlke/pythonlibs/ has binaries for 3.7-9, but 
you have to download manually to your machine using the instructions at 
the top of the page.


--
Terry Jan Reedy


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


Re: Unable to find 'edit with ide' option in the Context menu

2021-03-31 Thread Terry Reedy

On 3/31/2021 2:11 AM, Arjav Jain wrote:

I am using the lastest version of python recently. But I am facing a
problem with the python files, When I am right clicking any python file
there is no option for `Edit with idle'. I have repaired the python
installation too, but this doesn't  solves my problem, please help!


Did you check (or leave checked) [x] Install tkinter and IDLE?
Can you start IDLE otherwise?

--
Terry Jan Reedy

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


Re: Code Formatter Questions

2021-03-30 Thread Terry Reedy

On 3/29/2021 4:18 PM, dn via Python-list wrote:


Very good point: I'd much rather you spent time helping me with a
design/coding problem, helping debug, and/or reviewing/improving my code
(and I for you); than we had not time left-over after spending many
hours and much mental energy arguing about whether this format is [more]
right than that!


I am currently the main IDLE maintainer and spend essentially no time 
arguing over format.  If a contribution is within the bounderies of PEP 
8, that is good enough for me.


--
Terry Jan Reedy

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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-28 Thread Terry Reedy

On 3/27/2021 6:10 PM, lucas wrote:


I hope it will solve it too. Do i need to do anything ?


Review the patch by trying it out on your system.  If necessary because 
you do not have a local cpython clone, backup installed 3.9 
Lib/xmlrpc.py and hand-edit. Then report OS, python used, and result. 
(If it works, you can keep the patched version ;-).


For many issues, reviews are the bottleneck for getting fixes released.

--
Terry Jan Reedy

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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread Terry Reedy

On 3/27/2021 5:49 PM, Chris Angelico wrote:


https://bugs.python.org/issue38038

It seems to have been intended as a pure refactor, so I'd call this a
regression. Fortunately, it's not difficult to fix; but I'm not sure
if there are any other subtle changes.

The regression's already been reported so I'm adding to this issue:

https://bugs.python.org/issue43433


You added a PR, which is great, but useless unless a currently active 
coredev reviews and merges.  I requested such from the author and merger 
of the apparently offending commit.


--
Terry Jan Reedy

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


Re: Access to python37_d.lib

2021-03-27 Thread Terry Reedy

On 3/27/2021 11:34 AM, Kathleen Kennedy wrote:

When matplotlib-cpp from GitHub is used to add graphics to a Visual Studio
C++ Console application the following error is obtained: Cannot
open python37_d.lib.



The error was not resolved by re-installing python, including debug files.
Any assistance would be much appreciated.
JIMK


For me, current python3.x installed on Windows with the PSF installer 
has /libs/ containing 3 .lib files: 
_tkinter/python3/python3x.lib


My repository debug builds result in /PCbuild/win32 with lots 
of files, including python3_d.lib and python3x_d.lib.  I don't know if 
including 'debug files' includes these or not.  You can check in your 
/lib.


Is matplotlib-cpp possibly installed with its own debug build of 
python37?  Or using some other installed python on your system?


--
Terry Jan Reedy

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


Re: python documentation

2021-03-27 Thread Terry Reedy

On 3/27/2021 1:20 AM, pyt...@blackward.eu wrote:

By the way, some months ago I started trying to migrate to Python 3 and 
gave up in favor of creating said compilation.


Why?  What was biggest roadblock?


Compatibility of Python and its Packages decreased with V3 significantly.


I don't believe this without a clear explanation as to what you mean and 
strong evidence.  Are you claiming that you cannot put together a 
combination of modern python + numpy + scipy + qt + ... that work 
together?  (Many people including my daughter seem to manage just fine.) 
 If there are particular problems, it would be worth discussing and 
trying to solve them.  And what would 'compatibility have to do with 
'3.x'?  (With respect to unicode, compatibility has been improved in one 
important respect since 3.3.)



A whole lot of minor and major incompatibilities > between your subversions and 
belonging packages.


I don't understand 'subversions' and 'belonging packages'?

I understand 'incompatibities' in general but not what you mean 
specifically.  I don't know of any evidence that there are increased 
within, say, 3.8 or 3.9 packages versus 2.7 packages.


--
Terry Jan Reedy

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


Re: python documentation

2021-03-27 Thread Terry Reedy



I would like to suggest adding "Blythooon" to the list under "Other 
parties have re-packaged CPython" listed here:

https://www.python.org/download/alternatives/


Your title is misleading because you are proposing a change to a 
python.org website page, not the 'Python documentation'.  That term, as 
often used, refers to the official docs at python.org/doc.  See the list 
of "Documentation" links at the bottom of the page for a broader 
interpretation, which still excludes the page you are interested in.


Note: the 'core developers' control the contents of .../downloads, 
.../doc, and some of .../dev.  The rest of the website is done by a 
different PSF group.



Blythooon can be found here:
https://pypi.org/project/blythooon/
and the belonging installation step-by-step-guide video here:
https://www.youtube.com/channel/UCOE8xqYS_2azFsFjBVEwVMg


I don't know if the unknown to me page author(s) would consider this a 
'packaging' at they intend the term to mean.



May I ask - how can I do that best? Thanks in advance and


At the bottom of the page is "Submit Website Bug" linked to 
https://github.com/python/pythondotorg/issues


--
Terry Jan Reedy

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


Re: python documentation

2021-03-27 Thread Terry Reedy
I answered your actual question, in your original post, separately.  But 
by posting here, and continuing to respond, you implicitly invited 
extended discussion with questions and opinions.


On 3/26/2021 11:15 PM, pyt...@blackward.eu wrote:

in response to Chris Angelico, a long-time python-list discussant who 
has some strong opinions, especially with regard to 2.x versus 3.x:



No, I am not encouraging, I am just offering the possibility.


By only offering 2.7, you could be construed to be encouraging.  You 
must know that you are stepping into a long-term debate.  Your other 
comments suggests that you are not neutral.


...
It might be a good thing to recommend people to switch to Python 3.*, it 
might be a bad idea to FORCE people to do so by taking away the 
possibility to install Python 2.7.*;


The there is *obviously* no intention to take away that possibility. 
The download pages have everything available, all the way back to the 
original 0.9 sources.  The latter was recently added.  So suggesting 
that the website might 'censor' 2.7 is a kind unfair.


If I am right, 


This implies doubt.

the Python 2.7.* installers still are provided on the 
python.org website.


Along with Windows installers back to 1.5.2.

So long as this is done, I cannot see a reason not 
to list a 'distribution' using Python 2.7.* in said list, right?


Would you say the same for a 'distribution' using 2.0.1, or 1.5.2?


But, in the end, this naturally is not my decision.


AFAIK, none of the website maintainers post on this list.

--
Terry Jan Reedy

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


Re: .title() - annoying mistake

2021-03-19 Thread Terry Reedy

On 3/19/2021 6:17 PM, Thomas Jollans wrote:

 From a quick scan of my (medium-sized) bookshelf, most publishers seem 
to agree that the thing to do is set the title in all caps.


In my quick perusal, this is more true of 'popular' works, whereas 
'academic' work are more likely to use titlecase.  The title on the 
(optional) inner flyleaf and title page is more likely to be titlecase. 
 For the US Library of Congress catalog entry, the convention seems to 
be capitalize first word and proper names, like 'C' and 'Python', list a 
sentence, but no '.'.


Overall, the only rule is no rule.


--
Terry Jan Reedy

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


Re: IDLE python

2021-03-13 Thread Terry Reedy

On 3/11/2021 10:28 AM, Yoosuf Oluwatosin via Python-list wrote:


I have tried to startup my IDLE python severally but it keeps giving the 
following message:
IDLE’s  subprocess didn’t make connection. See the ‘Startup Failure’ section of 
the IDLE doc online at 
https://docs.python.org/3/library/idle.html#startup-failure.
I have gone to the page and followed all the procedures listed there but there is still no change. 


Did you try starting from a command line?

I need help on this.

I included in that page every reason and remedy I knew or could find on 
stackoverflow.  But what OS and Python version?  How did you try to 
start IDLE?  What happens with "python -m idlelib -e" on a command line 
(where 'python' is the word to start 3.x)?


--
Terry Jan Reedy


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


Re: REPL peculiarity

2021-03-11 Thread Terry Reedy

On 3/11/2021 6:01 AM, Rob Cliffe via Python-list wrote:

This is a valid Python program:

def f(): pass
print(f)

But at the REPL:

 >>> def f(): pass
... print(f)
   File "", line 2
     print(f)
     ^
SyntaxError: invalid syntax

It doesn't seem to matter what the second line is.  In the REPL you have 
to leave a blank line after the "def" line.  Why?


REPL executes *one* statement at a time.  It has always required a blank 
to end a compound statement because ending with a dedented second 
statement violates that.


Something like
>>> def f():
...  a = 3

is more typical.  A dedented statement looks like a buggy continuation 
line.


--
Terry Jan Reedy


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


Re: Application problems

2021-03-11 Thread Terry Reedy

On 3/10/2021 2:25 PM, Yoosuf Oluwatosin via Python-list wrote:


I have downloaded python 3.9.2 on my hp laptop with windows 10 and tried 
opening both the normal python and the idle python on my pc but the norml keeps 
opening the modify, repair and uninstall page while the idle keeps giving a 
startup error.


How did you try to start IDLE and what 'startup error' did you see.

--
Terry Jan Reedy

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


Re: "unexpected argument"

2021-03-09 Thread Terry Reedy

On 3/9/2021 3:03 PM, Quentin Bock wrote:

Error 1:
Space Invaders.py:90: SyntaxWarning: "is" with a literal. Did you mean "=="?
   if bullet_state is "fire":


Multiple string objects can have the same string value.  Just because 
bullet_state == 'fire' does not mean that it *is* the particular object 
being compared to.  Leaving testing aside, 'is' should only be used when 
the language mandates that there can only be one object with the value 
you want.  'is None' is the most common proper use.  Using 'is' when you 
should use '==' is a common and hard to understand beginner bug.




Error 2:
line 66, in 
 if event.key == pygame.K_SPACE:
AttributeError: 'Event' object has no attribute 'key'



 # Check whether keystroke is being pressed

 if event.type == pygame.KEYDOWN:
 if event.key == pygame.K_LEFT:
 player_X_change = -6
 if event.key == pygame.K_RIGHT:
 player_X_change = 6

 if event.key == pygame.K_SPACE:
 fire_bullet(player_X, bullet_Y)


For other keys, you check event.type first.  Here you do not.  At some 
point, you asked for the key for a non-key event.  Put this statement 
under the keyup or keydown event type check, depending on when you want 
fire to happen.



 if event.type == pygame.KEYUP:
 if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
 player_X_change = 0



--
Terry Jan Reedy

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


Re: Button placement

2021-03-09 Thread Terry Reedy

On 3/8/2021 9:08 PM, Bischoop wrote:


I try for a while place the top button in a a middle of column=0 with
span to column2 below so the button being centered to those, tried with
canvas as well but with no success. Is someone with Tkinter experience
able to advice what I could do?


Say more clearly what you want/expect and what you are getting and why 
you are unhappy.


--
Terry Jan Reedy

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


Please don't feed the trolls

2021-03-07 Thread Terry Reedy
Trolling, among other things, is fishing with a moving line, especially 
with a revolving lure, as from a moving boat.  A troll, among other 
things, is that method or the lure used.


On the internet, 'troll' is used metaphorically.  A troll is a flashy 
post designed to catch peoples emotions and hook them into responding. 
Trolling is posting such posts.  People do this either out of compulsion 
or for entertainment.


Quite separately, a troll in Scandinavian folklore is an unpleasant 
mythical creature living in a cave, or perhaps under or around a bridge. 
Bridge trolls are reputed to disrupt communication by travel.


Fishermen would not call a person trolling for fish a troll.  It would 
be an insult.  On the internet, we do call people trolling trolls, again 
methphorically, because they disrupt communication.


The proper response to trolls is to not feed them by responding as they 
wish.  When people respond, they continue trolling, and a moderator has 
to ban them.


People reading python-list posts on google groups or comp.lang.python 
should not help them evade their bans by quoting them.


On 3/6/2021 2:11 PM, Bonita Montero, responding to a banned troll for at 
least a third time:



Someone who says that he is capable of writing a compiler that
translates every language has megalomania. No one can do this.


We certainly need not believe so until it is done.

But we do not know whether X is an actual megalomaniac acting like a 
troll or an actual troll acting like a megalomaniac.  The same can apply 
to any other character type that can lead to trolling or be assumed as a 
pose by a troll.


In Spanish, bonito/a means a pretty male/female.  By coincidence, it is 
also a tuna-like fish caught by trolling.  (Decades ago, my father 
caught one on a boat one a Mexican river/lagoon.)  Please unhook 
yourself and swim away.



--
Terry Jan Reedy

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


Re: Problem with printing statement when condition is false

2021-03-05 Thread Terry Reedy

On 3/4/2021 4:28 PM, Terry Reedy wrote:

Quentin privately sent me 12 lines (which should have been posted here 
instead), which can be reduced to the following 4 that exhibit his bug.


if a == b:
     print('correct')
     if a != b:
     print('incorrect')

The bug is a != b will never be true when a == b and will not be tested 
when a != b.  The fix is to use else.


if a == b:
     print('correct')
else:
     print('incorrect')

This should not be reduced to a conditional expression since different 
code follows the print statements in the actual example.


Quentin wrote me privately that this, applied to his code, solved his 
problem.



--
Terry Jan Reedy


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


Re: Problem with printing statement when condition is false

2021-03-04 Thread Terry Reedy

On 3/4/2021 3:15 PM, Terry Reedy wrote:

On 3/4/2021 12:10 PM, Quentin Bock wrote:


I won't paste the code into
this because it's 164 lines so I will attach a file copy,


The alternative to posting too much is to reduce your code to the 
minimum needed to exhibit the behavior you want to change.  Doing so may 
reveal to you the solution.  It will certainly make it easier for anyone 
else to help you and will make any answer more useful to other readers.


Quentin privately sent me 12 lines (which should have been posted here 
instead), which can be reduced to the following 4 that exhibit his bug.


if a == b:
print('correct')
if a != b:
print('incorrect')

The bug is a != b will never be true when a == b and will not be tested 
when a != b.  The fix is to use else.


if a == b:
print('correct')
else:
print('incorrect')

This should not be reduced to a conditional expression since different 
code follows the print statements in the actual example.


--
Terry Jan Reedy


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


Re: Problem with printing statement when condition is false

2021-03-04 Thread Terry Reedy

On 3/4/2021 12:10 PM, Quentin Bock wrote:


I won't paste the code into
this because it's 164 lines so I will attach a file copy,


The alternative to posting too much is to reduce your code to the 
minimum needed to exhibit the behavior you want to change.  Doing so may 
reveal to you the solution.  It will certainly make it easier for anyone 
else to help you and will make any answer more useful to other readers.


--
Terry Jan Reedy

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


Re: Why assert is not a function?

2021-03-03 Thread Terry Reedy

On 3/1/2021 5:51 PM, Marco Sulla wrote:

I have a curiosity. Python, as many languages, has assert as a
keyword. Can't it be implemented as a function? Is there an advantage
to have it as a keyword?


One does not need to turn the test expression into a function.  One does 
not need to wrap the message expression to delay evaluation.



--
Terry Jan Reedy

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


Re: error of opening Python

2021-02-26 Thread Terry Reedy

On 2/26/2021 12:55 AM, Mladen Gogala via Python-list wrote:

On Thu, 25 Feb 2021 17:22:35 +, Botao Liu wrote:


Dear Python team,

This is my first time using Python, I tried to launch Python and it
showed "Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC
v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or
"license" for more information." I don't know what this meant and how to
fix this. Could you please help me? Thank you very much.

Kind regards,

Botao Liu


Try with this first: https://python.swaroopch.com/
It gives you the details of what that means and what to do next. Also,
your Python interpreter is broken 


No.

it says:



It should say something like this:
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC

v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or
"license"


That is exactly what it does say, which is correct.


-- [mgogala@umajor ~]$ python3
Python 3.9.1 (default, Jan 20 2021, 00:00:00)
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.




The problem string is "win32".


No.  'win32' is a historical artifact.

 You should be able to open a terminal

Window and execute "uname -r".


Not on Windows.  Please don't spew misleading garbage that will only 
confuse the new user on a different operating system.



--
Terry Jan Reedy

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


Re: Tkinter long-running window freezes

2021-02-25 Thread Terry Reedy

On 2/24/2021 6:53 PM, John O'Hagan wrote:

On Wed, 24 Feb 2021 11:03:30 -0500
Terry Reedy  wrote:


On 2/24/2021 6:35 AM, John O'Hagan wrote:

[...]


I am trying this out on Windows 10, with a wider label (so I can move
the window) and a button that changes when pressed, and a sequential
counter.  Will report when the Window freezes, or maybe a day if not.


Counter is up to 777000 with no problem.


Thank you! I've only run a few tests because of how long it takes
to freeze, but so far it seems that the trigger for the window freezing
is any attempt to interact with it, e.g. clicking on it, so try doing
that from time to time.


I clicked on Window, clicked on label, clicked on button (collectively 
at least 100 times), moved window all over screen, resized it multiple 
times, maximized it and restored it a couple of times, and no problem. 
I conclude for not that your issue does not occur on Windows.



Plus you seem to have a memory leak and may need to replicate that.


Can you explain what you mean by "replicate"?


I don't remember, so forget it.

--
Terry Jan Reedy

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


Re: Tkinter long-running window freezes

2021-02-24 Thread Terry Reedy

On 2/24/2021 6:35 AM, John O'Hagan wrote:

Hi list

I have a 3.9 tkinter interface that displays data from an arbitrary
number of threads, each of which runs for an arbitrary period of time.
A frame opens in the root window when each thread starts and closes
when it stops. Widgets in the frame and the root window control the
thread and how the data is displayed.

This works well for several hours, but over time the root window
becomes unresponsive and eventually freezes and goes grey. No error
messages are produced in the terminal.

Here is some minimal, non-threaded code that reproduces the problem on
my system (Xfce4 on Debian testing):


I am trying this out on Windows 10, with a wider label (so I can move 
the window) and a button that changes when pressed, and a sequential 
counter.  Will report when the Window freezes, or maybe a day if not.



from tkinter import *
from random import randint

root = Tk()

def display(label):
 label.destroy()
 label = Label(text=randint(0, 9))
 label.pack()
 root.after(100, display, label)

display(Label())
mainloop()


You could try with .grid instead.


This opens a tiny window that displays a random digit on a new label
every .1 second. (Obviously I could do this by updating the text rather
than recreating the label, but my real application has to destroy
widgets and create new ones).


Plus you seem to have a memory leak and may need to replicate that.


This works for 3-4 hours, but eventually the window freezes.

The process uses about 26 Mb of memory at first, and this gradually
increases to around 30 or so by the time it freezes.


--
Terry Jan Reedy

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


Re: Idle Python issue

2021-02-24 Thread Terry Reedy

On 2/24/2021 5:32 AM, jak wrote:

Hello everybody,
I encounter a problem using Idle Python in Windows when I use utf8 
characters longer than 2 bytes such as the character representing the 
smile emoticon:


The problem is with 'astral' unicode characters, those not in the Basic 
Multilingual Plane (BMP).  tcl/tk does not directly support them.



:-)
that is this:

Try to write this in Idle:
"".encode('utf8')
b'\xf0\x9f\x98\x8a'


Up until 1 1/2 years ago, you could not do this.  Now you can, as long 
as you do not try to edit anything after the astral character.  I 
thought I added something to the doc about this, but cannot find it, so 
it should be easier to find.



now try to write this:
"".encode('utf8')
now position the cursor between the double quotes and paste the smile 
character


Up until 1.5 years ago, this would have crashed either the window or 
IDLE itself.  For input, if one wants to edit, one is still better off 
using \U000# excapes.  At least now print('\U0001'), for 
instance, works to display the character is the OS font system supports it.



and try to add some text to the string (eg: 'the smile').
You may notice problems with editing.
Is there any way to prevent this from happening? It is an annoying problem.


Help the tcl/tk people to add full unicode support to tcl/tk. ;-)  They 
know it is needed.  I don't know what their timetable is now.



--
Terry Jan Reedy


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


Re: Deleting Python 3.8.5

2021-02-22 Thread Terry Reedy

On 2/22/2021 2:00 PM, Vinicius Costa Marques wrote:

Hello there Python team, I’m having this problem were I installed Python 3.9.2 
and then went to unistall 3.8.5 but here is the problem the version 3.8.5 
dosen’t get deleted properly. The uninstall program says that everything worked 
but the files for 3.8.5 still exist algong with 3.9.2 can someone help me?


The 3.8 directory should still be there if you added anything thing, 
such as to site-packages, but the stuff added by the installer should be 
gone.



--
Terry Jan Reedy


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


Re: Is there a way to subtract 3 from every digit of a number?

2021-02-20 Thread Terry Reedy

On 2/20/2021 12:02 PM, jak wrote:

Il 20/02/2021 15:40, C W ha scritto:

Hello everyone,

I'm curious if there is a way take number and back each digit by 3 ?

2342 becomes 9019
8475 becomes 5142
5873 becomes 2540

The tricky part is that 2 becomes 9, not -1.

Here's my toy example and what I attempted,

test_series = pd.Series(list(['2342', '8475', '5873']))
test_series

0    2342
1    8475
2    5873
dtype: object


test_series.str.split('')

[, 2, 3, 4, 2, ]
[, 8, 4, 7, 5, ]
[, 5, 8, 7, 3, ]
dtype: object

What a good approach to this? Is there a method or function that 
should be

handling this?


MRAB gave the proper answer -- str.translate (and str.maketrans.


 >>> num='0123456789'
 >>> n=8475
 >>> sn = ''
 >>> for x in str(n):
   sn += num[(int(x) - 3) % 10]


>  >>> int(sn)
> 5142

This works, but suggesting to beginners that they build strings with += 
is an O(n*n) trap. Try it with a string of millions of digits.  Much 
better to use str.join


''.join(num[(int(c)-3) % 10] for c in '9876543210')
#'6543210987'

Even better, improve your string lookup idea to avoid the arithmetic.

lookup1 = '7890123456'
''.join(lookup1[int(c)] for c in '9876543210')
#'6543210987'

To avoid the int call, make a lookup dictionary

lookup2 = {a:b for a, b in zip('0123456789', '7890123456')}
''.join(lookup2[c] for c in '9876543210')
#'6543210987'

To run faster, use the str methods maketrans and  translate to do the 
same thing.


lookup3 = str.maketrans('0123456789', '7890123456')
'9876543210'.translate(lookup3)
#'6543210987'

Note that "built-in function" str.maketrans is in effect a static method 
of the str class and is not an instance method. 
'0123456789'.maketrans('7890123456') does not work.  The reason is that 
the first argument can be a dict instead of a string.  Indeed, the dict 
could be the char-char mapping above created with the dict comprehension.


Also, the resulting dict maps unicode ordinals to unicode ordinals, 
rather than chars to chars, because at the C level, a string *is* a 
sequence of unsigned ints with a PyObject wrapper.


>>> lookup3
{48: 55, 49: 56, 50: 57, 51: 48, 52: 49, 53: 50, 54: 51, 55: 52, 56: 53, 
57: 54}


In Python, this is
{ord(a):ord(b) for a, b in zip('0123456789', '7890123456')}

--
Terry Jan Reedy


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


Re: use set notation for repr of dict_keys?

2021-02-20 Thread Terry Reedy

On 2/20/2021 2:25 AM, Wolfgang Stöcher wrote:

Having a dict like
   d = {'one': 1, 'two': 2}
the representation of its keys
   repr(d.keys())
gives
   "dict_keys(['one', 'two'])"

But since the keys are unique, wouldn't a representation using the set 
notation
be more intuitive, i.e. what about changing the output of 
dict_keys.__repr__ to

 "dict_keys({'one', 'two'})"
(using curly braces instead of brackets)


From 3.0 to 3.7?, when dict keys were unordered, that might have made 
sense.  But now that dict keys are insertion ordered, I think the list 
brackets suggesting a significant key order is better.  There is also 
the issue that representation changes can break code and therefore need 
substantial reason.



--
Terry Jan Reedy


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


Re: I need some help interpreting this error

2021-02-17 Thread Terry Reedy

On 2/17/2021 10:40 AM, Chris Green wrote:

I'm running this using Python 3.7 on a Linux system.

Most of the time (i.e. for a couple of days now) the program has been
satifactorily delivering mail messages, hundreds of them.  However one
mail message has provoked the following error:-

 chris@cheddar$ tail mail.err
 Traceback (most recent call last):
   File "/home/chris/.mutt/bin/filter.py", line 95, in 
 if sbstrip in msghdr["subject"]:
 TypeError: argument of type 'Header' is not iterable


But msghdr["subject"] is surely just a string isn't it?


Obviously not.


 Why is it
complaining about something of type 'Header'?


Because you tried to iterate it.  Header is defined in email.header 
(find 'class Header').  It has a __str__ to turn one into a string.  I 
have never read the email doc so I have no idea if 'subject' being a 
Header is a bug.


Grepping email package for case-sensitive word 'Header' also returns 3 
comment saying that something might be a Header, so stringify it.  I 
have the impression that these might have been added after the original 
code, perhaps in response to error reports.  In any case, you can do the 
same.



As I said the program has been running happily for a couple of days
with no errors, I guess it must be something strange in a mail that
has broken things - but what?


To determine that, look at (after logging or saving) the raw email and 
maybe the resulting Message (using msg.as_string).



# Read the message from standard input and make a message object from it
#
msg = mailbox.MaildirMessage(sys.stdin.buffer.read())


raw = sys.stdin.buffer.read()  # So can save
msg = mailbox.MaildirMessage(raw)


msghdr["subject"] = msg.get("Subject", "unknown")

...

 if sbstrip in msghdr["subject"]:


Replace with

  sub = msghdr["subject"]
  if 'Header' in str(sub.__class__):
# Or import email.message.class and use isinstance
   # stringify or skip or ???
   else:

 msg.replace_header("Subject", msghdr["subject"].replace(sbstrip, 


--
Terry Jan Reedy

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


Re: IDLE

2021-02-16 Thread Terry Reedy

On 2/16/2021 11:52 AM, Mats Wichmann wrote:

On 2/16/21 8:09 AM, Will Anderson wrote:

    Hi, I hope you are having a good day. I have a small IDLE problem and
    can’t seem to fix it. I have a .py file that I want to open using 
IDLE but

    there is no option I have even tried totally wiping python and
    reinstalling it nothing seems to work. Please help.


Can you describe what you mean by "there is no option"?

Normally, you click on the File menu, then click on Open. If you don't 
see these, maybe you have the wrong thing open in the first place?


Will, include what version of what operating system, the python versions 
you have and where obtained, whether you can run python itself, and how 
you tried run IDLE and open a file.


--
Terry Jan Reedy


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


Re: New Python implementation

2021-02-13 Thread Terry Reedy

On 2/12/2021 4:42 PM, Mr Flibble wrote:

On 12/02/2021 02:45, Terry Reedy wrote:

On 2/11/2021 5:33 PM, Mr Flibble wrote:

On 11/02/2021 22:25, Dan Stromberg wrote:
On Thu, Feb 11, 2021 at 2:00 PM Mr Flibble 


wrote:


On 11/02/2021 21:13, Dan Stromberg wrote:
Does your project have a name yet?  I'd like to follow it through 
google

alerts or an announcement mailing list.


"neos" - https://neos.dev/ https://github.com/i42output/neos



Pypi already appears to have another project named neos:
https://pypi.org/project/neos/


neos isn't a Python package so that isn't a problem.


Since it obviously is a Python package, as in importable into a Python 
program, why do you deny it?


You are mistaken: it isn't a Python package and it isn't importable into 
a Python program.


https://pypi.org/project/neos/ shows
import neos.makers as makers
import neos.cls as cls

When you wrote 'neos' without qualification right after the neos package 
url, I though you were referring to the package, not your neos.  My 
mistake and your unclear writing.


--
Terry Jan Reedy


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


Re: mutating a deque whilst iterating over it

2021-02-12 Thread Terry Reedy

On 2/11/2021 3:22 PM, duncan smith wrote:


   It seems that I can mutate a deque while iterating over it if I
assign to an index, but not if I append to it. Is this the intended
behaviour?


Does the deque doc say anything about mutation while iterating? 
(Knowing the author of deque, I would consider everything about it 
intentional without *good* reason to think otherwise.



from collections import deque
d = deque(range(8))
it = iter(d)
next(it)

0

d[1] = 78


This does not change the structure of the deque, so next does not 
notice.  It could be considered not be a mutation.  It could be detected 
by changing deque.__setitem__, but why bother and slow down all 
__setitem__ calls.



next(it)

78

d.append(8)


This changes the structure, which can apparently mess-up iteration.


next(it)

Traceback (most recent call last):
   File "", line 1, in 
 next(it)
RuntimeError: deque mutated during iteration





--
Terry Jan Reedy

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


Re: New Python implementation

2021-02-12 Thread Terry Reedy

On 2/11/2021 5:33 PM, Mr Flibble wrote:

On 11/02/2021 22:25, Dan Stromberg wrote:
On Thu, Feb 11, 2021 at 2:00 PM Mr Flibble 


wrote:


On 11/02/2021 21:13, Dan Stromberg wrote:
Does your project have a name yet?  I'd like to follow it through 
google

alerts or an announcement mailing list.


"neos" - https://neos.dev/ https://github.com/i42output/neos



Pypi already appears to have another project named neos:
https://pypi.org/project/neos/


neos isn't a Python package so that isn't a problem.


Since it obviously is a Python package, as in importable into a Python 
program, why do you deny it?


--
Terry Jan Reedy


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


Re: @unittest.skip doesn't print anything in Python <= 3.7

2021-02-12 Thread Terry Reedy

On 2/11/2021 3:25 PM, אורי wrote:

Hi,

https://stackoverflow.com/questions/66161394/unittest-skip-doesnt-print-anything-in-python-3-7

We are using Django with unittest. Some tests are skipped with the
@unittest.skip decorator. But if I run the tests with Python 3.6 or 3.7, I
get a number of tests passed (Ran 993 tests / OK), and if I run the same
tests with Python 3.8, I get the same number of tests but with some tests
skipped (Ran 993 tests / OK (skipped=4)).


...


I think the skipped tests are skipped in all Python versions, but in Python
3.6 and 3.7 there is no output about them being skipped. Is it a bug?


Perhaps you have discover a bug in 3.7 that was fixed in 3.8.  Each new 
version comes with a few hundred bug fixes, not just the new features, 
although only the latter are featured in the new version announcement.


If you are really concerned, find What's New in 3.8 and look changelog, 
linked in the first paragraph, for 'unittest' issues.


--
Terry Jan Reedy


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


  1   2   3   4   5   6   7   8   9   10   >