Python | Check the memory usage of  an object >>> import sys >>> x = 100 >>> print(sys.getsizeof(x)) 28  

Last updated 3 years, 4 months ago | 1548 views

Tags:- Python

The .py files are the python source code of a program. While the .pyc files contain the bytecode of the python files. We get bytecode after compilation of .py file (source code). The .pyc files are not …

Last updated 3 years, 5 months ago | 1547 views

Tags:- Python

Using PDB we debug code in python. Some pdb commands include- <b> — Add breakpoint <c> — Resume execution <s> — Debug step by step <n> — Move to next line <l> — List source code …

Last updated 3 years, 7 months ago | 1544 views

Tags:- Python

Yes, it is possible if the base class is instantiated by other child classes or if the base class is a static method.

Last updated 3 years, 7 months ago | 1541 views

Tags:- Python

Python | Docstring  A documentation string or docstring is a multiline string used to document a specific code segment. The docstring should describe what the function or method does.  

Last updated 3 years, 7 months ago | 1538 views

Tags:- Python

Python | map() Function The map() function executes a specified function for each item in an iterable. The map() function in Python has two parameters, function and iterable. The map() function takes a function as an argument and …

Last updated 3 years, 7 months ago | 1536 views

Tags:- Python

Python | Dogpile effect In case the cache expires, what happens when a client hits a website with multiple requests is what we call the dogpile effect. To avoid this, we can use a semaphore lock. When …

Last updated 3 years, 7 months ago | 1525 views

Tags:- Python

Python program to count the number of capital letters in a file. with open(FILE_NAME) as my_file: count = 0 text = my_file.read() for character in text: if character.isupper(): count += 1 print(count)    

Last updated 3 years, 5 months ago | 1523 views

Tags:- Python

yield is a keyword beares the ability to turn any function into a generator.  Much like the standard return keyword, but returns a generator object. It is also true that one function may observe multiple …

Last updated 3 years, 7 months ago | 1521 views

Tags:- Python

Django is a framework that allows you to build large projects. On the other hand, Flask is used to build smaller websites but flask is much easier to learn and use compared to Django. Django is …

Last updated 3 years, 7 months ago | 1521 views

Tags:- Django

We can use the python re module to match the string import re def check(txt): # regex pattern pattern = 'ab{4,8}' if re.search(pattern, txt): print('Match found') else: print('Match not found') check("abcbbbb") # Match not found check("aabbbbbc") # …

Last updated 3 years, 5 months ago | 1518 views

Tags:- Python

Python | Main Function In the world of programming languages, the main is considered as an entry point of execution for a program. But in python, it is known that the interpreter serially interprets the file …

Last updated 3 years, 7 months ago | 1517 views

Tags:- Python

Python | context manager Context managers allow you to allocate and release resources precisely when you want to. The most widely used example of context managers is the with() statement.  with open('some_file', 'w') as opened_file: opened_file.write('Hola!')   The …

Last updated 3 years, 7 months ago | 1511 views

Tags:- Python

Django | Difference between a project and an app The project covers the entire application, while an app is a module or application within the project that deals with one dedicated requirement. So, a project consists …

Last updated 3 years, 7 months ago | 1509 views

Tags:- Django

The csrf_token is used for protection against Cross-Site Request Forgeries. This kind of attack takes place when a malicious website consists of a link, some JavaScript, or a form whose aim is to perform some …

Last updated 3 years, 7 months ago | 1509 views

Tags:- PHP Django CodeIgniter