Re: advice on debugging a segfault
On 17/01/2021 21:35, Stestagg wrote: I would normally agree, except... This is a refcount issue (I was able to reproduce the problem, gbd shows a free error ) And I wouldn't recommend DGBing a refcount issue as a beginner to debugging. The other mailing list identified a PIL bug that messes up the refcount for True, but this refcount issue is for some tuple object, so may possibly be a different problem. Steve .. thanks for all the advice and apologies for the noise. It turns out that Victor Stinner's recommendation in the dev list was the solution as I don't see the segfault with pillow built from latest git Pillow @ git+git://github.com/python-pillow/pillow.git@8dc5f692dbd9a418d8c441f0e2aa09a3f5c03508 I did realize that this must be a late issue in the process as the pdf was being produced and written as expected and that is normally the end of things -- not segfaulting-ly yrs Robin Becker -- https://mail.python.org/mailman/listinfo/python-list
Re: Exploring terminfo
On Fri, Jan 15, 2021, at 13:36, Alan Gauld via Python-list wrote: > That could make a big difference, the putp() function specifically > states that it writes to stdout. I think there is a reasonable argument that this is a deficiency of the curses module. I think that the curses module should A) expose a version of tputs that accepts a python callback to process each output byte B) expose a version of putp that uses python's stdout[.buffer].write rather than C's putchar. -- https://mail.python.org/mailman/listinfo/python-list
Re: Exploring terminfo
On 2021-01-18, Random832 wrote: > On Fri, Jan 15, 2021, at 13:36, Alan Gauld via Python-list wrote: >> That could make a big difference, the putp() function specifically >> states that it writes to stdout. > > I think there is a reasonable argument that this is a deficiency of > the curses module. > > I think that the curses module should A) expose a version of tputs > that accepts a python callback to process each output byte B) expose > a version of putp that uses python's stdout[.buffer].write rather > than C's putchar. Agreed. I tried to use ctypes to call tputs with a Python callback that wrote to sys.stdout, but was unable to get it to work. FWIW, I've written up notes on the problem and provided demos of various solutions: https://github.com/GrantEdwards/Python-curses-and-terminfo -- https://mail.python.org/mailman/listinfo/python-list
Re: Exploring terminfo
On 18/01/2021 22:14, Random832 wrote: > On Fri, Jan 15, 2021, at 13:36, Alan Gauld via Python-list wrote: >> That could make a big difference, the putp() function specifically >> states that it writes to stdout. > > I think there is a reasonable argument that this is a deficiency of the > curses module. > > I think that the curses module should ..> B) expose a version of putp that > uses pthon's stdout[.buffer].write rather than C's putchar. To be fair that's a limitation of the C curses library. putp() is a wrapper around tputs() even there, and you can't change what it does. The gap in the curses module is that it doesn't offer the tputs() option as an alternative. But there are quite a lot of gaps in the curses module it's just that most folks don't use them so nobody complains or takes action to add them. I've been using curses (C and python) for nearly 30 years and this is the first time I've ever used the tiXXX functions, and it was mainly just out of curiosity rather than real need. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: Python not Running
On Sat, 16 Jan 2021 14:55:26 -0600, Logan Cranford wrote: > I downloaded Python but when I try to run Idle it says it is not found > and I should try to redownload it. When I try to do that all that comes > up is a page that says modify, repair or uninstall. I have repaired > several times but it still gives me the same message. Can anyone help > me with this? Have you tried with Perl? What is your OS and how are you trying to run it? I would suggest doing "sudo bash" and on the root prompt do this: dnf -y install python3 When you type "which python", your OS should tell you where your Python is: [mgogala@umajor tmp]$ which python /usr/bin/python You can further test by echoing Python version: [mgogala@umajor tmp]$ python -V Python 3.9.1 If you see something like C:\ prompt, then install Cygwin and use your Python from Cygwin. Your goal is have bash and vi editor. If that is an option, reformat your boot drive and install Ubuntu, Mint or Fedora. [mgogala@umajor tmp]$ cat /etc/redhat-release Fedora release 33 (Thirty Three) [mgogala@umajor tmp]$ Visual studio code is available both on Linux and Windows and is freaking awesome. No need to run Idle. Idle is a flint ax when compared to VSCode. VSCode supports auto-completion, formatting and many other things that you cannot even dream of in Idle. PS: Since you're most probably using Winduhs, use regedit and modify your PATH variable. Your python will be in c:\Program Files if you installed 64 bit version, which you should have done. Otherwise, it will be in C:\Program Files(x86). Your "idle" program will be in your "start menu" which came back in Winduhs 10. You would probably never have guessed, but I'm not particularly fond of Winduhs. -- Mladen Gogala Database Consultant http://mgogala.byethost5.com -- https://mail.python.org/mailman/listinfo/python-list
Re: count consecutive elements
On 2021-01-14, Stefan Ram wrote: > > If you want to know why, maybe you should insert print > statements to see the values of critical variables and > expression, especially in loops. > > Then compare the printed values with your expectations. > > Also, decompose into meaningful functions and test each > function separately. > > I sat to it again and solved it. import timeit run1 = ''' s = 'aabskbad' lil = tuple(set(s)) # list of characters in s li=[0,0,0,0,0,0] # list for counted repeats for i in lil: c = 0 h= lil.index(i) for letter in s: if letter == i: c += 1 if c > li[lil.index(letter)]: li[lil.index(letter)] = c else: c=0 continue m = max(li) for index, j in enumerate(li): if li[index] == m: print(f'{lil[index]} appears {m} consecutive times') ''' print(timeit.timeit(stmt=run1, number=1)) output: c appears 4 consecutive times a appears 4 consecutive times 0.00013008200039621443 -- https://mail.python.org/mailman/listinfo/python-list
Re: Exploring terminfo
On 19/01/21 2:34 pm, Alan Gauld wrote: To be fair that's a limitation of the C curses library. putp() is a wrapper around tputs() even there, and you can't change what it does. The gap in the curses module is that it doesn't offer the tputs() option as an alternative. Seems to me it would be useful to have something that returns what tputs() would have output, as a string, so you can send it where you want. -- Greg -- https://mail.python.org/mailman/listinfo/python-list