[Tutor] What's in a name.

Alan Gauld alan.gauld at yahoo.co.uk
Thu May 18 20:28:55 EDT 2023


On 19/05/2023 00:17, ThreeBlindQuarks via Tutor wrote:

> The word I am talking about now is "suffix" and in some sense 
> it means something appended to the end of something else. That > has more specifix meanings in areas of computer science where
> it may mean a part of a filename at the end 

And there are dedicated functions for manipulating filenames
and paths, including removing suffixes. (os.path.splitext())
Although it calls the file suffixes extensions, hence .splitext().

>  an old operating system, a file.c;3 

Ah, the joys of Vax/VMS

> So it looks like the OP thought about perhaps asking the 
> person who typed in the text a second questions asking what suffix

My impression was that they thought Python should remember and reuse the
first input value, maybe because it was on the same line? I dunno.

> As I see it, if the intent has to strip a suffix for a filename 
> and especially one that uses a period and may have more than one, 
> as in modern operating systems, it can be better to hunt for a 
> module that someone has written carefully and is well tested.

Indeed, like os.path

But that may not be obvious to a beginner - you need to know
what terms to search for - extension in this case!

> to back away from the C suffix if you really want what some might call a basename.

Which is what os.path calls it, with a method to match.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





More information about the Tutor mailing list