From: Jan Kohnert <nospam001-lists@jankoh.dyndns.org>
To: gentoo-user-de@lists.gentoo.org
Subject: [gentoo-user-de] Mein erstes Mal in Python ;)
Date: Tue, 6 Sep 2005 22:20:21 +0200 [thread overview]
Message-ID: <200509062220.26064.nospam001-lists@jankoh.dyndns.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]
Hallo Leute,
ich habe mir nun, nachdem mir bei der Einarbeitung in Python die Website nicht
sehr hilfreich erschien, ein kleines Buch mit einer Python-Einführung
gekauft. Es ließt sich so recht gut; aber soooo einfach, wie viele Leute
Python beschreiben, finde ich es noch nicht... ;)
Da ich bisher schon in C,php und bash programmiert habe, sind mir die
grundlegenden Sachen zwar schon nach ein paar Stunden weitgehend klar, aber
ich komme jetzt schon zu einem Problem, daß ich nicht wirklich lösen kann:
Ich schreibe ein kleines Testprogramm mit derzeit folgendem Inhalt:
#!/usr/bin/env python
import sys
if sys.argv[1] == "pop":
print "pop"
elif sys.argv[1] == "smtp":
print "smtp"
elif sys.argv[1] == "http":
print "http"
else:
print "Fehler"
sys.exit()
Das gibt mir auch aus, was es soll, nur bin ich gezwungen, einen Parameter
anzugeben, sonst kommt der schöne Traceback Fehlerdialog, der mir erlärt, es
gäbe kein argv[1]. Das ist ja richtig, nur hätte ich gerne, daß er in dem
FAll ebenfalls "Fehler" hinschreibt und das Programm normal endet. Der Code
würde in C so funktionieren, aber in Python ist das wohl etwas anderes... :-(
Ich kenne jedenfalls von C den Wert argc, der mir die Anzahl der Argumente
gibt, leider konnte ich bis jetzt nichts vergleichbares finden. Das einzige,
was mich entfernt an sowas erinnert, ist getopt - das habe ich noch nicht
ganz verstanden, naja das kommt noch - es erscheint mir aber etwas
Overhead... Das muß doch einfacher gehen, nur wie?
Danke!
MfG Jan
P.S.: Kennt jemand eine gute Onlinedoku über Python? So ähnlich wie die von
php, die ich einfach nur klasse finde...
--
OpenPGP Public-Key Fingerprint:
0E9B 4052 C661 5018 93C3 4E46 651A 7A28 4028 FF7A
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
next reply other threads:[~2005-09-06 20:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-06 20:20 Jan Kohnert [this message]
2005-09-06 20:53 ` [gentoo-user-de] Mein erstes Mal in Python ;) Emil Beinroth
2005-09-06 21:04 ` Jan Kohnert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200509062220.26064.nospam001-lists@jankoh.dyndns.org \
--to=nospam001-lists@jankoh.dyndns.org \
--cc=gentoo-user-de@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox