0

I tried the following code to create a python file of the name "test.py"

edit test.py

This command is not recognised as an internal command. Please suggest me an alternative code for creating a new python file using command line in windows. I have my python already installed in my computer and I have set the path variable too also.

Thanks.

G Surendar Thina
  • 28
  • 1
  • 1
  • 7
  • 2
    Are you just looking to create an empty file that has a python extention? Because then [this](http://stackoverflow.com/questions/1702762/how-to-create-an-empty-file-at-the-command-line) should answer your question. Also python's file ending is `.py`, not `.python`. – SuperBiasedMan Jul 16 '15 at 13:49
  • Yes! I want to make a file with .py extension – G Surendar Thina Jul 16 '15 at 13:54
  • Does this answer your question? [How to create an empty file at the command line in Windows?](https://stackoverflow.com/questions/1702762/how-to-create-an-empty-file-at-the-command-line-in-windows) – AMC Oct 29 '20 at 00:28

3 Answers3

9
TYPE CON>test.py

To terminate, hit Ctrl+C or Ctrl+Z,Enter (Ctrl+Z = EOF).

Victor Yan
  • 2,778
  • 2
  • 20
  • 25
  • 3
    @GSurendarThina, if you want to create and edit a new file, just use `notepad test.py`. 64-bit Windows doesn't ship with a console text editor. The old `edit` DOS program is only available in 32-bit Windows, which has the NT Virtual DOS Machine (NTVDM). – Eryk Sun Jul 16 '15 at 16:20
0

To create a new python file in your current working directory(cwd) use the following command in your terminal:-type NUL > 'test.py'

1.Here I have created a new python file named "test".....Here 'NUL' stands for an empty file.

2.In above command you can use any name that you want.....but be careful to mention the extension,like in our case(.py).

3.Using this command you can create new file of any type in your cwd.

4.After typing this command.....cmd might prompt an error.....but check in your directory....there will be a new file present.

0

if you want to create a new python file in your current directory using a terminal, you can use the following commands.

Windows:

python > fileName.py

Mac:

python3 > fileName.py

yavuzx
  • 1