[Tutor] How to load python code only after program startup?

2012-11-19 Thread Pete O'Connell
Hi I use a compositing program called Nuke which loads my custom modules on start up. So if I have an error in my python code somewhere, Nuke won't open and it throws a typical error which is easy enough to fix. The problem I am running into is that when others on my network are using an older vers

Re: [Tutor] reducing a list evenly when deleting elements by index

2012-09-18 Thread Pete O'Connell
Thanks Stephen. That looks like nice clean code too! Cheers Pete On Tue, Sep 18, 2012 at 9:59 AM, Stephen Haywood < step...@averagesecurityguy.info> wrote: > Someone has already tried. https://github.com/sebleier/RDP > > > On Mon, Sep 17, 2012 at 5:50 PM, Pete O'Connell

Re: [Tutor] reducing a list evenly when deleting elements by index

2012-09-17 Thread Pete O'Connell
> 1) You have a Bezier curver consisting of 20 control points and would like > to > approximate it with a simpler cubic Bezier curve consisting of only 4 > points. > I would call this "approximating a Bezier with a lower order Bezier". > > Hi Oscar. Thanks for your reply. This one above is the one

Re: [Tutor] reducing a list evenly when deleting elements by index

2012-09-16 Thread Pete O'Connell
Ah of course. Thanks very much Oscar! Pete On Mon, Sep 17, 2012 at 1:29 PM, Oscar Benjamin wrote: > On 17 September 2012 02:15, Pete O'Connell wrote: > >> Hi, I have a bezier line with 20 points on it and I am trying to reduce >> this to a line with 4 points, keeping th

[Tutor] reducing a list evenly when deleting elements by index

