RE: Subtracting dates to get hours and minutes

2022-12-12 Thread Mike Dewhirst
I have seen vast conversations on this topic but if everything is in the same time-zone and daylight saving switchovers are not involved it is relatively straightforward.Check the timedelta docs. Or convert datetimes to ordinals and subtract then convert the result to whatever units please you.M

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

2022-12-12 Thread Chris Green
Stefan Ram wrote: > Chris Green writes: > >import sys, termios, tty > > There might be some versions of Python and the Microsoft® > Windows operating system where "termios" is not available. > Ah, I did originally say that this was a Unix/Linux only solution but that was in my first respon

Re: Subtracting dates to get hours and minutes

2022-12-12 Thread Marc Lucke
my approach would be to convert your two date/times to seconds from epoch - e.g. https://www.geeksforgeeks.org/convert-python-datetime-to-epoch/ - then subtract the number, divide the resultant by 3600 (hours) & get the modulus for minutes.  There's probably a standard function - it should be

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-12 Thread Jach Feng
moi 在 2022年12月12日 星期一下午5:38:50 [UTC+8] 的信中寫道: > >>> ast.literal_eval("r'\x7a'") == ast.literal_eval("r'z'") > True > >>> ast.literal_eval("r'\xe0'") == ast.literal_eval("r'à'") > True > >>> ast.literal_eval("r'\x9c'") == ast.literal_eval("r'œ'") > False > > - > > > >>> print(codec

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

2022-12-12 Thread Chris Green
Barry Scott wrote: > > > > 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 > >

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

2022-12-12 Thread Alan Gauld
On 11/12/2022 21:07, dn wrote: > 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

Re: Subtracting dates to get hours and minutes

2022-12-12 Thread Weatherby,Gerard
The difference between two datetime objects is a timedelta object. https://docs.python.org/3/library/datetime.html#timedelta-objects . It has a total_seconds() method. This is a simple task, unless one of the datetimes has a time zone specified and the other doesn’t. From: Python-list on beh

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

2022-12-12 Thread Grant Edwards
On 2022-12-11, Chris Green wrote: > Is the only way to read single characters from the keyboard to use > curses.cbreak() or curses.raw()? No. > If so how do I then read characters, Use a termios.tcsetattr() to put fd 0 into raw mode and then use os.read(). Recent versions of Python include a

sqlite3 double quote behavior

2022-12-12 Thread John K. Parejko
Asking here before I file an improvement request issue on the python GitHub: sqlite has a known misfeature with double-quoted strings, whereby they will be interpreted as string literals if they don’t match a valid identifier [1]. The note in the sqlite docs describe a way to disable this misfea