-1

I have tried this code this code works fine but I want to add more code so it becomes complex to write it in one function only I want to use another it in different line. Is there any way?

I have tried saving this in some variable and accessing it but it doesn't work:

os.system('cmd.exe /K "cd %s & activate & mkdir  C:\Private\PY36-VirtualEnv\Source\%s &  cd C:\Private\PY36-VirtualEnv\Source\%s  & code . " '%(path_list[which_dir - 1] , new_folder,new_folder))
dome
  • 820
  • 7
  • 20
  • 2
    use subprocess for executing external command and catching their errors and outputs. refer [subprocess](https://docs.python.org/2/library/subprocess.html) – satyam soni Jun 07 '19 at 09:08
  • why dont you create a simple cmd file (if windows ) or shell script to execute you command. – satyam soni Jun 07 '19 at 09:11
  • Yeah but how to create a command file ? in windows i am working on – python_nerd Jun 07 '19 at 09:18
  • create a file with **.bat** extension. `@echo off cd %1 & activate & mkdir C:\Private\PY36-VirtualEnv\Source\%2 & cd C:\Private\PY36-VirtualEnv\Source\%2 & code . ` Here %1 and %2 are you command line arguments. Simply run **xyz.bat arg1 arg2** – satyam soni Jun 07 '19 at 09:21

1 Answers1

-1

why you use python for this work? if you can just code it with c#. it is very powerful for cmd works. try to use c# and then connect it to your python. C# code is ready on internet.