error in install.sh

2020-09-30 Thread RobH
I had to do a reinstall of my linux system due to a faulty ssd, and have 
a problem with a install.sh script.The said script is included in with 
lcd files. which I downloaded from github.


When I run ./install.sh, it fails at
./install.sh: line 34: syntax error: unexpected end of file.

I don't know what the syntax should be here;

These are the last 4 lines in the script, and if I count the spaces then:

echo "Should be now all finished. Please press any key to now reboot. 
After rebooting run"

echo "'sudo python demo_lcd.py' from this directory"
read -n1 -s < I think this is the line in question
sudo reboot

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


Re: error in install.sh

2020-09-30 Thread 2QdxY4RzWzUUiLuE
On 2020-09-30 at 13:27:43 +0100,
RobH  wrote:

> I had to do a reinstall of my linux system due to a faulty ssd, and have a
> problem with a install.sh script.The said script is included in with lcd
> files. which I downloaded from github.
> 
> When I run ./install.sh, it fails at
> ./install.sh: line 34: syntax error: unexpected end of file.
> 
> I don't know what the syntax should be here;
> 
> These are the last 4 lines in the script, and if I count the spaces then:
> 
> echo "Should be now all finished. Please press any key to now reboot. After
> rebooting run"
> echo "'sudo python demo_lcd.py' from this directory"
> read -n1 -s < I think this is the line in question
> sudo reboot

I'm not sure that this is a Python problem, but usually "unexpected end
of file" errors are due to missing or mismatched quotes.  Basically, the
interpreter (Python, shell, or whatever) detects an opening quoute and
doesn't find the matching closing quote until it runs off the end of the
file (or the script).

