[Python-de] abfrage: Wert == [None] ???
Fritz Cizmarov
fritz at sol.at
Die Nov 9 15:51:00 CET 2004
Hallo Frank,
Da frage ich mich, ob du an 'a' wirklich [None] oder None oder [] also
eine leere Liste zuweisen willst?
Im ersten Fall hast Du ja von Diez schon die Lösung,
Bei None kannst du am besten so abfragen:
if c is None:
...
bei [] reicht
if not c:
...
Gruß
Fritz
On Tue, 9 Nov 2004 14:39:51 +0100 (MET)
"Frank Immich" <frankimmich at gmx.de> wrote:
> Hallo zusammen,
>
> eine Frage zu einer Abfrage:
> Ich weise in einem dictionary einem Schluessel den
> Wert [None] zu. Nun möchte ich abfragen ob der Wert = [None].
> Das funktioniert aber irgendwie nicht...?
>
>
> .........
>
> d_msn = ....
>
> print d_msn
>
> for p,c in d_msn.items():
>
> print "p:",p
> print "c:",c
> print "type c", type(c)
> print "type c[0]", type(c[0])
>
> if c == [None]:
> print "Fall1:", p
> if c == ["None"]:
> print "Fall2:", p
> if c == "[None]":
> print "Fall3:", p
> if c == None:
> print "Fall3:", p
> if types.NoneType in c:
> print "Fall4:", p
> if c[0] == types.NoneType:
> print "Fall5:", p
>
> ergbnis:
>
> {'1': [None]}
> p: 1
> c: [None]
> type c <type 'list'>
> type c[0] <type 'NoneType'>
>
>
>
> und das wars... wie kann ich das abfragen ? Wo ist mein Denkfehler ?
>
> Vielen Dank für einen Tipp
>
> Grüße Frank
>
>
>
>
>
>
>
> --
> NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
> GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!
>
> _______________________________________________
> python-de maillist - python-de at python.net
> http://python.net/mailman/listinfo/python-de