Re: There is LTS?

2020-08-24 Thread Léo El Amri via Python-list
On 24/08/2020 04:54, 황병희 wrote:
> Hi, just i am curious. There is LTS for *Python*? If so, i am very thank
> you for Python Project.

Hi Byung-Hee,

Does the "LTS" acronym you are using here stands for "Long Term Support" ?

If so, then the short answer is: Yes, kind of. There is a 5 years
maintenance for each major version of Python 3.

You can find information on how Python is released and maintained at PEP
101 [1] and on the developers documentation [2].

Each major Python release typically have a PEP associated with it where
past minor releases dates and future plans are recorded.
For example: PEP 494 [3] for Python 3.6, PEP 537 [4] for Python 3.7 and
PEP 569 [5] for Python 3.8.

[1] https://www.python.org/dev/peps/pep-0101/
[2] https://devguide.python.org/devcycle/
[3] https://www.python.org/dev/peps/pep-0494/
[4] https://www.python.org/dev/peps/pep-0537/
[5] https://www.python.org/dev/peps/pep-0569/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program chaining on Windows

2020-08-24 Thread Chris Angelico
On Mon, Aug 24, 2020 at 5:30 PM Rob Cliffe  wrote:
>
> On 24/08/2020 00:57, Chris Angelico wrote:
> > 2) The same thing but entirely within Python. Instead of importing
> > modules, manually load them and exec the source code. (No relation to
> > the process-level exec - I'm talking about the exec function.)
> > Updating is way WAY faster, but it isn't the same thing as restarting.
> > Your code has to be built with this in mind.
> Ah, there's the rub.  This program will be run stand-alone at client
> sites and I need to test it "as is".  As I see it I can't responsibly
> rewrite the way it works (if I'm understanding you more or less correctly).

Yeah, makes sense. If you'd built it from the ground up to handle fast
code reloads, the client site wouldn't know or care about that
difference, and you wouldn't lose much performance (probably not lose
any at all, in fact), but recoding it to that model now would possibly
be a big change, so it's not really worth it.

Stick to what you have, I think. It's better than trying to exec.

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


Re: Program chaining on Windows

2020-08-24 Thread Rob Cliffe via Python-list



On 24/08/2020 00:08, Eryk Sun wrote:


For Windows, we need to spawn, wait, and proxy the exit status.

Sorry, I understand very little of this.  Here's where I get stuck:
    (1) "*spawn*": I see that there are some os.spawn* functions.  I 
tried this:


    # File X1.py
    import os, sys
    print("This is X1")
    pid = os.spawnl(os.P_NOWAIT, "C:\\Python38\\python.exe", 
"C:\\Python38\\X2.py")

    print(f"X1 got {pid=}")
    sys.exit()

but when I ran it, it displayed

    This is X1
    X1 got pid=...

and then apparently started the Python interactive interpreter, although 
in reality things were in one of the confused states that I described in 
my first post.

(FWIW If I type
    "C:\\Python38\\python.exe" "C:\\Python38\\X2.py"
from the DOS prompt, it works as expected.)

    (2) "*wait*": Wait for what?  How?
    (3) "*proxy the exit status*": Sorry, I have no idea what this means.

Are you suggesting something I could do in Python that would achieve my 
aim of *replacing* one program by another (or merely e.g. describing 
something you could do in C)?

If so, is there any chance you could give me some toy code?
As you can see, I'm pretty well lost.

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


Re: Program chaining on Windows

2020-08-24 Thread Rob Cliffe via Python-list



On 24/08/2020 00:57, Chris Angelico wrote:

On Mon, Aug 24, 2020 at 9:51 AM Rob Cliffe via Python-list
 wrote:

Let me describe my actual use case.  I am developing a large Python
program (in Windows, working in DOS boxes) and I constantly want to
modify it and re-run it.  What I have been doing is to make it respond
to a hotkey by calling itself via os.system.  The problem is that if I
do this 50 times I am left with 51 instances still running, each one
waiting for the next to finish.  That's actually OK, except that when I
finally shut it down, it takes a long time (about 2.5 sec per instance).

I have found a workaround: a small shell program which calls the main
program (wth os.system), then when the latter exits, calls it again (if
required).  Starting the main program is slightly slower, but acceptably
so; shutting it down becomes constant time.

But I would still like to be able to do it as I originally planned, if
possible.  Not least because I may have other uses for program
"chaining" in future.


Hmm. Python isn't really set up to make this sort of thing easy.

I guess this sentence pretty well answers my whole post. :-(

  My
recommendations, in order of priority, would be:

1) What you're doing, but with a dedicated exit code that means
"changed, please restart me"
That is pretty much what I am now doing.  I return (to a shell program) 
exit codes which mean "such-and-such a hotkey was hit, please restart me".


2) The same thing but entirely within Python. Instead of importing
modules, manually load them and exec the source code. (No relation to
the process-level exec - I'm talking about the exec function.)
Updating is way WAY faster, but it isn't the same thing as restarting.
Your code has to be built with this in mind.
Ah, there's the rub.  This program will be run stand-alone at client 
sites and I need to test it "as is".  As I see it I can't responsibly 
rewrite the way it works (if I'm understanding you more or less correctly).


3) Similar to #2 but using a language that's designed with that kind
of thing in mind. Off topic for this list but it's something I've done
on a number of occasions, so I'd be happy to discuss that with you.
No, no, no, Python is for me!  (Seriously: rewriting in another language 
would be far too time-consuming and *error-prone*.  Not to mention 
unenjoyable.)


4) Any other option available

