A Byte of Python

Total Page:16

File Type:pdf, Size:1020Kb

A Byte of Python A Byte of Python Swaroop C H Dedication To Kalyan Varma43 and many other seniors at PESIT44 who introduced us to GNU/ Linux and the world of open source. To the memory of Atul Chitnis45, a friend and guide who shall be missed greatly. To the pioneers who made the Internet happen46. This book was first written in 2003. It still remains popular, thanks to the nature of sharing knowledge on the Internet as envisioned by the pioneers. 43 http://www.kalyanvarma.net/ 44 http://www.pes.edu/ 45 http://www.nextbigwhat.com/atul-chitnis-obituary-297/ 46 http://www.ibiblio.org/pioneers/index.html ii Table of Contents ................................................................................................................................... x 1. Welcome ................................................................................................................ 1 1.1. Who reads A Byte of Python? .................................................................... 1 1.2. Academic Courses ...................................................................................... 9 1.3. License ...................................................................................................... 10 1.4. Read Now ................................................................................................. 10 1.5. Buy The Book ........................................................................................... 10 1.6. Download .................................................................................................. 11 1.7. Read the book in your native language .................................................... 11 Preface ..................................................................................................................... xii 1. Who This Book Is For .................................................................................. xii 2. History Lesson .............................................................................................. xii 3. Status Of The Book ..................................................................................... xiii 4. Official Website ............................................................................................ xiv 5. Something To Think About .......................................................................... xiv 2. Introduction .......................................................................................................... 15 2.1. Features of Python .................................................................................... 15 2.2. Python 2 versus 3 ..................................................................................... 17 2.3. What Programmers Say ............................................................................ 18 3. Installation ........................................................................................................... 19 3.1. Installation on Windows ............................................................................ 19 3.1.1. DOS Prompt .................................................................................... 19 3.1.2. Running Python prompt on Windows .............................................. 20 3.2. Installation on Mac OS X .......................................................................... 20 3.3. Installation on GNU/Linux ......................................................................... 21 3.4. Summary ................................................................................................... 21 4. First Steps ........................................................................................................... 22 4.1. Using The Interpreter Prompt ................................................................... 22 4.2. Choosing An Editor ................................................................................... 23 4.3. Light Table ................................................................................................ 24 4.4. Vim ............................................................................................................ 25 4.5. Emacs ....................................................................................................... 26 4.6. Using A Source File .................................................................................. 26 4.7. Getting Help .............................................................................................. 29 4.8. Summary ................................................................................................... 29 5. Basics .................................................................................................................. 30 iii A Byte of Python 5.1. Comments ................................................................................................. 30 5.2. Literal Constants ....................................................................................... 30 5.3. Numbers .................................................................................................... 31 5.4. Strings ....................................................................................................... 31 5.4.1. Single Quote ................................................................................... 31 5.4.2. Double Quotes ................................................................................ 31 5.4.3. Triple Quotes .................................................................................. 31 5.4.4. Strings Are Immutable .................................................................... 32 5.4.5. The format method ......................................................................... 32 5.4.6. Escape Sequences ......................................................................... 34 5.4.7. Raw String ...................................................................................... 35 5.5. Variable ..................................................................................................... 35 5.6. Identifier Naming ....................................................................................... 35 5.7. Data Types ................................................................................................ 36 5.8. Object ........................................................................................................ 36 5.9. How to write Python programs .................................................................. 36 5.10. Example: Using Variables And Literal Constants .................................... 36 5.11. Logical And Physical Line ....................................................................... 37 5.12. Indentation ............................................................................................... 39 5.13. Summary ................................................................................................. 40 6. Operators and Expressions ................................................................................. 41 6.1. Operators .................................................................................................. 41 6.2. Shortcut for math operation and assignment ............................................ 44 6.3. Evaluation Order ....................................................................................... 44 6.4. Changing the Order Of Evaluation ............................................................ 46 6.5. Associativity ............................................................................................... 46 6.6. Expressions ............................................................................................... 46 6.7. Summary ................................................................................................... 47 7. Control Flow ........................................................................................................ 48 7.1. The if statement .................................................................................... 48 7.2. The while Statement ................................................................................. 50 7.3. The for loop ........................................................................................... 52 7.4. The break Statement ................................................................................ 53 7.5. The continue Statement ...................................................................... 54 7.6. Summary ................................................................................................... 55 8. Functions ............................................................................................................. 56 8.1. Function Parameters ................................................................................. 57 8.2. Local Variables .......................................................................................... 58 iv A Byte of Python 8.3. The global statement ........................................................................... 59 8.4. Default Argument Values .......................................................................... 60 8.5. Keyword Arguments .................................................................................. 61 8.6. VarArgs parameters .................................................................................. 62 8.7. The return statement ........................................................................... 62 8.8. DocStrings ................................................................................................
Recommended publications
  • Wikis with Moinmoin Wiki Creative Group Writing
    KNOW HOW MoinMoin Wiki Building wikis with MoinMoin Wiki Creative Group Writing The members of a project team can profit from collecting their ideas, or any loose ends, in a central repository. Wikis are tailor-made for this task. BY HEIKE JURZIK ay before content manage- ment systems started to Wappear for website manage- ment, Wikis provided a kind of “open door” to HTML pages, allowing any visi- tor to click and edit the HTML content. Wiki is the abbreviation for WikiWiki- Web – “wiki wiki” is derived from Hawaiian and means “quick” or “quickly”. And the open authoring sys- restored at any time, should a page be MySQL, Oracle, or PostgreSQL. The soft- tem certainly is quick. The MoinMoin deleted or damaged by mistake. Also, ware then uses this data to create the Wiki engine is one of the better-known wikis allow you to assign special access public HTML pages. implementations of this technology. controls that can restrict editing to regis- Besides taking a look at the original Users can click to launch the embed- tered users, if required. wiki, you might like to visit what is cur- ded editor and access the content and The first wiki website was published rently the biggest wiki on the Web, the structure of the page they want to mod- by Ward Cunningham in 1995, and it is Wikipedia [3], which offers innumerable ify. Typically, an Edit link is provided to still online [1]. At the time, Cunningham articles on pages in multiple languages. make things easier. wrote an email message saying that he It is an example of how well information In contrast to “real” HTML, which had programmed a new kind of database can be organized with a wiki.
    [Show full text]
  • CSA ガイダンス Version 4.0 を用いた クラウドセキュリティリファレンス (OSS マッピング 2019)
    CSA ガイダンス version 4.0 を用いた クラウドセキュリティリファレンス (OSS マッピング 2019) 一般社団法人 日本クラウドセキュリティアライアンス(CSA ジャパン) クラウドセキュリティワーキンググループ Copyright © 2019 Cloud Security Alliance Japan Chapter 目次 1. はじめに ................................................................................................................................................ 4 2. 検討指針 ................................................................................................................................................ 5 3. DOMAIN6 管理画面と事業継続 ............................................................................................................... 6 4. DOMAIN7 インフラストラクチャ・セキュリティ ................................................................................ 10 5. DOMAIN8 仮想化とコンテナ技術 ......................................................................................................... 18 6. DOMAIN10 アプリケーションセキュリティ ......................................................................................... 22 7. DOMAIN11 データセキュリティと暗号化 ............................................................................................ 30 8. DOMAIN12 アイデンティティ管理、権限付与管理、アクセス管理 (IAM) ......................................... 35 9. 参考 URL ............................................................................................................................................... 39 Copyright © 2019 Cloud Security Alliance Japan Chapter 2 l 本書執筆編集メンバー 氏名 所属 井上 淳 NTT テクノクロス株式会社 釜山 公徳 日本電気株式会社 福田 貢士 (個人会員) 森田 翔 (個人会員) ※五十音順 l 変更履歴 日付 版数 変更内容 2019 年 2 月 26 日 1.0 初版発行 l 著作権についての留意事項 本書の著作権は、CSA
    [Show full text]
  • Research Article Constrained Wiki: the Wikiway to Validating Content
    Hindawi Publishing Corporation Advances in Human-Computer Interaction Volume 2012, Article ID 893575, 19 pages doi:10.1155/2012/893575 Research Article Constrained Wiki: The WikiWay to Validating Content Angelo Di Iorio,1 Francesco Draicchio,1 Fabio Vitali,1 and Stefano Zacchiroli2 1 Department of Computer Science, University of Bologna, Mura Anteo Zamboni 7, 40127 Bologna, Italy 2 Universit´e Paris Diderot, Sorbonne Paris Cit´e, PPS, UMR 7126, CNRS, F-75205 Paris, France Correspondence should be addressed to Angelo Di Iorio, [email protected] Received 9 June 2011; Revised 20 December 2011; Accepted 3 January 2012 Academic Editor: Kerstin S. Eklundh Copyright © 2012 Angelo Di Iorio et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. The “WikiWay” is the open editing philosophy of wikis meant to foster open collaboration and continuous improvement of their content. Just like other online communities, wikis often introduce and enforce conventions, constraints, and rules for their content, but do so in a considerably softer way, expecting authors to deliver content that satisfies the conventions and the constraints, or, failing that, having volunteers of the community, the WikiGnomes, fix others’ content accordingly. Constrained wikis is our generic framework for wikis to implement validators of community-specific constraints and conventions that preserve the WikiWay and their open collaboration features. To this end, specific requirements need to be observed by validators and a specific software architecture can be used for their implementation, that is, as independent functions (implemented as internal modules or external services) used in a nonintrusive way.
    [Show full text]
  • The Business of Free Software: Enterprise Incentives, Investment, and Motivation in the Open Source Community
    07-028 The Business of Free Software: Enterprise Incentives, Investment, and Motivation in the Open Source Community Dr. Marco Iansiti, Ph.D. Gregory L. Richards Marco Iansiti David Sarnoff Professor of Business Administration Harvard Business School Gregory L. Richards Managing Director Keystone Strategy, Inc. Copyright © 2006 by Dr. Marco Iansiti, Ph.D. and Gregory L. Richards Working papers are in draft form. This working paper is distributed for purposes of comment and discussion only. It may not be reproduced without permission of the copyright holder. Copies of working papers are available from the author. Harvard Business School Working Paper Series, No. 07-028, 2006 _______________________________________ The Business of Free Software: Enterprise Incentives, Investment, and Motivation in the Open Source Community _______________________________________ Marco Iansiti, David Sarnoff Professor of Business Administration, Harvard Business School Gregory L. Richards, Managing Director, Keystone Strategy, Inc. Boston, MA 02163, USA October 9, 2006 PRELIMINARY DRAFT – COMMENTS WELCOME ACKNOWLEDGEMENTS: We are grateful to Geoff Allan, Lester Chen, Mark McCormick, Boris Perlin, Alan MacCormack, and Karim Lakhani, who provided many valuable inputs and suggestions. 2 ABSTRACT In this paper, we examine the motivations of large information technology (“IT”) vendors, to invest in open source software (“OSS”). What drives companies with large, proprietary software portfolios to invest hundreds of millions of dollars in OSS? We approach this question by grouping a sample of OSS projects into clusters and examining vendors’ motivations for each cluster. We find one cluster has received almost no investment. Contributions to projects in this cluster are confined to the voluntary effort of the vendors’ employees, and vendors are likely altruistically motivated.
    [Show full text]
  • Essnet SCFE DELIVERABLE D5-4 Guidelines and Recommendations for Development of Training Materials and for Open Source Solutions and Projects
    ESSnet SCFE DELIVERABLE D5-4 Guidelines and recommendations for development of training materials and for open source solutions and projects Project acronym: SCFE Project title: “Sharing common functionalities in the ESS” Name(s), title(s) and organization or the auhor(s): Joaquim Machado, Dr. ([email protected]) José Carlos Martins, Eng. ([email protected]) Instituto Nacional de Estatítica Tel: +351 218 426 100 Fax: +351 218 454 083 e-mail: [email protected] This document is licensed under a Creative Commons License: Date: 29 Dec. 2017 Attribution-ShareAlike 4.0 International Table of Contents Introduction.............................................................................................................................1 Guidelines and recommendations.........................................................................................2 Open source solutions and projects.............................................................................2 What is Open Source?........................................................................................2 Why Open Source is good for business..............................................................6 How to make an Open Source Project..............................................................10 Development of training materials..............................................................................18 Sharing and re-using training materials............................................................18 Creating training materials................................................................................18
    [Show full text]
  • Dokuwiki Download Windows
    Dokuwiki download windows DokuWiki on a Stick can be downloaded from the official DokuWiki download page. Just choose the option under “Include Web-Server”. Download DokuWiki! Here you can download the latest DokuWiki-Version. Either just MicroApache (Windows) Apache , PHP , GD2 and SQLite ​Install:upgrade · ​Upgrade · ​Hosting · ​DokuWiki Archived Downloads. To create an “on the Stick” edition of DokuWiki, visit and check the “MicroApache (Windows)” checkbox in the. DokuWiki is a great wiki engine with minimal requirements that usually gets Download the non- thread-safe version of PHP for Windows from. XAMPP is a popular WAMP stack for the Windows operating system. Download the DokuWiki zip file from (e.g. Bitnami native installers automate the setup of a Bitnami application stack on Windows, OS X or Linux. Each installer includes all of the software necessary to run. The Bitnami DokuWiki Stack provides a one-click install solution for DokuWiki. Download installers and virtual machines, or run your own DokuWiki server in the. Download the executable file for the Bitnami DokuWiki Stack from the Bitnami This tool is named on Windows and is located in the. How to install DokuWiki on Windows XP in less then 5 minutes: 1) Download and install WAMP5 (or the latest version) for Windows XP. How install DokuWiki on your server . Install DokuWiki on windows 7 localhost (XAMPP + php7. DokuWiki latest version: Free and User-Friendly Open-Source Information Storage Software. DokuWiki is Download DokuWiki for Windows. DokuWiki ist eine schlanke Wiki-Anwendung auf PHP-Basis, die ohne Datenbank auskommt und eingetragene Texte als TXT-Dateien ablegt.
    [Show full text]
  • Uporaba Odprte Kode Kot Osnova Za Razvoj Programske Opreme
    Univerza v Ljubljani Fakulteta za računalništvo in informatiko Univerzitetni študij Diplomska naloga Uporaba odprte kode kot osnova za razvoj programske opreme Peter Primožič Mentor: prof. dr. Franc Solina, univ. dipl. ing. Ljubljana, februar 2005 Kazalo POVZETEK .............................................................................................................................VI 1 UVOD ................................................................................................................................ 1 2 FENOMEN ODPRTE KODE............................................................................................ 3 2.1 Zgodovina odprte kode............................................................................................... 3 2.1.1 GNU projekt....................................................................................................... 3 2.1.2 Linux .................................................................................................................. 5 2.1.3 Današnji čas........................................................................................................ 6 2.2 Definicija prostega programja in odprte kode............................................................ 7 2.2.1 Prosto programje ................................................................................................ 7 2.2.2 Odprta koda........................................................................................................ 9 2.3 Licenčni modeli prostega programja.......................................................................
    [Show full text]
  • WHY USE a WIKI? an Introduction to the Latest Online Publishing Format
    WHY USE A WIKI? An Introduction to the Latest Online Publishing Format A WebWorks.com White Paper Author: Alan J. Porter VP-Operations WebWorks.com a brand of Quadralay Corporation [email protected] WW_WP0309_WIKIpub © 2009 – Quadralay Corporation. All rights reserved. NOTE: Please feel free to redistribute this white paper to anyone you feel may benefit. If you would like an electronic copy for distribution, just send an e-mail to [email protected] CONTENTS Overview................................................................................................................................ 2 What is a Wiki? ...................................................................................................................... 2 Open Editing = Collaborative Authoring .................................................................................. 3 Wikis in More Detail................................................................................................................ 3 Wikis Are Everywhere ............................................................................................................ 4 Why Use a Wiki...................................................................................................................... 5 Getting People to Use Wikis ................................................................................................... 8 Populating the Wiki................................................................................................................. 9 WebWorks ePublisher and Wikis
    [Show full text]
  • Which Wiki for Which Uses
    Which wiki for which uses There are over 120 Wiki software available to set up a wiki plateform. Those listed below are the 13 more popular (by alphabetic order) wiki engines as listed on http://wikimatrix.org on the 16th of March 2012. The software license decides on what conditions a certain software may be used. Among other things, the software license decide conditions to run, study the code, modify the code and redistribute copies or modified copies of the software. Wiki software are available either hosted on a wiki farm or downloadable to be installed locally. Wiki software Reference Languages Wikifarm Technology Licence Main audience Additional notes name organization available available very frequently met in corporate environment. Arguably the most widely deployed wiki software in the entreprise market. A zero- Confluence Atlassian Java proprietary 11 confluence entreprise cost license program is available for non-profit organizations and open source projects aimed at small companies’ documentation needs. It works on plain DokuWiki several companies Php GPL2 50 small companies text files and thus needs no database. DrupalWiki Kontextwork.de Php GPL2+ 12 entreprise DrupalWiki is intended for enterprise use Entreprise wiki. Foswiki is a wiki + structured data + Foswiki community Perl GPL2 22 entreprise programmable pages education, public Wikimedia Php with backend MediaWiki is probably the best known wiki software as it is the MediaWiki GPLv2+ >300 wikia and many hostingservice, companies private Foundation and others database one used by Wikipedia. May support very large communities knowledge-based site MindTouchTCS MindTouch Inc. Php proprietary 26 SamePage partly opensource and partly proprietary extensions Jürgen Hermann & Python with flat tech savy MoinMoin GPL2 10+ ourproject.org Rather intended for small to middle size workgroup.
    [Show full text]
  • Snapshots of Open Source Project Management Software
    International Journal of Economics, Commerce and Management United Kingdom ISSN 2348 0386 Vol. VIII, Issue 10, Oct 2020 http://ijecm.co.uk/ SNAPSHOTS OF OPEN SOURCE PROJECT MANAGEMENT SOFTWARE Balaji Janamanchi Associate Professor of Management Division of International Business and Technology Studies A.R. Sanchez Jr. School of Business, Texas A & M International University Laredo, Texas, United States of America [email protected] Abstract This study attempts to present snapshots of the features and usefulness of Open Source Software (OSS) for Project Management (PM). The objectives include understanding the PM- specific features such as budgeting project planning, project tracking, time tracking, collaboration, task management, resource management or portfolio management, file sharing and reporting, as well as OSS features viz., license type, programming language, OS version available, review and rating in impacting the number of downloads, and other such usage metrics. This study seeks to understand the availability and accessibility of Open Source Project Management software on the well-known large repository of open source software resources, viz., SourceForge. Limiting the search to “Project Management” as the key words, data for the top fifty OS applications ranked by the downloads is obtained and analyzed. Useful classification is developed to assist all stakeholders to understand the state of open source project management (OSPM) software on the SourceForge forum. Some updates in the ranking and popularity of software since
    [Show full text]
  • Using Wikis in Software Development
    open source Editor: Christof Ebert ■ Alcatel ■ [email protected] Using Wikis in Software Development Panagiotis Louridas In only a few years, wikis have become one of the most popular tool shells imaginable based on open source software. You can find them just about everywhere that demands effective col- laboration and knowledge sharing at a low budget. Wikipedia has certainly enhanced their pop- ularity, but they also have a place in intranet-based applications such as defect tracking, re- quirements management, test-case management, and project portals. Panagiotis Louridas describes wiki essentials and nicely distinguishes a variety of types. You’ll find something useful, I’m sure. —Christof Ebert y 1995, Ward Cunningham, a promi- What is a wiki? nent member of the design patterns A wiki is actually two things: community, was experimenting with a hypertext environment to promote the ■ a program that makes it exceptionally easy exchange of the community’s ideas. for anybody to edit Web pages and B ■ The environment was based on the a philosophy regarding how users should then-popular Apple Hyper- go about that editing. Card application. That applica- tion worked well for individual Generally, Web pages are written in HTML. users, but Cunningham was While it’s not difficult to learn HTML, non- looking for a Web-based imple- programmers tend to shy away from it. Even mentation. On 25 March 1995, programmers find it easier to edit text than he posted the Web’s first-ever structured HTML, where linking between wiki, calling it “the simplest pages requires attention to things such as ad- online database that could pos- dresses and anchors.
    [Show full text]
  • Moinmoin Documentation Release 0.1.Dev196+G250faa1
    MoinMoin Documentation Release 0.1.dev196+g250faa1 The MoinMoin developers Aug 22, 2021 Contents 1 General 3 1.1 About MoinMoin.............................................3 1.2 What makes MoinMoin special?.....................................4 1.3 Who is using MoinMoin?........................................4 2 Features 7 2.1 Operating System Support........................................7 2.2 Servers..................................................7 2.3 Authentication..............................................8 2.4 Authorization...............................................8 2.5 Anti-Spam................................................8 2.6 Storage..................................................8 2.7 Search / Indexing.............................................9 2.8 User Interface..............................................9 2.9 Logging.................................................. 10 2.10 Technologies............................................... 11 3 License 13 4 Using MoinMoin 21 4.1 User Accounts.............................................. 21 4.2 Markups Supported by MoinMoin.................................... 24 4.3 Templates and Meta Data........................................ 77 4.4 Searching and Finding.......................................... 78 4.5 File Upload................................................ 81 4.6 Namespaces............................................... 82 4.7 User Subscriptions............................................ 82 5 Administrating MoinMoin 85 5.1 Requirements..............................................
    [Show full text]