Infographic by Veracode Application Security
Mostly Linux & Python syntax notes and hyperlinks.
Infographic by Veracode Application Security
>>> import os
>>> pth="/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma/y.te.tuerces"
>>> os.path.split(pth)
('/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma', 'y.te.tuerces')
>>> os.path.dirname(pth)
'/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma'
>>> os.path.basename(pth)
'y.te.tuerces'
>>> os.path.splitext(os.path.basename(pth))
('y.te', '.tuerces')
>>> os.path.splitext(pth)
('/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma/y.te', '.tuerces')
$ l foo
-rw-rw-r-- 1 usr grp 8 Jul 11 2012 foo
$ ln -s foo fiBad
create symbolic link `fiBad' to `foo'
$ mv foo foooo
`foo' -> `foooo'
$ ln -s foooo fiGood
create symbolic link `fiGood' to `foooo'
$ l f*
-rw-rw-r-- 1
usr grp
8 Jul 11 2012 foooo
lrwxrwxrwx 1
usr grp
3 Jun 4 18:23 fiBad -> foo
lrwxrwxrwx 1
usr grp
5 Jun 4 18:24 fiGood -> foooo
$ python
Python 2.4.1 (#2, Jul 24 2007, 12:14:31)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-34)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> if os.path.exists("foooo"):
... print "T"
...
T
>>> if os.path.exists("fiGood"):
... print "T"
...
T
>>> if os.path.exists("fiBad"):
... print "T"
... else:
... print "F"
...
F
>>> if os.path.lexists("fiBad"):
... print "T"
... else:
... print "F"
...
T
>>> if os.path.lexists("foooo"):
... print "T"
...
T
>>> if os.path.lexists("fiGood"):
... print "T"
...
T
>>> if os.path.islink("fiGood"):
... print "T"
...
T
>>> if os.path.islink("fiBad"):
... print "T"
... else:
... print "F"
...
T