5) Messing with exec on Windows

Which I've been doing, but without success.

Thanks again, Chris.
Rob


ChrisA


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


Re: Embedded python: How to debug code in an isolated way

2020-08-24 Thread Eko palypse
Thank you very much for your interest in my little problem.

> When the app calls into python does the event loop of the gui block?

Yes, the cpp app calls a callback function from the embedded python
interpreter synchronously.


> When you print does that trigger the event loop to run in a nested call
back into the cpp?

I can't say for sure but I don't think so. At least my script or the
embedded interpreter doesn't do that.


>  Maybe you need to run python in its own thread and Marshall in and out
of the gui main thread with the event loop?

I've checked by using GetCurrentThreadId

that the registered callback function and debugger run in the same thread
but it is different to the UI thread.
Do you think I have to run the debugger in its own thread? I'll give it a
try anyways. :-)

Thx
Eren

Am So., 23. Aug. 2020 um 22:55 Uhr schrieb Barry :

>
>
> > On 22 Aug 2020, at 20:53, Eko palypse  wrote:
> >
> > Hello,
> >
> > background info first. On windows, python3.8.5
> >
> > A cpp app has an embedded python interpreter which allows to
> modify/enhance the cpp app
> > by providing objects to manipulate the cpp app and callbacks to act on
> certain events,
> > like fileopen, fileclose, updateui ... which are send by the cpp app.
> > The embedded python interpreter acts more or less like the standard
> python REPL.
> > If you run a script with code like
> >
> > def test(i):
> >print(i*2)
> >
> > test(4)
> >
> > then the test function is now globally available as long as the cpp app
> is alive.
> >
> > I've written a debugger based on bdb and encountered a situation which I
> haven't found out how to handle correctly yet.
> >
> > Let's assume I've registered a callback when something changes in the UI.
> > In that case an object function gets called which highlights certain
> aspects in the UI.
> >
> > Now if I run a script via this debugger it works as long as I don't use
> the same object function.
> > If I do use it, then the stack gets corrupted(?).
>
> When the app calls into python does the event loop of the gui block?
> When you print does that trigger the event loop to run in a nested call
> back into the cpp?
>
> Maybe you need to run python in its own thread and Marshall in and out of
> the gui main thread with the event loop?
>
> Barry
>
> > For example it look like this
> >
> > stack:
> > ,
> 580
> > ', line 1, code >, 1
> >  code >, 8
> >
> > now if I enter the function which call this object function this gets add
> >
> >  add_match>, 5
> >
> > I step through the code and suddenly the stack looks like this
> >
> > ,
> 580
> > ', line 1, code >, 1
> >  code >, 8
> >  code >, 154
> >  code paint_it>, 102)]
> >
> > EnhanceAnyLexer is neither part of the test_pydebugger script nor part
> of the debugger.
> > It is used to register a callback on the updateui event.
> >
> > So the question is, what do I need to read/learn/understand in order to
> solve this issue?
> > Or in other words, how can I debug my script in an isolated environment.
> > I can't manipulate the __main__.dict as this seems to have general
> impact on registered callbacks as well.
> > Any ideas?
> >
> > Thank you
> > Eren
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program chaining on Windows

