<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>python on Ohidur's Blog</title><link>https://blog.ohidur.com/tags/python/</link><description>Recent content in python on Ohidur's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>me@ohidur.com (Ohidur Rahman Bappy)</managingEditor><webMaster>me@ohidur.com (Ohidur Rahman Bappy)</webMaster><copyright>©{year} Ohidur.com</copyright><lastBuildDate>Sat, 23 Jan 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.ohidur.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Python - PyQt5</title><link>https://blog.ohidur.com/posts/python/pyqt5/</link><pubDate>Sat, 23 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Thu, 22 Apr 2021 11:44:07 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/pyqt5/</guid><description>Install PyQt5 pip install pyqt5 pip install pyqt5-tools Convert .ui file to .py pyuic5 -x demo.ui -o demo.py QLabel lable=QLabel()
Signals
linkActivated: If the label containing embedded hyperlink is clicked, the URL will open. setOpenExternalLinks feature must be set to true. linkHovered: Slot method associated with this signal will be called when the label having embedded hyperlinked is hovered by the mouse. Methods
setText() setAlignment() setPixmap(QPixmap(&amp;lsquo;image.png&amp;rsquo;)) setOpenExternalLinks(bool) setTextInteractionFlags(Qt.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Data type</title><link>https://blog.ohidur.com/posts/python/data-types/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/data-types/</guid><description>Python Data Types Data types are the classification or categorization of data items. Python supports the following built-in data types.
Scalar Types int: Positive or negative whole numbers (without a fractional part) e.g. -10, 10, 456, 4654654. float: Any real number with a floating-point representation in which a fractional component is denoted by a decimal symbol or scientific notation e.g. 1.23, 3.4556789e2. complex: A number with a real and imaginary component represented as x + 2y.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Generator</title><link>https://blog.ohidur.com/posts/python/generator/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/generator/</guid><description>Python - Generator Python provides a generator to create your own iterator function. A generator is a special type of function which does not return a single value, instead it returns an iterator object with a sequence of values. In a generator function, a yield statement is used rather than a return statement. The following is a simple generator function.
def myGenerator(): print(&amp;#39;First item&amp;#39;) yield 10 print(&amp;#39;Second item&amp;#39;) yield 20 print(&amp;#39;Last item&amp;#39;) yield 30 In the above example, myGenerator() is a generator function.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Iterator</title><link>https://blog.ohidur.com/posts/python/iterator/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/iterator/</guid><description>Python - Iterator Here, we will learn about the iterator function iter() in Python.
Iterators are implicitly used whenever we deal with collections of data types such as list, tuple or string (they are quite fittingly called iterables). The usual method to traverse a collection is using the for loop, as shown below.
myList = [1, 2, 3, 4] for item in myList: print(item) Result:
1
2
3</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Magic Methods</title><link>https://blog.ohidur.com/posts/python/magicmethods/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/magicmethods/</guid><description>A complete example
&amp;#34;&amp;#34;&amp;#34; magicmethods.py Want to try out the examples? Don&amp;#39;t want to type them up yourself? Never worry, magicmethods.py is a convenient Python module with all the class definitions for the examples in the magic methods guide in it. &amp;#34;&amp;#34;&amp;#34; # FileObject class, demonstrating __init__ and __del__ from os.path import join class FileObject: &amp;#34;&amp;#34;&amp;#34;Wrapper for file objects to make sure the file gets closed on deletion.&amp;#34;&amp;#34;&amp;#34; def __init__(self, filepath=&amp;#34;~&amp;#34;, filename=&amp;#34;sample.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Numbers</title><link>https://blog.ohidur.com/posts/python/numbers/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/numbers/</guid><description>Python Number Types: int, float, complex
Python includes three numeric types to represent numbers: integers, float, and complex number.
Int
In Python, integers are zero, positive or negative whole numbers without a fractional part and having unlimited precision, e.g. 0, 100, -10. The followings are valid integer literals in Python.
&amp;gt;&amp;gt;&amp;gt; 0 0 &amp;gt;&amp;gt;&amp;gt; 100 100 &amp;gt;&amp;gt;&amp;gt; -10 10 &amp;gt;&amp;gt;&amp;gt; 1234567890 1234567890 &amp;gt;&amp;gt;&amp;gt; y=5000000000000000000000000000000000000000000000000000000 5000000000000000000000000000000000000000000000000000000 Integers can be binary, octal, and hexadecimal values.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Recursion</title><link>https://blog.ohidur.com/posts/python/recursion/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/recursion/</guid><description>Recursion in Python A function that calls itself is a recursive function. This method is used when a certain problem is defined in terms of itself. Although this involves iteration, using an iterative approach to solve such a problem can be tedious. The recursive approach provides a very concise solution to a seemingly complex problem. It looks glamorous but can be difficult to comprehend!
The most popular example of recursion is the calculation of the factorial.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Strings</title><link>https://blog.ohidur.com/posts/python/strings/</link><pubDate>Tue, 19 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/strings/</guid><description>Python - String
In Python, string is an immutable sequence data type. It is the sequence of Unicode characters wrapped inside single, double, or triple quotes.
The followings are valid string literals in Python.
'This is a string in Python' # string in single quotes &amp;quot;This is a string in Python&amp;quot; # string in double quotes '''This is a string in Python''' # string in triple quotes &amp;quot;&amp;quot;&amp;quot;This is a string in Python&amp;quot;&amp;quot;&amp;quot; # string in triple double-quotes A string literal can be assigned to a variable, as shown below.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Deploy Django on heroku with postgres</title><link>https://blog.ohidur.com/posts/python/articles/django-heroku-deployment/</link><pubDate>Sun, 17 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/django-heroku-deployment/</guid><description>Python Heroku Deployment Steps to create a postgres database and deply a Python app to Heroku
Install Postgres dependencies pip install psycopg2 Install guinicorn locally pip install gunicorn Install Heroku CLI https://devcenter.heroku.com/articles/heroku-cli
Login via CLI heroku login Create app heroku create appname Create database heroku addons:create heroku-postgresql:hobby-dev --app appname or you can create from dashboard and add the details to settings.py
Get URI heroku config --app appname # Add to your app Create Procfile at the root touch Procfile # Add this web: gunicorn project_name.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>devops</category><category>programming</category></item><item><title>Creating a Django REST API</title><link>https://blog.ohidur.com/posts/django-rest-todo/</link><pubDate>Sat, 16 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/django-rest-todo/</guid><description>There are a few key options for a REST API request:
GET — The most common option, returns some data from the API based on the endpoint you visit and any parameters you provide POST — Creates a new record that gets appended to the database PUT — Looks for a record at the given URI you provide. If it exists, update the existing record. If not, create a new record DELETE — Deletes the record at the given URI PATCH — Update individual fields of a record Install Django</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>django</category></item><item><title>Python in browser - Brython</title><link>https://blog.ohidur.com/posts/python/articles/brython/</link><pubDate>Tue, 12 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/brython/</guid><description>How to run python code in browser with brython &amp;lt;!DOCTYPE html&amp;gt; &amp;lt;html lang=&amp;#34;en&amp;#34;&amp;gt; &amp;lt;head&amp;gt; &amp;lt;meta charset=&amp;#34;UTF-8&amp;#34;&amp;gt; &amp;lt;meta name=&amp;#34;viewport&amp;#34; content=&amp;#34;width=device-width, initial-scale=1.0&amp;#34;&amp;gt; &amp;lt;script src=&amp;#34;https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js&amp;#34; integrity=&amp;#34;sha256-rA89wPrTJJQFWJaZveKW8jpdmC3t5F9rRkPyBjz8G04=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;script src=&amp;#34;https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js&amp;#34; integrity=&amp;#34;sha256-Gnrw9tIjrsXcZSCh/wos5Jrpn0bNVNFJuNJI9d71TDs=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;style&amp;gt; * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, Helvetica, sans-serif; font-size: 25px; padding: 30px; line-height: 1.6; } h1 { text-align: center; margin-bottom: 30px; border-bottom: 1px #ccc solid; } h2 { margin-top: 20px; } button { cursor: pointer; display: block; background: #333; color: #fff; border: 0; border-radius: 5px; padding: 10px 20px; margin: 20px 0; } input[type=&amp;#34;text&amp;#34;] { border: 1px #ccc solid; width: 300px; padding: 4px; height: 35px; margin-top: 20px; } .</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>programming</category></item><item><title>Some experiments with tkinter - custom window title , network progress</title><link>https://blog.ohidur.com/posts/python/tkinter-experiments/</link><pubDate>Mon, 11 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/tkinter-experiments/</guid><description>Centering a window
# utility function that centers the program window on our screen def center_window(toplevel): toplevel.update_idletasks() screen_width = toplevel.winfo_screenwidth() screen_height = toplevel.winfo_screenheight() size = tuple(int(_) for _ in toplevel.geometry().split(&amp;#39;+&amp;#39;)[0].split(&amp;#39;x&amp;#39;)) x = screen_width/2 - size[0]/2 y = screen_height/2 - size[1]/2 toplevel.geometry(&amp;#34;+%d+%d&amp;#34; % (x, y)) Customized title bar
def move_window(event): window.geometry(&amp;#39;+{0}+{1}&amp;#39;.format(event.x_root, event.y_root)) window=tk.Tk() window.title(&amp;#34;Cutom title bar&amp;#34;) window.iconbitmap(default=&amp;#39;icon.ico&amp;#39;) window.config(borderwidth=2) window.columnconfigure(0,minsize=600) window.rowconfigure([0],minsize=30) window.rowconfigure([1,2],minsize=100) # hiding the default title bar window.overrideredirect(True) topbar_frame=tk.Frame(master=window,bg=&amp;#34;#f20011&amp;#34;,bd=2) lbl_title=tk.Label(master=topbar_frame,text=&amp;#34;Shopify Order&amp;#34;, background=TOP_BACKGROUND_COLOR,foreground=&amp;#34;#fafafa&amp;#34;) lbl_title.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Obfuscating python source code with pyarmor</title><link>https://blog.ohidur.com/posts/python/articles/obfuscating-with-pyarmor/</link><pubDate>Thu, 07 Jan 2021 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/obfuscating-with-pyarmor/</guid><description>PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts. It protects Python scripts by the following ways:
Install pyarmor pip install pyarmor
Obfuscate code object to protect constants and literal strings. Obfuscate co_code of each function (code object) in runtime. Clear f_locals of frame as soon as code object completed execution. Verify the license file of obfuscated scripts while running it.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>pyarmor</category><category>obfuscate</category><category>python</category></item><item><title>Accessing files from zip with package resources in python</title><link>https://blog.ohidur.com/posts/python/articles/aceesing-files-from-zip-with-package-resources/</link><pubDate>Wed, 30 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/aceesing-files-from-zip-with-package-resources/</guid><description>You could use pkg_resources functions to access files:
# __main__.py import pkg_resources from PIL import Image print(pkg_resources.resource_string(__name__, &amp;#39;README.txt&amp;#39;)) im = Image.open(pkg_resources.resource_stream(&amp;#39;app&amp;#39;, &amp;#39;im.png&amp;#39;)) im.rotate(45).show() Where zipfile contains:
. |-- app | |-- im.png | `-- __init__.py |-- README.txt `-- __main__.py To make zipfile executable, run:
$ echo &amp;#39;#!/usr/bin/env python&amp;#39; | cat - zipfile &amp;gt; program-name $ chmod +x program-name To test it:
$ cp program-name /another-dir/ $ cd /another-dir &amp;amp;&amp;amp; ./program-name</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Creating temporary directory and file with python</title><link>https://blog.ohidur.com/posts/python/tempfile/</link><pubDate>Thu, 24 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/tempfile/</guid><description>Creating a Temporary Directory So far, we&amp;rsquo;ve created permanent entries in the file system. For various reasons like parking data temporarily it can be necessary to just have a temporary directory. The tempfile module contains methods that handle such cases in a safe and consistent way.
Listing 5 shows an example that uses the TemporaryDirectory() method in combination with the with statement. After the with statement the temporary directory does not exist anymore because both the directory, and its contents have been entirely removed.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Compiling Python Code to Executable with nuitka</title><link>https://blog.ohidur.com/posts/python/articles/compiling-code-with-nuitka/</link><pubDate>Mon, 14 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/compiling-code-with-nuitka/</guid><description>From the official documentation of Nuitka it says
Nuitka is the Python compiler. It is written in Python. It is a seamless replacement or extension to the Python interpreter and compiles every construct that CPython 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, and 3.8 have, when itself run with that Python version.
How to get started?
Install Nuitka
pip install nuitka
Make a folder named HelloWorld</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python Fun facts</title><link>https://blog.ohidur.com/posts/python/articles/fun-facts/</link><pubDate>Sun, 13 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/fun-facts/</guid><description>Python was a hobby project
Guido Van Rossum was looking for a hobby project and choose python in december, 1989.
The Zen of Python
Open your python terminal and type import this. This is an easter egg in python.
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Deploy python on heroku with postgres</title><link>https://blog.ohidur.com/posts/python/articles/heroku-deployment/</link><pubDate>Sat, 12 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/heroku-deployment/</guid><description>Python Heroku Deployment Steps to create a postgres database and deply a Python app to Heroku
Install guinicorn locally pipenv install gunicorn or pip install gunicorn Install Heroku CLI https://devcenter.heroku.com/articles/heroku-cli
Login via CLI heroku login Create app heroku create appname Create database heroku addons:create heroku-postgresql:hobby-dev --app appname Get URI heroku config --app appname # Add to your app Create Procfile touch Procfile # Add this web: gunicorn app:app Create requirements.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>devops</category><category>programming</category></item><item><title>Python</title><link>https://blog.ohidur.com/posts/python/</link><pubDate>Sat, 12 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Thu, 22 Apr 2021 11:44:07 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/</guid><description>Python by Topic Basic Python Basic Get Started Basic Syntax Variables Data Types Basic Operators Decision Making Numbers Type Casting Booleans Strings String Formatting Lists Arrays Tuples Sets Dictionary Loops Recursion Iterator Generator Functions Map Filter Reduce Date &amp;amp; Time Math Modules Command line arguments Files I/O Plain text JSON CSV XML Yaml Exceptions Advanced Advanced Object Oriented Programming Magic Methods Regular Expression CGI Programming Database Redis GraphQL SQLite MySQL MongoDB Networking Email Multithreading GUI Programming PDF PyGame Modules Modules Builtin Modules Statistics Math cmath tempfile External Modules NumPy Pandas Matplotlib Plotly Pydot Seaborn SciPy Requests Scrapy BeautifulSoup PIL OpenCV Genism pyMySQL SymPy pyMongo SQLAlchemy Theano Bokeh Poetry Dash PyTorch Scikit-Learn Keras Tensorflow NLTK TextBlob Bokeh GUI Libraries GUI Libraries Tkinter PyQt5 Kivy wxPython Libvag PySimpleGUI PyForms Wax PySide2 Machine Learning Machine Learning Articles Articles Logging in Python Obfuscating python source code with pyarmor Python and postgres deployment on heroku Brython - Run python code in browser Creating system tray icon with pystray Fun facts Compiling code with Nuitka Setting up Python Embeddable Zip on Windows Python 2 vs Python 3</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>programming</category></item><item><title>Python virtualenv management with pipenv</title><link>https://blog.ohidur.com/posts/cheatsheet/pipenv/</link><pubDate>Sat, 12 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/cheatsheet/pipenv/</guid><description>Pipenv Cheat Sheet Install pipenv pip3 install pipenv Activate pipenv shell Check version of Python python --version Check path python &amp;gt;&amp;gt;&amp;gt; import sys &amp;gt;&amp;gt;&amp;gt; sys.executable quit() Install a package pipenv install camelcase Check local packages pipenv lock -r Uninstall a package pipenv uninstall camelcase Install a dev package pipenv install nose --dev Install from requirements.txt pipenv install -r ./requirements.txt Check security vulnerabilities pipenv check Check dependency graph pipenv graph Ignore pipfile pipenv install --ignore-pipfile Set lockfile - before deployment pipenv lock Exiting the virtualenv exit Run with pipenv pipenv run *</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category><category>programming</category></item><item><title>Caching a response in python</title><link>https://blog.ohidur.com/posts/python/articles/python-caching/</link><pubDate>Fri, 11 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/python-caching/</guid><description>We sometime need to cache our server response to save time and bandwidth.
There are external libraries out there for caching like dictttl
The following is a python implementation without any 3rd party libs.
Wou can add one more parameter to your expensive function: ttl_hash=None. This new parameter is so-called &amp;ldquo;time sensitive hash&amp;rdquo;, its the only purpose is to affect lru_cache.
from functools import lru_cache import time @lru_cache() def my_expensive_function(a, b, ttl_hash=None): del ttl_hash # to emphasize we don&amp;#39;t use it and to shut pylint up return a + b # horrible CPU load.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Creating a system tray icon with pystray</title><link>https://blog.ohidur.com/posts/python/articles/creating-system-tray-icon-with-pystray/</link><pubDate>Fri, 11 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/creating-system-tray-icon-with-pystray/</guid><description>Install the library:
pip install pystray
Creating a system tray icon In order to create a system tray icon, the class pystray.Icon is used:
In order for the icon to be displayed, you must provide an icon. This icon must be specified as a PIL.Image.Image:
import pystray icon = pystray.Icon(&amp;#39;test name&amp;#39;) from PIL import Image, ImageDraw def create_image(): image = Image.new(&amp;#39;RGB&amp;#39;, (width, height), color1) dc = ImageDraw.Draw(image) dc.rectangle( (width // 2, 0, width, height // 2), fill=color2) dc.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Logging in Python</title><link>https://blog.ohidur.com/posts/python/articles/python-logging/</link><pubDate>Thu, 10 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/python-logging/</guid><description>Logging is a very useful tool in a programmer’s toolbox. It can help you develop a better understanding of the flow of a program and discover scenarios that you might not even have thought of while developing.
Logs provide developers with an extra set of eyes that are constantly looking at the flow that an application is going through. They can store information, like which user or IP accessed the application.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Extra steps to send email with python from gmail</title><link>https://blog.ohidur.com/posts/python/articles/extra-steps-to-send-mail-with-gmail-python/</link><pubDate>Fri, 04 Dec 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/extra-steps-to-send-mail-with-gmail-python/</guid><description>Authenticating with Gmail There are a few steps you need to take before you can send emails through Gmail with SMTP, and it has to do with authentication. If you&amp;rsquo;re using Gmail as the provider, you&amp;rsquo;ll need to tell Google to allow you to connect via SMTP, which is considered a &amp;ldquo;less secure&amp;rdquo; method.
You can&amp;rsquo;t really blame Google for setting it up this way since your application (or some other 3rd party app) will need to have your plaint-text password for this to work, which is definitely not ideal.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python - Selenium Basics</title><link>https://blog.ohidur.com/posts/python/selenium/</link><pubDate>Tue, 10 Nov 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/selenium/</guid><description>Import the Selenium library You can get Selenium from here.
from selenium import webdriver common imports
from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By Start the webdriver and the browser
Starting the webdriver and the Chrome browser. You can get ChromeDriver from here.
chromedriver = &amp;#34;C:/tests/chromedriver.exe&amp;#34; driver = webdriver.Chrome(executable_path = chromedriver) Starting the webdriver and the Firefox browser.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Making a programming language with python</title><link>https://blog.ohidur.com/posts/python/articles/making-a-programming-language/</link><pubDate>Sun, 11 Oct 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/making-a-programming-language/</guid><description>Getting Started Install SLY for Python. SLY is a lexing and parsing tool which makes our process much easier.
pip install sly
Building a Lexer The first phase of a compiler is to convert all the character streams(the high level program that is written) to token streams. This is done by a process called lexical analysis. However, this process is simplified by using SLY
First let’s import all the necessary modules.</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Setting up Python embeddable distribution on windows</title><link>https://blog.ohidur.com/posts/python/articles/setting-up-python-embeddable-distribution/</link><pubDate>Wed, 11 Mar 2020 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/setting-up-python-embeddable-distribution/</guid><description>Embeddable distribution If there is anything I like about Windows as a pythonist, it must be that you can use embedded distribution of python.
The embedded distribution is a ZIP file containing a minimal Python environment. It is intended for acting as part of another application, rather than being directly accessed by end-users.
In my opinion, it is a portable, ready-to-ship virtualenv. However, the embedded distribution comes with some limitation:</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item><item><title>Python projects</title><link>https://blog.ohidur.com/posts/python/articles/project-ideas/</link><pubDate>Wed, 11 Dec 2019 00:00:00 +0000</pubDate><author>me@ohidur.com (Ohidur Rahman Bappy)</author><atom:modified>Mon, 08 Mar 2021 14:06:10 +0600</atom:modified><guid>https://blog.ohidur.com/posts/python/articles/project-ideas/</guid><description>Python projects ideas Flight Ticket Price Predictor using Python Automatic Salt Segmentation with UNET in Python using Deep Learning Transformer Conversational Chatbot in Python using TensorFlow 2.0 Lane-Line Detection System in Python using OpenCV Online Sports Turf Playground Booking System Price Comparison Website for Online Shopping Project Online College Admission Management System Project Web Based Blood Donation Management System Project Online Property Management System Project Online Employee Payroll Management System Project Online Grocery Recommender System Using Collaborative Filtering Online Shoes Shopping Website Project Online Organic Health Food Store Project Color Detection Using OpenCv Python Project Logistics Management System Project in Python Web Based Place Finder Using Django and GeoDjango Online Transaction Fraud Detection using Python &amp;amp; Backlogging on E-Commerce Graphical Password Authentication System by Using Pass Point Scheme Ecommerce Food Products Sales Forecasting System Predicting House Prices Using Linear Regression Online Employee Recruitment System Project in Python Decision Tree Based Tourism Recommendation System Ecommerce Website Live Visitor Tracking System Project Efficient Courier Tracking System Project Online Crime Reporting System in Python Project Image Steganography Project using Python Web Based Pharmaceutical Store Sales Forecasting System Online Healthcare Information Management System Project Online Inventory Management System Project in Python Wish list Products Price Comparison Website Project Secure File Storage on Cloud Using Hybrid Cryptography in Python Data Duplication Removal using File Checksum with Python Efficient Courier Tracking System Project GUI Based Stock Management &amp;amp; Control System Project</description><dc:creator>Ohidur Rahman Bappy</dc:creator><category>python</category></item></channel></rss>