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

  • Anthony Cumia

    Anthony Cumi

    5 EYLÜL 2006
  • ghosti66

    ghosti66

    27 AĞUSTOS 2006
  • The Amazing Atheist

    The Amazing

    20 Kasım 2006