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

  • movies95

    movies95

    27 Kasım 2006
  • The Scary Snowman

    The Scary Sn

    1 ŞUBAT 2011
  • TurkishRoyal

    TurkishRoyal

    16 Ocak 2007