AW: [Python-de] Datentype none
Josef Cihal
josef.cihal at irm.at
Mon Aug 26 20:04:30 EDT 2002
FRAG EINFACH:
if not feld:
print "null"
-----Ursprüngliche Nachricht-----
Von: python-de-admin at python.net [mailto:python-de-admin at python.net]Im
Auftrag von Gerhard Häring
Gesendet: Montag, 26. August 2002 19:04
An: python-de at python.net
Betreff: Re: [Python-de] Datentype none
* Ron Opitz <ron.opitz at dts.de> [2002-08-26 18:26 +0200]:
> Hallo,
>
> ich erhalte von einer DB Abfrage den Wert (Datentyp) none zurückgeliefert.
> Das ist richtig, da das Feld leer ist. Wie kann ich das jetzt prüfen?
>
> ...
> if ???(feld)==none
> feld = 0
if feld is None:
feld = 0
None ist ein Singleton und Singletons überprüft man mit dem
"is"-Operator.
Eine Möglichkeit ist auch, das einfach so zu schreiben:
feld = feld or 0
So, das geht jetzt aber auch direkt in (Oracle-)SQL:
SELECT NVL(feld, 0) FROM table
> ...
>
>
> Gibt es fertige Funktionen die das Dezimaltrennzeichen von de nach us
> konvertieren.
Wozu? Es gibt das locale-Modul zum Formatieren.
> Da Oracle als Trenner das Komma zurückgibt?
Autsch. NUMBER kommt doch wohl als float zurück?
Gerhard
--
This sig powered by Python!
Außentemperatur in München: 25.8 °C Wind: 2.9 m/s
_______________________________________________
Python-de maillist - Python-de at starship.python.net
http://starship.python.net/mailman/listinfo/python-de
More information about the Python-de
mailing list