About 50 results
Open links in new tab
  1. What alternative is there to execfile in Python 3? / How to include a ...

    Feb 8, 2025 · It seems like in Python 3 they've removed all of the easy ways to quickly load a script, by removing execfile(). What alternative is there to include a Python file in another one, and execute it?

  2. python - How to open a file using the open with statement - Stack …

    I'm looking at how to do file input and output in Python. I've written the following code to read a list of names (one per line) from a file into another file while checking a name against the name...

  3. python - How do I check whether a file exists without exceptions ...

    How do I check whether a file exists, using Python, without using a try statement? Now available since Python 3.4, import and instantiate a Path object with the file name, and check the is_file method …

  4. python - How do I call a function from another .py file ... - Stack ...

    function(a, b) Note that file is one of Python's core modules, so I suggest you change the filename of file.py to something else. Note that if you're trying to import functions from a.py to a file called b.py, …

  5. python - What is the difference between a .py file and .ipynb file ...

    63 .py is a regular python file. It's plain text and contains just your code. .ipynb is a python notebook and it contains the notebook code, the execution results and other internal settings in a specific format. …

  6. python - Find the current directory and file's directory - Stack Overflow

    How do I determine: the current directory (where I was in the shell when I ran the Python script), and where the Python file I am executing is?

  7. python - How to reliably open a file in the same directory as the ...

    102 On Python 3.4, the pathlib module was added, and the following code will reliably open a file in the same directory as the current script:

  8. Creating a BAT file for python script - Stack Overflow

    Jan 1, 2011 · How can I create a simple BAT file that will run my python script located at C:\\somescript.py?

  9. python - How do I get the full path of the current file's directory ...

    The above answer assumes the most common scenario of running a python script that is in a file. References pathlib in the python documentation. os.path - Python 2.7, os.path - Python 3 os.getcwd …

  10. python - How to open a file for both reading and writing ... - Stack ...

    Jul 11, 2011 · Is there a way to open a file for both reading and writing? As a workaround, I open the file for writing, close it, then open it again for reading. But is there a way to open a file for both readi...