get name of a file in python

Solutions on MaxInterview for get name of a file in python by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "get name of a file in python"
Irene
05 Nov 2018
1>>> f = open('/tmp/generic.png','r')
2>>> f.name
3'/tmp/generic.png'
4>>> import os
5>>> os.path.basename(f.name)
6'generic.png'