Python | Send an email To send an email, Python provides smtplib and email modules. Import these modules into the created mail script and send mail by authenticating a user. It has a method SMTP(smtp-server, port). …

Last updated 1 year, 11 months ago | 456 views

Tags:- Python

Django | Set up environment variables in Django   1. Install Django Environ In your terminal, inside the project directory, type: $ pip install django-environ 2. Import environ in settings.py import environ 3. Initialise environ …

Last updated 1 year, 8 months ago | 453 views

Tags:- Django

Python | Global, Protected, and Private Global, Protected, and Private access modifiers in Python. Python does not use these keywords to control access modifications instead single and double underscore  ‘_’ symbols are used to specify Protected and  Private to determine the access control. …

Last updated 1 year, 11 months ago | 453 views

Tags:- Python

Python | split() and join() You can use split() method to split a string based on a delimiter to a list of strings. and join() method is used to join a list of strings based on …

Last updated 1 year, 11 months ago | 449 views

Tags:- Python

Python | strip() Function | Remove whitespaces from a string  To remove the whitespaces and trailing spaces from the string, Python provides a strip([str]) built-in function. This function returns a copy of the string after removing whitespaces …

Last updated 1 year, 11 months ago | 446 views

Tags:- Python

Python | Generator Functions that return an iterable set of items are called generators. It is a normal function except that it yields expression in the function. It does not implements __itr__ and next() method and …

Last updated 1 year, 11 months ago | 444 views

Tags:- Python

Python | Delete a file Using command  os.remove(file_name)   Use the os module to delete a file, we need to first import it, and then use the remove() function provided by the module to delete the file. It …

Last updated 1 year, 11 months ago | 443 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 1 year, 11 months ago | 441 views

Tags:- Python

MRO stands for Method Resolution Order. Talking of multiple inheritances, whenever we search for an attribute in a class, Python first searches in the current class. If found, its search is satiated. If not, it …

Last updated 1 year, 11 months ago | 440 views

Tags:- Python

Django | Cookie  A cookie is a small piece of information that is stored in the client's browser. It is used to store a user’s data in a file permanently (or for a specified time). Cookie …

Last updated 1 year, 10 months ago | 436 views

Tags:- Django

It means that a function can be treated just like an object. You can assign them to variables and pass them as arguments to other functions. You can even return them from another function.  You …

Last updated 1 year, 10 months ago | 435 views

Tags:- Python

Negative indexes mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.

Last updated 1 year, 11 months ago | 434 views

Tags:- Python

Python | accessors, mutators, and @property What we call getters and setters in languages like Java, we term accessors and mutators in Python. In Java, if we have a user-defined class with the property ‘x’, we …

Last updated 1 year, 11 months ago | 431 views

Tags:- Python

Using the query method we can print SQL query from the queryset post = Post.objects.all() print(post.query)  

Last updated 1 year, 10 months ago | 431 views

Tags:- Django

Python | Access Specifiers Python does not make use of access specifiers specifically like private, public, protected, etc. However, it does not derive this from any variables. It has the concept of imitating the behavior of …

Last updated 1 year, 11 months ago | 430 views

Tags:- Python