Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore Python Language Part 2

Python Language Part 2

Published by Jiruntanin Sidangam, 2020-10-25 07:58:23

Description: Python Language Part 2

Keywords: Python Language,Python, Language,Part 2

Search

Read the Text Version

where <envname> in an arbitrary name for your virtual environment, and <version> is a specific Python version you wish to setup. Activate and deactivate your environment # Linux, Mac source activate <envname> source deactivate or # Windows activate <envname> deactivate View a list of created environments conda env list Remove an environment conda env remove -n <envname> Find more commands and features in the official conda documentation. Checking if running inside a virtual environment Sometimes the shell prompt doesn't display the name of the virtual environment and you want to be sure if you are in a virtual environment or not. Run the python interpreter and try: import sys sys.prefix sys.real_prefix • Outside a virtual, environment sys.prefix will point to the system python installation and sys.real_prefix is not defined. • Inside a virtual environment, sys.prefix will point to the virtual environment python installation and sys.real_prefix will point to the system python installation. For virtual environments created using the standard library venv module there is no sys.real_prefix. Instead, check whether sys.base_prefix is the same as sys.prefix. Read Virtual environments online: https://riptutorial.com/python/topic/868/virtual-environments https://riptutorial.com/ 929

Chapter 199: Web scraping with Python Introduction Web scraping is an automated, programmatic process through which data can be constantly 'scraped' off webpages. Also known as screen scraping or web harvesting, web scraping can provide instant data from any publicly accessible webpage. On some websites, web scraping may be illegal. Remarks Useful Python packages for web scraping (alphabetical order) Making requests and collecting data requests A simple, but powerful package for making HTTP requests. requests-cache Caching for requests; caching data is very useful. In development, it means you can avoid hitting a site unnecessarily. While running a real collection, it means that if your scraper crashes for some reason (maybe you didn't handle some unusual content on the site...? maybe the site went down...?) you can repeat the collection very quickly from where you left off. scrapy Useful for building web crawlers, where you need something more powerful than using requests and iterating through pages. selenium Python bindings for Selenium WebDriver, for browser automation. Using requests to make HTTP requests directly is often simpler for retrieving webpages. However, this remains a useful tool when it is not possible to replicate the desired behaviour of a site using requests alone, particularly when JavaScript is required to render elements on a page. HTML parsing BeautifulSoup https://riptutorial.com/ 930

Query HTML and XML documents, using a number of different parsers (Python's built-in HTML Parser,html5lib, lxml or lxml.html) lxml Processes HTML and XML. Can be used to query and select content from HTML documents via CSS selectors and XPath. Examples Basic example of using requests and lxml to scrape some data # For Python 2 compatibility. from __future__ import print_function import lxml.html import requests def main(): r = requests.get(\"https://httpbin.org\") html_source = r.text root_element = lxml.html.fromstring(html_source) # Note root_element.xpath() gives a *list* of results. # XPath specifies a path to the element we want. page_title = root_element.xpath('/html/head/title/text()')[0] print(page_title) if __name__ == '__main__': main() Maintaining web-scraping session with requests It is a good idea to maintain a web-scraping session to persist the cookies and other parameters. Additionally, it can result into a performance improvement because requests.Session reuses the underlying TCP connection to a host: import requests with requests.Session() as session: # all requests through session now have User-Agent header set session.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'} # set cookies session.get('http://httpbin.org/cookies/set?key=value') # get cookies response = session.get('http://httpbin.org/cookies') print(response.text) Scraping using the Scrapy framework https://riptutorial.com/ 931

First you have to set up a new Scrapy project. Enter a directory where you’d like to store your code and run: scrapy startproject projectName To scrape we need a spider. Spiders define how a certain site will be scraped. Here’s the code for a spider that follows the links to the top voted questions on StackOverflow and scrapes some data from each page (source): import scrapy class StackOverflowSpider(scrapy.Spider): # the parsing starts from name = 'stackoverflow' # each spider has a unique name start_urls = ['http://stackoverflow.com/questions?sort=votes'] a specific set of urls def parse(self, response): # for each request this generator yields, its response is sent to parse_question for href in response.css('.question-summary h3 a::attr(href)'): # do some scraping stuff using css selectors to find question urls full_url = response.urljoin(href.extract()) yield scrapy.Request(full_url, callback=self.parse_question) def parse_question(self, response): yield { 'title': response.css('h1 a::text').extract_first(), 'votes': response.css('.question .vote-count-post::text').extract_first(), 'body': response.css('.question .post-text').extract_first(), 'tags': response.css('.question .post-tag::text').extract(), 'link': response.url, } Save your spider classes in the projectName\\spiders directory. In this case - projectName\\spiders\\stackoverflow_spider.py. Now you can use your spider. For example, try running (in the project's directory): scrapy crawl stackoverflow Modify Scrapy user agent Sometimes the default Scrapy user agent (\"Scrapy/VERSION (+http://scrapy.org)\") is blocked by the host. To change the default user agent open settings.py, uncomment and edit the following line to what ever you want. #USER_AGENT = 'projectName (+http://www.yourdomain.com)' For example USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' https://riptutorial.com/ 932

Scraping using BeautifulSoup4 from bs4 import BeautifulSoup import requests # Use the requests module to obtain a page res = requests.get('https://www.codechef.com/problems/easy') # Create a BeautifulSoup object page = BeautifulSoup(res.text, 'lxml') # the text field contains the source of the page # Now use a CSS selector in order to get the table containing the list of problems datatable_tags = page.select('table.dataTable') # The problems are in the <table> tag, # with class \"dataTable\" # We extract the first tag from the list, since that's what we desire datatable = datatable_tags[0] # Now since we want problem names, they are contained in <b> tags, which are # directly nested under <a> tags prob_tags = datatable.select('a > b') prob_names = [tag.getText().strip() for tag in prob_tags] print prob_names Scraping using Selenium WebDriver Some websites don’t like to be scraped. In these cases you may need to simulate a real user working with a browser. Selenium launches and controls a web browser. from selenium import webdriver browser = webdriver.Firefox() # launch firefox browser browser.get('http://stackoverflow.com/questions?sort=votes') # load url title = browser.find_element_by_css_selector('h1').text # page title (first h1 element) questions = browser.find_elements_by_css_selector('.question-summary') # question list for question in questions: # iterate over questions question_title = question.find_element_by_css_selector('.summary h3 a').text question_excerpt = question.find_element_by_css_selector('.summary .excerpt').text question_vote = question.find_element_by_css_selector('.stats .vote .votes .vote-count- post').text print \"%s\\n%s\\n%s votes\\n-----------\\n\" % (question_title, question_excerpt, question_vote) Selenium can do much more. It can modify browser’s cookies, fill in forms, simulate mouse clicks, take screenshots of web pages, and run custom JavaScript. Simple web content download with urllib.request The standard library module urllib.request can be used to download web content: from urllib.request import urlopen https://riptutorial.com/ 933

response = urlopen('http://stackoverflow.com/questions?sort=votes') data = response.read() # The received bytes should usually be decoded according the response's character set encoding = response.info().get_content_charset() html = data.decode(encoding) A similar module is also available in Python 2. Scraping with curl imports: from subprocess import Popen, PIPE from lxml import etree from io import StringIO Downloading: user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36' url = 'http://stackoverflow.com' get = Popen(['curl', '-s', '-A', user_agent, url], stdout=PIPE) result = get.stdout.read().decode('utf8') -s: silent download -A: user agent flag Parsing: tree = etree.parse(StringIO(result), etree.HTMLParser()) divs = tree.xpath('//div') Read Web scraping with Python online: https://riptutorial.com/python/topic/1792/web-scraping- with-python https://riptutorial.com/ 934

Chapter 200: Web Server Gateway Interface (WSGI) Parameters Parameter Details start_response A function used to process the start Examples Server Object (Method) Our server object is given an 'application' parameter which can be any callable application object (see other examples). It writes first the headers, then the body of data returned by our application to the system standard output. import os, sys def run(application): = sys.stdin environ['wsgi.input'] = sys.stderr environ['wsgi.errors'] headers_set = [] headers_sent = [] def write (data): \"\"\" Writes header data from 'start_response()' as well as body data from 'response' to system standard output. \"\"\" if not headers_set: raise AssertionError(\"write() before start_response()\") elif not headers_sent: status, response_headers = headers_sent[:] = headers_set sys.stdout.write('Status: %s\\r\\n' % status) for header in response_headers: sys.stdout.write('%s: %s\\r\\n' % header) sys.stdout.write('\\r\\n') sys.stdout.write(data) sys.stdout.flush() def start_response(status, response_headers): \"\"\" Sets headers for the response returned by this server.\"\"\" if headers_set: raise AssertionError(\"Headers already set!\") headers_set[:] = [status, response_headers] return write https://riptutorial.com/ 935

# This is the most important piece of the 'server object' # Our result will be generated by the 'application' given to this method as a parameter result = application(environ, start_response) try: for data in result: if data: write(data) # Body isn't empty send its data to 'write()' if not headers_sent: write('') # Body is empty, send empty string to 'write()' Read Web Server Gateway Interface (WSGI) online: https://riptutorial.com/python/topic/5315/web- server-gateway-interface--wsgi- https://riptutorial.com/ 936

Chapter 201: Webbrowser Module Introduction According to Python's standard documentation, the webbrowser module provides a high-level interface to allow displaying Web-based documents to users. This topic explains and demonstrates proper usage of the webbrowser module. Syntax • webbrowser.open(url, new=0, autoraise=False) • webbrowser.open_new(url) • webbrowser.open_new_tab(url) • webbrowser.get(usage=None) • webbrowser.register(name, constructor, instance=None) Parameters Parameter Details webbrowser.open() url the URL to open in the web browser new 0 opens the URL in the existing tab, 1 opens in a new window, 2 opens in new tab autoraise if set to True, the window will be moved on top of the other windows webbrowser.open_new() url the URL to open in the web browser webbrowser.open_new_tab() url the URL to open in the web browser webbrowser.get() using the browser to use webbrowser.register() url browser name constructor path to the executable browser (help) https://riptutorial.com/ 937

Parameter Details instance An instance of a web browser returned from the webbrowser.get() method Remarks The following table lists predefined browser types. The left column are names that can be passed into the webbrowser.get() method and the right column lists the class names for each browser type. Type Name Class Name 'mozilla' Mozilla('mozilla') 'firefox' Mozilla('mozilla') 'netscape' Mozilla('netscape') 'galeon' Galeon('galeon') 'epiphany' Galeon('epiphany') 'skipstone' BackgroundBrowser('skipstone') 'kfmclient' Konqueror() 'konqueror' Konqueror() 'kfm' Konqueror() 'mosaic' BackgroundBrowser('mosaic') 'opera' Opera() 'grail' Grail() 'links' GenericBrowser('links') 'elinks' Elinks('elinks') 'lynx' GenericBrowser('lynx') 'w3m' GenericBrowser('w3m') 'windows-default' WindowsDefault 'macosx' MacOSX('default') 'safari' MacOSX('safari') 'google-chrome' Chrome('google-chrome') 'chrome' Chrome('chrome') 'chromium' Chromium('chromium') 'chromium-browser' Chromium('chromium-browser') https://riptutorial.com/ 938

Examples Opening a URL with Default Browser To simply open a URL, use the webbrowser.open() method: import webbrowser webbrowser.open(\"http://stackoverflow.com\") If a browser window is currently open, the method will open a new tab at the specified URL. If no window is open, the method will open the operating system's default browser and navigate to the URL in the parameter. The open method supports the following parameters: • url - the URL to open in the web browser (string) [required] • new - 0 opens in existing tab, 1 opens new window, 2 opens new tab (integer) [default 0] • autoraise - if set to True, the window will be moved on top of other applications' windows (Boolean) [default False] Note, the new and autoraise arguments rarely work as the majority of modern browsers refuse these commmands. Webbrowser can also try to open URLs in new windows with the open_new method: import webbrowser webbrowser.open_new(\"http://stackoverflow.com\") This method is commonly ignored by modern browsers and the URL is usually opened in a new tab. Opening a new tab can be tried by the module using the open_new_tab method: import webbrowser webbrowser.open_new_tab(\"http://stackoverflow.com\") Opening a URL with Different Browsers The webbrowser module also supports different browsers using the register() and get() methods. The get method is used to create a browser controller using a specific executable's path and the register method is used to attach these executables to preset browser types for future use, commonly when multiple browser types are used. import webbrowser ff_path = webbrowser.get(\"C:/Program Files/Mozilla Firefox/firefox.exe\") ff = webbrowser.get(ff_path) ff.open(\"http://stackoverflow.com/\") Registering a browser type: import webbrowser ff_path = webbrowser.get(\"C:/Program Files/Mozilla Firefox/firefox.exe\") https://riptutorial.com/ 939

ff = webbrowser.get(ff_path) webbrowser.register('firefox', None, ff) # Now to refer to use Firefox in the future you can use this webbrowser.get('firefox').open(\"https://stackoverflow.com/\") Read Webbrowser Module online: https://riptutorial.com/python/topic/8676/webbrowser-module https://riptutorial.com/ 940

Chapter 202: Websockets 941 Examples Simple Echo with aiohttp aiohttp provides asynchronous websockets. Python 3.x3.5 import asyncio from aiohttp import ClientSession with ClientSession() as session: async def hello_world(): websocket = await session.ws_connect(\"wss://echo.websocket.org\") websocket.send_str(\"Hello, world!\") print(\"Received:\", (await websocket.receive()).data) await websocket.close() loop = asyncio.get_event_loop() loop.run_until_complete(hello_world()) Wrapper Class with aiohttp aiohttp.ClientSession may be used as a parent for a custom WebSocket class. Python 3.x3.5 import asyncio from aiohttp import ClientSession class EchoWebSocket(ClientSession): URL = \"wss://echo.websocket.org\" def __init__(self): super().__init__() self.websocket = None async def connect(self): \"\"\"Connect to the WebSocket.\"\"\" self.websocket = await self.ws_connect(self.URL) async def send(self, message): \"\"\"Send a message to the WebSocket.\"\"\" assert self.websocket is not None, \"You must connect first!\" self.websocket.send_str(message) print(\"Sent:\", message) https://riptutorial.com/

async def receive(self): 942 \"\"\"Receive one message from the WebSocket.\"\"\" assert self.websocket is not None, \"You must connect first!\" return (await self.websocket.receive()).data async def read(self): \"\"\"Read messages from the WebSocket.\"\"\" assert self.websocket is not None, \"You must connect first!\" while self.websocket.receive(): message = await self.receive() print(\"Received:\", message) if message == \"Echo 9!\": break async def send(websocket): for n in range(10): await websocket.send(\"Echo {}!\".format(n)) await asyncio.sleep(1) loop = asyncio.get_event_loop() with EchoWebSocket() as websocket: loop.run_until_complete(websocket.connect()) tasks = ( send(websocket), websocket.read() ) loop.run_until_complete(asyncio.wait(tasks)) loop.close() Using Autobahn as a Websocket Factory The Autobahn package can be used for Python web socket server factories. Python Autobahn package documentation To install, typically one would simply use the terminal command (For Linux): sudo pip install autobahn (For Windows): python -m pip install autobahn Then, a simple echo server can be created in a Python script: from autobahn.asyncio.websocket import WebSocketServerProtocol class MyServerProtocol(WebSocketServerProtocol): https://riptutorial.com/

'''When creating server protocol, the user defined class inheriting the WebSocketServerProtocol needs to override the onMessage, onConnect, et-c events for user specified functionality, these events define your server's protocol, in essence''' def onMessage(self,payload,isBinary): '''The onMessage routine is called when the server receives a message. It has the required arguments payload and the bool isBinary. The payload is the actual contents of the \"message\" and isBinary is simply a flag to let the user know that the payload contains binary data. I typically elsewise assume that the payload is a string. In this example, the payload is returned to sender verbatim.''' self.sendMessage(payload,isBinary) if__name__=='__main__': try: importasyncio except ImportError: '''Trollius = 0.3 was renamed''' import trollius as asyncio from autobahn.asyncio.websocketimportWebSocketServerFactory factory=WebSocketServerFactory() '''Initialize the websocket factory, and set the protocol to the above defined protocol(the class that inherits from autobahn.asyncio.websocket.WebSocketServerProtocol)''' factory.protocol=MyServerProtocol '''This above line can be thought of as \"binding\" the methods onConnect, onMessage, et-c that were described in the MyServerProtocol class to the server, setting the servers functionality, ie, protocol''' loop=asyncio.get_event_loop() coro=loop.create_server(factory,'127.0.0.1',9000) server=loop.run_until_complete(coro) '''Run the server in an infinite loop''' try: loop.run_forever() except KeyboardInterrupt: pass finally: server.close() loop.close() In this example, a server is being created on the localhost (127.0.0.1) on port 9000. This is the listening IP and port. This is important information, as using this, you could identify your computer's LAN address and port forward from your modem, though whatever routers you have to the computer. Then, using google to investigate your WAN IP, you could design your website to send WebSocket messages to your WAN IP, on port 9000 (in this example). It is important that you port forward from your modem back, meaning that if you have routers daisy chained to the modem, enter into the modem's configuration settings, port forward from the modem to the connected router, and so forth until the final router your computer is connected to is having the information being received on modem port 9000 (in this example) forwarded to it. Read Websockets online: https://riptutorial.com/python/topic/4751/websockets https://riptutorial.com/ 943

Chapter 203: Working around the Global Interpreter Lock (GIL) Remarks Why is there a GIL? The GIL has been around in CPython since the inception of Python threads, in 1992. It's designed to ensure thread safety of running python code. Python interpreters written with a GIL prevent multiple native threads from executing Python bytecodes at once. This makes it easy for plugins to ensure that their code is thread-safe: simply lock the GIL, and only your active thread is able to run, so your code is automatically thread-safe. Short version: the GIL ensures that no matter how many processors and threads you have, only one thread of a python interpreter will run at one time. This has a lot of ease-of-use benefits, but also has a lot of negative benefits as well. Note that a GIL is not a requirment of the Python language. Consequently, you can't access the GIL directly from standard python code. Not all implementations of Python use a GIL. Interpreters that have a GIL: CPython, PyPy, Cython (but you can disable the GIL with nogil) Interpreters that do not have a GIL: Jython, IronPython Details on how the GIL operates: When a thread is running, it locks the GIL. When a thread wants to run, it requests the GIL, and waits until it is available. In CPython, before version 3.2, the running thread would check after a certain number of python instructions to see if other code wanted the lock (that is, it released the lock and then requested it again). This method tended to cause thread starvation, largely because the thread that released the lock would acquire it again before the waiting threads had a chance to wake up. Since 3.2, threads that want the GIL wait for the lock for some time, and after that time, they set a shared variable that forces the running thread to yield. This can still result in drastically longer execution times, though. See the links below from dabeaz.com (in the references section) for more details. CPython automatically releases the GIL when a thread performs an I/O operation. Image processing libraries and numpy number crunching operations release the GIL before doing their processing. https://riptutorial.com/ 944

Benefits of the GIL For interpreters that use the GIL, the GIL is systemic. It is used to preserve the state of the application. Benefits include: • Garbage collection - thread-safe reference counts must be modified while the GIL is locked. In CPython, all of garbarge collection is tied to the GIL. This is a big one; see the python.org wiki article about the GIL (listed in References, below) for details about what must still be functional if one wanted to remove the GIL. • Ease for programmers dealing with the GIL - locking everything is simplistic, but easy to code to • Eases the import of modules from other languages Consequences of the GIL The GIL only allows one thread to run python code at a time inside the python interpreter. This means that multithreading of processes that run strict python code simply doesn't work. When using threads against the GIL, you will likely have worse performance with the threads than if you ran in a single thread. References: https://wiki.python.org/moin/GlobalInterpreterLock - quick summary of what it does, fine details on all the benefits http://programmers.stackexchange.com/questions/186889/why-was-python-written-with-the-gil - clearly written summary http://www.dabeaz.com/python/UnderstandingGIL.pdf - how the GIL works and why it slows down on multiple cores http://www.dabeaz.com/GIL/gilvis/index.html - visualization of the data showing how the GIL locks up threads http://jeffknupp.com/blog/2012/03/31/pythons-hardest-problem/ - simple to understand history of the GIL problem https://jeffknupp.com/blog/2013/06/30/pythons-hardest-problem-revisited/ - details on ways to work around the GIL's limitations Examples Multiprocessing.Pool https://riptutorial.com/ 945

The simple answer, when asking how to use threads in Python is: \"Don't. Use processes, instead.\" The multiprocessing module lets you create processes with similar syntax to creating threads, but I prefer using their convenient Pool object. Using the code that David Beazley first used to show the dangers of threads against the GIL, we'll rewrite it using multiprocessing.Pool: David Beazley's code that showed GIL threading problems from threading import Thread import time def countdown(n): while n > 0: n -= 1 COUNT = 10000000 t1 = Thread(target=countdown,args=(COUNT/2,)) t2 = Thread(target=countdown,args=(COUNT/2,)) start = time.time() t1.start();t2.start() t1.join();t2.join() end = time.time() print end-start Re-written using multiprocessing.Pool: import multiprocessing import time def countdown(n): while n > 0: n -= 1 COUNT = 10000000 start = time.time() with multiprocessing.Pool as pool: pool.map(countdown, [COUNT/2, COUNT/2]) pool.close() pool.join() end = time.time() print(end-start) Instead of creating threads, this creates new processes. Since each process is its own interpreter, there are no GIL collisions. multiprocessing.Pool will open as many processes as there are cores on the machine, though in the example above, it would only need two. In a real-world scenario, you want to design your list to have at least as much length as there are processors on your machine. The Pool will run the function you tell it to run with each argument, up to the number of processes it creates. When the function finishes, any remaining functions in the list will be run on https://riptutorial.com/ 946

that process. I've found that, even using the with statement, if you don't close and join the pool, the processes continue to exist. To clean up resources, I always close and join my pools. Cython nogil: Cython is an alternative python interpreter. It uses the GIL, but lets you disable it. See their documentation As an example, using the code that David Beazley first used to show the dangers of threads against the GIL, we'll rewrite it using nogil: David Beazley's code that showed GIL threading problems from threading import Thread import time def countdown(n): while n > 0: n -= 1 COUNT = 10000000 t1 = Thread(target=countdown,args=(COUNT/2,)) t2 = Thread(target=countdown,args=(COUNT/2,)) start = time.time() t1.start();t2.start() t1.join();t2.join() end = time.time() print end-start Re-written using nogil (ONLY WORKS IN CYTHON): from threading import Thread 947 import time def countdown(n): while n > 0: n -= 1 COUNT = 10000000 with nogil: t1 = Thread(target=countdown,args=(COUNT/2,)) t2 = Thread(target=countdown,args=(COUNT/2,)) start = time.time() t1.start();t2.start() t1.join();t2.join() https://riptutorial.com/

end = time.time() print end-start It's that simple, as long as you're using cython. Note that the documentation says you must make sure not to change any python objects: Code in the body of the statement must not manipulate Python objects in any way, and must not call anything that manipulates Python objects without first re-acquiring the GIL. Cython currently does not check this. Read Working around the Global Interpreter Lock (GIL) online: https://riptutorial.com/python/topic/4061/working-around-the-global-interpreter-lock--gil- https://riptutorial.com/ 948

Chapter 204: Working with ZIP archives Syntax • import zipfile • class zipfile.ZipFile(file, mode='r', compression=ZIP_STORED, allowZip64=True) Remarks If you try to open a file that is not a ZIP file, the exception zipfile.BadZipFile is raised. In Python 2.7, this was spelled zipfile.BadZipfile, and this old name is retained alongside the new one in Python 3.2+ Examples Opening Zip Files To start, import the zipfile module, and set the filename. import zipfile filename = 'zipfile.zip' Working with zip archives is very similar to working with files, you create the object by opening the zipfile, which lets you work on it before closing the file up again. zip = zipfile.ZipFile(filename) print(zip) # <zipfile.ZipFile object at 0x0000000002E51A90> zip.close() In Python 2.7 and in Python 3 versions higher than 3.2, we can use the with context manager. We open the file in \"read\" mode, and then print a list of filenames: with zipfile.ZipFile(filename, 'r') as z: print(zip) # <zipfile.ZipFile object at 0x0000000002E51A90> Examining Zipfile Contents There are a few ways to inspect the contents of a zipfile. You can use the printdir to just get a variety of information sent to stdout with zipfile.ZipFile(filename) as zip: zip.printdir() https://riptutorial.com/ 949

# Out: Modified Size # File Name 2016-06-25 22:13:34 157336 # pyexpat.pyd 2016-06-25 22:13:34 # python.exe 2016-06-25 22:13:34 39576 # python3.dll 2016-06-25 22:13:34 51864 # python35.dll 3127960 # etc. We can also get a list of filenames with the namelist method. Here, we simply print the list: with zipfile.ZipFile(filename) as zip: print(zip.namelist()) # Out: ['pyexpat.pyd', 'python.exe', 'python3.dll', 'python35.dll', ... etc. ...] Instead of namelist, we can call the infolist method, which returns a list of ZipInfo objects, which contain additional information about each file, for instance a timestamp and file size: with zipfile.ZipFile(filename) as zip: info = zip.infolist() print(zip[0].filename) print(zip[0].date_time) print(info[0].file_size) # Out: pyexpat.pyd # Out: (2016, 6, 25, 22, 13, 34) # Out: 157336 Extracting zip file contents to a directory Extract all file contents of a zip file import zipfile with zipfile.ZipFile('zipfile.zip','r') as zfile: zfile.extractall('path') If you want extract single files use extract method, it takes name list and path as input parameter import zipfile f=open('zipfile.zip','rb') zfile=zipfile.ZipFile(f) for cont in zfile.namelist(): zfile.extract(cont,path) Creating new archives To create new archive open zipfile with write mode. import zipfile new_arch=zipfile.ZipFile(\"filename.zip\",mode=\"w\") To add files to this archive use write() method. https://riptutorial.com/ 950

new_arch.write('filename.txt','filename_in_archive.txt') #first parameter is filename and second parameter is filename in archive by default filename will taken if not provided new_arch.close() If you want to write string of bytes into the archive you can use writestr() method. str_bytes=\"string buffer\" new_arch.writestr('filename_string_in_archive.txt',str_bytes) new_arch.close() Read Working with ZIP archives online: https://riptutorial.com/python/topic/3728/working-with-zip- archives https://riptutorial.com/ 951

Chapter 205: Writing extensions Examples Hello World with C Extension The following C source file (which we will call hello.c for demonstration purposes) produces an extension module named hello that contains a single function greet(): #include <Python.h> #include <stdio.h> #if PY_MAJOR_VERSION >= 3 #define IS_PY3K #endif static PyObject *hello_greet(PyObject *self, PyObject *args) { const char *input; if (!PyArg_ParseTuple(args, \"s\", &input)) { return NULL; } printf(\"%s\", input); Py_RETURN_NONE; } static PyMethodDef HelloMethods[] = { { \"greet\", hello_greet, METH_VARARGS, \"Greet the user\" }, { NULL, NULL, 0, NULL } }; #ifdef IS_PY3K static struct PyModuleDef hellomodule = { PyModuleDef_HEAD_INIT, \"hello\", NULL, -1, HelloMethods }; PyMODINIT_FUNC PyInit_hello(void) { return PyModule_Create(&hellomodule); } #else PyMODINIT_FUNC inithello(void) { (void) Py_InitModule(\"hello\", HelloMethods); } #endif To compile the file with the gcc compiler, run the following command in your favourite terminal: gcc /path/to/your/file/hello.c -o /path/to/your/file/hello To execute the greet() function that we wrote earlier, create a file in the same directory, and call it hello.py https://riptutorial.com/ 952

import hello # imports the compiled library hello.greet(\"Hello!\") # runs the greet() function with \"Hello!\" as an argument Passing an open file to C Extensions Pass an open file object from Python to C extension code. You can convert the file to an integer file descriptor using PyObject_AsFileDescriptor function: PyObject *fobj; int fd = PyObject_AsFileDescriptor(fobj); if (fd < 0){ return NULL; } To convert an integer file descriptor back into a python object, use PyFile_FromFd. int fd; /* Existing file descriptor */ PyObject *fobj = PyFile_FromFd(fd, \"filename\",\"r\",-1,NULL,NULL,NULL,1); C Extension Using c++ and Boost This is a basic example of a C Extension using C++ and Boost. C++ Code C++ code put in hello.cpp: #include <boost/python/module.hpp> #include <boost/python/list.hpp> #include <boost/python/class.hpp> #include <boost/python/def.hpp> // Return a hello world string. std::string get_hello_function() { return \"Hello world!\"; } // hello class that can return a list of count hello world strings. class hello_class { public: // Taking the greeting message in the constructor. hello_class(std::string message) : _message(message) {} // Returns the message count times in a python list. boost::python::list as_list(int count) { boost::python::list res; for (int i = 0; i < count; ++i) { https://riptutorial.com/ 953

res.append(_message); } return res; } private: std::string _message; }; // Defining a python module naming it to \"hello\". BOOST_PYTHON_MODULE(hello) { // Here you declare what functions and classes that should be exposed on the module. // The get_hello_function exposed to python as a function. boost::python::def(\"get_hello\", get_hello_function); // The hello_class exposed to python as a class. boost::python::class_<hello_class>(\"Hello\", boost::python::init<std::string>()) .def(\"as_list\", &hello_class::as_list) ; } To compile this into a python module you will need the python headers and the boost libraries. This example was made on Ubuntu 12.04 using python 3.4 and gcc. Boost is supported on many platforms. In case of Ubuntu the needed packages was installed using: sudo apt-get install gcc libboost-dev libpython3.4-dev Compiling the source file into a .so-file that can later be imported as a module provided it is on the python path: gcc -shared -o hello.so -fPIC -I/usr/include/python3.4 hello.cpp -lboost_python-py34 - lboost_system -l:libpython3.4m.so The python code in the file example.py: import hello print(hello.get_hello()) h = hello.Hello(\"World hello!\") print(h.as_list(3)) Then python3 example.py will give the following output: Hello world! ['World hello!', 'World hello!', 'World hello!'] Read Writing extensions online: https://riptutorial.com/python/topic/557/writing-extensions https://riptutorial.com/ 954

