range(a,b) starts at a and ends at b-1
>>> for n in range(1,3):
... print str(n)
...
1
2
>>>
You could introduce bugs in your code by not being careful of this.
Mostly Linux & Python syntax notes and hyperlinks.
counts=dict(A=dict(),B=dict())
for n in range(0,6):
Fn='F'+str(n)
counts['A'][Fn]=n
counts['B'][Fn]=-n
{'A': {'F0': 0, 'F1': 1, 'F2': 2, 'F3': 3, 'F4': 4, 'F5': 5}, 'B': {'F0': 0, 'F1': -1, 'F2': -2, 'F3': -3, 'F4': -4, 'F5': -5}}
counts[A][F0]=0
counts[A][F1]=1
counts[A][F2]=2
counts[A][F3]=3
counts[A][F4]=4
counts[A][F5]=5
counts[B][F0]=0
counts[B][F1]=-1
counts[B][F2]=-2
counts[B][F3]=-3
counts[B][F4]=-4
counts[B][F5]=-5
filename=os.path.basename(os.path.realpath(symbolicLinkName))
def emptyFunction(self):
pass
>>> import os
>>> pth="/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma/y.te.tuerces"
>>> os.path.split(os.path.dirname(pth))[1]
'alma'
>>>
open('onestep.txt','w').close()
grep $ *
grep \$ *
grep "$" *
grep "\$" *
grep - $ *
grep "$" *
grep '$' *
egrep '$' *
grep '$[A-Z]' *
if os.path.lexists(dest):
os.remove(dest)
os.symlink(src,dest)
(For more detail, see also June2013)$ cat list.csv a b c d e f g h iUsing this code:
import os,csv def test_fcn() : try: tabReader = csv.reader( open("list.csv", "rb"), delimiter='\t', quoting=csv.QUOTE_NONE ) fd = open("out.csv", "wb+") tabWriter = csv.writer(fd, delimiter='\t', quoting=csv.QUOTE_NONE) if tabReader != None : for record in tabReader: record.append("new_thing") tabWriter.writerow(record) fd.close() return except Exception,e : print "Exception : " + str(e) def main(): test_fcn() if __name__ == '__main__': import sys main(*sys.argv[1:])Here's the output:
$ cat out.csv a b c new_thing d e f new_thing g h i new_thing
$ ifconfig
bash: ifconfig: command not found
$ whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
$ /sbin/ifconfig
eth2 Link encap:Ethernet HWaddr ...
grep -- -D *.pyFrom http://stackoverflow.com/questions/2427913/grepping-for-string-containing-dash