string % dictionary question
Sam Sungshik Kong
ssk at chol.nospam.net
Tue Sep 14 16:06:32 EDT 2004
More information about the Python-list mailing list
Tue Sep 14 16:06:32 EDT 2004
- Previous message (by thread): string % dictionary question
- Next message (by thread): Easy question on opening a file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks Larry! What about numbers? s="%d" % di["test"] di["test"] could be a number or None. What can I do with that? "" is not appropriate, right? Sam "Larry Bates" <lbates at swamisoft.com> wrote in message news:x_-dnUD7uJRUYtvcRVn-vA at comcast.com... > di={} > di["test"]=None > s="%s" % (di["test"] or "") > print "s='%s'" % s > > works, but might be better to set values to empty strings > unless you want to test for the existence of None somewhere > else in your program. > > Larry Bates > > "Sam Sungshik Kong" <ssk at chol.nospam.net> wrote in message > news:ZFq1d.15197$QJ3.11816 at newssvr21.news.prodigy.com... > > 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? > > > > TIA. > > Sam > > > > > >
- Previous message (by thread): string % dictionary question
- Next message (by thread): Easy question on opening a file
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list