Re: [Linux-programlama] Python Programlama:Paremetre Ekleme:Nasıl?

---------

New Message Reply About this list Date view Thread view Subject view Author view Attachment view

From: Buğrahan Korkmaz (kickboksor@gmail.com)
Date: Tue 20 Jun 2006 - 05:35:03 GMT


Olabilir, evet.. Ama os.path.exists dosyaların var olup olmadığını kontrol
etmek için kullanılmaz mı?

2006/6/19, Ömer F. USTA <omerusta@gmail.com>:
>
> aslında bu biraz daha uygun gibi geldi
>
> #!/usr/bin/python
> #
> #uyar.py
> #
>
> ### Modules #
>
> import sys, os
>
> ############
>
> args = sys.argv
>
> def cal(x):
> os.system("madplay "+str(x))
>
> try:
> if sys.argv[1] == "cal" and sys.argv[2]:
> if os.path.exists(sys.argv[2]): #Burda dosyanın
> #bulunup
> bulunmadigina baktik
> print "Çalınıyor"
> cal( sys.argv[2])
> else:
> printf "Dosya bulunamadi"
>
> except:
> print """
>
>
> On 6/19/06, Buğrahan Korkmaz <kickboksor@gmail.com> wrote:
> > Buyurun bir mp3 çaldırma programı daha. Bunu kullanabilmek için sistemde
> > madplay kurulu olmalı...
> >
> > #!/usr/bin/python
> > #
> > #uyar.py
> > #
> >
> > ### Modules #
> >
> > import sys, os
> >
> > ############
> >
> > args = sys.argv
> >
> > def cal(x):
> > os.system("madplay "+str(x))
> >
> > try:
> > if sys.argv[1] == "cal" and sys.argv[2]:
> >
> > print "Çalınıyor"
> > cal( sys.argv[2])
> >
> > except:
> > print """
> >
> > İki argüman girmelisiniz.
> > Bunlardan birincisi 'cal' fonksiyonu,
> > diğeri ise mp3'ün bulunduğu dizin olmalı.
> >
> > Örn:
> > python uyar.py cal /usr/bin/sencanim1.mp3 """
> >
> >
> >
> > 2006/6/19, Buğrahan Korkmaz <kickboksor@gmail.com>:
> > >
> > > Teşekkürler...
> > >
> > > (Listeyi teşekkür için meşgul etmek ne kadar doğru bilmiyorum...)
> > >
> > >
> > >
> > > 2006/6/19, Burak Çelebi < burakcelebi@gmail.com>:
> > > > On 6/19/06, Buğrahan Korkmaz < kickboksor@gmail.com > wrote:
> > > > > Ya tekrar rahatsız ediyorum ama eğer vaktiniz ve sabrınız varsa
> ufak
> > bir
> > > > > python betiği yazar mısınız paremetreyle ilgili. Halaa anlamış
> > değilim.
> > > > > Örneğin:
> > > > >
> > > > > program.py --test denildiğinde merhaba desin
> > > > > program.py -go denildiğinde gülegüle desin...
> > > > >
> > > > > 2006/6/19, Buğrahan Korkmaz <kickboksor@gmail.com >:
> > > > > >
> > > > > > Teşekkür ederim...
> > > >
> > > >
> > > > import sys
> > > >
> > > > args = sys.argv
> > > >
> > > > if args[1] == 'test':
> > > > print 'merhaba'
> > > > elif args[1] == 'go':
> > > > print 'gule gule'
> > > >
> > > > kullanim:
> > > > python test.py test
> > > > python test.py go
> > > >
> > > > Basit scriptler icin bu isinizi gorur. Ancak kisa/uzun "flag"
> (-test,
> > > > --test) kullanmak isterseniz bunlara bakmalisiniz:
> > > >
> >
> http://diveintopython.org/scripts_and_streams/command_line_arguments.html
> > > > http://docs.python.org/lib/module-getopt.html
> > > > http://docs.python.org/lib/module-optparse.html
> > > >
> > > > Iyi calismalar.
> > > >
> > > > > >
> > > > > >
> > > > > > 2006/6/19, Burak Çelebi < burakcelebi@gmail.com >:
> > > > > >
> > > > > > >
> > > > > >
> > > > > > Bunlara da bakmak isteyebilirsiniz:
> > > > > >
> > > > > > http://docs.python.org/lib/module-getopt.html
> > > > > > http://docs.python.org/lib/module-optparse.html
> > > > > >
> > > > > > On 6/19/06, Burak Çelebi <burakcelebi@gmail.com> wrote:
> > > > > > > On 6/19/06, Burak Çelebi < burakcelebi@gmail.com> wrote:
> > > > > > > > sys.argv stringlerden olusan liste donduruyor:
> > > > > > > >
> > > > > > > > ornegin,
> > > > > > > > python test.py 5 mest
> > > > > > > >
> > > > > > > > icin
> > > > > > > > ['/home/burak/arg.py', '5', 'mest'] listesi doner. Burada
> 5'i
> > int
> > > > > > >
> > > > > > > Pardon dogrusu:
> > > > > > > ['/home/burak/test.py', '5', 'mest'] olacak.
> > > > > > >
> > > > > > > > olarak kullanmak icin string'ten int'e donusturmemiz gerek.
> > 'mest' i
> > > > > > > > ise dogrudan kullanabiliriz.
> > > > > > > >
> > > > > > > > import sys
> > > > > > > >
> > > > > > > > args = sys.argv
> > > > > > > >
> > > > > > > > print 4 + int(args[1])
> > > > > > > > print args[2]
> > > > > > > >
> > > > > > > >
> > > > > > > > On 6/19/06, Buğrahan Korkmaz < kickboksor@gmail.com> wrote:
> > > > > > > > > Lütfen, anlayamadım. Bir daha anlatır mısınız?
> > > > > > > > >
> > > > > > > > > Sys'yi import ettik. Tamam ondan sonrasını da anladım ama
> > nasıl
> > > > > > > > > kullanabileceğimi bilmiyorum. Biraz daha açın...
> > > > > > > > >
> > > > > > > > > 2006/6/19, Burak Çelebi < burakcelebi@gmail.com >:
> > > > > > > > > >
> > > > > > > > > Merhaba,
> > > > > > > > >
> > > > > > > > > On 6/19/06, Buğrahan Korkmaz < kickboksor@gmail.com >
> wrote:
> > > > > > > > > > Merhabalar,
> > > > > > > > > >
> > > > > > > > > > Arkadaşlar ben python programlama dili üzerinde
> çalışıyorum.
> > > > > Birşeyi
> > > > > > > > > > yapamıyorum. Mesela konsol uygulamaları paremetre
> kullanır.
> > Her
> > > > > > > > > paremetrede
> > > > > > > > > > çeşitli görevler yaparlar. Ben de konsolda pythonla
> > programlama
> > > > > yaptığım
> > > > > > > > > > için bunu öğrenmem lazım. Evet, nasıl paremetre
> > ekleyebilirim?
> > > > > > > > >
> > > > > > > > > import sys
> > > > > > > > >
> > > > > > > > > args = sys.argv
> > > > > > > > > print args[0]
> > > > > > > > > print args[1]
> > > > > > > > > ...
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Burak Celebi - http://www.burakcelebi.tk
> > > > > > > > >
> > > > > > > > >
> > _______________________________________________
> > > > > > > > > Linux-programlama mailing list
> > > > > > > > > Linux-programlama@liste.linux.org.tr
> > > > > > > > >
> > > > >
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Buğrahan Korkmaz
> > > > > > > > >
> > _______________________________________________
> > > > > > > > > Linux-programlama mailing list
> > > > > > > > > Linux-programlama@liste.linux.org.tr
> > > > > > > > >
> > > > >
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Burak Celebi - http://www.burakcelebi.tk
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Burak Celebi - http://www.burakcelebi.tk
> > > > > > > Jerry: But the question is, are you still master of your
> domain?
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Burak Celebi - http://www.burakcelebi.tk
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > >
> > > > > > Linux-programlama mailing list
> > > > > > Linux-programlama@liste.linux.org.tr
> > > > > >
> > > > >
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Buğrahan Korkmaz
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Buğrahan Korkmaz
> > > > > _______________________________________________
> > > > > Linux-programlama mailing list
> > > > > Linux-programlama@liste.linux.org.tr
> > > > >
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Burak Celebi - http://www.burakcelebi.tk
> > > >
> > > > _______________________________________________
> > > > Linux-programlama mailing list
> > > > Linux-programlama@liste.linux.org.tr
> > > >
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Buğrahan Korkmaz
> >
> >
> >
> > --
> > Buğrahan Korkmaz
> > _______________________________________________
> > Linux-programlama mailing list
> > Linux-programlama@liste.linux.org.tr
> > http://liste.linux.org.tr/mailman/listinfo/linux-programlama
> >
> >
> >
>
>
> --
> Ömer Fadıl USTA
> http://www.bilisimlab.com/
>
> _______________________________________________
> Linux-programlama mailing list
> Linux-programlama@liste.linux.org.tr
> http://liste.linux.org.tr/mailman/listinfo/linux-programlama
>
>
>

-- 
Buğrahan Korkmaz

_______________________________________________
Linux-programlama mailing list
Linux-programlama@liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama


New Message Reply About this list Date view Thread view Subject view Author view Attachment view

---------

Bu arsiv hypermail 2.1.2 tarafindan uretilmistir.