Chapter 206: Writing to CSV from String or List Introduction Writing to a .csv file is not unlike writing to a regular file in most regards, and is fairly straightforward. I will, to the best of my ability, cover the easiest, and most efficient approach to the problem. Parameters Parameter Details open (\"/path/\", \"mode\") Specify the path to your CSV file open (path, \"mode\") Specify mode to open file in (read, write, etc.) csv.writer(file, delimiter) Pass opened CSV file here csv.writer(file, delimiter=' ') Specify delimiter character or pattern Remarks open( path, \"wb\") \"wb\" - Write mode. The b parameter in \"wb\" we have used, is necessary only if you want to open it in binary mode, which is needed only in some operating systems like Windows. csv.writer ( csv_file, delimiter=',' ) Here the delimiter we have used, is ,, because we want each cell of data in a row, to contain the first name, last name, and age respectively. Since our list is split along the , too, it proves rather convenient for us. Examples Basic Write Example import csv #------ We will write to CSV in this function ------------ def csv_writer(data, path): https://riptutorial.com/ 955

#Open CSV file whose path we passed. with open(path, \"wb\") as csv_file: writer = csv.writer(csv_file, delimiter=',') for line in data: writer.writerow(line) #---- Define our list here, and call function ------------ if __name__ == \"__main__\": \"\"\" data = our list that we want to write. Split it so we get a list of lists. \"\"\" data = [\"first_name,last_name,age\".split(\",\"), \"John,Doe,22\".split(\",\"), \"Jane,Doe,31\".split(\",\"), \"Jack,Reacher,27\".split(\",\") ] # Path to CSV file we want to write to. path = \"output.csv\" csv_writer(data, path) Appending a String as a newline in a CSV file def append_to_csv(input_string): with open(\"fileName.csv\", \"a\") as csv_file: csv_file.write(input_row + \"\\n\") Read Writing to CSV from String or List online: https://riptutorial.com/python/topic/10862/writing-to- csv-from-string-or-list https://riptutorial.com/ 956

Credits S. Chapters Contributors No A. Raza, Aaron Critchley, Abhishek Jain, AER, afeique, 1 Getting started with Akshay Kathpal, alejosocorro, Alessandro Trinca Tornidor, Python Language Alex Logan, ALinuxLover, Andrea, Andrii Abramov, Andy, Andy Hayden, angussidney, Ani Menon, Anthony Pham, Antoine Bolvy, Aquib Javed Khan, Ares, Arpit Solanki, B8vrede , Baaing Cow, baranskistad, Brian C, Bryan P, BSL-5, BusyAnt , Cbeb24404, ceruleus, ChaoticTwist, Charlie H, Chris Midgley , Christian Ternus, Claudiu, Clíodhna, CodenameLambda, cʟᴅs ᴇᴇᴅ, Community, Conrad.Dean, Daksh Gupta, Dania, Daniel Minnaar, Darth Shadow, Dartmouth, deeenes, Delgan, depperm, DevD, dodell, Douglas Starnes, duckman_1991, Eamon Charles, edawine, Elazar, eli-bd, Enrico Maria De Angelis, Erica, Erica, ericdwang, Erik Godard, EsmaeelE, Filip Haglund, Firix, fox, Franck Dernoncourt, Fred Barclay, Freddy, Gerard Roche, glS, GoatsWearHats, GThamizh, H. Pauwelyn, hardmooth, hayalci, hichris123, Ian, IanAuld, icesin, Igor Raush, Ilyas Mimouni, itsthejoker, J F, Jabba, jalanb, James, James Taylor, Jean-Francois T., jedwards, Jeffrey Lin, jfunez, JGreenwell, Jim Fasarakis Hilliard, jim opleydulven, jimsug, jmunsch, Johan Lundberg, John Donner, John Slegers, john400, jonrsharpe, Joseph True, JRodDynamite, jtbandes, Juan T, Kamran Mackey, Karan Chudasama, KerDam, Kevin Brown, Kiran Vemuri, kisanme, Lafexlos, Leon, Leszek Kicior, LostAvatar, Majid, manu, MANU, Mark Miller, Martijn Pieters, Mathias711, matsjoyce, Matt, Mattew Whitt, mdegis, Mechanic , Media, mertyildiran, metahost, Mike Driscoll, MikJR, Miljen Mikic, mnoronha, Morgoth, moshemeirelles, MSD, MSeifert, msohng, msw, muddyfish, Mukund B, Muntasir Alam, Nathan Arthur, Nathaniel Ford, Ned Batchelder, Ni., niyasc, noɥʇʎԀ ʎzɐɹƆ, numbermaniac, orvi, Panda, Patrick Haugh, Pavan Nath, Peter Masiar, PSN, PsyKzz, pylang, pzp, Qchmqs, Quill, Rahul Nair, Rakitić, Ram Grandhi, rfkortekaas, rick112358, Robotski, rrao, Ryan Hilbert, Sam Krygsheld, Sangeeth Sudheer, SashaZd, Selcuk, Severiano Jaramillo Quintanar, Shiven, Shoe, Shog9, Sigitas Mockus, Simplans, Slayther, stark, StuxCrystal, SuperBiasedMan, Sнаđошƒа, taylor swift, techydesigner, Tejus Prasad, TerryA, The_Curry_Man, TheGenie OfTruth, Timotheus.Kampik, tjohnson, Tom Barron, Tom de Geus, Tony Suffolk 66, tonyo, TPVasconcelos, https://riptutorial.com/ 957

user2314737, user2853437, user312016, Utsav T, vaichidrewar, vasili111, Vin, W.Wong, weewooquestionaire, Will, wintermute, Yogendra Sharma, Zach Janicki, Zags 2 *args and **kwargs cjds, Eric Zhang, ericmarkmartin, Geeklhem, J F, Jeff Hutchins , Jim Fasarakis Hilliard, JuanPablo, kdopen, loading..., Marlon Abeykoon, Mattew Whitt, Pasha, pcurry, PsyKzz, Scott Mermelstein, user2314737, Valentin Lorentz, Veedrac 3 2to3 tool Alessandro Trinca Tornidor, Dartmouth, Firix, Kevin Brown, Naga2Raja, Stephen Leppik 4 Abstract Base Akshat Mahajan, Alessandro Trinca Tornidor, JGreenwell, Classes (abc) Kevin Brown, Mattew Whitt, mkrieger1, SashaZd, Stephen Leppik 5 Abstract syntax tree Teepeemm Accessing Python muddyfish, StuxCrystal, user2314737 6 source code and bytecode Alternatives to switch 7 statement from other davidism, J F, zmo, Валерий Павлов languages 8 ArcPy Midavalo, PolyGeo, Zhanping Shi 9 Arrays Andy, Pavan Nath, RamenChef, Vin 10 Asyncio Module 2Cubed, Alessandro Trinca Tornidor, Cimbali, hiro protagonist, obust, pylang, RamenChef, Seth M. Larson, Simplans, Stephen Leppik, Udi 11 Attribute Access Elazar, SashaZd, SuperBiasedMan 12 Audio blueberryfields, Comrade SparklePony, frankyjuang, jmunsch, orvi, qwertyuip9, Stephen Leppik, Thomas Gerot 13 Basic Curses with 4444, Guy, kollery, Vinzee Python 14 Basic Input and Doraemon, GoatsWearHats, J F, JNat, Marco Pashkov, Mark Output Miller, Martijn Pieters, Nathaniel Ford, Nicolás, pcurry, pzp, SashaZd, SuperBiasedMan, Vilmar 15 Binary Data Eleftheria, evuez, mnoronha 16 Bitwise Operators Abhishek Jain, boboquack, Charles, Gal Dreiman, intboolstring , JakeD, JNat, Kevin Brown, Matías Brignone, nemesisfixx, https://riptutorial.com/ 958

17 Boolean Operators poke, R Colmenares, Shawn Mehan, Simplans, Thomas Gerot , tmr232, Tony Suffolk 66, viveksyngh 18 Call Python from C# boboquack, Brett Cannon, Dair, Ffisegydd, John Zwinck, Checking Path Severiano Jaramillo Quintanar, Steven Maude 19 Existence and Julij Jegorov Permissions Esteis, Marlon Abeykoon, mnoronha, PYPL 20 ChemPy - python package Biswa_9937 21 Classes Aaron Hall, Ahsanul Haque, Akshat Mahajan, Andrzej Pronobis, Anthony Pham, Avantol13, Camsbury, cfi, CLI subcommands Community, Conrad.Dean, Daksh Gupta, Darth Shadow, 22 with precise help Dartmouth, depperm, Elazar, Ffisegydd, Haris, Igor Raush, InitializeSahib, J F, jkdev, jlarsch, John Militer, Jonas S, output Jonathan, Kallz, KartikKannapur, Kevin Brown, Kinifwyne, Leo, Liteye, lmiguelvargasf, Mailerdaimon, Martijn Pieters, Code blocks, Massimiliano Kraus, Mattew Whitt, MrP01, Nathan Arthur, ojas 23 execution frames, mohril, Pasha, Peter Steele, pistache, Preston, pylang, Richard Fitzhugh, rohittk239, Rushy Panchal, Sempoo, and namespaces Simplans, Soumendra Kumar Sahoo, SuperBiasedMan, techydesigner, then0rTh, Thomas Gerot, Tony Suffolk 66, 24 Collections module tox123, UltraBob, user2314737, wrwrwr, Yogendra Sharma 25 Comments and Alessandro Trinca Tornidor, anatoly techtonik, Darth Shadow Documentation Jeremy, Mohammed Salman 26 Common Pitfalls asmeurer, Community, Elazar, jmunsch, kon psych, Marco Pashkov, MSeifert, RamenChef, Shawn Mehan, Simplans, Steven Maude, Symmitchry, void, XCoder Real Ani Menon, FunkySayu, MattCorr, SuperBiasedMan, TuringTux abukaj, ADITYA, Alec, Alessandro Trinca Tornidor, Alex, Antoine Bolvy, Baaing Cow, Bhargav Rao, Billy, bixel, Charles, Cheney, Christophe Roussy, Dartmouth, DeepSpace, DhiaTN, Dilettant, fox, Fred Barclay, Gerard Roche, greatwolf, hiro protagonist, Jeffrey Lin, JGreenwell, Jim Fasarakis Hilliard, https://riptutorial.com/ 959

Lafexlos, maazza, Malt, Mark, matsjoyce, Matt Dodge, MervS, MSeifert, ncmathsadist, omgimanerd, Patrick Haugh, pylang, RamenChef, Reut Sharabani, Rob Bednark, rrao, SashaZd, Shihab Shahriar, Simplans, SuperBiasedMan, Tim D, Tom Dunbavan, tyteen4a03, user2314737, Will Vousden, Wombatz 27 Commonwealth Juan T, TemporalWolf Exceptions 28 Comparisons Anthony Pham, Ares, Elazar, J F, MSeifert, Shawn Mehan, SuperBiasedMan, Will, Xavier Combelle 29 Complex math Adeel Ansari, Bosoneando, bpachev 30 Conditionals Andy Hayden, BusyAnt, Chris Larson, deepakkt, Delgan, Elazar, evuez, Ffisegydd, Geeklhem, Hannes Karppila, James, Kevin Brown, krato, Max Feng, noɥʇʎԀʎzɐɹƆ, rajah9, rrao, SashaZd, Simplans, Slayther, Soumendra Kumar Sahoo, Thomas Gerot, Trimax, Valentin Lorentz, Vinzee, wwii, xgord, Zack 31 configparser Chinmay Hegde, Dunatotatos 32 Connecting Python to metmirr SQL Server 33 Context Managers Abhijeet Kasurde, Alessandro Trinca Tornidor, Andy Hayden, (“with” Statement) Antoine Bolvy, carrdelling, Conrad.Dean, Dartmouth, David Marx, DeepSpace, Elazar, Kevin Brown, magu_, Majid, Martijn Pieters, Matthew, nlsdfnbch, Pasha, Peter Brittain, petrs, Shuo , Simplans, SuperBiasedMan, The_Cthulhu_Kid, Thomas Gerot, tyteen4a03, user312016, Valentin Lorentz, vaultah, λ user 34 Copying data hashcode55, StuxCrystal 35 Counting Andy Hayden, MSeifert, Peter Mølgaard Pallesen, pylang Create virtual 36 environment with Sirajus Salayhin virtualenvwrapper in windows 37 Creating a Windows Simon Hibbs service using Python 38 Creating Python Claudiu, KeyWeeUsr, Marco Pashkov, pylang, packages SuperBiasedMan, Thtu https://riptutorial.com/ 960

39 ctypes Or East 40 Data Serialization Devesh Saini, Infinity, rfkortekaas 41 Data Visualization Aquib Javed Khan, Arun, ChaoticTwist, cledoux, Ffisegydd, with Python ifma 42 Database Access Alessandro Trinca Tornidor, Antonio, bee-sting, cʟᴅsᴇᴇᴅ, D. Alveno, John Y, LostAvatar, mbsingh, Michel Touw, 43 Date and Time qwertyuip9, RamenChef, rrawat, Stephen Leppik, Stephen Nyamweya, sumitroy, user2314737, valeas, zweiterlinde 44 Date Formatting 45 Debugging Ajean, alecxe, Andy, Antti Haapala, BusyAnt, Conrad.Dean, Elazar, ghostarbeiter, J F, Jeffrey Lin, jonrsharpe, Kevin Brown 46 Decorators , Nicole White, nlsdfnbch, Ohad Eytan, Paul, paulmorriss, proprius, RahulHP, RamenChef, sagism, Simplans, Sirajus 47 Defining functions Salayhin, Suku, Will with list arguments surfthecity 48 Deployment Aldo, B8vrede, joel3000, Sardathrion, Sardorbek Imomaliev, 49 Deque Module Vlad Bezden 50 Descriptor Alessandro Trinca Tornidor, ChaoticTwist, Community, Dair, 51 Design Patterns doratheexplorer0911, Emolga, greut, iankit, JGreenwell, jonrsharpe, kefkius, Kevin Brown, Mattew Whitt, MSeifert, 52 Dictionary muddyfish, Mukunda Modell, Nearoo, Nemo, Nuno André, Pasha, Rob Bednark, seenu s, Shreyash S Sarnayak, Simplans, StuxCrystal, Suhas K, technusm1, Thomas Gerot, tyteen4a03, Wladimir Palant, zvone zenlc2000 Gal Dreiman, Iancnorden, Wayne Werner Anthony Pham, BusyAnt, matsjoyce, ravigadila, Simplans, Thomas Ahle, user2314737 bbayles, cizixs, Nemo, pylang, SuperBiasedMan Charul, denvaar, djaszczurowski Amir Rachum, Anthony Pham, APerson, ArtOfCode, BoppreH, Burhan Khalid, Chris Mueller, cizixs, depperm, Ffisegydd, Gareth Latty, Guy, helpful, iBelieve, Igor Raush, Infinity, James , JGreenwell, jonrsharpe, Karsten 7., kdopen, machine yearning, Majid, mattgathu, Mechanic, MSeifert, muddyfish, Nathan, nlsdfnbch, noɥʇʎԀʎzɐɹƆ, ronrest, Roy Iacob, Shawn https://riptutorial.com/ 961

Mehan, Simplans, SuperBiasedMan, TehTris, Valentin Lorentz , viveksyngh, Xavier Combelle 53 Difference between DeepSpace, Simplans, tjohnson Module and Package 54 Distribution Alessandro Trinca Tornidor, JGreenwell, metahost, Pigman168, RamenChef, Stephen Leppik 55 Django code_geek, orvi Dynamic code 56 execution with `exec` Antti Haapala, Ilja Everilä and `eval` 57 Enum Andy, Elazar, evuez, Martijn Pieters, techydesigner 58 Exceptions Adrian Antunez, Alessandro Trinca Tornidor, Alfe, Andy, Benjamin Hodgson, Brian Rodriguez, BusyAnt, Claudiu, driax, Elazar, flazzarini, ghostarbeiter, Ilia Barahovski, J F, Marco Pashkov, muddyfish, noɥʇʎԀʎzɐɹƆ, Paul Weaver, Rahul Nair, RamenChef, Shawn Mehan, Shiven, Shkelqim Memolla, Simplans, Slickytail, Stephen Leppik, Sudip Bhandari, SuperBiasedMan, user2314737 59 Exponentiation Anthony Pham, intboolstring, jtbandes, Luke Taylor, MSeifert, Pasha, supersam654 60 Files & Folders I/O Ajean, Anthony Pham, avb, Benjamin Hodgson, Bharel, Charles, crhodes, David Cullen, Dov, Esteis, ilse2005, isvforall , jfsturtz, Justin, Kevin Brown, mattgathu, MSeifert, nlsdfnbch, Ozair Kafray, PYPL, pzp, RamenChef, Ronen Ness, rrao, Serenity, Simplans, SuperBiasedMan, Tasdik Rahman, Thomas Gerot, Umibozu, user2314737, Will, WombatPM, xgord 61 Filter APerson, cfi, J Atkin, MSeifert, rajah9, SuperBiasedMan 62 Flask Stephen Leppik, Thomas Gerot Functional Imran Bughio, mvis89, Rednivrug 63 Programming in Python 64 Functions Adriano, Akshat Mahajan, AlexV, Andy, Andy Hayden, Anthony Pham, Arkady, B8vrede, Benjamin Hodgson, btel, CamelBackNotation, Camsbury, Chandan Purohit, ChaoticTwist, Charlie H, Chris Larson, Community, D. Alveno, danidee, DawnPaladin, Delgan, duan, duckman_1991, elegent https://riptutorial.com/ 962

, Elodin, Emma, EsmaeelE, Ffisegydd, Gal Dreiman, ghostarbeiter, Hurkyl, J F, James, Jeffrey Lin, JGreenwell, Jim Fasarakis Hilliard, jkitchen, Jossie Calderon, Justin, Kevin Brown, L3viathan, Lee Netherton, Martijn Pieters, Martin Thurau, Matt Giltaji, Mike - SMT, Mike Driscoll, MSeifert, muddyfish, Murphy4, nd., noɥʇʎԀʎzɐɹƆ, Pasha, pylang, pzp, Rahul Nair, Severiano Jaramillo Quintanar, Simplans, Slayther , Steve Barnes, Steven Maude, SuperBiasedMan, textshell, then0rTh, Thomas Gerot, user2314737, user3333708, user405, Utsav T, vaultah, Veedrac, Will, Will, zxxz, λuser 65 Functools Module Alessandro Trinca Tornidor, enrico.bacis, flamenco, RamenChef, Shrey Gupta, Simplans, Stephen Leppik, StuxCrystal 66 Garbage Collection bogdanciobanu, Claudiu, Conrad.Dean, Elazar, FazeL, J F, James Elderfield, lukess, muddyfish, Sam Whited, SiggyF, Stephen Leppik, SuperBiasedMan, Xavier Combelle 67 Generators 2Cubed, Ahsanul Haque, Akshat Mahajan, Andy Hayden, Arthur Dent, ArtOfCode, Augustin, Barry, Chankey Pathak, Claudiu, CodenameLambda, Community, deeenes, Delgan, Devesh Saini, Elazar, ericmarkmartin, Ernir, ForceBru, Igor Raush, Ilia Barahovski, J0HN, jackskis, Jim Fasarakis Hilliard, Juan T, Julius Bullinger, Karl Knechtel, Kevin Brown, Kronen, Luc M, Lyndsy Simon, machine yearning, Martijn Pieters, Matt Giltaji, max, MSeifert, nlsdfnbch, Pasha, Pedro, PsyKzz, pzp, satsumas, sevenforce, Signal, Simplans, Slayther, StuxCrystal , tversteeg, Valentin Lorentz, Will, William Merrill, xtreak, Zaid Ajaj, zarak, λuser 68 getting start with GZip orvi 69 graph-tool xiaoyi 70 groupby() Parousia, Thomas Gerot 71 hashlib Mark Omo, xiaoyi 72 Heapq ettanany 73 Hidden Features Aaron Hall, Akshat Mahajan, Anthony Pham, Antti Haapala, Byte Commander, dermen, Elazar, Ellis, ericmarkmartin, Fermi paradox, Ffisegydd, japborst, Jim Fasarakis Hilliard, jonrsharpe, Justin, kramer65, Lafexlos, LDP, Morgan Thrapp, muddyfish, nico, OrangeTux, pcurry, Pythonista, Selcuk, Serenity, Tejas Jadhav, tobias_k, Vlad Shcherbina, Will 74 HTML Parsing alecxe, talhasch https://riptutorial.com/ 963

75 Idioms Benjamin Hodgson, Elazar, Faiz Halde, J F, Lee Netherton, loading..., Mister Mister 76 ijson Prem Narain Immutable 77 datatypes(int, float, Alessandro Trinca Tornidor, FazeL, Ganesh K, RamenChef, str, tuple and Stephen Leppik frozensets) 78 Importing modules angussidney, Anthony Pham, Antonis Kalou, Brett Cannon, BusyAnt, Casebash, Christian Ternus, Community, Conrad.Dean, Daniel, Dartmouth, Esteis, Ffisegydd, FMc, Gerard Roche, Gideon Buckwalter, J F, JGreenwell, Kinifwyne, languitar, Lex Scarisbrick, Matt Giltaji, MSeifert, niyasc, nlsdfnbch, Paulo Freitas, pylang, Rahul Nair, Saiful Azad, Serenity, Simplans, StardustGogeta, StuxCrystal, SuperBiasedMan, techydesigner, the_cat_lady, Thomas Gerot , Tony Meyer, Tushortz, user2683246, Valentin Lorentz, Valor Naram, vaultah, wnnmaw 671620616, Abhishek Kumar, Akshit Soota, Alex Gaynor, Allan Burleson, Alleo, Amarpreet Singh, Andy Hayden, Ani Menon, Antoine Bolvy, AntsySysHack, Antti Haapala, Antwan, arekolek, Ares, asmeurer, B8vrede, Bakuriu, Bharel, Bhargav Rao, bignose, bitchaser, Bluethon, Cache Staheli, Cameron Gagnon, Charles, Charlie H, Chris Sprague, Claudiu, Clayton Wahlstrom, cʟᴅsᴇᴇᴅ, Colin Yang, Cometsong, Community, Conrad.Dean, danidee, Daniel Stradowski, Darth Shadow, Dartmouth, Dave J, David Cullen, David Heyman, deeenes, DeepSpace, Delgan, DoHe, Duh-Wayne-101, Dunno, dwanderson, Ekeyme Mo, Elazar, enderland, enrico.bacis, Incompatibilities erewok, ericdwang, ericmarkmartin, Ernir, ettanany, 79 moving from Python 2 Everyone_Else, evuez, Franck Dernoncourt, Fred Barclay, to Python 3 garg10may, Gavin, geoffspear, ghostarbeiter, GoatsWearHats, H. Pauwelyn, Haohu Shen, holdenweb, iScrE4m, Iván C., J F, J. C. Leitão, James Elderfield, James Thiele, jarondl, jedwards , Jeffrey Lin, JGreenwell, Jim Fasarakis Hilliard, Jimmy Song, John Slegers, Jojodmo, jonrsharpe, Josh, Juan T, Justin, Justin M. Ucar, Kabie, kamalbanga, Karl Knechtel, Kevin Brown, King's jester, Kunal Marwaha, Lafexlos, lenz, linkdd, l'L'l, Mahdi, Martijn Pieters, Martin Thoma, masnun, Matt, Matt Dodge, Matt Rowland, Mattew Whitt, Max Feng, mgwilliams, Michael Recachinas, mkj, mnoronha, Moinuddin Quadri, muddyfish, Nathaniel Ford, niemmi, niyasc, noɥʇʎԀʎzɐɹƆ, OrangeTux, Pasha, Paul Weaver, Paulo Freitas, pcurry, pktangyue, poppie, pylang, python273, Pythonista, RahulHP, https://riptutorial.com/ 964

Rakitić, RamenChef, Rauf, René G, rfkortekaas, rrao, Ryan, sblair, Scott Mermelstein, Selcuk, Serenity, Seth M. Larson, ShadowRanger, Simplans, Slayther, solarc, sricharan, Steven Hewitt, sth, SuperBiasedMan, Tadhg McDonald-Jensen, techydesigner, Thomas Gerot, Tim, tobias_k, Tyler, tyteen4a03, user2314737, user312016, Valentin Lorentz, Veedrac, Ven, Vinayak, Vlad Shcherbina, VPfB, WeizhongTu, Wieland, wim, Wolf, Wombatz, xtreak, zarak, zcb, zopieux, zurfyx, zvezda 80 Indentation Alessandro Trinca Tornidor, depperm, J F, JGreenwell, Matt Giltaji, Pasha, RamenChef, Stephen Leppik 81 Indexing and Slicing Alleo, amblina, Antoine Bolvy, Bonifacio2, Ffisegydd, Guy, Igor Raush, Jonatan, Martec, MSeifert, MUSR, pzp, RahulHP, Reut Sharabani, SashaZd, Sayed M Ahamad, SuperBiasedMan, theheadofabroom, user2314737, yurib Input, Subset and 82 Output External Data Mark Miller Files using Pandas Introduction to eandersson 83 RabbitMQ using AMQPStorm IoT Programming with 84 Python and dhimanta Raspberry PI 85 Iterables and Iterators 4444, Conrad.Dean, demonplus, Ilia Barahovski, Pythonista 86 Itertools Module ADITYA, Alessandro Trinca Tornidor, Andy Hayden, balki, bpachev, Ffisegydd, jackskis, Julien Spronck, Kevin Brown, machine yearning, nlsdfnbch, pylang, RahulHP, RamenChef, Simplans, Stephen Leppik, Symmitchry, Wickramaranga, wnnmaw 87 JSON Module Indradhanush Gupta, Leo, Martijn Pieters, pzp, theheadofabroom, Underyx, Wolfgang kivy - Cross-platform 88 Python Framework dhimanta for NUI Development 89 Linked List Node orvi 90 Linked lists Nemo https://riptutorial.com/ 965

91 List Adriano, Alexander, Anthony Pham, Ares, Barry, blueenvelope , Bosoneando, BusyAnt, Çağatay Uslu, caped114, Chandan Purohit, ChaoticTwist, cizixs, Daniel Porteous, Darth Kotik, deeenes, Delgan, Elazar, Ellis, Emma, evuez, exhuma, Ffisegydd, Flickerlight, Gal Dreiman, ganesh gadila, ghostarbeiter, Igor Raush, intboolstring, J F, j3485, jalanb, James, James Elderfield, jani, jimsug, jkdev, JNat, jonrsharpe, KartikKannapur, Kevin Brown, Lafexlos, LDP, Leo Thumma, Luke Taylor, lukewrites, lxer, Majid, Mechanic, MrP01, MSeifert, muddyfish, n12312, noɥʇʎԀʎzɐɹƆ, Oz Bar-Shalom, Pasha, Pavan Nath, poke, RamenChef, ravigadila, ronrest, Serenity, Severiano Jaramillo Quintanar, Shawn Mehan, Simplans, sirin, solarc, SuperBiasedMan, textshell, The_Cthulhu_Kid, user2314737, user6457549, Utsav T, Valentin Lorentz, vaultah, Will, wythagoras, Xavier Combelle 3442, 4444, acdr, Ahsanul Haque, Akshay Anand, Akshit Soota, Alleo, Amir Rachum, André Laszlo, Andy Hayden, Ankit Kumar Singh, Antoine Bolvy, APerson, Ashwinee K Jha, B8vrede, bfontaine, Brian Cline, Brien, Casebash, Celeo, cfi, ChaoticTwist, Charles, Charlie H, Chong Tang, Community, Conrad.Dean, Dair, Daniel Stradowski, Darth Shadow, Dartmouth, David Heyman, Delgan, Dima Tisnek, eenblam, Elazar, Emma, enrico.bacis, EOL, ericdwang, ericmarkmartin, Esteis, Faiz Halde, Felk, Fermi paradox, Florian Bender, Franck Dernoncourt, Fred Barclay, freidrichen, G M, Gal Dreiman, garg10may, ghostarbeiter, GingerHead, griswolf, Hannele, Harry, Hurkyl, IanAuld, iankit, Infinity, intboolstring, J F, J0HN, James, JamesS, Jamie Rees, jedwards, Jeff Langemeier, JGreenwell, JHS, jjwatt, JKillian, JNat, joel3000, John Slegers, Jon, jonrsharpe, Josh Caswell, JRodDynamite, 92 List comprehensions Julian, justhalf, Kamyar Ghasemlou, kdopen, Kevin Brown, KIDJourney, Kwarrtz, Lafexlos, lapis, Lee Netherton, Liteye, Locane, Lyndsy Simon, machine yearning, Mahdi, Marc, Markus Meskanen, Martijn Pieters, Matt, Matt Giltaji, Matt S, Mattew Whitt, Maximillian Laumeister, mbrig, Mirec Miskuf, Mitch Talmadge, Morgan Thrapp, MSeifert, muddyfish, n8henrie, Nathan Arthur, nehemiah, noɥʇʎԀʎzɐɹƆ, Or East, Ortomala Lokni, pabouk, Panda, Pasha, pktangyue, Preston, Pro Q, pylang, R Nar, Rahul Nair, rap-2-h, Riccardo Petraglia, rll, Rob Fagen, rrao, Ryan Hilbert, Ryan Smith, ryanyuyu, Samuel McKay, sarvajeetsuman, Sayakiss, Sebastian Kreft, Shoe, SHOWMEWHATYOUGOT, Simplans, Slayther, Slickytail, solidcell, StuxCrystal, sudo bangbang, Sunny Patel, SuperBiasedMan, syb0rg, Symmitchry, The_Curry_Man, theheadofabroom, Thomas Gerot, Tim McNamara, Tom Barron, user2314737, user2357112, Utsav T, Valentin Lorentz, https://riptutorial.com/ 966

Veedrac, viveksyngh, vog, W.P. McNeill, Will, Will, Wladimir Palant, Wolf, XCoder Real, yurib, Yury Fedorov, Zags, Zaz 3442, Akshit Soota, André Laszlo, Andy Hayden, Annonymous , Ari, Bhargav, Chris Mueller, Darth Shadow, Dartmouth, Delgan, enrico.bacis, Franck Dernoncourt, garg10may, intboolstring, Jeff Langemeier, Josh Caswell, JRodDynamite, 93 List Comprehensions justhalf, kdopen, Ken T, Kevin Brown, kiliantics, longyue0521, Martijn Pieters, Mattew Whitt, Moinuddin Quadri, MSeifert, muddyfish, noɥʇʎԀʎzɐɹƆ, pktangyue, Pyth0nicPenguin, Rahul Nair, Riccardo Petraglia, SashaZd, shrishinde, Simplans, Slayther, sudo bangbang, theheadofabroom, then0rTh, Tim McNamara, Udi, Valentin Lorentz, Veedrac, Zags List destructuring J F, sth, zmo 94 (aka packing and unpacking) 95 List slicing (selecting Greg, JakeD parts of lists) 96 Logging Gal Dreiman, Jörn Hees, sxnwlfkk 97 Loops Adriano, Alex L, alfonso.kim, Alleo, Anthony Pham, Antti Haapala, Chris Hunt, Christian Ternus, Darth Kotik, DeepSpace, Delgan, DhiaTN, ebo, Elazar, Eric Finn, Felix D., Ffisegydd, Gal Dreiman, Generic Snake, ghostarbeiter, GoatsWearHats, Guy, Inbar Rose, intboolstring, J F, James, Jeffrey Lin, JGreenwell, Jim Fasarakis Hilliard, jrast, Karl Knechtel, machine yearning, Mahdi, manetsus, Martijn Pieters, Math, Mathias711, MSeifert, pnhgiol, rajah9, Rishabh Gupta, Ryan, sarvajeetsuman, sevenforce, SiggyF, Simplans, skrrgwasme, SuperBiasedMan, textshell, The_Curry_Man, Thomas Gerot, Tom, Tony Suffolk 66, user1349663, user2314737, Vinzee, Will 98 Manipulating XML 4444, Brad Larson, Chinmay Hegde, Francisco Guimaraes, greuze, heyhey2k, Rob Murray 99 Map Function APerson, cfi, Igor Raush, Jon Ericson, Karl Knechtel, Marco Pashkov, MSeifert, noɥʇʎԀʎzɐɹƆ, Parousia, Simplans, SuperBiasedMan, tlama, user2314737 100 Math Module Anthony Pham, ArtOfCode, asmeurer, Christofer Ohlsson, Ellis , fredley, ghostarbeiter, Igor Raush, intboolstring, J F, James Elderfield, JGreenwell, MSeifert, niyasc, RahulHP, rajah9, Simplans, StardustGogeta, SuperBiasedMan, yurib 101 Metaclasses 2Cubed, Amir Rachum, Antoine Pinsard, Camsbury, https://riptutorial.com/ 967

Community, driax, Igor Raush, InitializeSahib, Marco Pashkov, Martijn Pieters, Mattew Whitt, OozeMeister, Pasha, Paulo Scardine, RamenChef, Rob Bednark, Simplans, sisanared, zvone 102 Method Overriding DeepSpace, James 103 Mixins Doc, Rahul Nair, SashaZd 104 Multidimensional boboquack, Buzz, rrao arrays 105 Multiprocessing Alon Alexander, Nander Speerstra, unutbu, Vinzee, Will 106 Multithreading Alu, cʟᴅsᴇᴇᴅ, juggernaut, Kevin Brown, Kristof, mattgathu, Nabeel Ahmed, nlsdfnbch, Rahul, Rahul Nair, Riccardo Petraglia, Thomas Gerot, Will, Yogendra Sharma Mutable vs Immutable 107 (and Hashable) in Cilyan Python 108 Neo4j and Cypher Wingston Sharon using Py2Neo 109 Non-official Python Jacques de Hooge, Squidward implementations 110 Operator module MSeifert 111 Operator Precedence HoverHell, JGreenwell, MathSquared, SashaZd, Shreyash S Sarnayak 112 Optical Character rassar Recognition 113 os.path Claudiu, Fábio Perez, girish946, Jmills, Szabolcs Dombi, VJ Magar 114 Overloading Andy Hayden, Darth Shadow, ericmarkmartin, Ffisegydd, Igor Raush, Jonas S, jonrsharpe, L3viathan, Majid, RamenChef, Simplans, Valentin Lorentz Pandas Transform: Dee Preform operations 115 on groups and concatenate the results 116 Parallel computation Akshat Mahajan, Dair, Franck Dernoncourt, J F, Mahdi, https://riptutorial.com/ 968

nlsdfnbch, Ryan Smith, Vinzee, Xavier Combelle 117 Parsing Command amblina, Braiam, Claudiu, cledoux, Elazar, Gerard Roche, Line arguments krato, loading..., Marco Pashkov, Or Duan, Pasha, RamenChef, rfkortekaas, Simplans, Thomas Gerot, Topperfalkon, zmo, zondo 118 Partial functions FrankBr 119 Performance A. Ciclet, RamenChef, user2314737 optimization 120 Pickle data J F, Majid, Or East, RahulHP, rfkortekaas, zvone serialisation 121 Pillow Razik 122 pip: PyPI Package Andy, Arpit Solanki, Community, InitializeSahib, JNat, Mahdi, Manager Majid, Matt Giltaji, Nathaniel Ford, Rápli András, SerialDev, Simplans, Steve Barnes, StuxCrystal, tlo 123 Plotting with Arun, user2314737 Matplotlib 124 Plugin and Extension 2Cubed, proprefenetre, pylang, rrao, Simon Hibbs, Simplans Classes 125 Polymorphism Benedict Bunting, DeepSpace, depperm, Simplans, skrrgwasme, Vinzee 126 PostgreSQL Alessandro Trinca Tornidor, RamenChef, Stephen Leppik, user2027202827 127 Processes and Claudiu, Thomas Gerot Threads 128 Profiling J F, keiv.fly, SashaZd 129 Property Objects Alessandro Trinca Tornidor, Darth Shadow, DhiaTN, J F, Jacques de Hooge, Leo, Martijn Pieters, mnoronha, Priya, RamenChef, Stephen Leppik 130 py.test Andy, Claudiu, Ffisegydd, Kinifwyne, Matt Giltaji 131 pyaudio Biswa_9937 132 pyautogui module Damien, Rednivrug 133 pygame Anthony Pham, Aryaman Arora, Pavan Nath 134 Pyglet Comrade SparklePony, Stephen Leppik https://riptutorial.com/ 969

PyInstaller - ChaoticTwist, Eric, mnoronha 135 Distributing Python Code 136 Python and Excel bee-sting, Chinmay Hegde, GiantsLoveDeathMetal, hackvan, Majid, talhasch, user2314737, Will 137 Python Anti-Patterns Alessandro Trinca Tornidor, Annonymous, eenblam, Mahmoud Hashemi, RamenChef, Stephen Leppik 138 Python concurrency David Heyman, Faiz Halde, Iván Rodríguez Torres, J F, Thomas Moreau, Tyler Gubala 139 Python Data Types Gavin, lorenzofeliz, Pike D., Rednivrug 140 Python HTTP Server Arpit Solanki, J F, jmunsch, Justin Chadwell, Mark, MervS, orvi , quantummind, Raghav, RamenChef, Sachin Kalkur, Simplans, techydesigner 141 Python Lex-Yacc cʟᴅsᴇᴇᴅ 142 Python Networking atayenel, ChaoticTwist, David, Geeklhem, mattgathu, mnoronha, thsecmaniac 143 Python Persistence RamenChef, user2728397 144 Python Requests Ken Y-N, RandomHash Post Python Serial Alessandro Trinca Tornidor, Ani Menon, girish946, mnoronha, 145 Communication Saranjith, user2314737 (pyserial) 146 Python Server Sent Nick Humrich Events 147 Python speed of ADITYA, Antonio, Elodin, Neil A., Vinzee program Python Virtual Vikash Kumar Jain 148 Environment - virtualenv 149 Queue Module Prem Narain 150 Raise Custom Errors naren / Exceptions 151 Random module Alex Gaynor, Andrzej Pronobis, Anthony Pham, Community, David Robinson, Delgan, giucal, Jim Fasarakis Hilliard, https://riptutorial.com/ 970

michaelrbock, MSeifert, Nobilis, ppperry, RamenChef, Simplans, SuperBiasedMan 152 Reading and Writing Adam Matan, Franck Dernoncourt, Martin Valgur, mnoronha, CSV ravigadila, Setu 153 Recursion Bastian, japborst, JGreenwell, Jossie Calderon, mbomb007, SashaZd, Tyler Crompton 154 Reduce APerson, Igor Raush, Martijn Pieters, MSeifert 155 Regular Expressions Aidan, alejosocorro, andandandand, Andy Hayden, ashes999, (Regex) B8vrede, Claudiu, Darth Shadow, driax, Fermi paradox, ganesh gadila, goodmami, Jan, Jeffrey Lin, jonrsharpe, Julien Spronck, Kevin Brown, Md.Sifatul Islam, Michael M., mnoronha, Nander Speerstra, nrusch, Or East, orvi, regnarg, sarvajeetsuman, Simplans, SN Ravichandran KR, SuperBiasedMan, user2314737, zondo 156 Searching Dan Sanderson, Igor Raush, MSeifert 157 Secure Shell mnoronha, Shijo Connection in Python 158 Security and adeora, ArtOfCode, BSL-5, Kevin Brown, matsjoyce, Cryptography SuperBiasedMan, Thomas Gerot, Wladimir Palant, wrwrwr 159 Set Andrzej Pronobis, Andy Hayden, Bahrom, Cimbali, Cody Piersall, Conrad.Dean, Elazar, evuez, J F, James, Or East, pylang, RahulHP, RamenChef, Simplans, user2314737 160 setup.py Adam Brenecki, amblina, JNat, ravigadila, strpeter, user2027202827, Y0da 161 shelve Biswa_9937 Similarities in syntax, 162 Differences in user2683246 meaning: Python vs. JavaScript 163 Simple Mathematical amin, blueenvelope, Bryce Frank, Camsbury, David, Operators DeepSpace, Elazar, J F, James, JGreenwell, Jon Ericson, Kevin Brown, Lafexlos, matsjoyce, Mechanic, Milo P, MSeifert, numbermaniac, sarvajeetsuman, Simplans, techydesigner, Tony Suffolk 66, Undo, user2314737, wythagoras, Zenadix 164 Sockets David Cullen, Dev, MattCorr, nlsdfnbch, Rob H, StuxCrystal, textshell, Thomas Gerot, Will https://riptutorial.com/ 971

Sockets And Message 165 Encryption/Decryption Mohammad Julfikar Between Client and Server 166 Sorting, Minimum and Antti Haapala, APerson, GoatsWearHats, Mirec Miskuf, Maximum MSeifert, RamenChef, Simplans, Valentin Lorentz 167 Sqlite3 Module Chinmay Hegde, Simplans 168 Stack ADITYA, boboquack, Chromium, cjds, depperm, Hannes Karppila, JGreenwell, Jonatan, kdopen, OliPro007, orvi, SashaZd, Sнаđошƒа, textshell, Thomas Ahle, user2314737 169 String Formatting 4444, Aaron Christiansen, Adam_92, ADITYA, Akshit Soota, aldanor, alecxe, Alessandro Trinca Tornidor, Andy Hayden, Ani Menon, B8vrede, Bahrom, Bhargav, Charles, Chris, Darth Shadow, Dartmouth, Dave J, Delgan, dreftymac, evuez, Franck Dernoncourt, Gal Dreiman, gerrit, Giannis Spiliopoulos, GiantsLoveDeathMetal, goyalankit, Harrison, James Elderfield, Jean-Francois T., Jeffrey Lin, jetpack_guy, JL Peyret, joel3000 , Jonatan, JRodDynamite, Justin, Kevin Brown, knight, krato, Marco Pashkov, Mark, Matt, Matt Giltaji, mu , MYGz, Nander Speerstra, Nathan Arthur, Nour Chawich, orion_tvv, ragesz, SashaZd, Serenity, serv-inc, Simplans, Slayther, Sometowngeek, SuperBiasedMan, Thomas Gerot, tobias_k, Tony Suffolk 66, UloPe, user2314737, user312016, Vin, zondo 170 String Methods Amitay Stern, Andy Hayden, Ares, Bhargav Rao, Brien, BusyAnt, Cache Staheli, caped114, ChaoticTwist, Charles, Dartmouth, David Heyman, depperm, Doug Henderson, Elazar , ganesh gadila, ghostarbeiter, GoatsWearHats, idjaw, Igor Raush, Ilia Barahovski, j__, Jim Fasarakis Hilliard, JL Peyret, Kevin Brown, krato, MarkyPython, Metasomatism, Mikail Land, MSeifert, mu , Nathaniel Ford, OliPro007, orvi, pzp, ronrest, Shrey Gupta, Simplans, SuperBiasedMan, theheadofabroom, user1349663, user2314737, Veedrac, WeizhongTu, wnnmaw String Alessandro Trinca Tornidor, jedwards, JelmerS, RamenChef, representations of Stephen Leppik 171 class instances: __str__ and __repr__ methods 172 Subprocess Library Adam Matan, Andrew Schade, Brendan Abel, jfs, jmunsch, Riccardo Petraglia https://riptutorial.com/ 972

173 sys blubberdiblub 174 tempfile Alessandro Trinca Tornidor, amblina, Kevin Brown, Stephen NamedTemporaryFile Leppik 175 Templates in python 4444, Alessandro Trinca Tornidor, Fred Barclay, RamenChef, Ricardo, Stephen Leppik 176 The __name__ Annonymous, BusyAnt, Christian Ternus, jonrsharpe, Lutz special variable Prechelt, Steven Elliott 177 The base64 Module Thomas Gerot 178 The dis module muddyfish, user2314737 The Interpreter Aaron Christiansen, David, Elazar, Peter Shinners, ppperry 179 (Command Line Console) 180 The locale Module Will, XonAether 181 The os Module Andy, Christian Ternus, JelmerS, JL Peyret, mnoronha, Vinzee 182 The pass statement Anaphory 183 The Print Function Beall619, Frustrated, Justin, Leon Z., lukewrites, SuperBiasedMan, Valentin Lorentz 184 tkinter Dartmouth, rlee827, Thomas Gerot, TidB 185 Tuple Anthony Pham, Antoine Bolvy, BusyAnt, Community, Elazar, James, Jim Fasarakis Hilliard, Joab Mendes, Majid, Md.Sifatul Islam, Mechanic, mezzode, nlsdfnbch, noɥʇʎԀʎzɐɹƆ, Selcuk, Simplans, textshell, tobias_k, Tony Suffolk 66, user2314737 186 Turtle Graphics Luca Van Oort, Stephen Leppik 187 Type Hints alecxe, Annonymous, Antti Haapala, Elazar, Jim Fasarakis Hilliard, Jonatan, RamenChef, Seth M. Larson, Simplans, Stephen Leppik 188 Unicode wim 189 Unicode and bytes Claudiu, KeyWeeUsr 190 Unit Testing Alireza Savand, Ami Tavory, antimatter15, Arpit Solanki, bijancn, Claudiu, Dartmouth, engineercoding, Ffisegydd, J F, JGreenwell, jmunsch, joel3000, Kevin Brown, Kinifwyne, Mario Corchero, Matt Giltaji, Mattew Whitt, mgilson, muddyfish, pylang, strpeter https://riptutorial.com/ 973

191 Unzipping Files andrew 192 urllib Amitay Stern, ravigadila, sth, Will Usage of \"pip\" Zydnar 193 module: PyPI Package Manager 194 User-Defined Alessandro Trinca Tornidor, Beall619, mnoronha, RamenChef, Methods Stephen Leppik, Sun Qingyao 195 Using loops within naren functions 196 Variable Scope and Anthony Pham, davidism, Elazar, Esteis, Mike Driscoll, Binding SuperBiasedMan, user2314737, zvone virtual environment Sirajus Salayhin 197 with virtualenvwrapper 198 Virtual environments Adrian17, Artem Kolontay, ArtOfCode, Bhargav, brennan, Dair, Daniil Ryzhkov, Darkade, Darth Shadow, edwinksl, Fernando, ghostarbeiter, ha_1694, Hans Then, Iancnorden, J F, Majid, Marco Pashkov, Matt Giltaji, Mattew Whitt, nehemiah, Nuhil Mehdy, Ortomala Lokni, Preston, pylang, qwertyuip9, RamenChef, Régis B., Sebastian Schrader, Serenity, Shantanu Alshi, Shrey Gupta, Simon Fraser, Simplans, wrwrwr , ychaouche, zopieux, zvezda 199 Web scraping with alecxe, Amitay Stern, jmunsch, mrtuovinen, Ni., RamenChef, Python Saiful Azad, Saqib Shamsi, Simplans, Steven Maude, sth, sytech, talhasch, Thomas Gerot 200 Web Server Gateway David Heyman, Kevin Brown, Preston, techydesigner Interface (WSGI) 201 Webbrowser Module Thomas Gerot 202 Websockets 2Cubed, Stephen Leppik, Tyler Gubala Working around the Scott Mermelstein 203 Global Interpreter Lock (GIL) 204 Working with ZIP Chinmay Hegde, ghostarbeiter, Jeffrey Lin, SuperBiasedMan archives 205 Writing extensions Dartmouth, J F, mattgathu, Nathan Osman, techydesigner, ygram https://riptutorial.com/ 974

206 Writing to CSV from Hriddhi Dey, Thomas Crowley String or List https://riptutorial.com/ 975


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook