10 examples of 'python get current file name' in Python

Every line of 'python get current file name' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
328def get_current_file():
329 return sublime.active_window().active_view().file_name()
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

32def getFileName():
33 filefullpath = getFileFullPath()
34 return os.path.basename(filefullpath)
163def get_current_filename(self):
164 if self.data:
165 return self.data[self.currentIndex()].filename
945def get_current_filename(self):
946
947 return join(self._current_path, self._filename)
26def _get_script_path():
27 """Get directory path of current script"""
28 script_filename = inspect.getframeinfo(inspect.currentframe()).filename
29 script_path = os.path.dirname(os.path.abspath(script_filename))
30
31 return script_path
705def get_current_path( self ):
706 if self.CGIdata.has_key( "path" ):
707 relativ_path = posixpath.normpath( self.CGIdata["path"] )
708 else:
709 relativ_path = "."
710
711 cfg.base_path = posixpath.normpath( cfg.base_path )
712
713 absolute_path = posixpath.join( self.absolute_basepath, relativ_path )
714 absolute_path = posixpath.normpath( absolute_path )
715
716 self.check_absolute_path( absolute_path )
717
718 return relativ_path, absolute_path
25def _caller_module_name():
26 # Move up the stack twice: we want the module name of the
27 # function/module that called the function calling
28 # _caller_module_name
29 caller_module = inspect.getmodule(inspect.currentframe().f_back.f_back)
30 if caller_module is None:
31 return "<stdin>"
32 return caller_module.__name__
84def get_script_name():
85 """Return the name of the top-level script."""
86 return os.path.splitext(scriptinfo()["name"])[0]
57def get_data_files_path():
58 """Get a direct path to the data files colocated with the script.
59
60 Returns:
61 The directory where files specified in data attribute of py_test
62 and py_binary are stored.
63 """
64 return _os.path.dirname(_inspect.getfile(_sys._getframe(1)))
1415def getFileName(self):
1416 """
1417 Public method to return the name of the file being displayed.
1418
1419 @return filename of the displayed file (string)
1420 """
1421 p = self.parent()
1422 if p is None:
1423 return ""
1424 else:
1425 try:
1426 return p.getFileName()
1427 except AttributeError:
1428 return ""

Related snippets