Subtracting dates to get hours and minutes

2022-12-11 Thread Steve GS
How do I subtract two time/dates and calculate the hours and minutes between? Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Cameron Simpson
On 11Dec2022 22:22, Barry Scott wrote: # Get a single character, setcbreak rather than setraw meands CTRL/C etc. still work # def getch(): sys.stdout.flush() tty.setcbreak(fdInput) ch = sys.stdin.buffer.raw.read(1).decode(sys.stdin.encoding) Will not work f

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Chris Angelico
On Mon, 12 Dec 2022 at 09:24, Barry Scott wrote: > You would need to have a loop that collected all the utf-8 bytes of a single > code point. > You can to look at the first byte of know if the utf-8 is 1, 2, 3 or 4 bytes > for a code point. And cope with escape sequences too - if you press an a

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Barry Scott
> On 11 Dec 2022, at 18:50, Chris Green wrote: > > My solution in the end was copied from one I found that was much > simpler and straightforward than most. I meant to post this earlier > but it got lost somewhere:- > >import sys, termios, tty ># ># ># Read a single character

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread dn
On 11/12/2022 23.09, Chris Green wrote: Is the only way to read single characters from the keyboard to use curses.cbreak() or curses.raw()? If so how do I then read characters, it's not at all obvious from the curses documentation as that seems to think I'm using a GUI in some shape or form. Al

Re: on the python paradox

2022-12-11 Thread Abdur-Rahmaan Janhangeer
I choose Python and still stick with it as default as I choose Python because of its design beauty. Typing does not mean mandatory braces. There can be an indentation-based language that is strongly typed. Python is beautiful in itself. Beautiful to look at. Source code should be easy for the aver

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Chris Green
My solution in the end was copied from one I found that was much simpler and straightforward than most. I meant to post this earlier but it got lost somewhere:- import sys, termios, tty # # # Read a single character from teminal, specifically for 'Y/N' # fdInput = sys.std

Re: on the python paradox

2022-12-11 Thread Sabrina Almodóvar
On 11/12/2022 10:57, Martin Di Paola wrote: >> On Mon, Dec 05, 2022 at 10:37:39PM -0300, Sabrina Almodóvar wrote: >>>     The Python Paradox >>>    Paul Graham >>>    August 2004 >>> >>> [SNIP] >>> >>> Hence what, for lack of a bet

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Antoon Pardon
Op 11/12/2022 om 12:32 schreef Stefan Ram: r...@zedat.fu-berlin.de (Stefan Ram) writes: Curses is not portable IIRC. A more portable means would be to use tkinter with the "bind" function to bind keys. import tkinter text = tkinter.Text() text.pack() text.bind\ ( "", lambda event: tex

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Chris Nyland
You should try the input function. I use it all the time. It does require the user to hit enter but that is pretty typical of that kind of interface. So I would write a loop like while True: answer = input("Please answer the question (y/n):") if answer == 'y': break Chris On Sun, Dec 11

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Oscar Benjamin
On Sun, 11 Dec 2022 at 15:55, Chris Green wrote: > > Is the only way to read single characters from the keyboard to use > curses.cbreak() or curses.raw()? If so how do I then read characters, > it's not at all obvious from the curses documentation as that seems to > think I'm using a GUI in some

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Chris Green
Stefan Ram wrote: > Chris Green writes: > >Is the only way to read single characters from the keyboard to use > >curses.cbreak() or curses.raw()? If so how do I then read characters, > > It seems that you want to detect keypresses and not read > characters from a line-buffered console with

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread DFS
On 12/11/2022 5:09 AM, Chris Green wrote: Is the only way to read single characters from the keyboard to use curses.cbreak() or curses.raw()? If so how do I then read characters, it's not at all obvious from the curses documentation as that seems to think I'm using a GUI in some shape or form.

Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Chris Green
Is the only way to read single characters from the keyboard to use curses.cbreak() or curses.raw()? If so how do I then read characters, it's not at all obvious from the curses documentation as that seems to think I'm using a GUI in some shape or form. All I actually want to do is get 'Y' or 'N'

Re: on the python paradox

2022-12-11 Thread Martin Di Paola
On Mon, Dec 05, 2022 at 10:37:39PM -0300, Sabrina Almodóvar wrote: The Python Paradox Paul Graham August 2004 [SNIP] Hence what, for lack of a better name, I'll call the Python paradox: if a company chooses to write