2020-08-24 Thread Eryk Sun
On 8/24/20, Rob Cliffe  wrote:
>
> Are you suggesting something I could do in Python that would achieve my
> aim of *replacing* one program by another

No, it's not possible with the Windows API. Implementing POSIX exec
would require extensive use of undocumented NT runtime library
functions, system calls, and PEB data in order to reset the address
space and handle table and reinitialize the process, and it would
probably also require the help of a kernel driver to modify the
_EPROCESS record in kernel space.

>  (1) "*spawn*": I see that there are some os.spawn* functions.

The POSIX way to create a new process is fork (clone), which is
optionally followed by exec (image overlay). Cloning the current
process is fast and efficient. The Windows way to create a new process
is spawn, as implemented by WinAPI CreateProcessW, which is relatively
slow and laborious. In Python, the preferred way to call the latter is
with subprocess.Popen, or helper functions such as subprocess.run.

Spawing a Windows process is a lot of work. It involves creating a new
process object (a large _EPROCESS record in the kernel) and address
space (a VAD tree and page tables); allocating and initializing a
process environment block (PEB; a large block of memory that includes
process flags, parameters, environment variables, loader data,
activation contexts, and much more); optionally inheriting handles for
kernel objects from the parent process; mapping an executable file as
the process image; and creating an initial thread that starts at the
OS entrypoint function (a queued APC that calls LdrInitializeThunk,
which resumes at RtlUserThreadStart). The latter initializes the
process; registers with the session server csrss.exe via its LPC port;
loads and initializes dependent DLLs, which may require multiple
activation contexts and LPC message transactions with the SxS fusion
loader in the session server;  possibly (if it's a console app)
connects to or spawns the console-session host conhost.exe; and calls
the image entrypoint such as __wmainCRTStartup. The latter initializes
the C runtime before calling the application's entrypoint (e.g.
wmain). For Python, the latter calls Py_Main, which initializes the
interpreter before compiling and executing the main script.

>  (2) "*wait*": Wait for what?  How?

Functions such as os.system and subprocess.run wait on (i.e.
synchronize on) the process via WinAPI WaitForSingleObject[Ex], which
waits for the process to terminate.

If the child process uses console I/O and inherits the parent's
console, then it's important for the parent to wait before resuming
its own interactive console UI. Otherwise both parent and child will
compete for the console.

>  (3) "*proxy the exit status*": Sorry, I have no idea what this means.

Generally the parent process needs to know whether the child process
succeeded or failed.  Typically the exit status (aka exit code) for
success is 0, and all other values indicate failure. Commonly an exit
status of 1 is used for failure.

In Windows, the exit status for a process is returned by GetExitCodeProcess.

By "proxy the exit status", I mean that a program that spawns and
waits for another program will usually return the exit status from the
spawned child as its own exit status.

Consider the following snippet from the source code for the py.exe
launcher, which spawns python.exe for the selected version of Python:

ok = CreateProcessW(NULL, cmdline, NULL, NULL, TRUE,
0, NULL, NULL, &si, &pi);
if (!ok)
error(RC_CREATE_PROCESS, L"Unable to create process using
'%ls'", cmdline);
AssignProcessToJobObject(job, pi.hProcess);
CloseHandle(pi.hThread);
WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE);
ok = GetExitCodeProcess(pi.hProcess, &rc);
if (!ok)
error(RC_CREATE_PROCESS, L"Failed to get exit code of process");
debug(L"child process exit code: %d\n", rc);
exit(rc);

This C code includes the steps that I discussed: CreateProcessW,
WaitForSingleObjectEx, GetExitCodeProcess, and finally exit(rc), where
rc is the exit status from the spawned python.exe process.

The launcher also creates a kill-on-close, silent-breakaway job object
and assigns the child process to it. That way if the launcher is
terminated or crashes, the python.exe process will also be terminated,
so there's a tight coupling between py.exe and python.exe. The
silent-breakaway setting means processes spawned by python.exe are not
assigned to the job.

