Using PHP in Python
Hello, I've come across sites that discuss embedding Python in PHP, but is it possible to access PHP functions in Python? -- http://mail.python.org/mailman/listinfo/python-list
Re: Using PHP in Python
Diez B. Roggisch wrote: > Tgone wrote: > > > Hello, > > > > I've come across sites that discuss embedding Python in PHP, but is it > > possible to access PHP functions in Python? > > I'm not aware of a generic wrapper thingy. Which doesn't mean there is none. > But which functions are you interested in? I can't believe there is much > that PHP can do that python _can't_ do, so maybe we can point you in the > right direction. > > Diez I have some custom PHP functions that I didn't want to re-write in Python. But maybe I should just rewrite them :) -- http://mail.python.org/mailman/listinfo/python-list
Decimals
Hello, I have a price column in a MySQL table: price decimal(5,2) When I access them in Python with SQLObject, prices display as 15.0 instead of 15.00. Why is this happening? I can't figure out why Python is trimming off the hundredth place. I'm not doing any formatting... Thanks, Tony -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Laszlo Nagy wrote: > Tgone írta: > > Hello, > > > > I have a price column in a MySQL table: price decimal(5,2) > > > > When I access them in Python with SQLObject, prices display as 15.0 > > instead of 15.00. Why is this happening? I can't figure out why Python > > is trimming off the hundredth place. I'm not doing any formatting... > > > What do you mean by 'displays as 15.0'? Do you print in with the print > statement? If your DB access module returns decimal.Decimal instances, > then you are right. It should print as 15.00 instead of 15.0. Try to > determine the type of the returned value. Maybe your DB module uses > float instead of Decimal? Sorry, when I print out the variable it displays as '15.0'. The price is '15.00' in the database though. Here's my code: product = Product.get(2) print product.price # 15.0 I'm using MySQLdb if that helps. -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimals
Sybren Stuvel wrote: > Tgone enlightened us with: > > Sorry, when I print out the variable it displays as '15.0'. The > > price is '15.00' in the database though. > > That's the same thing, isn't it? 15.0 == 15.0 Yes, they're both mathematically the same. I never said they weren't... > > Here's my code: > > > > product = Product.get(2) > > print product.price # 15.0 > > Try string formatting: > > print '%.2f' % product.price That works. I expected Python to display the data exactly as it is in the database, like most languages. -- http://mail.python.org/mailman/listinfo/python-list
Re: django and mod_python
your suggestions worked. thanks. -- http://mail.python.org/mailman/listinfo/python-list
