Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

TweePy can't tweet float objects?

So I am using tweepy to tweet a variable that contains a float object.
This is the piece I am talking about:
Code
api = tweepy.API(auth)
api.update_status (variable)
(Keep in mind that the rest of the program works fine)
The problem is, when I run the code, I am getting this error:
Code
TypeError: 'float' object is not iterable
I guess it's giving that error because tweepy can't handle a float object, but I don't know how I would fix this. Do you guys know?

Thanks in advance
Convert it to a string.

Code
api.update_status(str(variable))

You can also do it before.

Code
variable = str(2.0)
api.update_status(variable)

And if you're combining a float object with a string.

Code
api.update_status("You're message and a %.2f float." % variable)
(May 22, 2015 10:12 AM)zmetra Wrote:  Convert it to a string.

Code
api.update_status(str(variable))

You can also do it before.

Code
variable = str(2.0)
api.update_status(variable)

And if you're combining a float object with a string.

Code
api.update_status("You're message and a %.2f float." % variable)

Thanks for your help! I am using the last option. I also discovered that tweepy has had an update recently. Since that update you must use this to tweet:

Code
api.status_updat(status = your variable or text)
Thanks again, you helped out


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by PsychoJul 3, 2021 11:15 PM 24 1,975 Jul 3, 2021 11:15 PM
Last Post: Lookdadon
[Python] by Bora or HyunaFeb 14, 2020 12:49 AM 2 311 Feb 14, 2020 12:49 AM
Last Post: Bora or Hyuna
[Python] by SympthFeb 4, 2020 07:54 AM 6 390 Feb 4, 2020 07:54 AM
Last Post: Nikix