2012-09-16 Thread Pete O'Connell
Hi, I have a bezier line with 20 points on it and I am trying to reduce this to a line with 4 points, keeping the first and last points and 2 evenly spaced points in between like so: ** becomes: *. . . .* These points are removable only by index, so if I remove poi

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-23 Thread Pete O'Connell
Hi, I have tried to simplify things and am running into a bit of trouble. What i am really trying to do is: Keep all the lines starting with "v " and then delete those lines whose modulus 5 don't equal zero I have written it like this which seems to take a really long time (a couple of minutes wh

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Ok thanks for the advice everyone. Cheers Pete On Thu, Aug 23, 2012 at 10:58 AM, Jerry Hill wrote: > On Wed, Aug 22, 2012 at 5:23 PM, Pete O'Connell > wrote: >> OK maybe I am wrong about it being slow (I thought for loops were >> slower than lis comprehensions). But I

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
On Thu, Aug 23, 2012 at 4:16 AM, Alan Gauld wrote: > theTextAsListNoVnOrVtOrEmptyLine = [x for x in theTextAsListStripped > if "vn" not in x > if "vt" not in x >

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
On Thu, Aug 23, 2012 at 2:53 AM, Steven D'Aprano wrote: > On 22/08/12 20:28, Pete O'Connell wrote: >> >> Hi. The next step for me to parse the file as I want to is to change >> lines that look like this: >> f 21/21/21 22/22/22 24/24/23 23/23/24 >> into

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
Thanks eryksun, that is a very clear example. Cheers pete On Wed, Aug 22, 2012 at 11:16 PM, eryksun wrote: > On Wed, Aug 22, 2012 at 3:06 AM, Peter Otten <__pete...@web.de> wrote: >> >> wanted = [line.strip("\n") for line in lines >> if "vn" not in line and "vt" not in line a

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
t;)[-1] + " " + aGoodLineAsList[2].split("/")[-1] + " " + aGoodLineAsList[3].split("/")[-1] + " " + aGoodLineAsList[4].split("/")[-1] for anItem in theGoodLines: print anItem #####

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
erator in a situation where the if statements were more numerous and complex. I am sure that will come in handy. Thanks On Wed, Aug 22, 2012 at 7:06 PM, Peter Otten <__pete...@web.de> wrote: > Pete O'Connell wrote: > >> Hi I am trying to parse a text file and create a lis

Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-22 Thread Pete O'Connell
d, Aug 22, 2012 at 6:23 PM, Puneeth Chaganti wrote: > On Wed, Aug 22, 2012 at 11:35 AM, Pete O'Connell > wrote: >> Hi I am trying to parse a text file and create a list of all the lines >> that don't include: "vn", "vt" or are empty. I want to m

[Tutor] list comprehension, testing for multiple conditions

2012-08-21 Thread Pete O'Connell
Hi I am trying to parse a text file and create a list of all the lines that don't include: "vn", "vt" or are empty. I want to make this as fast as possible because I will be parsing many files each containing thousands of lines. I though I would give list comprehensions a try. The last 3 lines of t

Re: [Tutor] commands.getoutput equivalent in subprocess

2012-03-19 Thread Pete O'Connell
Ok thanks a lot. Pete On Mon, Mar 19, 2012 at 10:01 PM, Peter Otten <__pete...@web.de> wrote: >> Pete O'Connell wrote: > >> Hi, I am using Python 2.6 I can't use Python 3 in this particular > situation. > > [Please reply to the list, not in pr

[Tutor] commands.getoutput equivalent in subprocess

2012-03-18 Thread Pete O'Connell
Hello I print a lot of values at work using grep and need to be constantly opening a shell window to do this (rather than staying within my main program which is Nuke by the Foundry). Is there a simple equilavent to commands.getoutput that is more up to date (I would assume within the subprocess mo

[Tutor] return, why do I need it?

2011-12-11 Thread Pete O'Connell
Hi I have been writing python code for a while now and I never return anything within any of my functions, I just (eg.) print stuff or make directories or update a log or what have you. When I look at other people's code they are always returning in their functions and I was wondering if someone co

[Tutor] how to temporarily disable a function

2011-07-27 Thread Pete O'Connell
Hi I was wondering if there is a way to disable a function. Hi have a GUI grid snapping function that I use in a program called Nuke (the film compositing software) Here is the function (which loads when Nuke loads): ### def theAutoplaceSnap(): try: nuke.thisNode().

[Tutor] getting the last file in a folder (reliably)

2011-03-21 Thread Pete O'Connell
Hi I have some code which works nine times out of ten. Maybe some could help me make this a little more robust. I have a bunch of files in a folder with a strict versioning based naming convention, where I want to open the highest version number of a nuke script (not necessarily the one with the ne

[Tutor] open linux file browser from nuke python script

2011-01-31 Thread Pete O'Connell
Hi, I am trying to get a python script to open up a file browser window with the location of a folder. I am using kubuntu 10.04. The string that gets created works fine if I paste it into a shell eg: 'kde-open path/to/the/sequence', but it doesn't seem to want to run from within my interpreter usin

[Tutor] How to numerically sort strings that start with numbers?

2010-09-13 Thread Pete O'Connell
theList = ["21 trewuuioi","3zxc","134445"] print sorted(theList) Hi, the result of the sorted list above doesn't print in the order I want. Is there a straight forward way of getting python to print ['3zxc','21 trewuuioi','134445'] rather than ['134445', '21 trewuuioi', '3zxc']? Any help would be

[Tutor] conventions for establishing and saving default values for variables

2010-06-15 Thread Pete O'Connell
Hi I was wondering if anyone could give me some insight as to the best way to get and save variables from a user the first time a script is opened. For example if the script prompts something like "What is the path to the folder?" and the result is held in a variable called thePath, what is the bes

[Tutor] find and replace relative to an nearby search string in a file

2009-07-12 Thread Pete O'Connell
Hi, I am trying to do a find and replace in a text file (a nuke script). Here are a couple excerpts from the file that demonstrate what I want to do. I am always looking for the line " name Write1" as my starting point. In the first example below, I want to replace the path, which is 2 lines above