You can work with job objects via ctypes or PyWin32's win32job module.
I can provide example code for either approach.

> from the DOS prompt, it works as expected.

You're not running DOS. Most likely the shell you're running is CMD or
PowerShell, attached to a console session that's hosted by either
conhost.exe (default) or openconsole.exe (an open-source build of
conhost.exe that's used by the new Windows Terminal). These are
Windows applications.
-- 
https://mail.pyth

ANN: Version 0.1.6 of sarge (a subprocess wrapper library) has been released.

2020-08-24 Thread Vinay Sajip via Python-list
Version 0.1.6 of Sarge, a cross-platform library which wraps the subprocess
module in the standard library, has been released.

What changed?
-

- Fixed #44: Added an optional timeout to Command.wait() and Pipeline.wait(), 
which
  only takes effect on Python >= 3.3.

- Fixed #47: Added the ``replace_env`` keyword argument which allows a complete
  replacement for ``os.environ`` to be passed.

- Fixed #51: Improved error handling around a Popen call.

What does Sarge do?
---

Sarge tries to make interfacing with external programs from your
Python applications easier than just using subprocess alone.

Sarge offers the following features:

* A simple way to run command lines which allows a rich subset of Bash-
style shell command syntax, but parsed and run by sarge so that you
can run on Windows without cygwin (subject to having those commands
available):

>>> from sarge import capture_stdout
>>> p = capture_stdout('echo foo | cat; echo bar')
>>> for line in p.stdout: print(repr(line))
...
'foo\n'
'bar\n'

* The ability to format shell commands with placeholders, such that
variables are quoted to prevent shell injection attacks.

* The ability to capture output streams without requiring you to
program your own threads. You just use a Capture object and then you
can read from it as and when you want.

* The ability to look for patterns in captured output and to interact
accordingly with the child process.

Advantages over subprocess
---

Sarge offers the following benefits compared to using subprocess:

* The API is very simple.

* It's easier to use command pipelines - using subprocess out of the
box often leads to deadlocks because pipe buffers get filled up.

* It would be nice to use Bash-style pipe syntax on Windows, but
Windows shells don't support some of the syntax which is useful, like
&&, ||, |& and so on. Sarge gives you that functionality on Windows,
without cygwin.

* Sometimes, subprocess.Popen.communicate() is not flexible enough for
one's needs - for example, when one needs to process output a line at
a time without buffering the entire output in memory.

* It's desirable to avoid shell injection problems by having the
ability to quote command arguments safely.

* subprocess allows you to let stderr be the same as stdout, but not
the other way around - and sometimes, you need to do that.

Python version and platform compatibility
-

Sarge is intended to be used on any Python version >= 2.6 and is
tested on Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 and 3.8 on Linux,
Windows, and Mac OS X (not all versions are tested on all platforms,
but sarge is expected to work correctly on all these versions on all
these platforms).

Finding out more


You can read the documentation at

http://sarge.readthedocs.org/

There's a lot more information, with examples, than I can put into
this post.

You can install Sarge using "pip install sarge" to try it out. The
project is hosted on BitBucket at

https://bitbucket.org/vinay.sajip/sarge/

And you can leave feedback on the issue tracker there.

I hope you find Sarge useful!

Regards,

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


Re: Program chaining on Windows

2020-08-24 Thread Michael Torrie
On 8/24/20 1:30 AM, Rob Cliffe via Python-list wrote:
>> Hmm. Python isn't really set up to make this sort of thing easy.
> I guess this sentence pretty well answers my whole post. :-(

After reading Eryk Sun's posts, it doesn't appear that Python is the
issue here, but rather Windows does not make it possible to do what you
want to do.  But his suggestions for emulating the behavior you seek are
good ones.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issue in installing Python (Windows 10)

2020-08-24 Thread Terry Reedy

On 8/23/2020 12:39 PM, Debasis Chatterjee wrote:


I started off by using "python-3.8.5.exe".


32-bit Windows installer?  Windows version might be relevant.


I use "Run as Administrator" option to click this (provide my local-admin
username/pwd).



After this, I see python shell available. But no IDLE. Not sure why?


You mean no IDLE entry on Python 3.8 directory on Start menu?

Installer has a checkbox for tkinter and IDLE.  It is on by default for 
a fresh install but I expect it defaults to previous install for reinstalls.


On a command line, run 'python -c "import tkinter' to see if you have 
tkinter.  'python -m idlelib' starts IDLE if present.



 From CMD, I can check "pip list". Surprisingly, it shows me packages that I
installed earlier, before deinstalling and reinstalling.


De-installing does not remove pythonxy directory if you add anything to it.


Something is not right. Hence I am trying to make a fresh restart.

One thing odd is that even after removing installed program (Python) from
control panel, I still find that from "Start".


Have you installed more than one version of Python?  Or both 32 and 64 
bit variation of same Python version?



--
Terry Jan Reedy

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


Re: Program chaining on Windows

2020-08-24 Thread Terry Reedy

On 8/23/2020 3:31 AM, Rob Cliffe via Python-list wrote:

On WIndows 10, running Python programs in a DOS box,


Please don't use 'DOS box' for Windows Command Prompt or other Windows 
consoles for running Windows programs from a command line.  DOSBox is 
program for running (old) DOS programs written for the IBM PC.  One use 
is running old games, such as some distributed by GOG.  Note that 
interactive command line interpreters existed long before MS/PC DOS.


I would like one 
Python program to chain to another.  I.e. the first program to be 
replaced by the second (*not* waiting for the second to finish, as with 
e.g. os.system).


For reasons explained especially well by Eryk Sun, you should probably 
use one python program as a master program to run others in succession.


--
Terry Jan Reedy


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


Output showing "None" in Terminal

2020-08-24 Thread Py Noob
Hi!

i'm new to python and would like some help with something i was working on
from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
my code and the terminal is showing the word "None" everytime I execute my
code.

Many thanks!

print("Conversion")

def km_mi():
return answer

selection = input("Type mi for miles or km for kilometers: ")

if selection == "mi":
n = int(input(print("Please enter distance in miles: ")))
answer = (1.6*n)
print("%.2f" % answer, "miles")

else:
n = float(input(print("Please enter distance in kilometers: ")))
answer = (n/1.6)
print("%.2f" % answer, "kilometers")

answer = km_mi
-- 
https://mail.python.org/mailman/listinfo/python-list


ABC with abstractmethod: kwargs on Base, explicit names on implementation

2020-08-24 Thread Samuel Marks
After a discussion on #python on Freenode, I'm here.

The gist of it is:
> Falc - Signature of method 'Pharm.foo()' does not match signature of base 
> method in class 'Base'

What's the right way of specialising the children and leaving the Base
pretty much empty?

Specifically I want:
• All implementers to be forced to implement Base's method
• Base to be able to do very basic things with kwargs, namely log it
(to a file like stdout or a db)
• Support for [at least] Python 3.6–3.9 (I don't think `Protocol` has
been backported?)
• Implementors to have access to the proper name, rather than having
to unpack kwargs

Should I be using a Base class? - Metaclass? - Something else
entirely? - I know giving `b` a default value would resolve the
[PyCharm] linter error… but I want it to be a required argument.

Full example:

from abc import ABC, abstractmethod


class Base(ABC):
@abstractmethod
def foo(self, a, **kwargs):
"""
:param a: var
:type a: ```int```

:param **kwargs: keyword args
:type **kwargs: ``dict``
"""
print(a)


class Pharm(Base):
def foo(self, a, b):
"""
:param a: var
:type a: ```int```

:param b: var
:type b: ```int```
"""
super(Pharm, self).foo(a=a)

Thanks,

Samuel Marks
Charity  | consultancy
 | open-source  |
LinkedIn 
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Embedded python: How to debug code in an isolated way

2020-08-24 Thread Schachner, Joseph
Another suggestion:  If your Python code only references  few things outside of 
itself, make a simulated environment in Python on your PC, so that you can run 
your embedded code after importing your simulated environment, which should 
supply the functions it expects to call and variables it expects to access.

Then you can use any PC based debugger (PyScripter, Jetbrains' PyCharm, Visual 
Studio with Python support, etc) to debug in the simulated environment.

--- Joseph S.

-Original Message-
From: Grant Edwards  
Sent: Sunday, August 23, 2020 12:59 PM
To: [email protected]
Subject: Re: Embedded python: How to debug code in an isolated way

On 2020-08-22, Chris Angelico  wrote:
> On Sun, Aug 23, 2020 at 5:51 AM Eko palypse  wrote:
>> So the question is, what do I need to read/learn/understand in order to 
>> solve this issue?
>> Or in other words, how can I debug my script in an isolated environment.
>
> I'd go for the old standby - IIDPIO: If In Doubt, Print It Out!
> Instead of trying to use a debug harness, just run your code normally, 
> and print out whatever you think might be of interest. If you don't 
> have a console, well, that would be the first thing to do - you
> *always* need a console.

Yep.  Even if you have to bit-bang a tx-only UART on a GPIO pin.

I've had to do that many times, and the last time was only a couple years ago.  
Though I must admit I never had to do that _in_ Python or on a platform capable 
of running Python...

--
Grant




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


Re: Embedded python: How to debug code in an isolated way

2020-08-24 Thread Chris Angelico
On Tue, Aug 25, 2020 at 6:30 AM Schachner, Joseph
 wrote:
>
> Another suggestion:  If your Python code only references  few things outside 
> of itself, make a simulated environment in Python on your PC, so that you can 
> run your embedded code after importing your simulated environment, which 
> should supply the functions it expects to call and variables it expects to 
> access.
>
> Then you can use any PC based debugger (PyScripter, Jetbrains' PyCharm, 
> Visual Studio with Python support, etc) to debug in the simulated environment.
>

That seldom works very well. since most of the point of running code
on embedded devices is to use the features of those devices. My
brother built a network-attached doorbell on an RPi, and all the
debugging work revolved around the exact electrical signals on the
GPIO pins.

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


Re: Output showing "None" in Terminal

2020-08-24 Thread Calvin Spealman
How are you actually running your code?

"None" is the default return value of all functions in Python. But, the
interpreter is supposed to suppress it as a displayed result.

As a side note, both your km_mi() function and the line "answer = km_mi"
are certainly wrong, but it is not clear what you intend to do.

On Mon, Aug 24, 2020 at 4:25 PM Py Noob  wrote:

> Hi!
>
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.
>
> Many thanks!
>
> print("Conversion")
>
> def km_mi():
> return answer
>
> selection = input("Type mi for miles or km for kilometers: ")
>
> if selection == "mi":
> n = int(input(print("Please enter distance in miles: ")))
> answer = (1.6*n)
> print("%.2f" % answer, "miles")
>
> else:
> n = float(input(print("Please enter distance in kilometers: ")))
> answer = (n/1.6)
> print("%.2f" % answer, "kilometers")
>
> answer = km_mi
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

[email protected]  M: +1.336.210.5107
[image: https://red.ht/sig] 
TRIED. TESTED. TRUSTED. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Output showing "None" in Terminal

2020-08-24 Thread Random832
On Mon, Aug 24, 2020, at 09:12, Py Noob wrote:
> Hi!
> 
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.

The reason it is displaying None is because print() returns none, and you are 
sending that into input().

Either do:

print("Please enter distance in miles: ")
n = int(input())
# this will wait for input on the next line

or

n = int(input("Please enter distance in miles: "))
# this will wait for input on the same line as the text

The km_mi function doesn't seem to have any purpose and you can delete it and 
the other line further down referencing it. If this is for something like a 
school assignment that requires you to write a km_mi function, it's not clear 
from your code what the requirement is for this function.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program chaining on Windows

2020-08-24 Thread Rob Cliffe via Python-list



On 24/08/2020 13:20, Eryk Sun wrote:


You can work with job objects via ctypes or PyWin32's win32job module.
I can provide example code for either approach.

No need, I'm already convinced that this is not the way for me to go.



from the DOS prompt, it works as expected.

You're not running DOS. Most likely the shell you're running is CMD or
PowerShell, attached to a console session that's hosted by either
conhost.exe (default) or openconsole.exe (an open-source build of
conhost.exe that's used by the new Windows Terminal). These are
Windows applications.

I'm running CMD.exe.  Sorry, I didn't realise I was using sloppy language.

Thanks for your very detailed repy, Eryk.
Best wishes
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list


Re: Output showing "None" in Terminal

2020-08-24 Thread 2QdxY4RzWzUUiLuE
On 2020-08-24 at 06:12:11 -0700,
Py Noob  wrote:

> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.

> if selection == "mi":
> n = int(input(print("Please enter distance in miles: ")))

You've got a couple of lines like that:  input(print(...)).  The print
function prints the string and None, and then the input function prints
the None.

> answer = km_mi

As Calvin pointed out, this is likely not what you want, either.

-- 
“Whoever undertakes to set himself up as a
judge of Truth and Knowledge is shipwrecked
by the laughter of the gods.” – Albert Einstein
Dan Sommers, http://www.tombstonezero.net/dan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program chaining on Windows

2020-08-24 Thread Rob Cliffe via Python-list



On 24/08/2020 19:54, Terry Reedy wrote:

On 8/23/2020 3:31 AM, Rob Cliffe via Python-list wrote:

On WIndows 10, running Python programs in a DOS box,


Please don't use 'DOS box' for Windows Command Prompt or other Windows 
consoles for running Windows programs from a command line.  DOSBox is 
program for running (old) DOS programs written for the IBM PC.  One 
use is running old games, such as some distributed by GOG.  Note that 
interactive command line interpreters existed long before MS/PC DOS.
Sorry, I was unintentionally using misleading terminology.  I was 
running programs in a cmd.exe window.


I would like one Python program to chain to another.  I.e. the first 
program to be replaced by the second (*not* waiting for the second to 
finish, as with e.g. os.system).


For reasons explained especially well by Eryk Sun, you should probably 
use one python program as a master program to run others in succession.

Yes, thats's what I'm doing now.
Thanks
Rob Cliffe

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


Re: There is LTS?

2020-08-24 Thread 황병희
Léo El Amri  writes:

> On 24/08/2020 04:54, 황병희 wrote:
>> Hi, just i am curious. There is LTS for *Python*? If so, i am very thank
>> you for Python Project.
>
> Hi Byung-Hee,
>
> Does the "LTS" acronym you are using here stands for "Long Term Support" ?
>
> If so, then the short answer is: Yes, kind of. There is a 5 years
> maintenance for each major version of Python 3.
>
> You can find information on how Python is released and maintained at PEP
> 101 [1] and on the developers documentation [2].
>
> Each major Python release typically have a PEP associated with it where
> past minor releases dates and future plans are recorded.
> For example: PEP 494 [3] for Python 3.6, PEP 537 [4] for Python 3.7 and
> PEP 569 [5] for Python 3.8.
>
> [1] https://www.python.org/dev/peps/pep-0101/
> [2] https://devguide.python.org/devcycle/
> [3] https://www.python.org/dev/peps/pep-0494/
> [4] https://www.python.org/dev/peps/pep-0537/
> [5] https://www.python.org/dev/peps/pep-0569/

Wow Léo you nice guy!!! Thank You!!!

Sincerely, Byung-Hee

-- 
^고맙습니다 _救濟蒼生_ 감사합니다_^))//
-- 
https://mail.python.org/mailman/listinfo/python-list


Training Review: Computational Thinking for Problem Solving

2020-08-24 Thread dn via Python-list
Many of us learn Python by memorising code-constructs and their use. 
Even over-coming this learning-curve is but a small portion of becoming 
a competent coder or programmer.


The challenges of learning how to construct an algorithm, and/or how to 
analyse a real-world problem to produce a solution, are not to be found 
in the Python Tutorial. However, such higher-order problems often 
surface on the Python-Tutor and Python Discussion Lists.


For newcomers (and anyone in the field who would like to fill-in topics 
'missing' in his/her basic understanding), Coursera offer a 
"Computational Thinking for Problem Solving" course (free* or 
$certified) from "Penn" (University of Pennsylvania, USA).


I have occupied various 'spare' moments during the last week or so, to 
review the course, and am recommend it to you/yours.


Aside from coders, you might also mention it to any friends who want to 
learn 'problem-solving' (an increasingly important skill in these 
modern-times where the only constant is 'change') because this is not a 
'computer course'. Starting at higher-level thinking, gradually more 
detail is added, before arriving at the level of implementing 
computer-based solutions in Python.


It offers a (rather brief) introduction to Python. Thus could be used as 
a 'taster', before moving to Python-for-the-sake-of-Python course.


Throughout the course reference is made to case-studies drawn from the 
university's wider operations. There is also an interesting topic in 
linguistic analysis (ie the stuff of grammar-checkers, search engines, 
etc) which trainees can gradually develop, stage-by-stage.



Here is their introduction:-
<<<
Computational thinking is the process of approaching a problem in a 
systematic manner and creating and expressing a solution such that it 
can be carried out by a computer.  But you don't need to be a computer 
scientist to think like a computer scientist!  In fact, we encourage 
students from any field of study to take this course.  Many quantitative 
and data-centric problems can be solved using computational thinking and 
an understanding of computational thinking will give you a foundation 
for solving problems that have real-world, social impact.


In this course, you will learn about the pillars of computational 
thinking, how computer scientists develop and analyze algorithms, and 
how solutions can be realized on a computer using the Python programming 
language.  By the end of the course, you will be able to develop an 
algorithm and express it to the computer by writing a simple Python 
program.


This course will introduce you to people from diverse professions who 
use computational thinking to solve problems. You will engage with a 
unique community of analytical thinkers and be encouraged to consider 
how you can make a positive social impact through computational thinking.

>>>

100% online
Flexible deadlines
Beginner Level
Approx. 17 hours to complete

Four 'weeks' or sessions:
Pillars of Computational Thinking
Expressing and Analyzing Algorithms
Fundamental Operations of a Modern Computer
Applied Computational Thinking Using Python

https://www.coursera.org/learn/computational-thinking-problem-solving#syllabus


They did conclude by uttering heresy: that graduates might like to move 
to "more advanced languages like Java ... JavaScript", but let's not 
hold that lapse of judgement against them (they are after-all, a school 
of Engineering)!



* the $free option allows access to quizzes, tests, and assignments but 
not to any grading process. That said, any 'problems', phrased with at a 
Python background, could likely be discussed/corrected in posts to the 
Python-Tutor List (don't forget to declare the course and notify which 
session/component).



Disclaimer: I use the ('competing') edX training/education platform - 
but for non-Python courses.

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


Re: Output showing "None" in Terminal

2020-08-24 Thread Py Noob
Thank you for the clarification.
What I'm trying to achieve here are:

User be able to choose miles or kilometers to convert.
When selected (mi/km), prints out the user input and the answer.
km to mi = km/1.609
mi to km = mi*1.609

Thank you again!


On Mon, Aug 24, 2020 at 1:41 PM Calvin Spealman  wrote:

> How are you actually running your code?
>
> "None" is the default return value of all functions in Python. But, the
> interpreter is supposed to suppress it as a displayed result.
>
> As a side note, both your km_mi() function and the line "answer = km_mi"
> are certainly wrong, but it is not clear what you intend to do.
>
> On Mon, Aug 24, 2020 at 4:25 PM Py Noob  wrote:
>
>> Hi!
>>
>> i'm new to python and would like some help with something i was working on
>> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below
>> is
>> my code and the terminal is showing the word "None" everytime I execute my
>> code.
>>
>> Many thanks!
>>
>> print("Conversion")
>>
>> def km_mi():
>> return answer
>>
>> selection = input("Type mi for miles or km for kilometers: ")
>>
>> if selection == "mi":
>> n = int(input(print("Please enter distance in miles: ")))
>> answer = (1.6*n)
>> print("%.2f" % answer, "miles")
>>
>> else:
>> n = float(input(print("Please enter distance in kilometers: ")))
>> answer = (n/1.6)
>> print("%.2f" % answer, "kilometers")
>>
>> answer = km_mi
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>>
>
> --
>
> CALVIN SPEALMAN
>
> SENIOR QUALITY ENGINEER
>
> [email protected]  M: +1.336.210.5107
> [image: https://red.ht/sig] 
> TRIED. TESTED. TRUSTED. 
>
-- 
https://mail.python.org/mailman/listinfo/python-list