Hallo Leute
Ich bin daran einen Explorer (like Midnight Commander) in Jython (ca. Python 2.1) zu realisieren und frage mich ob es eine Funktion (evt. von os) gibt, die true/false liefert je nachdem ob es sich um eine Datei oder ein Verzeichnis handelt.
Etwas in der Art os.isDirectory(Path)
Ansonsten würde ich mir da selber was basteln.
Vielen Dank.
isDirectory() Funktion
Code: Alles auswählen
import os.path
def isPath(path):
if path==os.path.dirname(path):
return True
else:
return False
[b][i]ein kleines game für die die lust haben http://konaminut.mybrute.com[/i][/b]
;-)
;-)
Code: Alles auswählen
In [1]: from os import path
In [2]: path.isdir?
Type: function
Base Class: <type 'function'>
String Form: <function isdir at 0x4806f1f0>
Namespace: Interactive
File: /usr/lib/python2.5/posixpath.py
Definition: path.isdir(path)
Docstring:
Test whether a path is a directory
Hallo
guck mal im Modul os.path http://docs.python.org/library/os.path. ... le-os.path
os.path.isdir(path)
Return True if path is an existing directory. This follows symbolic links, so both islink() and isdir() can be true for the same path.
Gruß...busfahrer
guck mal im Modul os.path http://docs.python.org/library/os.path. ... le-os.path
os.path.isdir(path)
Return True if path is an existing directory. This follows symbolic links, so both islink() and isdir() can be true for the same path.
Gruß...busfahrer
Alles wird gut ;-)
@derdon ... mist:
Code: Alles auswählen
import os.path
def isPath(path):
return path==os.path.dirname(path)
[b][i]ein kleines game für die die lust haben http://konaminut.mybrute.com[/i][/b]
;-)
;-)