I'd check with other users or the support system of that specific script
("lcd files" isn't enough for me to know where it came from), or check
any modifications you may have made to it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: error in install.sh

2020-09-30 Thread RobH

On 30/09/2020 13:49, [email protected] wrote:

On 2020-09-30 at 13:27:43 +0100,
RobH  wrote:


I had to do a reinstall of my linux system due to a faulty ssd, and have a
problem with a install.sh script.The said script is included in with lcd
files. which I downloaded from github.

When I run ./install.sh, it fails at
./install.sh: line 34: syntax error: unexpected end of file.

I don't know what the syntax should be here;

These are the last 4 lines in the script, and if I count the spaces then:

echo "Should be now all finished. Please press any key to now reboot. After
rebooting run"
echo "'sudo python demo_lcd.py' from this directory"
read -n1 -s < I think this is the line in question
sudo reboot


I'm not sure that this is a Python problem, but usually "unexpected end
of file" errors are due to missing or mismatched quotes.  Basically, the
interpreter (Python, shell, or whatever) detects an opening quoute and
doesn't find the matching closing quote until it runs off the end of the
file (or the script).

I'd check with other users or the support system of that specific script
("lcd files" isn't enough for me to know where it came from), or check
any modifications you may have made to it.



This is where I got the files from:

https://github.com/the-raspberry-pi-guy/lcd/find/master

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


Interference tkinter and plot from matplotlib

2020-09-30 Thread Pierre Bonville
 Hi everybody,
I am running this little program below on Win 10 with Python 3.8 (just
typing prog.py after the prompt c:\Users ...>), and while it correctly
displays the window and does the first plt.plot(), it does not reach the
input command and remains waiting after I shut the plot. If I replace
'quit' by 'destroy' in the button command, it works correctly. I looked on
various Python forums on the Net, but didn't find an answer.
Regards,
P.Bonville

import tkinter as tk
import matplotlib.pyplot as plt
r = tk.Tk()
b = tk.Button(r, text= r.quit)
b = tk.Button(r, text='quit', command=r.quit)
b.pack()
r.mainloop()  # This blocks until press button.
# Root window with button is still displayed.
plt.plot()
plt.show()
rep = input("Return")
plt.plot()
plt.show()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Interference tkinter and plot from matplotlib

2020-09-30 Thread Christian Gollwitzer

Am 30.09.20 um 15:46 schrieb Pierre Bonville:

  Hi everybody,



Interference tkinter and plot from matplotlib



You are mixing different ways of control flow. In a GUI program, don't 
call input(). Use the mainloop() as the very last of your calls, and 
only work in the callbacks. That means you would integrate a "Next" 
button in your GUI which switches the plots - or even show them side by 
side.


Concerning matplotlib, you'll need to tell it to integrate with Tk 
properly.

https://matplotlib.org/3.3.1/gallery/user_interfaces/embedding_in_tk_sgskip.html


If you want a simple solution instead of full-blown GUI programming, use 
IPython https://ipython.readthedocs.io/en/stable/config/eventloops.html

or jupyter notebooks.


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


new feature in Python.

2020-09-30 Thread yonatan
Hi, My name is Jonatan and i am programming in Python for about 4 years, 
I have a great idea, there are __iX__` methods, such as `__ior__`, `__iadd__`, 
`__iand__` etc.., which implements the |=, +=, &= behavior, 
it would be nice if you could implement also `__igetattr__` or something, which 
means:

instead of
con = "some text here"
con  = con.replace("here", "there")

we could do

con = "some text here"
con  .= replace("here", "there")


Please let me know what do you think about it, Jonatan.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new feature in Python.

2020-09-30 Thread Jason C. McDonald

> I have a great idea, there are __iX__` methods, such as `__ior__`,
> `__iadd__`, `__iand__` etc.., which implements the |=, +=, &=
> behavior, 
> it would be nice if you could implement also `__igetattr__` or
> something, which means:
> 
> instead of
> con = "some text here"
> con  = con.replace("here", "there")
> 
> we could do
> 
> con = "some text here"
> con  .= replace("here", "there")

I have three concerns about this. First, there's a lot of wizardry
under the covers with getattr() and dot access to begin with, so this
would be significantly non-trivial. I suspect the behavior would wind
up being "surprising" too often.

Second, explicit is better than implicit. It's better to explicitly
rebind the name (or mutate on the name) rather than have a fancy
shorthand for trampling over an existing mutable value. In the case of
the compound operators on numbers, you're dealing with immutable types
anyway, so you're really just rebinding the name. The same is true of
your string there. But what about a list?

spam = [1, 2, 3]
eggs = spam
eggs .= append(4)  # what is happening
eggs .= sort()  # how about now?
eggs .= sorted(eggs) # and now?

You see? It's going to be a lot of surprises, because you're stripping
the usual visual cues of explicit assignment:

spam = [1, 2, 3]
eggs = spam
eggs.append(4)  # mutating spam too
eggs.sort()  # mutating spam too
eggs = eggs.sorted() # rebinding eggs to a new value, spam is safe

Yes, yes, I know, you could "get used to it", but it's adding
complexity and detracting from the One Obvious Way to do things. If an
object decides to implement those compound operators and abuse them
thusly, that's a consenting adults situation. Introducing this new
syntax into the language creates a trip hazard for the user.

Third, that proposed operator, .=  oww that's hard to see. It looks
like a typo, and could easily be typed as one, or overlooked altogether
(again, surprises).

Explicit-is-better-than-implicit'ly yrs,

-- 
Jason C. McDonald
(CodeMouse92)

Author | Speaker | Hacker | Time Lord


signature.asc
Description: This is a digitally signed message part
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new feature in Python.

2020-09-30 Thread Chris Angelico
On Thu, Oct 1, 2020 at 2:14 AM Jason C. McDonald
 wrote:
>
>
> > I have a great idea, there are __iX__` methods, such as `__ior__`,
> > `__iadd__`, `__iand__` etc.., which implements the |=, +=, &=
> > behavior,
> > it would be nice if you could implement also `__igetattr__` or
> > something, which means:
> >
> > instead of
> > con = "some text here"
> > con  = con.replace("here", "there")
> >
> > we could do
> >
> > con = "some text here"
> > con  .= replace("here", "there")
>
> I have three concerns about this. First, there's a lot of wizardry
> under the covers with getattr() and dot access to begin with, so this
> would be significantly non-trivial. I suspect the behavior would wind
> up being "surprising" too often.
>
> Second, explicit is better than implicit. It's better to explicitly
> rebind the name (or mutate on the name) rather than have a fancy
> shorthand for trampling over an existing mutable value. In the case of
> the compound operators on numbers, you're dealing with immutable types
> anyway, so you're really just rebinding the name. The same is true of
> your string there. But what about a list?
>
> spam = [1, 2, 3]
> eggs = spam
> eggs .= append(4)  # what is happening
> eggs .= sort()  # how about now?
> eggs .= sorted(eggs) # and now?
>
> You see? It's going to be a lot of surprises, because you're stripping
> the usual visual cues of explicit assignment:
>
> spam = [1, 2, 3]
> eggs = spam
> eggs.append(4)  # mutating spam too
> eggs.sort()  # mutating spam too
> eggs = eggs.sorted() # rebinding eggs to a new value, spam is safe
>

These examples reveal a few other issues, though, which can best be
highlighted by this:

x = 5
x *= 2 + 3
print(x)

x = 5
x = x * 2 + 3
print(x)

Augmented assignment works with a single other operand. It's not
textually equivalent to "x = x  other"; it's closer to "x = x 
(other)", putting the right hand side in parentheses. That doesn't
work with a hypothetical igetattr, because you're invariably going to
want to do more than just get an attribute.

It's also notable that the in-place *methods* are actually used
something like this (omitting detaily bits about slots):

x += y
# is roughly equivalent to
x = x.__iadd__(y)

So there's assignment *as well as* the in-place method call. The only
value of the __iadd__ family of methods is with types that can
implement them directly; for instance, a list can append to itself,
rather than copying itself and then reassigning (which is semantically
different, as well as being far less efficient). The ".=" operator
wouldn't be able to take advantage of that.

If you find yourself frequently writing long chains of statements that
all do "thing = thing.method()", it may be better to consider writing
them as a single statement instead:

name = (name
.capitalize()
.expandtabs()
.lstrip(" ")
.replace(", ", ",")
)

It'd be as efficient and readable as the augmented assignment form would be.

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


Re: new feature in Python

2020-09-30 Thread Christman, Roger Graydon
On 30/09/2020, yonatan <[email protected]> proposed:
> instead of
> con = "some text here"
> con  = con.replace("here", "there")

> we could do

> con = "some text here"
> con  .= replace("here", "there")

That would require a major rewrite of the grammer
of the Python language, which would probably be a bad thing.

The operands to all of those assignment operators are
complete objects in their own rights.   This 'replace'
is not an independent object, but a member of the
string object.   Without that "con." in front of it,
you would likely get the error about
"'replace' not defined"

For the grammar to be clean and orthogonal,
it would not be at all good to have a context-sensitivity
introduced to allow orphaned method names to be
permitted,  just because there was this ".=" token
somewhere earlier in the program statement.

Besides, I could foresee a lot of programming
errors when people would start to generalize this
operation to do things like:

list .= append(item)
list .= sort()

which would most certainly be incorrect.

Roger Christman
Pennsylvania State University
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: error in install.sh

2020-09-30 Thread Dieter Maurer
RobH wrote at 2020-9-30 13:27 +0100:
>I had to do a reinstall of my linux system due to a faulty ssd, and have
>a problem with a install.sh script.The said script is included in with
>lcd files. which I downloaded from github.
>
>When I run ./install.sh, it fails at
>./install.sh: line 34: syntax error: unexpected end of file.
>
>I don't know what the syntax should be here;
>
>These are the last 4 lines in the script, and if I count the spaces then:
>
>echo "Should be now all finished. Please press any key to now reboot.
>After rebooting run"
>echo "'sudo python demo_lcd.py' from this directory"
>read -n1 -s < I think this is the line in question

The command above is broken:
`read` is a `SHELL BUILTIN COMMAND`;
its purpose is to read words from standard input into shell variables
specified on the command line. The command above does not name
any variables.
The "<<" in the command above introduces a `HERE DOCUMENT` redirection:
it allows a script to privide input data. Its syntax is:
  [n]<<[-]word
  here-document
  delimiter
The "HERE DOCUMENT" redirection reads the script text following
the command until *delimiter* (derived from *word*) is found on
a line by itself.
In your case, the delimiter is not found resulting in "unexpected EOF".




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


Re: [RELEASE] Python 3.8.6 is now available

2020-09-30 Thread Mats Wichmann
On 9/29/20 9:16 AM, David Raymond wrote:
>> Python 3.8.6 is the sixth maintenance release of Python 3.8. Go get it here:
> 
>> https://www.python.org/downloads/release/python-386/ 
>> 
> 
> 
> Just a quick note that there still seem to be a few places on the website 
> which are still showing 3.8.5 as the latest release. (Looking at it with 
> Firefox on Windows)
> 
> On the main page www.python.org it has 3.8.6 down in the latest news section, 
> and a direct link in the little download box right above that. But if you 
> hover over the big "Downloads" tab at the top it gives a big 3.8.5 button
> 
> If you click on that Downloads tab and go to www.python.org/downloads, again 
> there's a big gold button for 3.8.5, and if you scroll down to the "Looking 
> for a specific release?" section there is no 3.8.6 visible. The most recent 
> line is 3.5.10 from Sept 5th
> 

A lot of this is automated.

But if you go to https://www.python.org/downloads/windows, the entry for
3.8.6 says "No files for this release".  That's somewhat going to impact
the ability to download :)




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


Re: Problem

2020-09-30 Thread Eryk Sun
On 9/30/20, Dennis Lee Bieber  wrote:
> On Tue, 29 Sep 2020 22:31:18 + (UTC), Ron Villarreal via Python-list
>  declaimed the following:
>
>>Tried to open Python 3.8. I have Windows 10. Icon won’t open.
>
>   What "Icon"?
>
>   Python is a language interpreter/compiler -- it runs from a command
> prompt/shell. Clicking on a Python SCRIPT might open a shell, which will
> almost immediately close when the script finishes executing

No shell should be executed by a normal .py file association. If it's
running CMD or PowerShell, or any other shell, it's likely a mistake.

Double clicking on an icon for a .py file should run "py.exe" ->
"python.exe" or just "python.exe", assuming .py scripts are configured
to execute by default as opposed to opening in an editor. These are
console applications, which, when executed without an inherited
console session, will automatically create a new console session that
creates a window for the console/terminal user interface. The latter
includes keyboard and mouse input and display of the active screen
buffer. Client applications access the session's input buffer and
screen buffers via console I/O files that are attached to the console
session.  (In Windows 7+, a console session is an instance of
conhost.exe. In Windows 8+, console I/O files are provided by the
ConDrv device, which is implemented by the condrv.sys driver. In
Windows 10, console I/O also supports virtual-terminal ANSI sequences,
which improves API compatibility with terminals on other platforms.)
-- 
https://mail.python.org/mailman/listinfo/python-list


A library that converts a type-annotated function into a webpage with HTML forms?

2020-09-30 Thread James Lu
Is there a python library available that converts a type-annotated Python
function into a webpage with HTML forms?

Something like:


def foo(name: str, times: int):
return f"Hello {name}!" * times

serve_from(foo, host="0.0.0.0", port=3000)

Turning into a server that serves something like this:


name




And hitting the submit button executes the function.

I'm aware I could use sls, and build a form manually, but that's extra work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem

2020-09-30 Thread Mirko via Python-list
Am 30.09.2020 um 17:55 schrieb Dennis Lee Bieber:
> On Tue, 29 Sep 2020 22:31:18 + (UTC), Ron Villarreal via Python-list
>  declaimed the following:
> 
>> Tried to open Python 3.8. I have Windows 10. Icon won’t open.
> 
>   What "Icon"?
> 
>   Python is a language interpreter/compiler -- it runs from a command
> prompt/shell. Clicking on a Python SCRIPT might open a shell, which will
> almost immediately close when the script finishes executing (files with a
> .pyw extension are supposed to create their own GUI using one of a couple
> of libraries, and don't open a shell).


I'm just a lurker, hobby programmer and Linux geek, so take my words
with some caution.

We are seeing these troubles from newcomers on Windows all of the
time -- and that for years. Isn't it time to ask if the way Python
installs itself on Windows-Systems is appropriate?

I have only limited knowledge about current Windows systems. But it
seems to me that newcomers download some setup exe/msi and then
search the menu to run what ever is found (python.exe or even the
setup-program.)

That's Ok, if you understand what an interpreter/compiler for the
command-line is. But programming beginners usually don't know that
(especially not if there are Windows users).

There has been a lot of effort to make this group inclusive and
newcomer-friendly. But it seems to me that this is not the case for
the software itself. Given that Python ships with a rudimentary IDE
(IDLE), should that one be promoted more intensively?

Shouldn't IDLE be named something like "Python Editor" (or Python
IDE/App) in the menu, so beginners can more easily find it? Further
it might be a good idea to make this "Repair/Modify/Remove"-Dialog
more explicit by clearly saying "Python is already installed. If you
want to use it, do ...".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem

2020-09-30 Thread Chris Angelico
On Thu, Oct 1, 2020 at 7:33 AM Mirko via Python-list
 wrote:
>
> Am 30.09.2020 um 17:55 schrieb Dennis Lee Bieber:
> > On Tue, 29 Sep 2020 22:31:18 + (UTC), Ron Villarreal via Python-list
> >  declaimed the following:
> >
> >> Tried to open Python 3.8. I have Windows 10. Icon won’t open.
> >
> >   What "Icon"?
> >
> >   Python is a language interpreter/compiler -- it runs from a command
> > prompt/shell. Clicking on a Python SCRIPT might open a shell, which will
> > almost immediately close when the script finishes executing (files with a
> > .pyw extension are supposed to create their own GUI using one of a couple
> > of libraries, and don't open a shell).
>
>
> I'm just a lurker, hobby programmer and Linux geek, so take my words
> with some caution.
>
> We are seeing these troubles from newcomers on Windows all of the
> time -- and that for years. Isn't it time to ask if the way Python
> installs itself on Windows-Systems is appropriate?
>

The problem is that there isn't "the way". Did the person:

1) Download an MSI file from python.org?
2) Install ActiveState?
3) Install Enthought?
4) Install Anaconda?
5) Get Python from the Microsoft Store?
6) Something else?

They're all different, they all behave differently, they all have
different defaults. And then there's the question of "did you install
it for everyone or just you?", and so on.

The core Python devs have control of the first option, and some
control over the fifth, but none of the others. And quite often, it
turns out that these issues come from someone doing *more than one* of
these, making it even more difficult to figure out what's happened.

So, go ahead, ask if it's appropriate good luck getting a useful response :|

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


Re: Problem

2020-09-30 Thread Eryk Sun
On 9/30/20, Mirko via Python-list  wrote:
>
> I have only limited knowledge about current Windows systems. But it
> seems to me that newcomers download some setup exe/msi and then
> search the menu to run what ever is found (python.exe or even the
> setup-program.)

It might help some people who try to run Python via the installer if
it actually had "installer" in the name. For example,
"python-3.8.5-amd64-installer.exe" instead of
"python-3.8.5-amd64.exe".

> Shouldn't IDLE be named something like "Python Editor" (or Python
> IDE/App) in the menu, so beginners can more easily find it? Further
> it might be a good idea to make this "Repair/Modify/Remove"-Dialog
> more explicit by clearly saying "Python is already installed. If you
> want to use it, do ...".

Explorer tracks recently added start-menu items and indicates them as
"New". The Python 3.x start-menu folder has clearly named shell links
such as "IDLE (Python 3.9 64-bit)" and "Python 3.9 (64-bit)" (run
python.exe), as well as "Python 3.9 Manuals (64-bit)" (chm docs) and
"Python 3.9 Module Docs (64-bit)" (pydoc browser).

The successful installation message was recently changed to include
brief instructions for running Python via the `py` command as well as
a direct link to Python on Windows docs [1]:

New to Python? Start with the online tutorial [link] and
documentation [link]. At your terminal,
type "py" to launch Python, or search for Python in your Start menu.

See what's new [link] in this release, or find more info about
using Python on Windows [link].

I'd wager that Steve would welcome a PR to add a similar message to
the modify/repair dialog.

[1] 
https://github.com/python/cpython/blob/v3.9.0rc2/Tools/msi/bundle/Default.wxl#L108
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem

2020-09-30 Thread Michael Torrie
On 9/29/20 4:31 PM, Ron Villarreal via Python-list wrote:
> Tried to open Python 3.8. I have Windows 10. Icon won’t open.

Did you read the documentation? https://docs.python.org/3/using/windows.html

Seems like this comes up several times a week. Perhaps the installer
should automatically open this page.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A library that converts a type-annotated function into a webpage with HTML forms?

2020-09-30 Thread Kushal Kumaran
On Wed, Sep 30 2020 at 04:45:47 PM, James Lu  wrote:
> Is there a python library available that converts a type-annotated Python
> function into a webpage with HTML forms?
>
> Something like:
>
>
> def foo(name: str, times: int):
> return f"Hello {name}!" * times
>
> serve_from(foo, host="0.0.0.0", port=3000)
>
> Turning into a server that serves something like this:
>
> 
> name
> 
> 
> 
>
> And hitting the submit button executes the function.
>
> I'm aware I could use sls, and build a form manually, but that's extra work.

https://fastapi.tiangolo.com/

https://fastapi.tiangolo.com/tutorial/path-params/#documentation

Depending on what you need to use the forms for, this might suffice.

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


Re: Problem

2020-09-30 Thread Grant Edwards
On 2020-09-30, Mirko via Python-list  wrote:

> We are seeing these troubles from newcomers on Windows all of the
> time -- and that for years. Isn't it time to ask if the way Python
> installs itself on Windows-Systems is appropriate?

And that's been asked every few months for years.

Time and time again, people suggest that the installer should be
tweaked to end with a page explaining how to run python, or that some
sort of "launcher" or other be added.  Those sound like good ideas to
me (even though I'm not sure exactly what the "launger" suggestion
is), but I'm a Linux user, so what do I know?

--
Grant



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


Re: Problem

2020-09-30 Thread Grant Edwards
On 2020-09-30, Eryk Sun  wrote:
> On 9/30/20, Mirko via Python-list  wrote:
>>
>> I have only limited knowledge about current Windows systems. But it
>> seems to me that newcomers download some setup exe/msi and then
>> search the menu to run what ever is found (python.exe or even the
>> setup-program.)
>
> It might help some people who try to run Python via the installer if
> it actually had "installer" in the name. For example,
> "python-3.8.5-amd64-installer.exe" instead of
> "python-3.8.5-amd64.exe".

Yep. And, that too has been suggested many times over the years.

--
Grant

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