:vspfor vertical split screen.
Type control-W control-W to switch between them.
More at http://jmcpherson.org/windows.html
Mostly Linux & Python syntax notes and hyperlinks.
:vspfor vertical split screen.
tar -cvjf new.tar dir_or_files
tar -xvjf new.tarOr should there be a "j" in the ".tar" so people know they need 'j' to extract? Like:
tar -cvzf new.tar.Z dir_or_files
tar -xzvf new.tar.Z
if EXIST file1 (if EXIST file2 echo Both There)For the ELSE, it gets more complicated:
if EXIST file1 (if EXIST file2 (echo Both There) ELSE echo Nope)Will echo Nope if file1 exists and not file 2, but not if file2 exists but not file1. So you need:
if EXIST file1 (if EXIST file2 (echo Both There) ELSE echo Not 2) ELSE echo Not 1That will tell you either "Both There", or "Not 1" if only file1 isn't, or "Not 2" if only file2 isn't.
>def testf(foo="blah"):
... print foo
...
>testf("hi there")
hi there
>testf()
blah
ImportError: [/.../..]/python2.4/lib/python2.4/lib-dynload/datetime.so: cannot open shared object file: No such file or directoryWhen I did an ls for that directory, the shared object was in fact there. It didn't even help to move the shared object into the same directory as my code. I googled and looked on the python.org website and couldn't find any other mention of it. That is, besides making sure the python path and load path were set and that the .so was executable, but that didn't solve the problem.
[01,003839]PYTHON Error : Undefined Python Module :
$file /[..]/python2.4/lib/python2.4/lib-dynload/datetime.so
/[..]/python2.4/lib/python2.4/lib-dynload/datetime.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
$file cpgmTo solve this, re-compile cpgm in 64 bits, or point to the 32-bit version of python to run it.
cpgm: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
$ file cpgmYou can get into this trouble on a 64-bit machine or VM since it will run 32-bit compiled code (whereas a 32-bit machine won't run 64-bit compiled code.)
cpgm: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), not stripped
fdate=time.strptime("SEPTEMBER 19 2010", "%B %d %Y")worked, and
fdate=datetime.strptime("SEPTEMBER 19 2010", "%B %d %Y")triggered an exception.
from my_one_function_file import my_one_functionThen if I stop using that function, I know I can get rid of the import statement. When I look at the import statement, I know exactly why it is there.
import my_one_function_filethen calling my_one_function via
my_one_function_file.my_one_function()In general, this recommendation does look like wise practice. It's more object-oriented.
>>> x=['a','b']That's not what I want.. Instead:
>>> x
['a', 'b']
>>> y=['c','d']
>>> z={}
>>> z.fromkeys(x,y)
{'a': ['c', 'd'], 'b': ['c', 'd']}
>>> d=dict(zip(x,y))That's as close as I can get it.
>>> d
{'a': 'c', 'b': 'd'}
>>>
>>> d['a']It seems awkward, but if you put it in a loop, it looks fine:
'c'
>>> d['b']
'd'
>>> x=['a','b','c','d','e']
>>> y=['q','r','s','t','u']
>>> z=zip(x,y)
>>> z
[('a', 'q'), ('b', 'r'), ('c', 's'), ('d', 't'), ('e', 'u')]
>>> d=dict(z)
>>> d
{'a': 'q', 'c': 's', 'b': 'r', 'e': 'u', 'd': 't'}
>>> for key in x:
... print key, "=", d[key]
...
a = q
b = r
c = s
d = t
e = u
>>>
>>> a,b="c","d"
>>> a
'c'
>>> b
'd'
>>> a,b='f g'.split()
>>> a
'f'
>>> b
'g'