Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread John O'Hagan via Python-list
On Wed, 2023-09-13 at 01:33 +0100, MRAB via Python-list wrote: > On 2023-09-13 00:40, John O'Hagan via Python-list wrote: > > On Tue, 2023-09-12 at 20:51 +0200, Mirko via Python-list wrote: > > > Am 12.09.23 um 07:43 schrieb John O'Hagan via Python-list: > >

Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread John O'Hagan via Python-list
On Tue, 2023-09-12 at 20:51 +0200, Mirko via Python-list wrote: > Am 12.09.23 um 07:43 schrieb John O'Hagan via Python-list: > > > My issue is solved, but I'm still curious about what is happening > > here. > > MRAB already said it: When you enter the callbac

Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread John O'Hagan via Python-list
On Mon, 2023-09-11 at 22:25 +0200, Mirko via Python-list wrote: > Am 11.09.23 um 14:30 schrieb John O'Hagan via Python-list: > > I was surprised that the code below prints 'called' three times. > > > > > > from tkinter import * > > from tkin

Tkinter ttk Treeview binding responds to past events!

2023-09-11 Thread John O'Hagan via Python-list
I was surprised that the code below prints 'called' three times. from tkinter import * from tkinter.ttk import * root=Tk() def callback(*e):     print('called') tree = Treeview(root) tree.pack() iid = tree.insert('', 0, text='test') tree.selection_set(iid) tree.selection_remove(iid) tree.sel

Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-18 Thread John O'Hagan
On Tue, 2023-03-14 at 21:54 +1100, John O'Hagan wrote: [...] > Here is minimal code that demonstrates the problem in the subject > line: > > import cv2 > from tkinter import * > > images=['a.jpg', 'b.jpg', 'c.jpg'] #change to image paths

Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-17 Thread John O'Hagan
On Thu, 2023-03-16 at 04:21 -0400, aapost wrote: > On 3/15/23 07:37, John O'Hagan wrote: > > On Tue, 2023-03-14 at 16:22 -0400, aapost wrote: > > > On 3/14/23 06:54, John O'Hagan wrote: > > > > [...] > > > > > > > Read an alter

Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-15 Thread John O'Hagan
On Tue, 2023-03-14 at 16:22 -0400, aapost wrote: > On 3/14/23 06:54, John O'Hagan wrote: [...] > > > > Here is minimal code that demonstrates the problem in the subject > > line: > > > > import cv2 > > from tkinter import * > > > > i

Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-14 Thread John O'Hagan
On Tue, 2023-03-14 at 13:52 +, Weatherby,Gerard wrote: > Assuming you’re using opencv-python, I’d post query at > https://github.com/opencv/opencv-python/issues. Thanks Gerard I'm using the python3-opencv package from Debian testing. Is that github the appropriate place for this query? Than

Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-14 Thread John O'Hagan
On Tue, 2023-03-14 at 08:07 -0400, Thomas Passin wrote: > On 3/14/2023 6:54 AM, John O'Hagan wrote: > > Hi list > > > > I'm trying to use cv2 to display images created as numpy arrays, > > from > > within a tkinter app (which does other things with the

Tkinter and cv2: "not responding" popup when imshow launched from tk app

2023-03-14 Thread John O'Hagan
Hi list I'm trying to use cv2 to display images created as numpy arrays, from within a tkinter app (which does other things with the arrays before they are displayed as images). The arrays are colour-coded visualisations of genomes and can be over a billion elements in size, and I've found the PIL

Re: tkinter ttk.Treeview: changing background colour of single item when selected

2023-02-12 Thread John O'Hagan
On Sun, 2023-02-12 at 08:59 -0500, Thomas Passin wrote: [...] > On 2/12/2023 6:10 AM, John O'Hagan wrote: [...] > > > > My goal was to be able to change the colour of an individual item > > regardless of whether it is selected or not. To do that, it is > > ne

Re: tkinter ttk.Treeview: changing background colour of single item when selected

2023-02-12 Thread John O'Hagan
On Mon, 2023-02-06 at 10:19 -0800, stefalem wrote: > Il giorno sabato 4 febbraio 2023 alle 11:43:29 UTC+1 John O'Hagan ha > scritto: > ... > > > Is there another way to do what I want?  > > from tkinter import * > from tkinter.ttk import * > > root = T

tkinter ttk.Treeview: changing background colour of single item when selected

2023-02-04 Thread John O'Hagan
Hi list I'm using a ttk Treeview to display a hierarchical data structure. When an error condition arises in a node, I want the corresponding item in the Treeview to flash its background color.  Using a tag to flash the item background works, except when the item is selected, when the tag has no

Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency

2021-08-14 Thread John O'Hagan
On Fri, 13 Aug 2021 17:41:05 +0100 MRAB wrote: > On 2021-08-13 17:17, Chris Angelico wrote: > > On Sat, Aug 14, 2021 at 2:11 AM Terry Reedy > > wrote: > >> > >> On 8/13/2021 6:53 AM, Umang Goswami wrote: > >> > Hi There, Hope you find this mail in good health. > >> > > >> > I am Umang Goswami, a

Re: Tkinter long-running window freezes

2021-03-02 Thread John O'Hagan
On Wed, 24 Feb 2021 22:35:32 +1100 John O'Hagan wrote: > Hi list > > I have a 3.9 tkinter interface that displays data from an arbitrary > number of threads, each of which runs for an arbitrary period of time. > A frame opens in the root window when each thread starts and cl

Re: Tkinter long-running window freezes

2021-02-26 Thread John O'Hagan
On Sat, 27 Feb 2021 10:59:24 +1100 John O'Hagan wrote: > On Fri, 26 Feb 2021 08:19:14 +0100 > Christian Gollwitzer wrote: [...] > > > Can you also check this program, which reuses the same widget path > > name, albeit does the crea

Re: Tkinter long-running window freezes

2021-02-26 Thread John O'Hagan
On Sat, 27 Feb 2021 01:06:06 + MRAB wrote: > On 2021-02-26 23:59, John O'Hagan wrote: > > On Fri, 26 Feb 2021 08:19:14 +0100 > > Christian Gollwitzer wrote: > > > >> Am 26.02.21 um 06:15 schrieb John O'Hagan: > > [...] > >> >

Re: Tkinter long-running window freezes

2021-02-26 Thread John O'Hagan
On Fri, 26 Feb 2021 08:19:14 +0100 Christian Gollwitzer wrote: > Am 26.02.21 um 06:15 schrieb John O'Hagan: [...] > > > > I've followed your suggestions as per my last post, and can confirm > > the same freezing behaviour when running your code directly as a >

Re: Tkinter long-running window freezes

2021-02-25 Thread John O'Hagan
On Thu, 25 Feb 2021 21:57:19 +0100 Christian Gollwitzer wrote: > Am 24.02.21 um 12:35 schrieb John O'Hagan: > > Hi list > > > > I have a 3.9 tkinter interface that displays data from an arbitrary > > number of threads, each of which runs for an arbitrary period o

Re: Tkinter long-running window freezes

2021-02-25 Thread John O'Hagan
On Thu, 25 Feb 2021 11:06:05 -0500 Richard Damon wrote: > On 2/24/21 6:35 AM, John O'Hagan wrote: > > Here is some minimal, non-threaded code that reproduces the problem > > on my system (Xfce4 on Debian testing): > > > > from tkinter import * > > from r

Re: Tkinter long-running window freezes

2021-02-25 Thread John O'Hagan
On Thu, 25 Feb 2021 09:54:15 -0500 Terry Reedy wrote: > On 2/24/2021 6:53 PM, John O'Hagan wrote: > > On Wed, 24 Feb 2021 11:03:30 -0500 > > Terry Reedy wrote: > > > >> On 2/24/2021 6:35 AM, John O'Hagan wrote: > > [...] > >> >

Re: Tkinter long-running window freezes

2021-02-24 Thread John O'Hagan
On Thu, 25 Feb 2021 00:27:33 + MRAB wrote: > On 2021-02-24 23:23, John O'Hagan wrote: [...] > > In case it's relevant, to clarify what I mean by "freeze": the > > window continues to display the digits indefinitely if no attempt > > is made to inter

Re: Tkinter long-running window freezes

2021-02-24 Thread John O'Hagan
On Wed, 24 Feb 2021 11:03:30 -0500 Terry Reedy wrote: > On 2/24/2021 6:35 AM, John O'Hagan wrote: [...] > > I am trying this out on Windows 10, with a wider label (so I can move > the window) and a button that changes when pressed, and a sequential > counter. Will re

Re: Tkinter long-running window freezes

2021-02-24 Thread John O'Hagan
On Wed, 24 Feb 2021 13:07:24 + MRAB wrote: > On 2021-02-24 11:35, John O'Hagan wrote: [...] > > > > Here is some minimal, non-threaded code that reproduces the problem > > on my system (Xfce4 on Debian testing): > > > > from tkinter import * > &

Tkinter long-running window freezes

2021-02-24 Thread John O'Hagan
Hi list I have a 3.9 tkinter interface that displays data from an arbitrary number of threads, each of which runs for an arbitrary period of time. A frame opens in the root window when each thread starts and closes when it stops. Widgets in the frame and the root window control the thread and how

Re: Threading plus multiprocessing plus cv2 error

2020-09-01 Thread John O'Hagan
On Sun, 30 Aug 2020 09:59:15 +0100 Barry Scott wrote: > > > > On 29 Aug 2020, at 18:01, Dennis Lee Bieber > > wrote: > > > > On Sat, 29 Aug 2020 18:24:10 +1000, John O'Hagan > > declaimed the following: > > > >> There's no e

Re: Threading plus multiprocessing plus cv2 error

2020-08-30 Thread John O'Hagan
On Sat, 29 Aug 2020 13:01:12 -0400 Dennis Lee Bieber wrote: > On Sat, 29 Aug 2020 18:24:10 +1000, John O'Hagan > declaimed the following: > > >There's no error without the sleep(1), nor if the Process is started > >before the Thread, nor if two Processes are used

Threading plus multiprocessing plus cv2 error

2020-08-29 Thread John O'Hagan
Dear list Thanks to this list, I haven't needed to ask a question for a very long time, but this one has me stumped. Here's the minimal 3.8 code, on Debian testing: - from multiprocessing import Process from threading import Thread from time import sleep import cv2 def show(im, title, locat

Re: Detection of a specific sound

2015-10-27 Thread John O'Hagan
On Sun, 25 Oct 2015 17:17:28 -0700 Montana Burr wrote: > I'm looking for a library that will allow Python to listen for the > shriek of a smoke alarm. Once it detects this shriek, it is to notify > someone. Ideally, specificity can be adjusted for the user's > environment. I've used python to d

Re: Defamation

2015-10-23 Thread John O'Hagan
On Thu, 22 Oct 2015 13:19:14 +0200 Laura Creighton wrote: > One thing to recall is that 'who/what can be defamed' > varies a lot. In Sweden you cannot defame a corporation. The > defamation regulations in the Penal Code only apply to private > individuals. If you cannot bleed, you cannot be

Re: Defamation

2015-10-23 Thread John O'Hagan
On Thu, 22 Oct 2015 13:19:14 +0200 Laura Creighton wrote: > One thing to recall is that 'who/what can be defamed' > varies a lot. In Sweden you cannot defame a corporation. The > defamation regulations in the Penal Code only apply to private > individuals. If you cannot bleed, you cannot be

Re: Defamation

2015-10-22 Thread John O'Hagan
On Thu, 22 Oct 2015 19:05:04 +1100 Chris Angelico wrote: > On Thu, Oct 22, 2015 at 11:45 AM, John O'Hagan [...] > > > > For better or worse, that's not how defamation law works. Generally, > > the defaming is regarded as happening where the material is read, &g

Re: Defamation

2015-10-22 Thread John O'Hagan
On Wed, 21 Oct 2015 00:09:18 +1100 Steven D'Aprano wrote: > I don't believe that the Python mailing list archives are hosted in a > country under the jurisdiction of European Law. If I'm right, then > removing posts sets a dangerous precedent of obeying laws in foreign > countries that don't ap

Re: Tuples and immutability

2014-02-27 Thread John O'Hagan
On Thu, 27 Feb 2014 18:19:09 +0200 Marko Rauhamaa wrote: > Eric Jacoboni : > > a_tuple[1] += [20] > > Traceback (most recent call last): > > File "", line 1, in > > TypeError: 'tuple' object does not support item assignment > > > > [...] > > > > But, then, why a_tuple is still modified?

Re: a question about list as an element in a tuple

2014-02-18 Thread John O'Hagan
On Mon, 16 Dec 2013 11:30:13 +0800 liuerfire Wang wrote: > Just like below: > > In [1]: a = ([], []) > > In [2]: a[0].append(1) > > In [3]: a > Out[3]: ([1], []) > > In [4]: a[0] += [1] > --- > TypeError

Update image in same window with, say, PIL

2014-01-04 Thread John O'Hagan
I'm using something like the following to display an image and refresh it in the same window each time the image file is updated: import cv def display(filename): """Display scores as they are created""" cv.NamedWindow(filename) while 1: ... #wait for signal that filename has

Re: Recursive generator for combinations of a multiset?

2013-11-27 Thread John O'Hagan
On Tue, 26 Nov 2013 10:33:06 + Oscar Benjamin wrote: > On 26 November 2013 06:18, John O'Hagan > wrote: > > [...] > > > > def _multicombs(prepend, words, r, chkstr): > > """chkstr is the string of remaining availalable characters"

Re: Recursive generator for combinations of a multiset?

2013-11-25 Thread John O'Hagan
On Mon, 25 Nov 2013 12:15:15 + Oscar Benjamin wrote: > On 21 November 2013 13:01, John O'Hagan > wrote: > > In my use-case the first argument to multicombs is a tuple of words > > which may contain duplicates, and it produces all unique > > combinations of a

Re: Recursive generator for combinations of a multiset?

2013-11-23 Thread John O'Hagan
On Fri, 22 Nov 2013 22:33:29 -0800 Dan Stromberg wrote: > On Fri, Nov 22, 2013 at 4:58 PM, John O'Hagan > wrote: > > > On Thu, 21 Nov 2013 12:59:26 -0800 > > Dan Stromberg wrote: > > > > > On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan >

Re: Recursive generator for combinations of a multiset?

2013-11-23 Thread John O'Hagan
On Sat, 23 Nov 2013 04:23:42 + MRAB wrote: > On 23/11/2013 00:58, John O'Hagan wrote: > > On Thu, 21 Nov 2013 12:59:26 -0800 > > Dan Stromberg wrote: > > > >> On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan > >> wrote: > >> > >

Re: Recursive generator for combinations of a multiset?

2013-11-22 Thread John O'Hagan
On Thu, 21 Nov 2013 18:14:41 -0800 (PST) James wrote: > On Thursday, November 21, 2013 5:01:15 AM UTC-8, John O'Hagan wrote: [...] > > > On 21 November 2013 06:46, John O'Hagan > > > > > wrote: > > [...] > > > > >

Re: Recursive generator for combinations of a multiset?

2013-11-22 Thread John O'Hagan
On Thu, 21 Nov 2013 12:59:26 -0800 Dan Stromberg wrote: > On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan > wrote: > > > > > Short story: the subject says it all, so if you have an answer > > already, fire away. Below is the long story of what I'm using it &g

Re: Recursive generator for combinations of a multiset?

2013-11-21 Thread John O'Hagan
On Thu, 21 Nov 2013 11:42:49 + Oscar Benjamin wrote: > On 21 November 2013 06:46, John O'Hagan > wrote: > > > > I found a verbal description of such an algorithm and came up with > > this: > > > > def multicombs(it, r): > > resul

Recursive generator for combinations of a multiset?

2013-11-20 Thread John O'Hagan
Short story: the subject says it all, so if you have an answer already, fire away. Below is the long story of what I'm using it for, and why I think it needs to be recursive. It may even be of more general interest in terms of filtering the results of generators. I'm playing with an anagram-gene

Re: lambda in list comprehension acting funny

2012-07-11 Thread John O'Hagan
On Wed, 11 Jul 2012 13:21:34 -0700 (PDT) John Ladasky wrote: > Exactly. It's threads like these which remind me why I never use lambda. I > would rather give a function an explicit name and adhere to the familiar > Python syntax, despite the two extra lines of code. I don't even like the > nam

Apology for OT posts (was: code review)

2012-07-05 Thread John O'Hagan
On Tue, 03 Jul 2012 23:39:20 -0600 "Littlefield, Tyler" wrote: > On 7/3/2012 10:55 PM, Simon Cropper wrote: > > Some questions to Tyler Littlefield, who started this thread. > > > > Q1 -- Did you get any constructive feedback on your code? > > I did get some, which I appreciated. someone mention

Re: code review

2012-07-03 Thread John O'Hagan
On Mon, 2 Jul 2012 22:10:00 -0700 (PDT) rusi wrote: > On Jul 3, 7:25 am, John O'Hagan wrote: > > > > I agree to some extent, but as a counter-example, when I was a child there > > a subject called "Weights and Measures" which is now redundant because of

Re: code review

2012-07-02 Thread John O'Hagan
On Tue, 3 Jul 2012 11:22:55 +1000 Chris Angelico wrote: > On Tue, Jul 3, 2012 at 10:57 AM, Steven D'Aprano > wrote: > > > Perhaps the world would be better off if mathematicians threw out the > > existing precedence rules and replaced them with a strict left-to-right > > precedence. (Personally

Re: code review

2012-07-01 Thread John O'Hagan
On Sun, 01 Jul 2012 13:41:20 -0400 Dennis Lee Bieber wrote: > I'd think a true newcomer (to programming) would have NO > expectations... And if they'd had any complex math classes may actually > consider > if 1 < x < 10: > to be the norm [...] +1 I've only ever known Pyth

Re: Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
On Thu, 21 Jun 2012 14:20:23 +0200 Thomas Rachel wrote: > Am 21.06.2012 13:25 schrieb John O'Hagan: > > > But what about a generator? > > Yes, but... > > > def some_func(): > > arg = big_calculation() > > while 1: > > i

Re: Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
On 21 Jun 2012 12:19:20 GMT Steven D'Aprano wrote: > On Thu, 21 Jun 2012 21:25:04 +1000, John O'Hagan wrote: > > > Sometimes a function gets called repeatedly with the same expensive > > argument: > > > > def some_func(arg, i): > > (do_s

Generator vs functools.partial?

2012-06-21 Thread John O'Hagan
Sometimes a function gets called repeatedly with the same expensive argument: def some_func(arg, i): (do_something with arg and i) same_old_arg = big_calculation() for i in lots_of_items: some_func(same_old_arg, i) A simple case like that looks OK, but it can get messy when groups of arg

Re: Threads vs subprocesses

2012-06-17 Thread John O'Hagan
On Sat, 16 Jun 2012 13:27:45 -0400 Dennis Lee Bieber wrote: > On Sat, 16 Jun 2012 20:01:12 +1000, John O'Hagan > declaimed the following in > gmane.comp.python.general: > > > > > That looks like a possible way to do all the streams in a single thread, &

Re: Threads vs subprocesses

2012-06-16 Thread John O'Hagan
On Fri, 15 Jun 2012 16:34:57 -0400 Dennis Lee Bieber wrote: > On Sat, 16 Jun 2012 03:24:13 +1000, John O'Hagan > declaimed the following in > gmane.comp.python.general: > > > > I should have made it clear that I'm not using threads to speed anything

Re: Threads vs subprocesses

2012-06-15 Thread John O'Hagan
On Fri, 15 Jun 2012 11:51:01 -0400 Dave Angel wrote: > On 06/15/2012 09:49 AM, John O'Hagan wrote: > > I have a program in which the main thread launches a number of CPU-intensive > > worker threads. For each worker thread two python subprocesses are started, [...] > &g

Threads vs subprocesses

2012-06-15 Thread John O'Hagan
I have a program in which the main thread launches a number of CPU-intensive worker threads. For each worker thread two python subprocesses are started, each of which runs in its own terminal: one displays output received from the worker thread via a socket, the other takes text input to control th

Re: How to generate only rotationally-unique permutations?

2012-05-19 Thread John O'Hagan
On Sat, 19 May 2012 04:21:35 -0400 Zero Piraeus wrote: > : > > On 19 May 2012 01:23, John O'Hagan wrote: > > How to generate only the distinct permutations of a sequence which are not > > rotationally equivalent to any others? More precisely, to generate only the >

Re: How to generate only rotationally-unique permutations?

2012-05-19 Thread John O'Hagan
On Sat, 19 May 2012 09:15:39 +0100 Arnaud Delobelle wrote: > On 19 May 2012 06:23, John O'Hagan wrote: [...] > > > > How to generate only the distinct permutations of a sequence which are not > > rotationally equivalent to any others? More precisely, to generate only

How to generate only rotationally-unique permutations?

2012-05-18 Thread John O'Hagan
To revisit a question which I'm sure none of you remember from when I posted it a year or so ago - there were no takers at the time - I'd like to try again with a more concise statement of the problem: How to generate only the distinct permutations of a sequence which are not rotationally equivale

Re: argparse - option with optional value

2012-05-17 Thread John O'Hagan
On Thu, 17 May 2012 14:26:50 -0700 (PDT) Miki Tebeka wrote: > Greetings, > > I'd like to have an --edit option in my program. That if not specified will > not open editor. If specified without value will open default editor > ($EDITOR) and if specified with value, assume this value is the editor

Minor gripe about module names

2012-05-12 Thread John O'Hagan
Not sure if this is only package-manager specific, but occasionally I come across a module that sounds interesting, install it (in my case by apt-get), and then can't find it, because the actual module has a different name from what it says on the package - unlike the majority, which if they are ca

Re: Real time event accuracy

2012-05-10 Thread John O'Hagan
On Wed, 09 May 2012 08:52:59 -0700 Tobiah wrote: > I'd like to send MIDI events from python to another > program. I'd like advice as to how to accurately > time the events. I'll have a list of floating point > start times in seconds for the events, and I'd like to send them > off as close to th

Re: pyjamas / pyjs

2012-05-03 Thread John O'Hagan
On Thu, 3 May 2012 04:52:36 -0700 (PDT) alex23 wrote: > Anyone else following the apparent hijack of the pyjs project from its > lead developer? > -- Just read the thread on pyjamas-dev. Even without knowing anything about the lead-up to the coup, its leader's linguistic contortions trying to j

Re: confusing doc: mutable and hashable

2012-04-29 Thread John O'Hagan
On Sat, 28 Apr 2012 11:35:12 -0700 Chris Rebert wrote: [...] > Correct. Pedantically, you can define __hash__() on mutable objects; > it's just not very useful or sensible, so people generally don't. As > http://docs.python.org/reference/datamodel.html#object.__hash__ states > [emphasis added]: >

Re: Learn Technical Writing from Unix Man in 10 Days

2012-04-29 Thread John O'Hagan
On Sat, 28 Apr 2012 14:55:42 -0700 (PDT) Xah Lee wrote: > Learn Technical Writing from Unix Man in 10 Days > > Quote from man apt-get: > > remove > remove is identical to install except that packages are > removed > instead of installed. > > Translation: > > kicking >

Re: Half-baked idea: list comprehensions with "while"

2012-04-27 Thread John O'Hagan
On Fri, 27 Apr 2012 19:57:31 +1000 Chris Angelico wrote: > On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote: > > We have if inside list comprehensions? I didn't know that, could you provide > > an example? > > You mean like: > > [x*2+1 for x in range(10) if x%3] > Speaking of list comprehen

Re: why () is () and [] is [] work in other way?

2012-04-20 Thread John O'Hagan
On Sat, 21 Apr 2012 04:25:36 +0100 Rotwang wrote: > On 21/04/2012 01:01, Roy Smith wrote: > > In article<877gxajit0@dpt-info.u-strasbg.fr>, > > Alain Ketterlin wrote: > > > >> Tuples are immutable, while lists are not. > > > > If you really want to have fun, consider this classic paradox:

Re: Bug in Python

2012-04-17 Thread John O'Hagan
On Wed, 18 Apr 2012 03:08:08 +0200 Kiuhnm wrote: > I'm using Python 3.2.2, 64 bit on Windows 7. > > Consider this code: > ---> > print(1) > print(2) > print(3) > > with open('test') as f: > data = f.read() > with open('test') as f: > data = f.read() > <--- > If I debug this code with

Re: Deep merge two dicts?

2012-04-13 Thread John O'Hagan
On Fri, 13 Apr 2012 10:50:15 -0600 Ian Kelly wrote: > On Fri, Apr 13, 2012 at 5:11 AM, John O'Hagan wrote: > > I think you also have to check if a[k] is a dict before making the recursive > > call, else for example dmerge({'a': 1}, {'a': {'b':

Re: Deep merge two dicts?

2012-04-13 Thread John O'Hagan
On Thu, 12 Apr 2012 12:35:21 -0600 Ian Kelly wrote: > On Thu, Apr 12, 2012 at 11:59 AM, John Nagle wrote: > > On 4/12/2012 10:41 AM, Roy Smith wrote: > >> > >> Is there a simple way to deep merge two dicts?  I'm looking for Perl's > >> Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/M

Re: ordering with duck typing in 3.1

2012-04-07 Thread John O'Hagan
On Sat, 7 Apr 2012 05:23:25 -0700 (PDT) andrew cooke wrote: > > hi, > > please, what am i doing wrong here? the docs say > http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons "in > general, __lt__() and __eq__() are sufficient, if you want the conventional > meanings of the

Re: Reading Live Output from a Subprocess

2012-04-06 Thread John O'Hagan
On Fri, 6 Apr 2012 12:21:51 -0700 (PDT) Dubslow wrote: > On Friday, April 6, 2012 3:37:10 AM UTC-5, Nobody wrote: > > > In all probability, this is because the child process (pypy) is > > buffering its stdout, meaning that the data doesn't get passed to the OS > > until either the buffer is full

Re: Python Gotcha's?

2012-04-05 Thread John O'Hagan
On Thu, 05 Apr 2012 10:15:03 -0400 John Posner wrote: > On 4/4/2012 7:32 PM, Chris Angelico wrote: > > Don't know if it's what's meant on that page by the += operator, > > Yes, it is. > > >> a=([1],) > >> a[0].append(2) # This is fine > > [In the following, I use the term "name" rather loosely

Re: Run once while loop

2012-04-04 Thread John O'Hagan
On Tue, 3 Apr 2012 23:00:22 +0200 Anatoli Hristov wrote: > On 03 Apr 2012, at 22:45, Ian Kelly wrote: > > > On Tue, Apr 3, 2012 at 2:36 PM, Anatoli Hristov wrote: > >> Hi, > >> > >> I'm trying to do a while loop with condition of time if time is > >> 12:00:00 print text, but for this one secon

Re: Daemonization / Popen / pipe issue

2012-03-17 Thread John O'Hagan
On Sat, 17 Mar 2012 18:17:10 -0400 Lee Clemens wrote: > On 03/16/2012 11:37 PM, John O'Hagan wrote: > > On Fri, 16 Mar 2012 22:12:14 -0400 > > Lee Clemens wrote: > > > >> I have a multi-threaded application > >> > >> I have provided a

Re: Daemonization / Popen / pipe issue

2012-03-16 Thread John O'Hagan
On Fri, 16 Mar 2012 22:12:14 -0400 Lee Clemens wrote: > > I have a multi-threaded application, each thread has an instance of a class > which calls Popen. The command(s) being executed (shell=True) include pipes. > The errors I have seen involve "broken pipe" and unexepected output (as > demons

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-15 Thread John O'Hagan
On Tue, 14 Feb 2012 17:26:36 -0800 (PST) Rick Johnson wrote: > On Feb 14, 6:44 pm, Chris Angelico wrote: > > But WE are the fittest! Because we are INTELLIGENT! And the whales say: But WE are the fittest! Because we are BIG! And the rabbits say: But WE are the fittest! Because we are FERTILE!

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread John O'Hagan
On Mon, 13 Feb 2012 13:01:05 -0800 (PST) Rick Johnson wrote: > On Feb 13, 12:38 pm, Ian Kelly wrote: > > I hate being suckered in by trolls, but this paragraph demands a response. Ditto... > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > > > wrote: > > > You are born with rights. Life, L

Re: Common LISP-style closures with Python

2012-02-04 Thread John O'Hagan
On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > [...] > > i.

Re: copy on write

2012-02-03 Thread John O'Hagan
On 03 Feb 2012 05:04:39 GMT Steven D'Aprano wrote: > On Fri, 03 Feb 2012 14:08:06 +1100, John O'Hagan wrote: > > > I think we're 12 years late on this one. It's PEP 203 from 2000 and > > the key phrase was: > > > > "The in-place function

Re: copy on write

2012-02-02 Thread John O'Hagan
On Thu, 02 Feb 2012 12:25:00 -0500 Terry Reedy wrote: > On 2/2/2012 9:17 AM, John O'Hagan wrote: > > > It's not so much about the type of x but that of x[1]. Wouldn't it > > be possible to omit the assignment simply if the object referred to > > by x[1]

Re: copy on write

2012-02-02 Thread John O'Hagan
On 02 Feb 2012 09:16:40 GMT Steven D'Aprano wrote: > On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote: > > > You're right, in fact, for me the surprise is that "t[1] +=" is > > interpreted as an assignment at all, given that for lists (and other

Re: copy on write

2012-02-02 Thread John O'Hagan
On Thu, 2 Feb 2012 01:34:48 -0500 Devin Jeanpierre wrote: > On Wed, Feb 1, 2012 at 10:18 PM, John O'Hagan > wrote: > > On Fri, 13 Jan 2012 10:40:47 -0800 > > Ethan Furman wrote: > > > >> Steven D'Aprano wrote: > >> > Normally this is harm

Re: copy on write

2012-02-01 Thread John O'Hagan
On Fri, 13 Jan 2012 10:40:47 -0800 Ethan Furman wrote: > Steven D'Aprano wrote: > > Normally this is harmless, but there is one interesting little > > glitch you can get: > > > t = ('a', [23]) > t[1] += [42] > > Traceback (most recent call last): > > File "", line 1, in > > TypeErro

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread John O'Hagan
On Wed, 25 Jan 2012 15:38:12 -0800 Chris Kaynor wrote: [...] > > > > Would you prefer the Oxford or Merriam-Webster dictionaries. They are > a bit more established than dictionary.com in terms of standardizing > the languages. > > Definition 4 of the Merriam-Webster dictionary for "pretty" as a

Get reference to parent class from subclass?

2011-08-29 Thread John O'Hagan
class P(): pass class C(P): pass Can I get P from C? IOW, can I get a reference to the object P from the object C? This should be obvious one way or the other, but I haven't been able to find the answer. Regards, John -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do closures do this?

2011-08-27 Thread John O'Hagan
On Sun, 28 Aug 2011 00:19:07 -0400 Terry Reedy wrote: > On 8/27/2011 11:45 PM, John O'Hagan wrote: > > Somewhat apropos of the recent "function principle" thread, I was recently > > surprised by this: > > > > funcs=[] > > for n in r

Why do closures do this?

2011-08-27 Thread John O'Hagan
Somewhat apropos of the recent "function principle" thread, I was recently surprised by this: funcs=[] for n in range(3): def f(): return n funcs.append(f) [i() for i in funcs] The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google tells me I'm not the only one

Re: Adding modified methods from another class without subclassing

2011-08-24 Thread John O'Hagan
On Tue, 23 Aug 2011 17:25:22 +1000 Steven D'Aprano wrote: > On Mon, 22 Aug 2011 11:08 pm John O'Hagan wrote: > > > On Mon, 22 Aug 2011 15:27:36 +1000 > > Steven D'Aprano wrote: > [...] > >> # Untested > >> class MySeq(object): &

Re: Adding modified methods from another class without subclassing

2011-08-24 Thread John O'Hagan
On Mon, 22 Aug 2011 20:38:30 +0200 Peter Otten <__pete...@web.de> wrote: > John O'Hagan wrote: > > > On Mon, 22 Aug 2011 11:32:18 +0200 > > Peter Otten <__pete...@web.de> wrote: > > > >> John O'Hagan wrote: > >> > >>

Re: Adding modified methods from another class without subclassing

2011-08-22 Thread John O'Hagan
On Mon, 22 Aug 2011 23:08:50 +1000 John O'Hagan wrote: > On Mon, 22 Aug 2011 15:27:36 +1000 > Steven D'Aprano wrote: [..] > > Looks like a call for (semi-)automatic delegation! > > > > Try something like this: > > > > > > # Untested

Re: Adding modified methods from another class without subclassing

2011-08-22 Thread John O'Hagan
On Mon, 22 Aug 2011 11:32:18 +0200 Peter Otten <__pete...@web.de> wrote: > John O'Hagan wrote: > > > I have a class like this: > > > > class MySeq(): > > def __init__(self, *seq, c=12): > > self.__c = c > >

Re: Adding modified methods from another class without subclassing

2011-08-22 Thread John O'Hagan
On Mon, 22 Aug 2011 15:27:36 +1000 Steven D'Aprano wrote: > On Mon, 22 Aug 2011 03:04 pm John O'Hagan wrote: > > > The "pitches" attribute represents the instances and as such I found > > myself adding a lot of methods like: > > > > def __g

Adding modified methods from another class without subclassing

2011-08-21 Thread John O'Hagan
I have a class like this: class MySeq(): def __init__(self, *seq, c=12): self.__c = c self.__pc = sorted(set([i % __c for i in seq])) self.order = ([[self.__pc.index(i % __c), i // __c] for i in seq]) #other calculated attributes @property def pitches(s

Re: Compare tuples of different lenght

2011-08-20 Thread John O'Hagan
On Sat, 20 Aug 2011 01:25:18 -0700 (PDT) Jurgens de Bruin wrote: > Hi, > > I have a list of tuples: > > [(2,),(12,13),(2,3,4),(8,),(5,6),(7,8,9),] > > I would like to compare all the tuples to each other and if one > element if found two tuples the smallest tuples is removed from the > list. [

Re: Restricted attribute writing

2011-08-07 Thread John O'Hagan
On Mon, 08 Aug 2011 03:07:30 +1000 Steven D'Aprano wrote: > John O'Hagan wrote: > > > I'm looking for good ways to ensure that attributes are only writable such > > that they retain the characteristics the class requires. > > That's what properties a

Restricted attribute writing

2011-08-07 Thread John O'Hagan
ength): self.__order = Order(lis, length) self.length = length @property def order(self): return self.__order @order.setter def order(self, lis): if not isinstance(lis, Order): lis = Order(lis, self.length) self.__order = lis -- John O'Hagan -- http://mail.python.org/mailman/listinfo/python-list

Re: a little parsing challenge ☺

2011-07-24 Thread John O'Hagan
On Thu, 21 Jul 2011 05:58:48 -0700 (PDT) Xah Lee wrote: [...] > > > On Sunday, July 17, 2011 2:48:42 AM UTC-7, Raymond Hettinger wrote: > > >> On Jul 17, 12:47 am, Xah Lee wrote: > > >>> i hope you'll participate. Just post solution here. Thanks. > > > > >>http://pastebin.com/7hU20NNL > > > > >

Re: Python3: imports don't see files from same directory?

2011-05-07 Thread John O'Hagan
On Sat, 7 May 2011, Ian Kelly wrote: [...] > > Implicit relative imports were removed in Python 3 to prevent > ambiguity as the number of packages grows. See PEP 328. > > If you have two modules in the same package, pack1.mod1 and > pack1.mod2, then in pack1.mod1 you can no longer just do "impor

Re: Reassign or discard Popen().stdout from a server process

2011-02-11 Thread John O'Hagan
On Fri, 11 Feb 2011, Nobody wrote: > On Thu, 10 Feb 2011 08:35:24 +0000, John O'Hagan wrote: > >> > But I'm still a little curious as to why even unsuccessfully > >> > attempting to reassign stdout seems to stop the pipe buffer from > >> > filling u

  1   2   >