<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python Archives - Tech Chronicles</title>
	<atom:link href="http://kostacipo.stream/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://kostacipo.stream/tag/python/</link>
	<description>Ramblings of a Tech Dude</description>
	<lastBuildDate>Fri, 25 Jul 2025 20:45:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://kostacipo.stream/wp-content/uploads/2019/12/cropped-profile-32x32.jpg</url>
	<title>python Archives - Tech Chronicles</title>
	<link>https://kostacipo.stream/tag/python/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AutoSploit: Automated Mass Exploiter</title>
		<link>http://kostacipo.stream/autosploit-automated-mass-exploiter/</link>
					<comments>http://kostacipo.stream/autosploit-automated-mass-exploiter/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 25 Jul 2025 20:43:36 +0000</pubDate>
				<category><![CDATA[Exploitation Tools]]></category>
		<category><![CDATA[Exploit]]></category>
		<category><![CDATA[metasploit]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://kostacipo.stream/?p=2219</guid>

					<description><![CDATA[<p>AutoSploit is a powerful hacking tool that has the ability to automate exploitation operations on remote hosts. This tool enables you to perform mass exploitations on the system being targeted by utilizing the services offered by Shodan, Censys, Zoomeye and Metasploit. This tool is developed using Python. Autosploit: Advanced Remote Host Mass Exploitation With this tool, [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/autosploit-automated-mass-exploiter/">AutoSploit: Automated Mass Exploiter</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="text-justify">AutoSploit is a powerful hacking tool that has the ability to automate exploitation operations on remote hosts. This tool enables you to perform mass exploitations on the system being targeted by utilizing the services offered by <a href="https://www.shodan.io/">Shodan</a>, <a href="https://censys.io/">Censys</a>, <a href="https://www.zoomeye.org/">Zoomeye </a>and Metasploit. This tool is developed using Python.</p>
<figure class="wp-block-image size-large img-fluid text-center"><img decoding="async" class="wp-image-11728 lazyloaded" src="https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo.jpg" sizes="(max-width: 1000px) 100vw, 1000px" srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo.jpg 1000w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-300x54.jpg 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-768x138.jpg 768w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-350x63.jpg 350w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-500x90.jpg 500w" alt="AutoSploit: Automated Mass Exploiter Logo/Banner" data-srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo.jpg 1000w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-300x54.jpg 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-768x138.jpg 768w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-350x63.jpg 350w, https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo-500x90.jpg 500w" data-src="https://cdn.cyberpunk.rs/wp-content/uploads/2020/01/autosploit_banner_logo.jpg" data-sizes="(max-width: 1000px) 100vw, 1000px" /></figure>
<h2>Autosploit: Advanced Remote Host Mass Exploitation</h2>
<p class="text-justify">With this tool, you can easily launch an attack on a remote host within a fairly short time. This is made possible due to the availability of Shodan, a powerful search engine that allows you to automatically fish out targets that are connected to a particular network service. Alternatively, you can also use target seeking tools such as Zoomeye and Censys to search out intended targets.</p>
<p class="text-justify">Apart from the automated host searching and collection, AutoSploit also gives you the option of creating your own customized target list. With this option in place, you can effectively launch attack-intended searches on hosts of your choice by manually adding them to your list.</p>
<h3>Metasploit Modules and How They Work Together</h3>
<div class="alert alert-secondary">The available powerful Metasploit modules are responsible for handling the rest of the work after the targets have been collected. By default, Metasploit comes with a long list of attack modules but you can manually add other modules of your liking to make the tool more powerful. The module deployed will depend on the platform search query that was used when an attack was launched. The Metasploit modules can help a pentester to gain access to services such as Meterpreter sessions and also be able to make remote code executions and many other attacks.</div>
<div class="alert alert-secondary">The combination of Shodan and Metasploit makes it very easy to use autosploit especially since the whole process is automated. The inclusion of Metasploit makes autosploit very effective tool when it comes to launching attacks on Apache-based projects.</div>
<h3>AutoSploit Features:</h3>
<ul>
<li>Automated Target Collection</li>
<li>Customized Target List (allows you to add your own list of targets)</li>
<li>Metasploit Modules</li>
<li>Custom user-agent</li>
<li>Mass exploitations</li>
</ul>
<h3>Supported Platforms:</h3>
<ul>
<li>Linux</li>
<li>OS X (must be within virtual environments to properly function)</li>
</ul>
<h3>Dependencies:</h3>
<p>This tool relies on the below <code>Python 2.7</code> modules:</p>
<ul>
<li>requests</li>
<li>psutil</li>
</ul>
<p>The required dependencies should all be in place after performing an installation with the recommended method, but you can easily install them using <code>pip</code>:</p>
<pre class="wp-block-preformatted">$ pip install -r requirements.txt</pre>
<p>Alternatively:</p>
<pre class="wp-block-preformatted">$ pip install requests psutil</pre>
<h2>Autosploit Install</h2>
<h3>Install AutoSploit via Docker Compose:</h3>
<p>Clone the repo:</p>
<pre class="wp-block-preformatted">$ git clone https://github.com/NullArray/AutoSploit.git</pre>
<p>Navigate to the Autosploit directory and run:</p>
<pre class="wp-block-preformatted">$ cd Autosploit/Docker
$ docker-compose run --rm autosploit</pre>
<h3>Install AutoSploit on Linux (via cloning)</h3>
<p>Clone:</p>
<pre class="wp-block-preformatted">$ git clone https://github.com/NullArray/AutoSploit</pre>
<p>Navigate to the AutoSploit directory, make the install script executable and install:</p>
<pre class="wp-block-preformatted">$ cd AutoSploit
$ chmod +x install.sh
$ ./install.sh</pre>
<h2>Usage</h2>
<p>To start AutoSploit run:</p>
<pre class="wp-block-preformatted">$ python autosploit.py</pre>
<p>This will take you to the available user options that you can choose from.</p>
<pre class="wp-block-preformatted">usage: python autosploit.py -[c|z|s|a] -[q] QUERY
                            [-C] WORKSPACE LHOST LPORT [-e] [--whitewash] PATH
                            [--ruby-exec] [--msf-path] PATH [-E] EXPLOIT-FILE-PATH
                            [--rand-agent] [--proxy] PROTO://IP:PORT [-P] AGENT

optional arguments:
  -h, --help            show this help message and exit

search engines:
  possible search engines to use

  -c, --censys          use censys.io as the search engine to gather hosts
  -z, --zoomeye         use zoomeye.org as the search engine to gather hosts
  -s, --shodan          use shodan.io as the search engine to gather hosts
  -a, --all             search all available search engines to gather hosts

requests:
  arguments to edit your requests

  --proxy PROTO://IP:PORT
                        run behind a proxy while performing the searches
  --random-agent        use a random HTTP User-Agent header
  -P USER-AGENT, --personal-agent USER-AGENT
                        pass a personal User-Agent to use for HTTP requests
  -q QUERY, --query QUERY
                        pass your search query

exploits:
  arguments to edit your exploits

  -E PATH, --exploit-file PATH
                        provide a text file to convert into JSON and save for
                        later use
  -C WORKSPACE LHOST LPORT, --config WORKSPACE LHOST LPORT
                        set the configuration for MSF (IE -C default 127.0.0.1
                        8080)
  -e, --exploit         start exploiting the already gathered hosts

misc arguments:
  arguments that don't fit anywhere else

  --ruby-exec           if you need to run the Ruby executable with MSF use
                        this
  --msf-path MSF-PATH   pass the path to your framework if it is not in your
                        ENV PATH
  --whitelist PATH      only exploit hosts listed in the whitelist file</pre>
<div class="row justify-content-center mb-3">
<div class="col-lg-4"><a href="https://github.com/NullArray/AutoSploit/wiki">Documentation</a></div>
<div><a href="https://github.com/NullArray/AutoSploit">Download</a></div>
</div>
<div class="row justify-content-center mb-3">
<div class="col-lg-4"></div>
</div>
<p>The post <a href="http://kostacipo.stream/autosploit-automated-mass-exploiter/">AutoSploit: Automated Mass Exploiter</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/autosploit-automated-mass-exploiter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SqliSniper – Enhancing Web Security By Detecting SQL Injection Vulnerabilities With Python</title>
		<link>http://kostacipo.stream/sqlisniper-enhancing-web-security-by-detecting-sql-injection-vulnerabilities-with-python/</link>
					<comments>http://kostacipo.stream/sqlisniper-enhancing-web-security-by-detecting-sql-injection-vulnerabilities-with-python/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 23:39:18 +0000</pubDate>
				<category><![CDATA[Data]]></category>
		<category><![CDATA[Exploitation Tools]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sql injection]]></category>
		<guid isPermaLink="false">https://kostacipo.stream/?p=2177</guid>

					<description><![CDATA[<p>SqliSniper is a robust Python tool designed to detect time-based blind SQL injections in HTTP request headers. It enhances the security assessment process by rapidly scanning and identifying potential vulnerabilities using multi-threaded, ensuring speed and efficiency. Unlike other scanners, SqliSniper is designed to eliminates false positives through and send alerts upon detection, with the built-in Discord [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/sqlisniper-enhancing-web-security-by-detecting-sql-injection-vulnerabilities-with-python/">SqliSniper – Enhancing Web Security By Detecting SQL Injection Vulnerabilities With Python</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>SqliSniper</strong> is a robust Python tool designed to detect time-based blind SQL injections in HTTP request headers.</p>
<p>It enhances the security assessment process by rapidly scanning and identifying potential vulnerabilities using multi-threaded, ensuring speed and efficiency.</p>
<p>Unlike other scanners, SqliSniper is designed to eliminates false positives through and send alerts upon detection, with the built-in Discord notification functionality.</p>
<h2 class="wp-block-heading"><strong>Key Features</strong></h2>
<ul>
<li><strong>Time-Based Blind SQL Injection Detection:</strong> Pinpoints potential SQL injection vulnerabilities in HTTP headers.</li>
<li><strong>Multi-Threaded Scanning:</strong> Offers faster scanning capabilities through concurrent processing.</li>
<li><strong>Discord Notifications:</strong> Sends alerts via Discord webhook for detected vulnerabilities.</li>
<li><strong>False Positive Checks:</strong> Implements response time analysis to differentiate between true positives and false alarms.</li>
<li><strong>Custom Payload and Headers Support:</strong> Allows users to define custom payloads and headers for targeted scanning.</li>
</ul>
<h2 class="wp-block-heading"><strong>Installation</strong></h2>
<pre class="wp-block-code"><code>git clone https://github.com/danialhalo/SqliSniper.git
cd SqliSniper
chmod +x sqlisniper.py
pip3 install -r requirements.txt</code></pre>
<h2 class="wp-block-heading"><strong>Usage</strong></h2>
<p>This will display help for the tool. Here are all the options it supports.</p>
<pre class="wp-block-code"><code>ubuntu:~/sqlisniper$ ./sqlisniper.py -h


███████╗ ██████╗ ██╗     ██╗    ███████╗███╗   ██╗██╗██████╗ ███████╗██████╗
██╔════╝██╔═══██╗██║     ██║    ██╔════╝████╗  ██║██║██╔══██╗██╔════╝██╔══██╗
███████╗██║   ██║██║     ██║    ███████╗██╔██╗ ██║██║██████╔╝█████╗  ██████╔╝
╚════██║██║▄▄ ██║██║     ██║    ╚════██║██║╚██╗██║██║██╔═══╝ ██╔══╝  ██╔══██╗
███████║╚██████╔╝███████╗██║    ███████║██║ ╚████║██║██║     ███████╗██║  ██║
╚══════╝ ╚══▀▀═╝ ╚══════╝╚═╝    ╚══════╝╚═╝  ╚═══╝╚═╝╚═╝     ╚══════╝╚═╝  ╚═╝

                            -: By Muhammad Danial :-

usage: sqlisniper.py [-h] [-u URL] [-r URLS_FILE] [-p] [--proxy PROXY] [--payload PAYLOAD] [--single-payload SINGLE_PAYLOAD] [--discord DISCORD] [--headers HEADERS]
                     [--threads THREADS]

Detect SQL injection by sending malicious queries

options:
  -h, --help            show this help message and exit
  -u URL, --url URL     Single URL for the target
  -r URLS_FILE, --urls_file URLS_FILE
                        File containing a list of URLs
  -p, --pipeline        Read from pipeline
  --proxy PROXY         Proxy for intercepting requests (e.g., http://127.0.0.1:8080)
  --payload PAYLOAD     File containing malicious payloads (default is payloads.txt)
  --single-payload SINGLE_PAYLOAD
                        Single payload for testing
  --discord DISCORD     Discord Webhook URL
  --headers HEADERS     File containing headers (default is headers.txt)
  --threads THREADS     Number of threads</code></pre>
<h2 class="wp-block-heading"><strong>Running SqliSniper</strong></h2>
<h3 class="wp-block-heading"><strong>Single Url Scan</strong></h3>
<p>The url can be provided with <code>-u flag</code> for single site scan</p>
<pre class="wp-block-code"><code>./sqlisniper.py -u http://example.com</code></pre>
<h3 class="wp-block-heading"><strong>File Input</strong></h3>
<p>The <code>-r flag</code> allows SqliSniper to read a file containing multiple URLs for simultaneous scanning.</p>
<pre class="wp-block-code"><code>./sqlisniper.py -r url.txt</code></pre>
<h3 class="wp-block-heading"><strong>Piping URLs</strong></h3>
<p>The SqliSniper can also worked with the pipeline input with <code>-p flag</code></p>
<pre class="wp-block-code"><code>cat url.txt | ./sqlisniper.py -p</code></pre>
<p>The pipeline feature facilitates seamless integration with other tools. For instance, you can utilize tools like subfinder and httpx, and then pipe their output to SqliSniper for mass scanning.</p>
<pre class="wp-block-code"><code>subfinder -silent -d google.com | sort -u | httpx -silent | ./sqlisniper.py -p</code></pre>
<h3 dir="auto" tabindex="-1">Scanning with custom payloads</h3>
<p dir="auto">By default the SqliSniper use the payloads.txt file. However <code>--payload flag</code> can be used for providing custom payloads file.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code>./sqlisniper.py -u http://example.com --payload mssql_payloads.txt</code></pre>
</div>
<p dir="auto">While using the custom payloads file, ensure that you substitute the sleep time with <code>%__TIME_OUT__%</code>. SqliSniper dynamically adjusts the sleep time iteratively to mitigate potential false positives. The payloads file should look like this.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code>ubuntu:~/sqlisniper$ cat payloads.txt 
0\"XOR(if(now()=sysdate(),sleep(%__TIME_OUT__%),0))XOR\"Z
"0"XOR(if(now()=sysdate()%2Csleep(%__TIME_OUT__%)%2C0))XOR"Z"
0'XOR(if(now()=sysdate(),sleep(%__TIME_OUT__%),0))XOR'Z</code></pre>
</div>
<h3 dir="auto" tabindex="-1">Scanning with Single Payloads</h3>
<p dir="auto">If you want to only test with the single payload <code>--single-payload flag</code> can be used. Make sure to replace the sleep time with <code>%__TIME_OUT__%</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code>./sqlisniper.py -r url.txt --single-payload "0'XOR(if(now()=sysdate(),sleep(%__TIME_OUT__%),0))XOR'Z"</code></pre>
</div>
<h3 dir="auto" tabindex="-1">Scanning Custom Header</h3>
<p dir="auto">Headers are saved in the file headers.txt for scanning custom header save the custom HTTP Request Header in headers.txt file.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code>ubuntu:~/sqlisniper$ cat headers.txt 
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
X-Forwarded-For: 127.0.0.1</code></pre>
</div>
<h3 dir="auto" tabindex="-1">Sending Discord Alert Notifications</h3>
<p dir="auto">SqliSniper also offers Discord alert notifications, enhancing its functionality by providing real-time alerts through Discord webhooks. This feature proves invaluable during large-scale scans, allowing prompt notifications upon detection.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code>./sqlisniper.py -r url.txt --discord &lt;web_hookurl&gt;
</code></pre>
</div>
<h3 dir="auto" tabindex="-1">Multi-Threading</h3>
<p dir="auto">Threads can be defined with <code>--threads flag</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto">
<pre class="notranslate"><code> ./sqlisniper.py -r url.txt --threads 10
</code></pre>
<div class="zeroclipboard-container"></div>
</div>
<p dir="auto"><strong>Note:</strong> It is crucial to consider that <strong>employing a higher number of threads might lead to potential false positives or overlooking valid issues</strong>. Due to the nature of time-based SQL injection it is recommended to use lower thread for more accurate detection.</p>
<hr />
<table style="width: 99.7078%; height: 6px;">
<tbody>
<tr>
<td>
<h2 dir="auto" tabindex="-1">Legal Disclaimer</h2>
</td>
</tr>
</tbody>
</table>
<p dir="auto">Usage of this tool for attacking targets without prior mutual consent is strictly prohibited. It is the end user&#8217;s responsibility to obey all applicable local, state, and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program.</p>
<p>The post <a href="http://kostacipo.stream/sqlisniper-enhancing-web-security-by-detecting-sql-injection-vulnerabilities-with-python/">SqliSniper – Enhancing Web Security By Detecting SQL Injection Vulnerabilities With Python</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/sqlisniper-enhancing-web-security-by-detecting-sql-injection-vulnerabilities-with-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Rose Grabber: Python-Powered Discord Token Logger</title>
		<link>http://kostacipo.stream/rose-grabber-python-powered-discord-token-logger/</link>
					<comments>http://kostacipo.stream/rose-grabber-python-powered-discord-token-logger/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 24 Nov 2023 00:15:08 +0000</pubDate>
				<category><![CDATA[Exploitation Tools]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Password Cracking]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://kostacipo.stream/?p=2160</guid>

					<description><![CDATA[<p>This tool is designed for educational purposes, aiming to showcase file vulnerabilities and promote proactive security measures. Rose Grabber emphasizes a didactic approach, highlighting the significance of strengthening data security and using technology ethically. Rose Grabber: Capture Discord Tokens With Reduced Detection Rates While this tool has a sophisticated mechanism that could exploit Discord Nitro [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/rose-grabber-python-powered-discord-token-logger/">Rose Grabber: Python-Powered Discord Token Logger</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="row">
<div class="col-lg-12">
<p>This tool is designed for educational purposes, aiming to showcase file vulnerabilities and promote proactive security measures. Rose Grabber emphasizes a didactic approach, highlighting the significance of strengthening data security and using technology ethically.</p>
<h2>Rose Grabber: Capture Discord Tokens With Reduced Detection Rates</h2>
<p>While this tool has a sophisticated mechanism that could exploit Discord Nitro privileges through compromised accounts, the author strongly urges you not to go down that path for personal gain. Remember, the purpose here is to teach and emphasize the importance of data security and ethical tech use. Stay safe and responsible!</p>
<figure class="wp-block-image size-large img-fluid text-center"><img decoding="async" class="wp-image-16586 lazyloaded" src="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1.png" sizes="(max-width: 744px) 100vw, 744px" srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1.png 744w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-300x210.png 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-100x70.png 100w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-276x193.png 276w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-444x310.png 444w" alt="" data-srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1.png 744w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-300x210.png 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-100x70.png 100w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-276x193.png 276w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1-444x310.png 444w" data-src="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber1.png" data-sizes="(max-width: 744px) 100vw, 744px" /></figure>
<h3 class="accent-green">Features:</h3>
<ol>
<li><strong>GUI Builder:</strong> Create user-friendly interfaces easily.</li>
<li><strong>Custom Icon:</strong> Set a unique icon for your application.</li>
<li><strong>Runs On Startup:</strong> Automatically start with Windows.</li>
<li><strong>Anti-VM:</strong> Detect and evade virtual machine environments.</li>
<li><strong>Melt Stub:</strong> Make the malware difficult to detect by self-destructing.</li>
<li><strong>Fake Error:</strong> Display fake error messages to deceive users.</li>
<li><strong>File Pumper:</strong> Inflate file sizes to hide malicious content.</li>
<li><strong>Discord Injection:</strong> Inject code into Discord processes.</li>
<li><strong>Steals Discord Tokens:</strong> Extract user tokens from Discord.</li>
<li><strong>Steals Passwords From Many Browsers:</strong> Extract stored passwords.</li>
<li><strong>Steals Cookies From Many Browsers:</strong> Collect browser cookies.</li>
<li><strong>Steals History From Many Browsers:</strong> Access browsing history.</li>
<li><strong>Steals Roblox Cookies:</strong> Gather Roblox-related data.</li>
<li><strong>Steals IP Information:</strong> Collect IP addresses.</li>
<li><strong>Steals System Info:</strong> Gather system-specific details.</li>
<li><strong>Steals Saved Wifi Passwords:</strong> Extract saved Wi-Fi passwords.</li>
<li><strong>Captures Screenshot:</strong> Take screenshots of the user’s desktop.</li>
<li><strong>Captures Webcam Image:</strong> Access and capture webcam images.</li>
<li><strong>Sends All Data Through Discord Webhook:</strong> Send stolen data to specified destinations.</li>
<li><strong>File Type Selection:</strong> Choose between screensaver or executable.</li>
<li><strong>Ransomware:</strong> Forces the victim to pay a specific amount in Monero or they will lose all their data. Decrypter can be found in components/tools.</li>
</ol>
</div>
<h2><img decoding="async" src="https://raw.githubusercontent.com/DamagingRose/Rose-Grabber/main/resources/assets/rosebb.png" alt="R" /></h2>
<div class="col-lg-12">
<h2 class="accent-purple">Installation:</h2>
<p>Click on the provided link to download the repository.</p>
<p>Unzip the downloaded ZIP folder to access its contents.</p>
<p>Since the current install script is not optimized and may not work properly, you need to install the requirements manually. Open a command prompt in the <code>components/scrapedata</code> directory and run this command:</p>
<pre class="wp-block-code"><code>pip uninstall crypto &amp;&amp; pip uninstall pycryptodome &amp;&amp; pip uninstall pycrypto &amp;&amp; pip install -r requiremens.txt.</code></pre>
<p>To run the program, simply double-click the start script (<code>start.bat</code>). This will initiate the builder after successfully installing the requirements.</p>
<figure class="wp-block-image size-large"><img decoding="async" class="wp-image-16583 lazyloaded" src="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1024x524.png" sizes="(max-width: 1024px) 100vw, 1024px" srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1024x524.png 1024w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-300x154.png 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-768x393.png 768w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1536x786.png 1536w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-350x179.png 350w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-500x256.png 500w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2.png 1969w" alt="" data-srcset="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1024x524.png 1024w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-300x154.png 300w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-768x393.png 768w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1536x786.png 1536w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-350x179.png 350w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-500x256.png 500w, https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2.png 1969w" data-src="https://cdn.cyberpunk.rs/wp-content/uploads/2023/10/rose-grabber2-1024x524.png" data-sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
<div class="row justify-content-center mb-3">
<div class="col-lg-4"><a href="https://github.com/DamagingRose/Rose-Grabber/blob/main/README.md">DOCUMENTATION</a>    <a href="https://github.com/DamagingRose/Rose-Grabber">DOWNLOAD</a></div>
</div>
</div>
</div>
<p>The post <a href="http://kostacipo.stream/rose-grabber-python-powered-discord-token-logger/">Rose Grabber: Python-Powered Discord Token Logger</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/rose-grabber-python-powered-discord-token-logger/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>16 Python Libraries to &#8216;pip&#8217; in 2020</title>
		<link>http://kostacipo.stream/16-python-libraries-to-pip-in-2020/</link>
					<comments>http://kostacipo.stream/16-python-libraries-to-pip-in-2020/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Mon, 20 Jan 2020 10:51:41 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1673</guid>

					<description><![CDATA[<p>&#160; In this article we will get familiar with several amazing Python libraries being used by the best software teams. With the exception of HTTPX (which is in beta), the libraries listed below are being actively developed &#38; maintained and are backed by a strong community. HTTPX HTTPX was developed by Tom Christine, who is [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/16-python-libraries-to-pip-in-2020/">16 Python Libraries to &#8216;pip&#8217; in 2020</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<div class="paragraph">In this article we will get familiar with several amazing Python libraries being used by the best software teams. With the exception of HTTPX (which is in beta), the libraries listed below are being actively developed &amp; maintained and are backed by a strong community.</div>
<h2>HTTPX</h2>
<div class="paragraph"><a href="https://github.com/encode/httpx">HTTPX</a> was developed by Tom Christine, who is a software engineer specialized in API design and development.</div>
<div>&nbsp;</div>
<div class="paragraph">The async paradigm is increasingly becoming more common in high-performance modern applications, but when you are using the async paradigm, the <a href="https://pypi.org/project/requests/">Requests </a>library cannot do its job very well.</div>
<div>&nbsp;</div>
<div class="paragraph">Therefore, HTTPX comes to solve this problem. HTTPX is an asynchronous HTTP client based on the well-established usability of <a href="https://pypi.org/project/requests/">Requests </a>and gives you HTTP/2 and HTTP/1.1 support. It gives you an API compatible with the Requests library as much as possible, and it has a tight control on the timeouts. HTTPX can also call directly into a Python web application using the ASGI protocol and it is fully type annotated. The library&nbsp; is also equipped with all the standard features of Requests, such as International Domains and URLs, Keep-Alive &amp; Connection Pooling, and Sessions with Cookie Persistence, etc.</div>
<div>&nbsp;</div>
<div class="paragraph">Moreover, you can use either asyncio or trio for HTTPX and apply this in high-performance async web frameworks. As a result HTTPX is able to handle a large numbers of requests.</div>
<h2>Arrow</h2>
<div class="paragraph">As many Python developers know, one way to work with date &amp; time objects is by using the uncompleted date, time, and timezone functions in the Python&#8217;s standard library and some other low-level modules. However, they don&#8217;t have high performance and good usability; for example, they have too many modules and types, which is hard for users to remember and distinguish. The conversions between timezones and timestamps are also long-winded.</div>
<div class="paragraph">Luckily, a sensible and human-friendly Python Library called <a href="https://github.com/crsmithdev/arrow">Arrow</a> can help users create, manipulate, format, and convert dates. It mainly aims to reduce your imports and code for dealing with dates and times.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">Arrow supports Python 2.7, 3.5, 3.6, 3.7 and 3.8, and broadly supports ISO 8601. Of course, it can do timezone conversion, and the timestamp is also a property in it.</div>
<div class="paragraph">Some features of Arrow can give you a clue of&nbsp; its capability. Arrow has a drop-in replacement for DateTime, and is Timezone-aware by default. Users will get easy-to-use creation options for many general input scenarios. The shift method is beneficial for relative offsets, such as offsets for weeks. It&#8217;s possible to automatically format and parse strings, which saves a lot of time. One more attractive feature is that Arrow can create periods, ranges, floors, and ceilings for time frames, ranging from microseconds to years.</div>
<h2>Python Fire</h2>
<div class="paragraph"><a href="https://github.com/google/python-fire">Python Fire</a> can automatically generate CLIs for any projects. The library makes the process of creating CLIs super simple. You only need to write the functionality at the command line as a function, module, or class, and once you call Fire, the CLI that you desire is ready for you.</div>
<div>&nbsp;</div>
<div class="paragraph">You probably want to test early on during the process of writing a Python library. Without Python Fire, you have to write a primary test method to run the functionality you desire to achieve. Although you can do the test in this way, you need to change the primary method whenever you have new features you want to test, updating the primary method again and again, which is time-consuming and annoying. Using Fire you don&#8217;t need to change your primary test method continuously when you test your command line.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">It is usually not super quick to understand a function by looking at its code, particularly when the function was written by someone else. A better way is to call Fire on the module. This feature allows you to easily inspect all module functions/methods.</div>
<div>&nbsp;</div>
<div class="paragraph">Moreover, Fire can let you transit directly between Bash and Python so that you can use the unix tools at the same time.&nbsp;</div>
<h2>Starlette</h2>
<div class="paragraph"><a href="https://www.starlette.io/">Starlette</a> is a lightweight ASGI framework or toolkit for building high-performance asyncio services.</div>
<div>&nbsp;</div>
<div class="paragraph">This production-ready library has many features, including support for WebSocket and GraphQL. Starlette can do in-process background tasks, CORS, GZip, Static Files and Streaming responses. All of these features have extensive test coverage and a code base that is 100% type annotated with zero hard dependencies.</div>
<div>&nbsp;</div>
<div class="paragraph">Starlette is meant to be used as a complete framework, or as an ASGI toolkit, providing users with the flexibility to apply any of the components independently. Moreover, reusable components can be shared between any ASGI framework, creating an ecosystem of shared middleware and mountable applications.</div>
<h2>Mypy</h2>
<div class="paragraph"><a href="https://github.com/python/mypy">Mypy</a> is an optimal static type checker for Python 3 and Python 2.7, and it is similar to a static analyzer, or a lint-like tool. By adding some typing annotations when you write your program, Mypy can help you type check your code and look for general bugs. Those annotations you leave in your code guide Mypy to do its job without interfering with your application because the annotations are viewed as comments that have no effects in the execution of your code.</div>
<div>&nbsp;</div>
<div class="paragraph">Mypy gives developers the flexibility to decide the workflow. The purpose of Mypy is to combine the advantages of dynamic typing and static typing in the applications. Therefore, users can use dynamic typing as a backup when static typing doesn&#8217;t work, such as for legacy code. When you run Mypy in your program like a linter, the errors will be reported in a compiler-style format. Mypy provides programmers with a robust and consistent check for a project and its dependencies.</div>
<div>&nbsp;</div>
<div class="paragraph">Another advantage of Mypy is its learning curve, which is minimal. Most new users of Mypy should be able to annotate the code correctly for the first time. Moreover, the <a href="https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html">Mypy cheat sheet</a> is a perfect start. One more advantage of Mypy is that It has a much lower false-positive rate compared to most static analyzers.</div>
<h2>FastAPI</h2>
<div class="paragraph"><a href="https://fastapi.tiangolo.com/">FastAPI</a> is a high-performance web framework for API development. FastAPI is based on standard Python type hints for Python 3.6+.</div>
<div class="paragraph">FastAPI comes with many interesting features, perhaps the most important one is speed since it is one of the fastest Python frameworks available. The speed of coding is also 200% faster compared to other frameworks.</div>
<div>&nbsp;</div>
<div class="paragraph">And if that wasn&#8217;t enough, FastAPI can help to keep a low bug rate and can even reduce human related errors by almost 40%. The framework is easy to learn and has an interactive documentation.</div>
<div>&nbsp;</div>
<div class="paragraph">FastAPI is based on open standards, for instance OpenAPI. It also comes with declarations of path operations, parameters, body requests, and security. Features for automatic client code generation in different languages are also available.</div>
<h2>Immutables</h2>
<div class="paragraph"><a href="https://github.com/magicstack/immutables">Immutables</a> is an immutable mapping type for Python. A Hash Array Mapped Trie (HAMT)&nbsp; used in Clojure, Scala, Haskell, and other functional languages.</div>
<div class="paragraph">Immutable mappings based on HAMT have O(log N) performance for both set() and get() operations, which is essentially O(1) for relatively small mappings.</div>
<h2>Expiring Dict</h2>
<div class="paragraph"><a href="https://github.com/mailgun/expiringdict">Expiring Dict</a> is a very handy Python caching library. It provides a dictionary with ordering and auto-expiring values for caching purposes. Dictionary elements have a TTL (max age) and max length, which are checked on each access.&nbsp;</div>
<h2>VCR.py</h2>
<div class="paragraph">Have you ever used Ruby&#8217;s VCR library? It records your test suite&#8217;s HTTP interactions and replays them during future test runs for fast, deterministic and accurate tests.</div>
<div>&nbsp;</div>
<div class="paragraph"><a href="https://github.com/kevin1024/vcrpy">VCR.py</a> is similar to Ruby&#8217;s VCR library. It makes the tests with HTTP requests more straightforward and quicker. If your code is in a VCR.py context manager or decorated function, when you run it VCR.py will record all the HTTP interactions during your tests. Then VCR.py will serialize and write the HTTP interactions to a cassette, which is a flat file. When you execute the recorded code it will replay the serialized requests and responses from the cassette file.</div>
<div>&nbsp;</div>
<div class="paragraph">This process has many benefits because the requests will not generate any HTTP traffic. Therefore, VCR.py can do its job offline, help to generate deterministic tests as well as significantly increase their execution speed.</div>
<div>&nbsp;</div>
<div class="paragraph">When you make changes to your tests all you need to do is to delete the cassette file. Then when you re-run the code, VCR.py will record again the HTTP interactions and generate a new cassette.</div>
<h2>Transformers</h2>
<div class="paragraph"><a href="https://github.com/huggingface/transformers">Transformers </a>(former pytorch-transformers and pytorch-pretrained-bert) provides Natural Language Understanding (NLU) and Natural Language Generation (NLG) with more than 32 prepared models in over 100 languages and deep interoperability between TensorFlow 2.0 and PyTorch. Those architectures generally are BERT, GPT-2, RoBERTa, XLM, DistilBert, XLNet, and others.</div>
<div>&nbsp;</div>
<div class="paragraph">Transformers is an easy-to-use library with no barriers to get familiar with. It is even more powerful and concise than <a href="https://keras.io/">Keras</a>, with the added benefit that it has extraordinary high performance when dealing with NLU and NLG projects.</div>
<div>&nbsp;</div>
<div class="paragraph">The goal of Transformers is to become the state-of-the-art NLP for everyone. No matter if you are a deep learning researcher, hands-on practitioner, or AI/ML/NLP teacher and educator, you can get a lot of support from Transformers.&nbsp; The library is very efficient as it reduces the compute costs. For example, you can share your trained models with your colleagues so that they do not need to spend extra efforts retraining models. It comes with more than 30 preset models, and over 100 languages which can save a lot of time on computing and thus help to reduce production costs.</div>
<div>&nbsp;</div>
<div class="paragraph">Lastly, Transformers can use the most suitable framework for each part of your applications over time. Specifically, Transformers can use only three lines of code to train a state-of-the-art system for you. The deep interoperability between TensorFlow 2.0 and PyTorch models is an added benefit.&nbsp;</div>
<h2>Modin</h2>
<div class="paragraph">If you are a data scientist you are probably familiar with the Pandas library. <a href="https://github.com/modin-project/modin">Modin</a> can scale your Pandas workflows by changing only one line of code. Sounds great, right?&nbsp;</div>
<div class="paragraph">Before proving more details on Modin we first need to introduce <a href="https://github.com/ray-project/ray">Ray</a>, which is the key to how Modin works. Ray is a fast and accessible framework for building and running distributed applications. Ray is packaged with Tune, RLlib, and Distributed Training.</div>
<div>&nbsp;</div>
<div class="paragraph">The relationship between Modin and Ray is that Modin uses Ray to speed up the Pandas notebook, scripts, and libraries in an effortless way. A weakness of other distributed DataFrame libraries is the regular conflicts among Pandas code. Modin can solve this problem by integrating the Pandas code seamlessly.</div>
<div>&nbsp;</div>
<div class="paragraph">Using Modin, you do not need to know details about the cores of your system and the distribution of the data. You do not need to abandon the Pandas notebooks you previously used to take advantage of the enormous acceleration provided by Modin.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">Moreover, the modin.pandas is an extremely lightweight parallel DataFrame. After you install Modin, there is no need to stop using the previous Pandas API because Modin can do transparent distribution of the data and computation.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">Sometimes, when facing different data sizes it may be difficult to scale 1KB DataFrames to 1TB, there is often a significant overhead. With Modin, you can directly get DataFrames at both 1KB and 1TB.</div>
<h2>Dash</h2>
<div class="paragraph">If you are building web apps with complex or large datasets, <a href="https://github.com/plotly/dash">Dash</a> might be for you. Dash is very suitable for visualizing data and it also provides apps with customized user interfaces in pure Python.</div>
<div>&nbsp;</div>
<div class="paragraph">Dash can even help you to build user interfaces with Python code in a short amount of time. Dash replaces many of the tools and technologies used for building an interactive web application and it does its job in a simple way.</div>
<h2>Detectron 2</h2>
<div class="paragraph">Detectron is an object detection platform. It is one of the open-source projects adopted by the Facebook AI Research group.</div>
<div>&nbsp;</div>
<div class="paragraph"><a href="https://github.com/facebookresearch/detectron2">Detectron 2</a> is the second generation of this library with many performance enhancements. The library is flexible and extensible and makes training on GPU servers a very quick process. It also comes with state-of-the-art object detection algorithms, allowing developers to do advanced research without the whole complete dataset.</div>
<div>&nbsp;</div>
<div class="paragraph">Detectron 2 was rewritten from Scratch in PyTorch, which is a great tool for deep learning. The vast and active community behind PyTorch is an added benefit for Detectron2 users.</div>
<div>&nbsp;</div>
<div class="paragraph">With Detectron2, users can insert their customized code into the object detection system as they see fit. Under this situation, hundreds of lines of code can successfully develop a new research project, and the core Detectron2 and the brand-new research achievement can be divided clearly. Moreover, Detectron2 also supports semantic segmentation and panoptic segmentation.</div>
<div>&nbsp;</div>
<div class="paragraph">The reason why Detectron2 is faster than the original version is due to moving the entire training pipeline to GPU. Distributing the training to different GPU servers makes the scaling process of large data sets much easier.</div>
<h2>Streamlit</h2>
<div class="paragraph"><a href="https://github.com/streamlit/streamlit">Streamlit</a> is a library that can provide you with the fastest way to build custom Machine Learning tools.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">The library embraces Python scripting resulting in clean code and fast prototyping. Each change in the Python code directly reruns the code from top to bottom. The cache primitive in Streamlit is consistent, immutable-by-default so users can reuse the information effortlessly.</div>
<h2>Imbalanced-learn</h2>
<div class="paragraph"><a href="https://github.com/scikit-learn-contrib/imbalanced-learn">Imbalanced-learn</a> offers many re-sampling techniques for machine learning projects. This python library is widely used in datasets to show a robust between-class imbalance.</div>
<div>&nbsp;</div>
<div class="paragraph">Imbalanced-learn is compatible with scikit-learn. Scikit-learn is a simple and efficient tool for predictive data analysis. It is built on NumPy, SciPy,and matplotlib. It is open source and very reusable. The library is available for Python 3.6+.</div>
<h2>PyTorch</h2>
<div class="paragraph"><a href="https://github.com/pytorch/pytorch">PyTorch</a> offers rapid prototyping for dynamic neural networks and&nbsp;strong GPU support.</div>
<div>&nbsp;</div>
<div class="paragraph">The compositions of PyTorch are torch, torch.autograd, torch.jit, torch.nn, torch.multiprocessing, and torch.utils. Component torch is a NumPy like Tensor library, which has the strong GPU support.&nbsp; Torch.autograd is a tape-based automatic differentiation library that is accessible to all various Tensor operations in torch. Torch.jit can work as a compilation stack to create serializable and ideal models. Troch.nn is aggregated with autograd as a neural network aiming for maximum flexibility. Torch.multiprocessing is useful for data loading and Hogwild training.</div>
<div>&nbsp;</div>
<div class="paragraph">Lastly, torch.utils has a data loader and other utility functions for convenience.</div>
<p>The post <a href="http://kostacipo.stream/16-python-libraries-to-pip-in-2020/">16 Python Libraries to &#8216;pip&#8217; in 2020</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/16-python-libraries-to-pip-in-2020/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Build a Chatbot Project Using Python</title>
		<link>http://kostacipo.stream/how-to-build-a-chatbot-project-using-python/</link>
					<comments>http://kostacipo.stream/how-to-build-a-chatbot-project-using-python/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 17 Jan 2020 10:57:01 +0000</pubDate>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1663</guid>

					<description><![CDATA[<p>&#160; Chatbots are extremely helpful for business organizations and also the customers. The majority of people prefer to talk directly from a chatbox instead of calling service centers. &#160; Facebook released data that proved the value of bots. More than 2 billion messages are sent between people and companies monthly. The HubSpot research tells that [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/how-to-build-a-chatbot-project-using-python/">How To Build a Chatbot Project Using Python</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<div class="paragraph">Chatbots are extremely helpful for business organizations and also the customers. The majority of people prefer to talk directly from a chatbox instead of calling service centers.</div>
<div>&nbsp;</div>
<div class="paragraph">Facebook released data that proved the value of bots. More than 2 billion messages are sent between people and companies monthly. The HubSpot research tells that 71% of the people want to get customer support from messaging apps. It is a quick way to get their problems solved so chatbots have a bright future in organizations.</div>
<div>&nbsp;</div>
<div class="paragraph">Today we are going to build an exciting project on Chatbot. We will implement a chatbot from scratch that will be able to understand what the user is talking about and give an appropriate response.</div>
<div>&nbsp;</div>
<div class="paragraph"><strong>Prerequisites</strong></div>
<div>&nbsp;</div>
<div class="paragraph">To implement the chatbot we will be using Keras which is a Deep Learning library, NLTK which is a Natural Language Processing Toolkit and some helpful libraries. Run the below command to make sure all the libraries are installed</div>
<div class="code-container">
<pre><code>pip install tensorflow keras pickle nltk&nbsp;</code></pre>
</div>
<div class="paragraph">Python Cheat Sheet &#8211;&nbsp;<a href="https://sites.google.com/view/learn-python-data-science/home"><strong><em>Master guide to learn Python for free</em></strong></a>.&nbsp;</div>
<h2>How do Chatbots work?</h2>
<div class="paragraph">Chatbots are nothing but an intelligent piece of software that can interact and communicate with people just like humans. Interesting isn’t it! So now let us understand how they actually work.&nbsp;All the chatbot comes under the NLP (Natural Language Processing) concepts. NLP is composed of two things:&nbsp;</div>
<ol>
<li><strong>NLU (Natural Language Understanding):</strong> The ability of machines to understand human language like English.</li>
<li><strong>NLG (Natural Language Generation):</strong> The ability of a machine to generate text similar to human written sentences.</li>
</ol>
<div class="paragraph">Image a user asking a question to a chatbot “Hey, What’s on the news today? ”&nbsp;The chatbot will break down the user sentence into two things: Intent and an Entity. The intent for this sentence could be get_news as it refers to an action the user wants to perform. The entity tells specific details about the intent, so here ‘today’ will be the entity. So this way a machine learning model is used to recognize the intents and entities of the chat.</div>
<h2>Project file structure&nbsp;</h2>
<div class="paragraph">After the project is complete, you will be left with all these files. Lets quickly go through each of them, it will give you an idea of how the project will be implemented.&nbsp;</div>
<ol>
<li><strong>Train_chatbot.py &#8211;</strong>&nbsp;In this file, we will build and train the deep learning model that can classify and identify what the user is asking to the bot.</li>
<li><strong>Gui_Chatbot.py &#8211;</strong>&nbsp;This file is where we will build a graphical user interface to chat with our trained chatbot.</li>
<li><strong>Intents.json &#8211;</strong>&nbsp;The intents file has all the data that we will use to train the model. It contains a collection of tags with their corresponding patterns and responses.</li>
<li><strong>Chatbot_model.h5 &#8211;</strong>&nbsp;This is a hierarchical data format file in which we have stored the weights and the architecture of our trained model.</li>
<li><strong>Classes.pkl &#8211;</strong> The pickle file can be used to store all the tag names to classify when we are predicting the message.</li>
<li><strong>Words.pkl &#8211;</strong> The words.pkl pickle file contains all the unique words that are the vocabulary of our model.</li>
</ol>
<div class="paragraph"><a href="https://drive.google.com/drive/folders/1r6MrrdE8V0bWBxndGfJxJ4Om62dJ2OMP?usp=sharing"><em>Download the source code and the dataset</em></a></div>
<h2>How to build your own chatbot?</h2>
<div class="paragraph">The building of this chatbot is simplified in 5 steps:</div>
<div>&nbsp;</div>
<div class="paragraph"><strong>Step 1.&nbsp; Import libraries and load the data</strong>&nbsp;&#8211;&nbsp;Create a new python file and name it as train_chatbot and then we are going to import all the required modules. After that, we will read the JSON data file in our python program.&nbsp;</div>
<div class="code-container">
<pre><code>import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Activation, Dropout
from keras.optimizers import SGD
import random
import nltk
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
import json
import pickle
intents_file = open('intents.json').read()
intents = json.loads(intents_file)</code></pre>
</div>
<div class="paragraph">Here’s how our intents file looks like.</div>
<div>&nbsp;</div>
<div class="image-container"><img decoding="async" src="https://hackernoon.com/photos/1nWBP7HnklXk2egeiTHTBjYAe6G2-nq6c30pk" alt=""></div>
<div>&nbsp;</div>
<div class="paragraph"><strong>Step 2. Preprocessing the data</strong></div>
<div>&nbsp;</div>
<div class="paragraph">The model cannot take the raw data. It has to go through a lot of pre-processing for machine to easily understand. For a textual data, there are many preprocessing techniques available. The first technique is Tokenizing in which we break the sentences into words.&nbsp;&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">By observing the intents file we can see that each tag contains a list of patterns and responses. We tokenize each pattern and add the words in a list. Also, we create a list of classes and documents to add all the intents associated with patterns.&nbsp;</div>
<div class="code-container">
<pre><code>words=[]
classes = []
documents = []
ignore_letters = ['!', '?', ',', '.']
for intent in intents['intents']:
&nbsp;&nbsp;&nbsp;&nbsp;for pattern in intent['patterns']:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#tokenize each word
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;word = nltk.word_tokenize(pattern)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;words.extend(word)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#add documents in the corpus
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;documents.append((word, intent['tag']))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# add to our classes list
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if intent['tag'] not in classes:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classes.append(intent['tag'])
print(documents)</code></pre>
</div>
<div class="paragraph">Another technique is the Lemmatization. We can convert words into the lemma form so that we can reduce all the canonical words. For example, the words play, playing, plays, played, etc will all be replaced with play. This way we can reduce the number of total words in our vocabulary. So now we lemmatize each word and remove the duplicate words.&nbsp;</div>
<div class="code-container">
<pre><code># lemmaztize and lower each word and remove duplicates
words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in ignore_letters]
words = sorted(list(set(words)))
# sort classes
classes = sorted(list(set(classes)))
# documents = combination between patterns and intents
print (len(documents), "documents")
# classes = intents
print (len(classes), "classes", classes)
# words = all words, vocabulary
print (len(words), "unique lemmatized words", words)
pickle.dump(words,open('words.pkl','wb'))
pickle.dump(classes,open('classes.pkl','wb'))</code></pre>
</div>
<div class="paragraph">In the end, the words contain the vocabulary of our project and classes contain the total entities to classify. To save the python object in a file we used the <strong>pickle.dump()</strong> method. These files will be helpful after the training is done and we predict the chats.</div>
<div>&nbsp;</div>
<div class="paragraph"><strong>Step 3. Create training and testing data</strong></div>
<div>&nbsp;</div>
<div class="paragraph">To train the model we will convert each input pattern into numbers. First, we will lemmatize each word of the pattern and create a list of zeroes of the same length as the total number of words. We will set value 1 to only those index that contains the word in the patterns. Same way we will create the output by setting 1 to the class input pattern belongs to.&nbsp;</div>
<div class="code-container">
<pre><code># create the training data
training = []
# create empty array for the output
output_empty = [0] * len(classes)
# training set, bag of words for every sentence
for doc in documents:
&nbsp;&nbsp;&nbsp;&nbsp;# initializing bag of words
&nbsp;&nbsp;&nbsp;&nbsp;bag = []
&nbsp;&nbsp;&nbsp;&nbsp;# list of tokenized words for the pattern
&nbsp;&nbsp;&nbsp;&nbsp;word_patterns = doc[0]
&nbsp;&nbsp;&nbsp;&nbsp;# lemmatize each word - create base word, in attempt to represent related words
&nbsp;&nbsp;&nbsp;&nbsp;word_patterns = [lemmatizer.lemmatize(word.lower()) for word in word_patterns]
&nbsp;&nbsp;&nbsp;&nbsp;# create the bag of words array with 1, if word is found in current pattern
&nbsp;&nbsp;&nbsp;&nbsp;for word in words:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bag.append(1) if word in word_patterns else bag.append(0)
&nbsp;&nbsp;&nbsp;&nbsp;# output is a '0' for each tag and '1' for current tag (for each pattern)
&nbsp;&nbsp;&nbsp;&nbsp;output_row = list(output_empty)
&nbsp;&nbsp;&nbsp;&nbsp;output_row[classes.index(doc[1])] = 1
&nbsp;&nbsp;&nbsp;&nbsp;training.append([bag, output_row])
# shuffle the features and make numpy array
random.shuffle(training)
training = np.array(training)
# create training and testing lists. X - patterns, Y - intents
train_x = list(training[:,0])
train_y = list(training[:,1])
print("Training data is created")</code></pre>
</div>
<div class="paragraph"><strong>Step 4. Training the model&nbsp;</strong></div>
<div>&nbsp;</div>
<div class="paragraph">The architecture of our model will be a neural network consisting of 3 Dense layers. The first layer has 128 neurons, second one has 64 and the last layer will have the same neurons as the number of classes. The dropout layers are introduced to reduce overfitting of the model. We have used SGD optimizer and fit the data to start training of the model. After the training of 200 epochs is completed we then save the trained model using Keras model.save(“chatbot_model.h5”) function.&nbsp;</div>
<div class="code-container">
<pre><code># deep neural networds model
model = Sequential()
model.add(Dense(128, input_shape=(len(train_x[0]),), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(len(train_y[0]), activation='softmax'))
# Compiling model. SGD with Nesterov accelerated gradient gives good results for this model
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])
#Training and saving the model&nbsp;
hist = model.fit(np.array(train_x), np.array(train_y), epochs=200, batch_size=5, verbose=1)
model.save('chatbot_model.h5', hist)
print("model is created")</code></pre>
</div>
<div class="paragraph"><strong>Step 5. Interacting with the chatbot</strong></div>
<div>&nbsp;</div>
<div class="paragraph">Our model is ready to chat so now let’s create a nice graphical user interface for our chatbot in a new file. You can name the file as gui_chatbot.py</div>
<div>&nbsp;</div>
<div class="paragraph">In our GUI file, we will be using the Tkinter module to build the structure of the desktop application and then we will capture the user message and again perform some preprocessing before we input the message into our trained model.</div>
<div>&nbsp;</div>
<div class="paragraph">The model will then predict the tag of the user’s message and we will randomly select the response from the list of responses in our intents file.&nbsp;</div>
<div>&nbsp;</div>
<div class="paragraph">Here’s the full source code for the GUI file.&nbsp;</div>
<div class="code-container">
<pre><code>import nltk
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
import pickle
import numpy as np
from keras.models import load_model
model = load_model('chatbot_model.h5')
import json
import random
intents = json.loads(open('intents.json').read())
words = pickle.load(open('words.pkl','rb'))
classes = pickle.load(open('classes.pkl','rb'))
<span class="hljs-function">def clean_up_sentence(sentence):</span>
&nbsp;&nbsp;&nbsp;&nbsp;# tokenize the pattern - splitting words into array
&nbsp;&nbsp;&nbsp;&nbsp;sentence_words = nltk.word_tokenize(sentence)
&nbsp;&nbsp;&nbsp;&nbsp;# stemming every word - reducing to base form
&nbsp;&nbsp;&nbsp;&nbsp;sentence_words = [lemmatizer.lemmatize(word.lower()) for word in sentence_words]
&nbsp;&nbsp;&nbsp;&nbsp;return sentence_words
# return bag of words array: 0 or 1 for words that exist in sentence
<span class="hljs-function">def bag_of_words(sentence, words, show_details=True):</span>
&nbsp;&nbsp;&nbsp;&nbsp;# tokenizing patterns
&nbsp;&nbsp;&nbsp;&nbsp;sentence_words = clean_up_sentence(sentence)
&nbsp;&nbsp;&nbsp;&nbsp;# bag of words - vocabulary matrix
&nbsp;&nbsp;&nbsp;&nbsp;bag = [0]*len(words)&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;for s in sentence_words:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for i,word in enumerate(words):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if word == s:&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# assign 1 if current word is in the vocabulary position
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bag[i] = 1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if show_details:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print ("found in bag: %s" % word)
&nbsp;&nbsp;&nbsp;&nbsp;return(np.array(bag))
<span class="hljs-function">def predict_class(sentence):</span>
&nbsp;&nbsp;&nbsp;&nbsp;# filter below&nbsp; threshold predictions
&nbsp;&nbsp;&nbsp;&nbsp;p = bag_of_words(sentence, words,show_details=False)
&nbsp;&nbsp;&nbsp;&nbsp;res = model.predict(np.array([p]))[0]
&nbsp;&nbsp;&nbsp;&nbsp;ERROR_THRESHOLD = 0.25
&nbsp;&nbsp;&nbsp;&nbsp;results = [[i,r] for i,r in enumerate(res) if r&gt;ERROR_THRESHOLD]
&nbsp;&nbsp;&nbsp;&nbsp;# sorting strength probability
&nbsp;&nbsp;&nbsp;&nbsp;results.sort(key=lambda x: x[1], reverse=True)
&nbsp;&nbsp;&nbsp;&nbsp;return_list = []
&nbsp;&nbsp;&nbsp;&nbsp;for r in results:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return_list.append({"intent": classes[r[0]], "probability": str(r[1])})
&nbsp;&nbsp;&nbsp;&nbsp;return return_list
<span class="hljs-function">def getResponse(ints, intents_json):</span>
&nbsp;&nbsp;&nbsp;&nbsp;tag = ints[0]['intent']
&nbsp;&nbsp;&nbsp;&nbsp;list_of_intents = intents_json['intents']
&nbsp;&nbsp;&nbsp;&nbsp;for i in list_of_intents:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(i['tag']== tag):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = random.choice(i['responses'])
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break
&nbsp;&nbsp;&nbsp;&nbsp;return result
#Creating tkinter GUI
import tkinter
from tkinter import *
<span class="hljs-function">def send():</span>
&nbsp;&nbsp;&nbsp;&nbsp;msg = EntryBox.get("1.0",'end-1c').strip()
&nbsp;&nbsp;&nbsp;&nbsp;EntryBox.delete("0.0",END)
&nbsp;&nbsp;&nbsp;&nbsp;if msg != '':
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.config(state=NORMAL)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.insert(END, "You: " + msg + '\n\n')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.config(foreground="#446665", font=("Verdana", 12 ))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ints = predict_class(msg)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res = getResponse(ints, intents)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.insert(END, "Bot: " + res + '\n\n')
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.config(state=DISABLED)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChatBox.yview(END)
root = Tk()
root.title("Chatbot")
root.geometry("400x500")
root.resizable(width=FALSE, height=FALSE)
#Create Chat window
ChatBox = Text(root, bd=0, bg="white", height="8", width="50", font="Arial",)
ChatBox.config(state=DISABLED)
#Bind scrollbar to Chat window
scrollbar = Scrollbar(root, command=ChatBox.yview, cursor="heart")
ChatBox['yscrollcommand'] = scrollbar.set
#Create Button to send message
SendButton = Button(root, font=("Verdana",12,'bold'), text="Send", width="12", height=5,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bd=0, bg="#f9a602", activebackground="#3c9d9b",fg='#000000',
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command= send )
#Create the box to enter message
EntryBox = Text(root, bd=0, bg="white",width="29", height="5", font="Arial")
#EntryBox.bind("&lt;Return&gt;", send)
#Place all components on the screen
scrollbar.place(x=376,y=6, height=386)
ChatBox.place(x=6,y=6, height=386, width=370)
EntryBox.place(x=128, y=401, height=90, width=265)
SendButton.place(x=6, y=401, height=90)
root.mainloop()</code></pre>
</div>
<h2><strong>Running the chatbot</strong></h2>
<div class="paragraph">Now we have two separate files, one is the train_chatbot.py which we will use first to train the model.&nbsp;</div>
<div class="code-container">
<pre><code>python train_chatbot.py</code></pre>
</div>
<p>The post <a href="http://kostacipo.stream/how-to-build-a-chatbot-project-using-python/">How To Build a Chatbot Project Using Python</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/how-to-build-a-chatbot-project-using-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Testing REST APIs easily in Python with pyhttptest</title>
		<link>http://kostacipo.stream/testing-rest-apis-easily-in-python-with-pyhttptest/</link>
					<comments>http://kostacipo.stream/testing-rest-apis-easily-in-python-with-pyhttptest/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 24 Dec 2019 12:31:05 +0000</pubDate>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1527</guid>

					<description><![CDATA[<p>&#160; Nowadays every one of us is facing REST APIs by either developing or consuming such a service. Also, we’re in the trendy era of microservices, where we splitting our business logic into small separate services independent from each one. Mostly these services follow RESTful principles and using the JSON format for communication, which became [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/testing-rest-apis-easily-in-python-with-pyhttptest/">Testing REST APIs easily in Python with pyhttptest</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<div class="paragraph">Nowadays every one of us is facing REST APIs by either developing or consuming such a service. Also, we’re in the trendy era of microservices, where we splitting our business logic into small separate services independent from each one. Mostly these services follow RESTful principles and using the JSON format for communication, which became the most widely used format, because of its simplicity.</p>
</div>
<div class="paragraph"><a href="https://github.com/slaily/pyhttptest"><strong>pyhttptest</strong></a> &#8211; A command-line tool for HTTP tests over RESTful APIs&nbsp;</div>
<div class="paragraph">This tool automate testing in a simple three steps.</p>
</div>
<div class="paragraph"><strong>1. Install the package</strong></div>
<div class="code-container">
<pre><code>pip install pyhttptest</code></pre>
</div>
<div class="paragraph"><strong>2. Describe your HTTP Requests test cases against your API service in a simplest and widely used format JSON within a file.</strong></div>
<h5 class="paragraph"><strong>Single test case definition examples</strong>&nbsp;</h5>
<p>To send an HTTP GET Request:</p>
<p>Create a JSON file, for example, data/test_server_status.json</p>
<div class="code-container">
<pre><code>{
  <span class="hljs-attr">"name"</span>: "TEST: Get server status",
  <span class="hljs-attr">"verb"</span>: "GET",
  <span class="hljs-attr">"endpoint"</span>: "/get",
  <span class="hljs-attr">"host"</span>: "https://httpbin.org",
  <span class="hljs-attr">"headers"</span>: {
    <span class="hljs-attr">"Accept-Language"</span>: "en-US"
  }
}
</code></pre>
</div>
<p>To send an HTTP POST Request:</p>
<p>Create a JSON file, for example, data/test_create_html_bin.json</p>
<div class="code-container">
<pre><code>{
  <span class="hljs-attr">"name"</span>: "TEST: Create an HTML bin",
  <span class="hljs-attr">"verb"</span>: "POST",
  <span class="hljs-attr">"endpoint"</span>: "post",
  <span class="hljs-attr">"host"</span>: "https://httpbin.org",
  <span class="hljs-attr">"payload"</span>: {
    <span class="hljs-attr">"content"</span>: "Hello, world!"
  }
}
</code></pre>
</div>
<div class="paragraph"><strong>Multiple test cases definition example</strong></div>
<ul>
<li>Create a JSON file, for example, data/requests.json</li>
</ul>
<div class="code-container">
<pre><code>[
  {
    <span class="hljs-attr">"name"</span>: "TEST: List all users",
    <span class="hljs-attr">"verb"</span>: "GET",
    <span class="hljs-attr">"endpoint"</span>: "api/v1/users",
    <span class="hljs-attr">"host"</span>: "http://localhost:8085/",
    <span class="hljs-attr">"headers"</span>: {
      <span class="hljs-attr">"Accept-Language"</span>: "en-US"
    },
    <span class="hljs-attr">"query_string"</span>: {
      <span class="hljs-attr">"limit"</span>: 1
    }
  },
  {
    <span class="hljs-attr">"name"</span>: "TEST: Add a new user",
    <span class="hljs-attr">"verb"</span>: "POST",
    <span class="hljs-attr">"endpoint"</span>: "api/v1/users",
    <span class="hljs-attr">"host"</span>: "http://localhost:8085/",
    <span class="hljs-attr">"payload"</span>: {
      <span class="hljs-attr">"username"</span>: "pyhttptest",
      <span class="hljs-attr">"email"</span>: "admin@pyhttptest.com"
    }
  },
  {
    <span class="hljs-attr">"name"</span>: "TEST: Modify an existing user",
    <span class="hljs-attr">"verb"</span>: "PUT",
    <span class="hljs-attr">"endpoint"</span>: "api/v1/users/XeEsscGqweEttXsgY",
    <span class="hljs-attr">"host"</span>: "http://localhost:8085/",
    <span class="hljs-attr">"payload"</span>: {
      <span class="hljs-attr">"username"</span>: "pyhttptest"
    }
  },
  {
    <span class="hljs-attr">"name"</span>: "TEST: Delete an existing user",
    <span class="hljs-attr">"verb"</span>: "DELETE",
    <span class="hljs-attr">"endpoint"</span>: "api/v1/users/XeEsscGqweEttXsgY",
    <span class="hljs-attr">"host"</span>: "http://localhost:8085/"
  }
]
</code></pre>
</div>
<div class="paragraph"><strong>3. Run command and gain report</strong></div>
<div class="code-container">
<pre><code>pyhttptest execute data/test_server_status.json</code></pre>
</div>
<div class="paragraph">The report from the single test case</div>
<div class="image-container"><img decoding="async" src="https://hackernoon.com/photos/yiScHMLD3KMMgF6nwvdcdTcgDdP2-4ha32tw" alt=""></div>
<div class="code-container">
<pre><code>pyhttptest execute data/requests.json</code></pre>
</div>
<div class="paragraph">The report from the multiple test cases</div>
<div class="image-container"><img decoding="async" src="https://hackernoon.com/photos/yiScHMLD3KMMgF6nwvdcdTcgDdP2-hc1r2324k" alt=""></div>
<div class="paragraph">The properties, which you can pass to a json file are:</div>
<ul>
<li>name &#8211; The name of the test case.</li>
<li>verb &#8211; An HTTP Method.</li>
<li>endpoint &#8211; The resource you want to invoke on the server.</li>
<li>host &#8211; Server host address.</li>
<li>headers &#8211; An HTTP Headers. All HTTP header <a href="https://en.wikipedia.org/wiki/List_of_HTTP_header_fields">fields</a> are supported.</li>
<li>query_string &#8211; Query string parameters in the URL after the question mark.</li>
<li>payload &#8211; The data.</li>
</ul>
<div class="paragraph"><strong>Best practices</strong></div>
<div class="paragraph">One question may arise in your mind, how to add, structure and organize the test cases into my existing/new project. Every Python project, which has tests contains in his project directory a folder namely</p>
<pre><code>tests/</code></pre>
<p>From this directory by convention, great frameworks like</p></div>
<div class="paragraph">
<pre><code>unittest</code></pre>
<p>and</p>
<pre><code>pytest</code></pre>
<p>discover and execute defined test cases in Python scripts. To not mess up with these tests and break the conventions, I suggest creating a new directory in your project root directory named</p>
<pre><code>live_tests/</code></pre>
<p>Inside the new directory, you can put all .</p></div>
<div class="paragraph">
<pre><code>json</code></pre>
<p>files with defined test cases for the API. By doing this your tests will be easily distinguished. But it’s really up to you!</p></div>
<p>The post <a href="http://kostacipo.stream/testing-rest-apis-easily-in-python-with-pyhttptest/">Testing REST APIs easily in Python with pyhttptest</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/testing-rest-apis-easily-in-python-with-pyhttptest/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>10 Python Tips and Tricks You Should Learn Today</title>
		<link>http://kostacipo.stream/10-python-tips-and-tricks-you-should-learn-today/</link>
					<comments>http://kostacipo.stream/10-python-tips-and-tricks-you-should-learn-today/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 03 Dec 2019 10:13:56 +0000</pubDate>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripts]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1413</guid>

					<description><![CDATA[<p>&#160; Python snippets that can be taken as a reference for your daily work According to Stack Overflow, Python is the fastest growing programming language. The latest report from Forbes states that Python showed a 456-percent growth in last year. Netflix uses Python, IBM uses Python, and hundreds of other companies all use Python. Let’s [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/10-python-tips-and-tricks-you-should-learn-today/">10 Python Tips and Tricks You Should Learn Today</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<blockquote>
<p class="aq ef gc gd av"><em><span style="font-size: 10pt;">Python snippets that can be taken as a reference for your daily work</span></em></p>
</blockquote>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<p id="9c0b" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">According to Stack Overflow, Python is the fastest growing programming language. The latest <a class="bo dd im in io ip" href="https://www.whatech.com/development/press-release/442278-why-developers-vote-python-as-the-best-application-programming-language" target="_blank" rel="noopener nofollow noreferrer">report from Forbes</a> states that Python showed a 456-percent growth in last year. Netflix uses Python, IBM uses Python, and hundreds of other companies all use Python. Let’s not forget Dropbox. Dropbox is also created in Python. According to <a class="bo dd im in io ip" href="https://insights.dice.com/2016/02/01/whats-hot-and-not-in-tech-skills/" target="_blank" rel="noopener nofollow noreferrer">research by Dice</a> Python is also one of the hottest skills to have and also the most popular programming language in the world based on the <a class="bo dd im in io ip" href="https://pypl.github.io/PYPL.html" target="_blank" rel="noopener nofollow noreferrer">Popularity of Programming Language Index</a>.</p>
<p id="8af1" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph=""><strong>Some of the advantages Python</strong> offers when compared to other programming languages are:</p>
<ol>
<li>&#8211; Compatible with major platforms and operating systems</li>
<li>&#8211; Many open-source frameworks and tools</li>
<li>&#8211; Readable and maintainable code</li>
<li>&#8211; Robust standard library</li>
<li>&#8211; Standard test-driven development</li>
</ol>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4>&nbsp;</h4>
<h4 id="f9d1" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">Python Tips and Tricks</h4>
<p id="f321" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">In this piece, We’ll present 10 useful code tips and tricks that can help you in your day-to-day tasks. So without further ado, let’s get started.</p>
<h4 id="5217" class="ju jv cn ar aq jw jx kn jz ko kb kp kd kq kf kr kh">1. Concatenating Strings</h4>
<p id="2b3d" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">When you need to concatenate a list of strings, you can do this using a <em class="ks">for loop</em> by adding each element one by one. However, this would be very inefficient, especially if the list is long. In Python, strings are immutable, and thus the left and right strings would have to be copied into the new string for every pair of concatenation.</p>
<p id="24ac" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">A better approach is to use the <code class="ib kt ku kv kw b">join()</code> function as shown below:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="3d16" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">characters = ['p', 'y', 't', 'h', 'o', 'n']
word = "".join(characters)
print(word) <strong class="kw ld"># python</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="1162" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">2. Using List Comprehensions</h4>
<p id="47e1" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">List comprehensions are used for creating new lists from other iterables. As list comprehensions returns lists, they consist of brackets containing the expression, which is executed for each element along with the for loop to iterate over each element. List comprehension is faster because it is optimized for the Python interpreter to spot a predictable pattern during looping.</p>
<p id="a7bc" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">As an example let’s find the squares of the first five whole numbers using list comprehensions.</p>
<pre class="ho hp hq hr hs kx ky du"><span id="63bb" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">m = [x ** 2 for x in range(5)]
print(m)<strong class="kw ld"> # [0, 1, 4, 9, 16]</strong></span></pre>
<p id="61c0" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Now let’s find the common numbers from two list using list comprehension</p>
<pre class="ho hp hq hr hs kx ky du"><span id="12d9" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">list_a = [1, 2, 3, 4]
list_b = [2, 3, 4, 5]
common_num = [a for a in list_a for b in list_b if a == b]
print(common_num) <strong class="kw ld"># [2, 3, 4]</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="a568" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">3. Iterate With <code class="ib kt ku kv kw b">enumerate()</code></h4>
<p id="4452" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Enumerate() method adds a counter to an iterable and returns it in a form of enumerate object.</p>
<p id="79dd" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Let’s solve the classic coding interview question named popularly as the Fizz Buzz problem.</p>
<blockquote class="le lf lg">
<p id="9622" class="iq ir cn ks is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph=""><span style="font-size: 14pt;">Write a program that prints the numbers in a list, for multiples of ‘3’ print “fizz” instead of the number, for the multiples of ‘5’ print “buzz” and for multiples of both 3 and 5 it prints “fizzbuzz”.</span></p>
</blockquote>
<pre class="ho hp hq hr hs kx ky du"><span id="e165" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">numbers = [30, 42, 28, 50, 15]
for i, num in enumerate(numbers):
    if num % 3 == 0 and num % 5 == 0:
       numbers[i] = 'fizzbuzz'
    elif num % 3 == 0:
       numbers[i] = 'fizz'
    elif num % 5 == 0:
       numbers[i] = 'buzz'
print(numbers) <strong class="kw ld"># ['fizzbuzz', 'fizz', 28, 'buzz', 'fizzbuzz']</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="a416" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">4. Using ZIP When Working with Lists</h4>
<p id="5b40" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Suppose you were given a task to combine several lists with the same length and print out the result? Again, here is a more generic way to get the desired result by utilizing <code class="ib kt ku kv kw b">zip()</code>as shown in the code below:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="1c92" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">countries = ['France', 'Germany', 'Canada']
capitals = ['Paris', 'Berlin', 'Ottawa']
for country, capital in zip(countries,capitals):
    print(country, capital) <strong class="kw ld"># France Paris 
                              Germany Berlin
                              Canada Ottawa</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="9589" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">5. Using itertools</h4>
<p id="7ffc" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">The Python <code class="ib kt ku kv kw b">itertools</code> module is a collection of tools for handling iterators. <code class="ib kt ku kv kw b">itertools</code> has multiple tools for generating iterable sequences of input data. Here I will be using <code class="ib kt ku kv kw b">itertools.combinations()</code> as an example. <code class="ib kt ku kv kw b">itertools.combinations()</code> is used for building combinations. These are also the possible groupings of the input values.</p>
<p id="8042" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Let’s take a real world example to make the above point clear.</p>
<blockquote class="le lf lg">
<p id="6d38" class="iq ir cn ks is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph=""><span style="font-size: 14pt;">Suppose there are four teams playing in a tournament. In the league stages every team plays against every other team. Your task is to generate all the possible teams that would compete against each other.</span></p>
</blockquote>
<p id="46d5" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Let’s take a look at the code below:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="1a10" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">import itertools
friends = ['Team 1', 'Team 2', 'Team 3', 'Team 4']
list(itertools.combinations(friends, r=2)) <strong class="kw ld"># [('Team 1', 'Team 2'),      ('Team 1', 'Team 3'),  ('Team 1', 'Team 4'),  ('Team 2', 'Team 3'),  ('Team 2', 'Team 4'),  ('Team 3', 'Team 4')]</strong></span></pre>
<p id="c9e8" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">The important thing to notice is that order of the values doesn’t matter. Because <code class="ib kt ku kv kw b">('Team 1', 'Team 2')</code> and <code class="ib kt ku kv kw b">('Team 2', 'Team 1')</code> represent the same pair, only one of them would be included in the output list. Similarly we can use <code class="ib kt ku kv kw b">itertools.permutations()</code> as well as other functions from the module. For a more complete reference, check out <a class="bo dd im in io ip" href="https://medium.com/@jasonrigden/a-guide-to-python-itertools-82e5a306cdf8" target="_blank" rel="noopener noreferrer">this amazing tutorial</a>.</p>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="8668" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">6. Using Python Collections</h4>
<p id="30f1" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Python collections are container data types, namely lists, sets, tuples, dictionary. The collections module provides high-performance datatypes that can enhance your code, making things much cleaner and easier. There are a lot of functions provided by the collections module. For this demonstration, I will be using <code class="ib kt ku kv kw b">Counter()</code> function.</p>
<p id="f158" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">The <code class="ib kt ku kv kw b">Counter()</code> function takes an iterable, such as a list or tuple, and returns a Counter Dictionary. The dictionary’s keys will be the unique elements present in the iterable, and the values for each key will be the count of the elements present in the iterable.</p>
<p id="3be5" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">To create a <code class="ib kt ku kv kw b">counter</code> object, pass an iterable (list) to <code class="ib kt ku kv kw b">Counter()</code> function as shown in the code below.</p>
<pre class="ho hp hq hr hs kx ky du"><span id="fd71" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">from collections import Countercount = Counter(['a','b','c','d','b','c','d','b'])
print(count) <strong class="kw ld"># Counter({'b': 3, 'c': 2, 'd': 2, 'a': 1})</strong></span></pre>
<p id="abcb" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">For a more complete reference, check out my <a class="bo dd im in io ip" href="https://towardsdatascience.com/a-hands-on-guide-to-python-collections-aa350cb399e3" target="_blank" rel="noopener noreferrer">python collections tutorial</a>.</p>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="59f2" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">7. Convert Two Lists Into a Dictionary</h4>
<p id="8051" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Let’s say we have two lists, one list contains names of the students and second contains marks scored by them. Let’s see how we can convert those two lists into a single dictionary. Using the zip function, this can be done using the code below:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="f095" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">students = ["Peter", "Julia", "Alex"]
marks = [84, 65, 77]
dictionary = dict(zip(students, marks))
print(dictionary) <strong class="kw ld"># {'Peter': 84, 'Julia': 65, 'Alex': 77}</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="9eae" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">8. Using Python Generators</h4>
<p id="b00e" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Generator functions allow you to declare a function that behaves like an iterator. They allow programmers to make an iterator in a fast, easy, and clean way. Let’s take an example to explain this concept.</p>
<blockquote class="le lf lg">
<p id="5f94" class="iq ir cn ks is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph=""><span style="font-size: 14pt;">Suppose you’ve been given to find the sum of the first 100000000 perfect squares, starting with 1.</span></p>
</blockquote>
<p id="6167" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Looks easy right? This can easily be done using list comprehension but the problem is the large inputs size. As an example let’s take a look at the below code:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="07c6" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">t1 = time.clock()
sum([i * i for i in range(1, 100000000)])
t2 = time.clock()
time_diff = t2 - t1
print(f"It took {time_diff} Secs to execute this method") <strong class="kw ld"># It took 13.197494000000006 Secs to execute this method</strong></span></pre>
<p id="1710" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">On increasing the perfect numbers we need to sum over, we realize that this method is not feasible due to higher computation time. Here’s where Python Generators come to the rescue. On replacing the brackets with parentheses we change the list comprehension into a generator expression. Now let’s calculate the time taken:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="0f8e" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">t1 = time.clock()
sum((i * i for i in range(1, 100000000)))
t2 = time.clock()
time_diff = t2 - t1
print(f"It took {time_diff} Secs to execute this method") <strong class="kw ld"># It took 9.53867000000001 Secs to execute this method</strong></span></pre>
<p id="e1e3" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">As we can see, time taken has been reduced quite a bit. This effect will be even more pronounced for larger inputs.</p>
<p id="eea1" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">For a more complete reference, check out my article <a class="bo dd im in io ip" href="https://towardsdatascience.com/reduce-memory-usage-and-make-your-python-code-faster-using-generators-bd79dbfeb4c" target="_blank" rel="noopener noreferrer">Reduce Memory Usage and Make Your Python Code Faster Using Generators</a>.</p>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="9d52" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">9. Return Multiple Values From a Function</h4>
<p id="bf2d" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Python has the ability to return multiple values from a function call, something missing from many other popular programming languages. In this case the return values should be a comma-separated list of values and Python then constructs a <em class="ks">tuple</em> and returns this to the caller. As an example see the code below:</p>
<pre class="ho hp hq hr hs kx ky du"><span id="8a66" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">def multiplication_division(num1, num2):
    return num1*num2, num1/num2</span><span id="6f8e" class="kz jv cn ar kw b bj lh li lj lk ll lb r lc" data-selectable-paragraph="">product, division = multiplication_division(15, 3)
print("Product=", product, "Quotient =", division) <strong class="kw ld"># Product= 45 Quotient = 5.0</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="6f25" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">10. Using sorted() Function</h4>
<p id="6519" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">Sorting any sequence is very easy in Python using the built-in method <code class="ib kt ku kv kw b">sorted()</code>which does all the hard work for you. <code class="ib kt ku kv kw b">sorted()</code>sorts any sequence (list, tuple) and always returns a list with the elements in sorted manner. Let’s take an example to sort a list of numbers in ascending order.</p>
<pre class="ho hp hq hr hs kx ky du"><span id="13a7" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">sorted([3,5,2,1,4]) <strong class="kw ld"># [1, 2, 3, 4, 5]</strong></span></pre>
<p id="55a9" class="iq ir cn ar is b it iu iv iw ix iy iz ja jb jc jd" data-selectable-paragraph="">Taking another example, let’s sort a list of strings in descending order.</p>
<pre class="ho hp hq hr hs kx ky du"><span id="cbf4" class="kz jv cn ar kw b bj la lb r lc" data-selectable-paragraph="">sorted(['france', 'germany', 'canada', 'india', 'china'], reverse=True) <strong class="kw ld"># ['india', 'germany', 'france', 'china', 'canada']</strong></span></pre>
</div>
</div>
</section>
<section class="fd fe ff fg fh">
<div class="n p">
<div class="ac ae af ag ah fi aj ak">
<h4 id="c1ec" class="ju jv cn ar aq jw jx jy jz ka kb kc kd ke kf kg kh">Conclusions</h4>
<p id="9d84" class="iq ir cn ar is b it ki iv kj ix kk iz kl jb km jd" data-selectable-paragraph="">In this article, We&#8217;ve presented 10 Python tips and tricks that can be used as a reference in your day-to-day work. We hope you enjoyed this article.</p>
</div>
</div>
</section>
<p>&nbsp;</p>
<p>The post <a href="http://kostacipo.stream/10-python-tips-and-tricks-you-should-learn-today/">10 Python Tips and Tricks You Should Learn Today</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/10-python-tips-and-tricks-you-should-learn-today/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
