Software engineering and personal development

Tag: method

Demystifying Python’s Method: A Peek into Object Representation

In the realm of Python programming, there’s a special method that offers a glimpse into an object’s soul, revealing its identity and state in a unique way. Meet __repr__, a method that plays a crucial role in the world of object-oriented Python. In this short blog article, we’ll delve into the fascinating world of __repr__, exploring its purpose, usage, and why it’s an essential tool for any developer.

Continue reading

How to Quickly Count the Number of Times an Element Appears in a Tuple in Python

In Python, a tuple is an ordered and immutable collection of elements. Tuples are often used to store related pieces of information together, such as the x and y coordinates of a point, or the name and age of a person. Sometimes, we may need to count the number of times a particular element appears in a tuple. Python provides a built-in method called count() that makes it easy to accomplish this task. In this article, we will explore how to use the count() method to count the number of times an element appears in a tuple.

The count() method is a built-in method in Python that returns the number of times a specified element appears in a tuple. The method takes a single argument, which is the element to be counted. Here’s an example:

my_tuple = ('a', 1, 'f', 'a', 5, 'a')
print(my_tuple.count('a'))  # 3
Continue reading

Remove all whitespace in your strings with the squish method in your Ruby projects

It is really hard to think about a real world project in which you are not going to have strings. As a result, having pre-existing methods for manipulating strings is really productive, as it saves you time. In today’s article, I want to emphasize a particular method in Ruby on Rails, that’s surprisingly not that much well known, which helps you with the whitespaces. Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