Re: [Edu-sig] alluding to earlier thread re "pythonic" versus "obtuse"
23 Nov
2014
23 Nov
'14
7:43 p.m.
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.
3615
Age (days ago)
3615
Last active (days ago)
0 comments
1 participants
participants (1)
-
Lee Harr