Mesela programı çalıştırınca 1. numarayı kendi otomatik olarak indirmesini istiyorum ama OS. System komutuyla müdahale edemiyorum çünkü ilk komut bitmemiş sayıyor.
Python ile bunu yapabilmem mümkun mü?
Not: Biliyorum başka şekillerde de yapılabilir. Ama ben bir komutun içinde alt komutu nasıl verebileceğimizi öğenmek istiyorum.
Mesela programı çalıştırınca 1. numarayı kendi otomatik olarak indirmesini istiyorum ama OS. System komutuyla müdahale edemiyorum çünkü ilk komut bitmemiş sayıyor.
Python ile bunu yapabilmem mümkun mü?
Not: Biliyorum başka şekillerde de yapılabilir. Ama ben bir komutun içinde alt komutu nasıl verebileceğimizi öğenmek istiyorum.
Source code: Lib/os.py This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, s...
docs.python.org
Kod:
Execute the command (a string) in a subshell.
This is implemented by calling the Standard C function system(), and has the same limitations.
Changes to sys.stdin, etc. are not reflected in the environment of the executed command.
Kullanici tercihini stdin olarak gondermeyeceksen, output ve input stream'i pipe ederek manipule edebilecegin farkli yollar kullanman gerekiyor.
Bu sebeple kaliteli kod yazmak icin
1) Gerekmedikce kontrolun disindaki modullere dependency vermemek ( bash script etc )
2) Dokumani iyi okuyup tavsiye edilen best-practice'leri uygulamak ( ve bunu neden yaptigini bilmek )
Source code: Lib/subprocess.py The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace seve...