Posts for: #Python 3

Graphical Effects with Python, Tkinter, Cython, and Numba

Yesterday, Saturday, I felt like creating a flame effect (fire) in Python. This effect was quite popular in the early 90s. I remembered that the algorithm was quite simple, but there were some tricks to do with the color palette.

I found this article with the implementation in C: https://lodev.org/cgtutor/fire.html

From the same article, we can get an idea of how the effect looks:

Flame Effect

After reading the article and watching some videos on YouTube, I faced two problems:

Read more

Graphical Effects with Python, Tkinter, Cython, and Numba

Yesterday, Saturday, I felt like creating a flame effect (fire) in Python. This effect was quite popular in the early 90s. I remembered that the algorithm was quite simple, but there were some tricks to do with the color palette.

I found this article with the implementation in C: https://lodev.org/cgtutor/fire.html

From the same article, we can get an idea of how the effect looks:

Flame Effect

After reading the article and watching some videos on YouTube, I faced two problems:

Read more

Telegram Queries - Interesting Questions

Last week I had the opportunity to see three interesting questions discussed in the Telegram groups, but the explanation would be too long for a chat.

  1. Why True, True, True == (True, True, True) returns True, True, False?

  2. Why -2 * 5 // 3 + 1 returns -3?

  3. How to add times in Python?

Why True, True, True == (True, True, True) returns True, True, False?

This question was presented as a weird syntax of Python, but it’s actually a visual trap. Look at the operator == (equal equal).

Read more

Telegram Queries - Interesting Questions

Last week I had the opportunity to see three interesting questions discussed in the Telegram groups, but the explanation would be too long for a chat.

  1. Why True, True, True == (True, True, True) returns True, True, False?

  2. Why -2 * 5 // 3 + 1 returns -3?

  3. How to add times in Python?

Why True, True, True == (True, True, True) returns True, True, False?

This question was presented as a weird syntax of Python, but it’s actually a visual trap. Look at the operator == (equal equal).

Read more

A bot for Telegram with Tic-Tac-Toe.

This post is a reissue of the article published in the magazine Portugal a Programar number 55 from March 2017, pages 26 to 34.

In a world with so many instant messaging applications, Telegram stands out for the rich API it provides for creating bots. Bots are small programs that can interact with users and provide services, such as executing commands, managing files or images, and even proposing games!

The Python community has long explored libraries like Telebot and more recently, Telepot. Although the difference in the names of the two is just one letter, the design of Telepot seems more robust to me, and best of all: it integrates asynchronous calls!

Read more

A bot for Telegram with Tic-Tac-Toe.

This post is a reissue of the article published in the magazine Portugal a Programar number 55 from March 2017, pages 26 to 34.

In a world with so many instant messaging applications, Telegram stands out for the rich API it provides for creating bots. Bots are small programs that can interact with users and provide services, such as executing commands, managing files or images, and even proposing games!

The Python community has long explored libraries like Telebot and more recently, Telepot. Although the difference in the names of the two is just one letter, the design of Telepot seems more robust to me, and best of all: it integrates asynchronous calls!

Read more

Migrating the chat server to Python 3.6

When Python 3.4 was released, I was so happy with the Asyncio integration that I wrote a chat server here.

Time passed and new versions of Python were released. So I decided to migrate the server to Python 3.6.

One of the big changes that occurred in Python 3.5 was support for async and await to replace @asyncio.coroutine and yield from respectively. This small change alone makes the code much easier to read, which has become lighter. But one of the main changes in Python 3.6 are f-strings that make it easy to form messages.

Read more

Migrating the chat server to Python 3.6

When Python 3.4 was released, I was so happy with the Asyncio integration that I wrote a chat server here.

Time passed and new versions of Python were released. So I decided to migrate the server to Python 3.6.

One of the big changes that occurred in Python 3.5 was support for async and await to replace @asyncio.coroutine and yield from respectively. This small change alone makes the code much easier to read, which has become lighter. But one of the main changes in Python 3.6 are f-strings that make it easy to form messages.

Read more

Consultations via Telegram

It would be nice if IT professionals could give consultations like doctors or lawyers, but something prevents us from charging for everything and this desire to share ideas consumes us.

I participate in several Telegram groups, mainly about Python, one of which is the PyCoding group and the other is the pybr. Normally I read the groups when I’m using my cell phone, so it’s not always possible to help with questions, but I’ll try to set aside a little time to explore some ideas here and there.

Read more

Consultations via Telegram

It would be nice if IT professionals could give consultations like doctors or lawyers, but something prevents us from charging for everything and this desire to share ideas consumes us.

I participate in several Telegram groups, mainly about Python, one of which is the PyCoding group and the other is the pybr. Normally I read the groups when I’m using my cell phone, so it’s not always possible to help with questions, but I’ll try to set aside a little time to explore some ideas here and there.

Read more