Re: [Tutor] Interactive editing of variables.
Allen, As I am using Python 3.7 under windows. I have tried to use the win32gui, and Tkinter. Both generate the below errors and I cannot identify a module release to support the version of Python I am using. C:\Users\mhysn>pip install Tkinter graphic 948 Collecting Tkinter ERROR: Could not find a version that satisfies the requirement Tkinter (from versions: none) graphic 948 ERROR: No matching distribution found for Tkinter I gave up on the cursers due to the above issues and looking at example code. It was far to complex to achieve the simple thing I wanted too do. Easygui module has installed and I will look for examples. The issue I have with a lot of GUI programs built for Python they generally fail in the accessibility department for a screen reader. Most open source software which is multi-platform supported fail in this department. I will check out the module and see. This is a major issue for software developers not considering all users and there is legal requirements here. Sorry, I am falling on to my band wagon of in-accessible or non-inclusive design products which is my passion. -Original Message- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Saturday, 1 June 2019 4:50 PM To: tutor@python.org Subject: Re: [Tutor] Interactive editing of variables. On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: > I have no clue on how to achieve what I want to do and the code I have > creates an hash. As shown below: Thats because what you want is not a standard feature of CLI apps. You will need to do one of the following(in order of easiness): 1) Use a GUI - it then becomes a trivial matter 2) Use a pseudo GUI like curses to provide cursor control 3) Find a module that already does what you need (maybe readline can be made to work?) 4) Write a function yourself using screen primitives that manage the cursor > for row in description: > text = description_rejex(row) > if text[0] not in narration: > Result = input(text[0]) > narration[result] = text The standard tools allow you to input a new value and overwrite the existing one. But there is no simple way to interactively modify an existing value (and of course you would need to convert it to/from a string for that to be possible) > I have had a look and cannot find an example where I can interactively > edit a content of a variable at the command line. I do not want to use > GUI at all. A GUI makes this a trivial problem. Simply display an edit control and insert the current value as a string. Allow the user to modify it and when done read the new value back. If you don't want to use a GUI you need to provide GUI like controls yourself, either through an existing module or by writing one. Something like easygui would be eminently suitable. But even vanilla Tkinter is almost trivial. The curses library will do it but that is not standard on Windows and I've heard varying reports of how well it works there. The readline library allows basic editing of the commands line but I'm not sure how you would insert your variable into the command line initially... For windows there are a couple of modules available that provide low level cursor control and character input/output, so you could use one of those to write such a function. And if you search hard enough you should find that somebody, somewhere has already done the work for you. But I don't know where... -- 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Interactive editing of variables.
As I thought. Easygui is not accessible at all with a screen reader due to the underlying graphic library. Win32 could work if I could load it. Since then I could use standard windows objects. Note, I didn't see anything in the quick scan I did ion the API. Very frustrating and disappointing. -Original Message- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Saturday, 1 June 2019 4:50 PM To: tutor@python.org Subject: Re: [Tutor] Interactive editing of variables. On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: > I have no clue on how to achieve what I want to do and the code I have > creates an hash. As shown below: Thats because what you want is not a standard feature of CLI apps. You will need to do one of the following(in order of easiness): 1) Use a GUI - it then becomes a trivial matter 2) Use a pseudo GUI like curses to provide cursor control 3) Find a module that already does what you need (maybe readline can be made to work?) 4) Write a function yourself using screen primitives that manage the cursor > for row in description: > text = description_rejex(row) > if text[0] not in narration: > Result = input(text[0]) > narration[result] = text The standard tools allow you to input a new value and overwrite the existing one. But there is no simple way to interactively modify an existing value (and of course you would need to convert it to/from a string for that to be possible) > I have had a look and cannot find an example where I can interactively > edit a content of a variable at the command line. I do not want to use > GUI at all. A GUI makes this a trivial problem. Simply display an edit control and insert the current value as a string. Allow the user to modify it and when done read the new value back. If you don't want to use a GUI you need to provide GUI like controls yourself, either through an existing module or by writing one. Something like easygui would be eminently suitable. But even vanilla Tkinter is almost trivial. The curses library will do it but that is not standard on Windows and I've heard varying reports of how well it works there. The readline library allows basic editing of the commands line but I'm not sure how you would insert your variable into the command line initially... For windows there are a couple of modules available that provide low level cursor control and character input/output, so you could use one of those to write such a function. And if you search hard enough you should find that somebody, somewhere has already done the work for you. But I don't know where... -- 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] is this doable
Hello, Thank you for your responses. I am indeed developing for windows at the moment, with an eye casually glancing in the MAC direction as a possibility for the future that I shall think about. I'm sorry I couldn't explain better, but being only familiar with the concept in my head from one language, I wasn't quite sure what to say for each thing, how to explain it. The language is actually a bit obscure, and is used in the development of MUDs, Multi-user dungeons. I never considered it would be broken down into several modules, but that makes sense. Now it has been mentioned, I do recall, on linux, briefly playing with psutil to retrieve memory values for a few tasks I keep running on my server. To that end, I think I now know roughly what to do. Something like this: import psutil import os path=os.getcwd()+"\\program.exe" slist=[] for x in psutil.process_iter(): if(x.exe()==path): slist.append([x, x.create_time]_) r.sort() # not sure how to sort by second element, but I'd sort the list by start time if(len(r)>1): # send signal to other program to tell it to do something, either through a ntofiy app or through psutil.send_signal() # exit the program Hope I'm making more sense now, and thank you for the help everyone. Nate On 01/06/2019 04:30, Mats Wichmann wrote: > On 5/31/19 1:41 PM, nathan tech wrote: >> Hi there, >> >> So for a future project of mine, I was wondering something. >> >> Is it possible, in python, to store a running task id in the registry? >> >> I might be using the complete wrong terms here, because I'm only used to >> doing this with a specific language, but here's what I want to do: >> >> >> python mytest.py: >> >> if(registry.taskid==valid_task): >> >> print 'already open' >> >> send to open program to make a ding noise. >> >> >> I understand that the second part, the "send to program" requires the >> program to handle being sent a "wake up!" event, which is fine, it's the >> "is it already running" which I am not sure on. > there's a lot your question leaves unasked... do you want to just code > your own apps and have one be able to poke another? that's one problem, > you can define the interface yourself. Or do you want to be able to > poke arbitrary running tasks? that ends up more complicated. many > systems have notification APIs that you can make use of, some of those > are more oriented to that model (the mobile systems Android and Tizen), > some a little less but still support it (Windows - it's a more prevalent > thing in the UWP model). > > the psutil module can let you find things out about processes, might be > useful in your "is the task running" query. > > if it's okay to start processes together and it's not arbitrary, the > multiprocessing module may be of some help. > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Interactive editing of variables.
On 01/06/2019 08:55, mhysnm1...@gmail.com wrote: > As I am using Python 3.7 under windows. I have tried to use the win32gui, > and Tkinter. Both generate the below errors and I cannot identify a module > release to support the version of Python I am using. Tkinter should be included in the standard Windows download you should not need to install it. try >>> import tkinter # not Tkinter! If there are no errors it is available > I gave up on the cursers due to the above issues and looking at example > code. It was far to complex to achieve the simple thing I wanted too do. Here is some basic Tkinter code that does what I think you want. You have to close the window by clicking the close icon but that could be incorporated in the button code. import tkinter as tk myVar = "" def get_value(edt): global myVar myVar = edt.get() def edit_val(val): top = tk.Tk() ed = tk.Entry(top) ed.insert(tk.END, val) ed.pack() tk.Button(top,text="Store changes", command=lambda : get_value(ed)).pack() top.mainloop() myVar = input("Enter a start value: ") print( "Before: ", myVar) edit_val(myVar) print( "After: ", myVar) > The issue I have with a lot of GUI programs built for Python they generally > fail in the accessibility department for a screen reader. I can't help there I have nearly zero experience of using accessibility tools. But I'd expect any GUI toolkit to work with the standard OS tools. After all they are ultimately all built using the underlying primitive GUI API > Most open source software which is multi-platform supported fail in this Of course, since most open source authors have no incentive to develop accessible specific code. They are just scratching their own itch and making it available to anyone who wants to use it. That's how open source works. > This is a major issue for software developers > not considering all users and there is legal requirements here. Sorry, I am > falling on to my band wagon of in-accessible or non-inclusive design > products which is my passion. I can understand why folks get excited about it, especially if they (or friends/family) need that feature. But the cost (both in time and money) of doing so is considerable and if nobody is paying (or there is a time deadline) then it tends not to get done. That's capitalism in action. -- 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Interactive editing of variables.
Mike, thanks for this debug tool. I might have a look at it. No that’s not the goal I’m after. I want to have a basic l input line which is already populated with a value. The value is extracted from a list of strength. Each element in the list are unique. I want to modify the string and then re-insert it back into the same element as the new modified string I’m currently look at read line or piegnurl module this might do the trick. Using GUI is way over the top for the simple thing I’m trying to do The model which Alan kindly suggested if not accessible with a screen reader. As I cannot see e.g. blind, this is a critical component of my programming. Please excuse any errors because I’m using Siri to send this email. My experience is the part > On 1 Jun 2019, at 10:05 pm, Mike Barnett wrote: > > TL;DR > There's a run-time debugger out, "imwatchingyou" that is being developed > daily, fast paced, that enables debugging without stopped your code or using > an IDE. > > I'm unsure if I'm super late to the party of if I understand the "problem" / > request properly. I apologize if I'm off-base. > > Do you want to be able to examine and modify variables while your program is > running, without breaking into it with a debugger? Is that part of it? > > If so, I've been working my ass off for a couple of weeks to do just that, > develop a realtime "watcher" / debugger. > > You'll find the project here: > https://github.com/PySimpleGUI/imwatchingyou > > At this time, you must pip install imwatchingyou. If you're concerned > because of the name "imwatchingyou", it's meant to be YOU are watching YOUR > code. If I wanted to watch your Python code, I would have named it > "makefreemoneyminingbitcoininpython". > > There is a nice screenshot, although things have been changing. There are 2 > primary windows. The brown one in the upper right of the screen is a > realtime update of all of your local variables. Then there's the large debug > window that allows you to do more including running the built-in REPL. > > There is also a version being built into the PySimpleGUI library itself so > you do not have to do any imports, etc. All PySimpleGUI will have this > watch/debug capability in it. > > > > > @mike > > -Original Message- > From: mhysnm1...@gmail.com > Sent: Saturday, June 1, 2019 4:53 AM > To: 'Alan Gauld' ; tutor@python.org > Subject: Re: [Tutor] Interactive editing of variables. > > As I thought. Easygui is not accessible at all with a screen reader due to > the underlying graphic library. Win32 could work if I could load it. Since > then I could use standard windows objects. > > Note, I didn't see anything in the quick scan I did ion the API. > > > Very frustrating and disappointing. > -Original Message- > From: Tutor On Behalf Of Alan > Gauld via Tutor > Sent: Saturday, 1 June 2019 4:50 PM > To: tutor@python.org > Subject: Re: [Tutor] Interactive editing of variables. > >> On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: >> >> I have no clue on how to achieve what I want to do and the code I have >> creates an hash. As shown below: > > Thats because what you want is not a standard feature of CLI apps. > You will need to do one of the following(in order of easiness): > 1) Use a GUI - it then becomes a trivial matter > 2) Use a pseudo GUI like curses to provide cursor control > 3) Find a module that already does what you need > (maybe readline can be made to work?) > 4) Write a function yourself using screen primitives > that manage the cursor > > >> for row in description: >>text = description_rejex(row) >>if text[0] not in narration: >>Result = input(text[0]) >>narration[result] = text > > The standard tools allow you to input a new value and overwrite the existing > one. But there is no simple way to interactively modify an existing value > (and of course you would need to convert it to/from a string for that to be > possible) > >> I have had a look and cannot find an example where I can interactively >> edit a content of a variable at the command line. I do not want to use >> GUI at all. > > A GUI makes this a trivial problem. Simply display an edit control and insert > the current value as a string. Allow the user to modify it and when done read > the new value back. If you don't want to use a GUI you need to provide GUI > like controls yourself, either through an existing module or by writing one. > Something like easygui would be eminently suitable. But even vanilla Tkinter > is almost trivial. > > The curses library will do it but that is not standard on Windows and I've > heard varying reports of how well it works there. > > The readline library allows basic editing of the commands line but I'm not > sure how you would insert your variable into the command line initially... > > For windows there are a couple of modules available that provide low level > cursor control and c
Re: [Tutor] Interactive editing of variables.
Oh, do you need WxPython for all your GUI type work since it can be used with screen readers? A GUI like you're describing in PySimpleGUI could be 15 or 20 lines of code in total depending on the number of these fields you have. Do you happen to have a sketch of this screen? Even pencil and paper would be helpful. I mocked this up really quickly. It takes short cuts to give you a mock-up. It's possible to write little GUIs like you're talking about easily, so that they're not over the top but rather "useful". Here's a mockup running in PySimpleGUI / tkinter: https://repl.it/@PySimpleGUI/Reddit-Change-variables-GUI My estimate wasn't too far off 18 lines of code in total. Is this the kind of modification of variables you where talking about? @mike -Original Message- From: Sean Murphy Sent: Saturday, June 1, 2019 8:21 AM To: Mike Barnett Cc: Alan Gauld ; tutor@python.org Subject: Re: [Tutor] Interactive editing of variables. Mike, thanks for this debug tool. I might have a look at it. No that’s not the goal I’m after. I want to have a basic l input line which is already populated with a value. The value is extracted from a list of strength. Each element in the list are unique. I want to modify the string and then re-insert it back into the same element as the new modified string I’m currently look at read line or piegnurl module this might do the trick. Using GUI is way over the top for the simple thing I’m trying to do The model which Alan kindly suggested if not accessible with a screen reader. As I cannot see e.g. blind, this is a critical component of my programming. Please excuse any errors because I’m using Siri to send this email. My experience is the part > On 1 Jun 2019, at 10:05 pm, Mike Barnett wrote: > > TL;DR > There's a run-time debugger out, "imwatchingyou" that is being developed > daily, fast paced, that enables debugging without stopped your code or using > an IDE. > > I'm unsure if I'm super late to the party of if I understand the "problem" / > request properly. I apologize if I'm off-base. > > Do you want to be able to examine and modify variables while your program is > running, without breaking into it with a debugger? Is that part of it? > > If so, I've been working my ass off for a couple of weeks to do just that, > develop a realtime "watcher" / debugger. > > You'll find the project here: > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2FPySimpleGUI%2Fimwatchingyou&data=02%7C01%7C%7C6fb3d0274c9 > d4f43c41408d6e68b8c39%7C84df9e7fe9f640afb435%7C1%7C0%7C636 > 949884355243495&sdata=D4hun2k3Al2O2cwoSbLwBTlHZDCe17t0n8ijIBoWJUw% > 3D&reserved=0 > > At this time, you must pip install imwatchingyou. If you're concerned > because of the name "imwatchingyou", it's meant to be YOU are watching YOUR > code. If I wanted to watch your Python code, I would have named it > "makefreemoneyminingbitcoininpython". > > There is a nice screenshot, although things have been changing. There are 2 > primary windows. The brown one in the upper right of the screen is a > realtime update of all of your local variables. Then there's the large debug > window that allows you to do more including running the built-in REPL. > > There is also a version being built into the PySimpleGUI library itself so > you do not have to do any imports, etc. All PySimpleGUI will have this > watch/debug capability in it. > > > > > @mike > > -Original Message- > From: mhysnm1...@gmail.com > Sent: Saturday, June 1, 2019 4:53 AM > To: 'Alan Gauld' ; tutor@python.org > Subject: Re: [Tutor] Interactive editing of variables. > > As I thought. Easygui is not accessible at all with a screen reader due to > the underlying graphic library. Win32 could work if I could load it. Since > then I could use standard windows objects. > > Note, I didn't see anything in the quick scan I did ion the API. > > > Very frustrating and disappointing. > -Original Message- > From: Tutor On Behalf > Of Alan Gauld via Tutor > Sent: Saturday, 1 June 2019 4:50 PM > To: tutor@python.org > Subject: Re: [Tutor] Interactive editing of variables. > >> On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: >> >> I have no clue on how to achieve what I want to do and the code I >> have creates an hash. As shown below: > > Thats because what you want is not a standard feature of CLI apps. > You will need to do one of the following(in order of easiness): > 1) Use a GUI - it then becomes a trivial matter > 2) Use a pseudo GUI like curses to provide cursor control > 3) Find a module that already does what you need > (maybe readline can be made to work?) > 4) Write a function yourself using screen primitives > that manage the cursor > > >> for row in description: >>text = description_rejex(row) >>if text[0] not in narration: >>Result = input(text[0]) >>narration[result] = text > > The sta
Re: [Tutor] Interactive editing of variables.
TL;DR There's a run-time debugger out, "imwatchingyou" that is being developed daily, fast paced, that enables debugging without stopped your code or using an IDE. I'm unsure if I'm super late to the party of if I understand the "problem" / request properly. I apologize if I'm off-base. Do you want to be able to examine and modify variables while your program is running, without breaking into it with a debugger? Is that part of it? If so, I've been working my ass off for a couple of weeks to do just that, develop a realtime "watcher" / debugger. You'll find the project here: https://github.com/PySimpleGUI/imwatchingyou At this time, you must pip install imwatchingyou. If you're concerned because of the name "imwatchingyou", it's meant to be YOU are watching YOUR code. If I wanted to watch your Python code, I would have named it "makefreemoneyminingbitcoininpython". There is a nice screenshot, although things have been changing. There are 2 primary windows. The brown one in the upper right of the screen is a realtime update of all of your local variables. Then there's the large debug window that allows you to do more including running the built-in REPL. There is also a version being built into the PySimpleGUI library itself so you do not have to do any imports, etc. All PySimpleGUI will have this watch/debug capability in it. @mike -Original Message- From: mhysnm1...@gmail.com Sent: Saturday, June 1, 2019 4:53 AM To: 'Alan Gauld' ; tutor@python.org Subject: Re: [Tutor] Interactive editing of variables. As I thought. Easygui is not accessible at all with a screen reader due to the underlying graphic library. Win32 could work if I could load it. Since then I could use standard windows objects. Note, I didn't see anything in the quick scan I did ion the API. Very frustrating and disappointing. -Original Message- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Saturday, 1 June 2019 4:50 PM To: tutor@python.org Subject: Re: [Tutor] Interactive editing of variables. On 01/06/2019 03:53, mhysnm1...@gmail.com wrote: > I have no clue on how to achieve what I want to do and the code I have > creates an hash. As shown below: Thats because what you want is not a standard feature of CLI apps. You will need to do one of the following(in order of easiness): 1) Use a GUI - it then becomes a trivial matter 2) Use a pseudo GUI like curses to provide cursor control 3) Find a module that already does what you need (maybe readline can be made to work?) 4) Write a function yourself using screen primitives that manage the cursor > for row in description: > text = description_rejex(row) > if text[0] not in narration: > Result = input(text[0]) > narration[result] = text The standard tools allow you to input a new value and overwrite the existing one. But there is no simple way to interactively modify an existing value (and of course you would need to convert it to/from a string for that to be possible) > I have had a look and cannot find an example where I can interactively > edit a content of a variable at the command line. I do not want to use > GUI at all. A GUI makes this a trivial problem. Simply display an edit control and insert the current value as a string. Allow the user to modify it and when done read the new value back. If you don't want to use a GUI you need to provide GUI like controls yourself, either through an existing module or by writing one. Something like easygui would be eminently suitable. But even vanilla Tkinter is almost trivial. The curses library will do it but that is not standard on Windows and I've heard varying reports of how well it works there. The readline library allows basic editing of the commands line but I'm not sure how you would insert your variable into the command line initially... For windows there are a couple of modules available that provide low level cursor control and character input/output, so you could use one of those to write such a function. And if you search hard enough you should find that somebody, somewhere has already done the work for you. But I don't know where... -- 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Interactive editing of variables.
On 01/06/2019 09:52, mhysnm1...@gmail.com wrote: > the underlying graphic library. Win32 could work if I could load it. Since > then I could use standard windows objects. If you are running windows then you can access the Win32 DLLs via ctypes. The win32 package should also be easily installable as a binary. If not try using the ActiveState distribution of python because it bundles all the windows tools in the installer. Personally I always use ActiveState pyton for my Windows boxes. -- 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 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Interactive editing of variables.
>> The issue I have with a lot of GUI programs built for Python they generally >> fail in the accessibility department for a screen reader. > > I can't help there I have nearly zero experience of using accessibility > tools. But I'd expect any GUI toolkit to work with the standard > OS tools. After all they are ultimately all built using the > underlying primitive GUI API On the gui front, tk developers make no bones about tk not having been built with accessibility considerations tk (and thus tkinter which is just the Python binding to tk), is not going to work with a screen reader. wxPython is probably the best choice, it explicitly has support (although sadly only for Windows): https://docs.wxpython.org/wx.Accessible.html possibly some of the other toolkits do - I wouldn't rule out Qt either, but haven't any experience. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] is this doable
On 01Jun2019 10:02, nathan tech wrote: Now it has been mentioned, I do recall, on linux, briefly playing with psutil to retrieve memory values for a few tasks I keep running on my server. To that end, I think I now know roughly what to do. Something like this: import psutil import os path=os.getcwd()+"\\program.exe" Remark: try: r'\program.exe' instead of: "\\program.exe" because backslash escapes have meaning inside single or double quotes it is generally more reliable to use raw strings (r'') for such strings to avoid accidents. slist=[] for x in psutil.process_iter(): if(x.exe()==path): slist.append([x, x.create_time]_) r.sort() # not sure how to sort by second element, but I'd sort the list by start time list.sort() and sorted() accept an optional key= parameter which is a function that takes an element and returns the sort key. For example (untested): r.sort(key=lambda x: x[1]) to sort on x[1]. if(len(r)>1): Stylisticly we tend to just write: if r: It is a convention in Python that collections (such as lists) are "false" if they are empty. Urr, I see you said >1, not >0; this remark probably isn't relevant. But you could drop the outer brackets, not needed in Python: if len(r) > 1: It sounds like your "task" is then a running instance of "program.exe", yes? In that case the usual practive is to keep a "pid file" around with a distinctive pathname associated with the task. That is just a text file containing the process id of the task program. So rather than iterating over the process list with psutils (which will show you _other_ instances of program.exe, perhaps being run for another purpose), you just read the pid from the pid file and see if it is running. If it is, assume the task is already active. Untested incomplete example: pid_filepath = 'taskname.pid' try: pid = int(open(pid_filepath).read().strip()) os.kill(pid, 0) except (OSError, ValueError): # missing pid file, invalid contents) running = False else: running = True The "os.kill(pid, 0)" is a UNIX specific idiom for testing for a process; you can send signal 0 to a process you own successfully (the process itself never sees it); it will fail if the process doesn't exist or isn't yours. There should be a Windows equivalent for probing a process. The converse part where you start the process includes this: P = subprocess.Popen(.) # start the program with open(pid_filename, 'w') as pidf: print(P.pid, file=pidf) to update the process id file. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor