class KStock( db.Model ):
Style = db.TextProperty()
def get( self ):
qry = db.GqlQuery( "select * from KStock where Code =
'000002'" )
stcData = qry.get()
if stcData: #here, stcData.Style
is "[]"
self.response.out.write( "style str is " + stcData.Style )
style = eval( stcData.Style )
self.response.out.write( "<br>-----<br>style type is " +
( "right." if isinstance( style, list ) else "wrong." ))
style = eval( '[]' )
self.response.out.write( "<br>-----<br>style type is " +
( "right." if isinstance( style, list ) else "wrong." ))
the output is:
style str is '[]'
-----
style type is wrong.
-----
style type is right.
you see, the eval() did not work so well for db.TextProperty as for
str. i have tryed:
style = eval( str( stcData.Style ))
the type is still wrong.
if the db.TextProperty is not '[]', it works well. output is:
style str is [[-1, 11.81, 79], [1, 11.779999999999999, 87], [-1,
11.800000000000001, 95], [1, 11.789999999999999, 96], [-1,
11.800000000000001, 97], [1, 11.789999999999999, 97], [-1,
11.800000000000001, 98], [1, 11.789999999999999, 99], [-1, 11.81,
103], [1, 11.800000000000001, 104], [-1, 11.800000000000001, 105], [1,
11.789999999999999, 106], [-1, 11.800000000000001, 107], [1,
11.789999999999999, 108], [-1, 11.81, 112], [1, 11.800000000000001,
113]]
-----
style type is right.
-----
style type is right.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.