HOME - Recent Changes - Search:

Academic Work


Personal

* pot de départ


dblp


(:twitter:)

-----

[ edit | logout ]
[ help | sandbox | passwd ]

HOME dir., listing files and directories

#############################

Locate your HOME dir.:

import os

home = os.path.expanduser("~")
print home   # /home/jabba

List everything (files, dirs) in a given directory:

print os.listdir(home)

Collect files in a given directory:

files = [f for f in os.listdir(home) if os.path.isfile(os.path.join(home, f))]
print files

Collect subdirectories in a given directory:

dirs = [f for f in os.listdir(home) if os.path.isdir(os.path.join(home, f))]
print dirs

Collect files with a specified extension in a directory (glob):

import glob

print glob.glob('/home/jabba/dwhelper/*.txt')
# ['/home/jabba/dwhelper/a.txt', '/home/jabba/dwhelper/b.txt']   <-- full path is returned
Cloud City


anime | bash | blogs | bsd | c/c++ | c64 | calc | comics | convert | cube | del.icio.us | digg | east | eBooks | egeszseg | elite | firefox | flash | fun | games | gimp | google | groovy | hardware | hit&run | howto | java | javascript | knife | lang | latex | liferay | linux | lovecraft | magyar | maths | movies | music | p2p | perl | pdf | photoshop | php | pmwiki | prog | python | radio | recept | rts | scala | scene | sci-fi | scripting | security | shell | space | súlyos | telephone | torrente | translate | ubuntu | vim | wallpapers | webutils | wikis | windows


Blogs and Dev.

* Ubuntu Incident
* Python Adventures
* me @ GitHub


Places

Debrecen | France | Hungary | Montreal | Nancy


Notes

full circle | km


Hobby Projects

* Jabba's Codes
* PmWiki
* Firefox
* PHP
* JavaScript
* Scriptorium
* Tutorials
* me @ GitHub


Quick Links


[ edit ]

View - Edit - History - Attach - Print *** Report - Recent Changes - Search
Page last modified on 2009 November 14, 04:30