Is it possible to run a Python script directly in VSCode or PowerShell with a custom command? I’m used to using the terminal (for PowerShell scripts) because it’s super fast, is this possible with Python scripts? /u/grep212 Python Education

Let’s say you have a Python script that prompts the user for their name and then writes “Hi, {Name}”

Now in PowerShell this is super easy, I can create a custom function, throw it into my PowerShell $Profile, and set an alias (and call it something like Get-Name). Then, in VSCode I can simply type “Get-Name” without having to search for the program, open it, fiddle with it, etc. Meaning I can have any file open in VSCode and type Get-Name and it always works. As you can imagine, this is super fast and convenient.

How do I do the same thing with Python? Suppose the file is in c:/code/name.py, what would you do? Again the goal is so I don’t have to constantly navigate through the folders, find the file, open it, click run, and then use it.

submitted by /u/grep212
[link] [comments]

​r/learnpython Let’s say you have a Python script that prompts the user for their name and then writes “Hi, {Name}” Now in PowerShell this is super easy, I can create a custom function, throw it into my PowerShell $Profile, and set an alias (and call it something like Get-Name). Then, in VSCode I can simply type “Get-Name” without having to search for the program, open it, fiddle with it, etc. Meaning I can have any file open in VSCode and type Get-Name and it always works. As you can imagine, this is super fast and convenient. How do I do the same thing with Python? Suppose the file is in c:/code/name.py, what would you do? Again the goal is so I don’t have to constantly navigate through the folders, find the file, open it, click run, and then use it. submitted by /u/grep212 [link] [comments] 

Let’s say you have a Python script that prompts the user for their name and then writes “Hi, {Name}”

Now in PowerShell this is super easy, I can create a custom function, throw it into my PowerShell $Profile, and set an alias (and call it something like Get-Name). Then, in VSCode I can simply type “Get-Name” without having to search for the program, open it, fiddle with it, etc. Meaning I can have any file open in VSCode and type Get-Name and it always works. As you can imagine, this is super fast and convenient.

How do I do the same thing with Python? Suppose the file is in c:/code/name.py, what would you do? Again the goal is so I don’t have to constantly navigate through the folders, find the file, open it, click run, and then use it.

submitted by /u/grep212
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *