Building a Python Library for returning basic file info (ongoing)

Things are going smoothly so far since working with strings and filenames are pretty straight forward in python 3.6

my github project so far:
https://github.com/jayyyin/python-filelib-thingy

going with the simplest task of extracting filename from a path in python comes with a built in module called os.path,really useful

 getting the filesize of the file was a bit more tricky as it could be either an absolute path or relative path as it is more complicated I'll use a code snippet from my github


def getFileSize(pathName):
"""gets size of file, if it's an absolute path it'll find the file specifed otherwise it's a relative path and it will use a sub directory"""
if(os.path.isabs(pathName)):
return os.path.getsize(pathName)
else:
fn = os.path.join(os.path.dirname(__file__), pathName)
return os.path.getsize(fn)
view raw gistfile1.txt hosted with ❤ by GitHub

Comments

Popular posts from this blog

#Python-dev: adding pathlike functionality

#Python-dev: Starting to contribute to (c)python

Working on my first open source bug/request