[Edu-sig] alluding to earlier thread re "pythonic" versus "obtuse"
Lee Harr
missive at hotmail.com
Sun Nov 23 20:43:18 CET 2014
> ext = os.path.splitext(fn)[1][1:]
I find this line a bit ... wider than I prefer.
With these functions that return two things, I will often do...
root, ext = os.path.splitext(fn)
ext = ext[1:]
Two lines instead of one, true, but especially when working with
students it illustrates one of python's cooler features (unpacking).
If I will not be using the root portion, I might do...
_, ext = os.path.splitext(fn)
ext = ext[1:]
I sat and thought about using a different name for the first ext --
maybe dotext or dot_ext, but I don't think it is necessary.
More information about the Edu-sig
mailing list