#GitHubCoPilot 🤖 – Real Scenario: let’s send a tweet! 🐦

Hi !

Next question on the line: how useful is CoPilot in day to day tasks?

So, I decided to use copilot to help me solve a current problem: send a tweet.

Usually I’ll perform a couple of search, test some libraries, etc.

I’ll do this at full speed with the CoPilot suggestion.

use copilot to generate code to send a tweet in python

This is the generated code

# send a tweet with a custom message

import tweepy


auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

api.update_status(status='Hello World from Copilot !!!')

I used CoPilot in 2 steps

  • First suggestion to use a library, tweepy.
  • Use the library to send a tweet.

Installed, the library with the following command

pip install tweepy

And I was ready to send a tweet!

test to send a tweet and see the tweet in real time

This is the generated tweet !


Test done, and it works ! in less than 5 minutes, I was able to send a tweet.

However, I need to share a couple of thoughts:

  • If I’m planning to really use this, I will spend more time reading about the tweepy library. It looks great, and I’ll add some reading work to validate that.
  • I may also test some other libraries, learning moment.
  • I’m not an expert on how twitter API handles security, so why now study some OAuth.
  • I already have a set of keys and secrets in Twitter. That saved me at least 5 minutes.

At the end, this 5 minutes will result in a full set of days of learning new technologies. Awesome !

Happy coding!


El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno

¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: