SORU
21 EKİM 2010, PERŞEMBE


Python: komut satırından fonksiyonu Çalıştır

Dosyama aşağıdaki kodu var:

def hello():
    return 'Hi :)'

Nasıl komut satırından çalıştırmak istiyorsunuz?

CEVAP
21 EKİM 2010, PERŞEMBE


-c ile(komut)bağımsız değişken (dosya foo.py adlı varsayarak):

$ python -c 'import foo; print foo.hello()'

Eğer ad kirliliği umurunda bile alternatif olarak,:

$ python -c 'from foo import *; print hello()'

Ve orta yere:

$ python -c 'from foo import hello; print hello()'

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 365multimedia

    365multimedi

    26 ŞUBAT 2009
  • Amazon Web Services

    Amazon Web S

    8 NİSAN 2009
  • The Platform

    The Platform

    14 HAZİRAN 2006