I wonder if there's a way to assign a value to the object obtained with: from os.path import * splitext(basename("c:\pyfiles\sample.txt"))[0] -----> sample and make it possible something like this, for example: sample = 123 Thank you in advance.