string % dictionary question
Jorge Godoy
godoy at ieee.org
Mon Sep 13 23:30:01 EDT 2004
More information about the Python-list mailing list
Mon Sep 13 23:30:01 EDT 2004
- Previous message (by thread): Greenlets: where are they now???
- Next message (by thread): string % dictionary question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Sam Sungshik Kong" <ssk at chol.nospam.net> writes: > Hello, group! > > <code> >>>> di={} >>>> di["test"]=None >>>> s="%(test)s" % di >>>> s > 'None' > </code> > > I want the result to be just empty string when the dictionary value is None. > Is there a good way? You can check it after the definition and make the necessary changes... >>> di={} >>> di["test"]=None >>> s="%(test)s" % di >>> if s == "None": s = "" ... >>> s '' >>> di["test"] = 1 >>> s = "%(test)s" % di >>> if s == "None": s = "" ... >>> s '1' >>> Be seeing you, -- Godoy. <godoy at ieee.org>
- Previous message (by thread): Greenlets: where are they now???
- Next message (by thread): string % dictionary question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list