M-X string-replace:
C-q C-m (for ^M)
Wednesday, 11 February 2009
Wednesday, 30 July 2008
Python conditional expressions
Available from 2.5.
>>> word = "banana" if 0 is 0 else "peel"
>>> word
'banana'
>>> word = "banana" if 1 is 0 else "peel"
>>> word
'peel'
>>> word = "banana" if 0 is 0 else "peel"
>>> word
'banana'
>>> word = "banana" if 1 is 0 else "peel"
>>> word
'peel'
Tuesday, 29 July 2008
python list to string
So easy I always forget...
>>> l = ['1', '2', '3']
>>> ' '.join(l)
'1 2 3'
works only on lists of strings though.
>>> l = [1, 2, 3]
>>> ' '.join(l)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: sequence item 0: expected string, int found
>>> l = ['1', '2', '3']
>>> ' '.join(l)
'1 2 3'
works only on lists of strings though.
>>> l = [1, 2, 3]
>>> ' '.join(l)
Traceback (most recent call last):
File "
TypeError: sequence item 0: expected string, int found
Handy foreach + grep
Today I wanted to list a bunch of python files that used a setValue command.
To get some colour in the output
--colour=always
Ignore case
-i
Show line number
-n
Put it all together
grep --colour=always -i -n setValue
And combine with the foreach.
foreach j (*)
foreach? echo $j
foreach? cat $j |grep --colour=always -i -n setValue
foreach? end
Lovely.
To get some colour in the output
--colour=always
Ignore case
-i
Show line number
-n
Put it all together
grep --colour=always -i -n setValue
And combine with the foreach.
foreach j (*)
foreach? echo $j
foreach? cat $j |grep --colour=always -i -n setValue
foreach? end
Lovely.
Sunday, 8 June 2008
Python Terminology
Attribute
I use the word attribute for any name following a dot -- for example, in the expression
I use the word attribute for any name following a dot -- for example, in the expression
z.real, real is an attribute of the object z.
Wednesday, 28 May 2008
Executing python scripts through nuke-python
Python scripts can be executed through nuke's python interpreter using the following method.
cat [py script] | nuke -t
A fudge to be sure, but it does work.
cat [py script] | nuke -t
A fudge to be sure, but it does work.
Subscribe to:
Posts (Atom)