Zero Buffer Documentation

Size: px
Start display at page:

Download "Zero Buffer Documentation"

Transcription

1 Zero Buffer Documentation Release Alex Gaynor and David Reid March 02, 2017

2

3 Contents 1 Installation 3 2 Contents API Reference i

4 ii

5 Zero Buffer Documentation, Release zero_buffer is a high-performance, zero-copy, implementation of a byte-buffer for Python. from zero_buffer import Buffer # Create a buffer which has space for 8192 bytes. b = Buffer.allocate(8192) with open(path, "rb") as f: # Read up to 8192 bytes from the file into the buffer b.read_from(f.fileno()) # Create a read-only view of the buffer, this performs no copying. view = b.view() # Split the view on colons, this returns a generator which yields sub-views # of the view. for part in view.split(b":"): print(part) zero_buffer works on Python 2.6, 2.7, 3.3+, and PyPy. Contents 1

6 Zero Buffer Documentation, Release 2 Contents

7 CHAPTER 1 Installation Install it with pip: $ pip install zero_buffer If you are installing zero_buffer on Ubuntu, you may need to run the following before installing it with pip. $ sudo apt-get install build-essential libffi-dev python-dev 3

8 Zero Buffer Documentation, Release 4 Chapter 1. Installation

9 CHAPTER 2 Contents API Reference class zero_buffer.buffer A buffer is a fixed-size, append only, contigious region of memory. Once data is in it, that data cannot be mutated, however data can be read into the buffer with multiple calls. classmethod allocate(size) Parameters size (int) Number of bytes. Return Buffer The new buffer. Allocates a new buffer of size bytes. capacity Returns the size of the underlying buffer. This is the same as what it was allocated with. writepos Returns the current, internal writing position, this increases on calls to read_from() and add_bytes(). free Returns the remaining space in the Buffer. read_from(fd) Parameters fd (int) A file descriptor. Return int Number of bytes read. Raises OSError on an error reading from the file descriptor. EOFError when the read position of the file is at the end. BufferFull when the buffer has no remaining space when called Reads from the file descriptor into the Buffer. Note that the number of bytes copied may be less than the number of bytes in the file. add_bytes(b) Parameters b (bytes) Bytes to copy into the buffer. Return int Number of bytes copied into the buffer. Raises BufferFull when the buffer has no remaining space when called 5

10 Zero Buffer Documentation, Release Copies the bytes into the Buffer. Note that the number of bytes copied may be less than len(b) if there isn t space in the Buffer. view(start=0, stop=none) Parameters start (int) The byte-offset from the beggining of the buffer. stop (int) The byte-offset from start. Return BufferView Raises ValueError If the stop is before the start, if the start is negative or after the writepos, or if the stop is after the writepos. Returns a view of the buffer s data. This does not perform any copying. class zero_buffer.bufferview A buffer view is an immutable, fixed-size, view over a contigious region of memory. It exposes much of the same API as bytes, except most methods return BufferViews and do not make copies of the data. A buffer view is either a view into a Buffer or into another BufferView. bytes () Returns a copy of the contents of the view as a bytes. len () Returns the length of the view. eq (other) Checks whether the contents of the view are equal to other, which can be either a bytes or a BufferView. contains (needle) Returns whether or not the needle exists in the view as a contigious series of bytes. getitem (idx) If idx is a slice, returns a BufferView over that data, it does not perform a copy. If idx is an integer, it returns the ordinal value of the byte at that index. Unlike other containers in Python, this does not support slices with steps (view[::2]). add (other) Parameters other (BufferView) Returns a BufferView over the concatenated contents. If other is contigious with self in memory, no copying is performed, otherwise both views are copied into a new one. find(needle, start=0, stop=none) The same as bytes.find(). index(needle, start=0, stop=none) The same as bytes.index(). rfind(needle, start=0, stop=none) The same as bytes.rfind(). rindex(needle, start=0, stop=none) The same as bytes.rindex(). split(by, maxsplit=-1) Similar to bytes.split(), except it returns an iterator (not a list) over the results, and each result is a BufferView (not a bytes). 6 Chapter 2. Contents

11 Zero Buffer Documentation, Release splitlines(keepends=false) Similar to bytes.splitlines(), except it returns an iterator (not a list) over the results, and each result is a BufferView (not a bytes). isspace() The same as bytes.isspace(). isdigit() The same as bytes.isdigit(). isalpha() The same as bytes.isalpha(). strip(chars=none) The same as bytes.strip() except it returns a BufferView (and not a bytes). lstrip(chars=none) The same as bytes.lstrip() except it returns a BufferView (and not a bytes). rstrip(chars=none) The same as bytes.rstrip() except it returns a BufferView (and not a bytes). write_to(fd) Parameters fd (int) A file descriptor. Return int Number of bytes written. Raises OSError on an error writing to the file descriptor. Writes the contents of the buffer to a file descriptor. Note that the number of bytes written may be less than the number of bytes in the buffer view. class zero_buffer.buffercollator A buffer collator is a collection of BufferView objects which can be collapsed into a single BufferView. len () Returns the sum of the lengths of the views inside the collator. append(view) Parameters view (BufferView) Adds the contents of a view to the collator. collapse() Collapses the contents of the collator into a single BufferView. Also resets the internal state of the collator, so if you call it twice successively, the second call will return an empty BufferView API Reference 7

12 Zero Buffer Documentation, Release 8 Chapter 2. Contents

13 Index Symbols add () (zero_buffer.bufferview method), 6 bytes () (zero_buffer.bufferview method), 6 contains () (zero_buffer.bufferview method), 6 eq () (zero_buffer.bufferview method), 6 getitem () (zero_buffer.bufferview method), 6 len () (zero_buffer.buffercollator method), 7 len () (zero_buffer.bufferview method), 6 A add_bytes() (zero_buffer.buffer method), 5 allocate() (zero_buffer.buffer class method), 5 append() (zero_buffer.buffercollator method), 7 B Buffer (class in zero_buffer), 5 BufferCollator (class in zero_buffer), 7 BufferView (class in zero_buffer), 6 C capacity (zero_buffer.buffer attribute), 5 collapse() (zero_buffer.buffercollator method), 7 F find() (zero_buffer.bufferview method), 6 free (zero_buffer.buffer attribute), 5 I index() (zero_buffer.bufferview method), 6 isalpha() (zero_buffer.bufferview method), 7 isdigit() (zero_buffer.bufferview method), 7 isspace() (zero_buffer.bufferview method), 7 L lstrip() (zero_buffer.bufferview method), 7 R read_from() (zero_buffer.buffer method), 5 rfind() (zero_buffer.bufferview method), 6 rindex() (zero_buffer.bufferview method), 6 rstrip() (zero_buffer.bufferview method), 7 S split() (zero_buffer.bufferview method), 6 splitlines() (zero_buffer.bufferview method), 6 strip() (zero_buffer.bufferview method), 7 V view() (zero_buffer.buffer method), 6 W write_to() (zero_buffer.bufferview method), 7 writepos (zero_buffer.buffer attribute), 5 9

Python Tutorial. Day 1

Python Tutorial. Day 1 Python Tutorial Day 1 1 Why Python high level language interpreted and interactive real data structures (structures, objects) object oriented all the way down rich library support 2 The First Program #!/usr/bin/env

More information

Strings. Upsorn Praphamontripong. Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break

Strings. Upsorn Praphamontripong. Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break Note: for reference when we practice loop. We ll discuss Strings in detail after Spring break Strings Upsorn Praphamontripong CS 1111 Introduction to Programming Spring 2018 Strings Sequence of characters

More information

Introductory Linux Course. Python I. Martin Dahlö UPPMAX. Author: Nina Fischer. Dept. for Cell and Molecular Biology, Uppsala University

Introductory Linux Course. Python I. Martin Dahlö UPPMAX. Author: Nina Fischer. Dept. for Cell and Molecular Biology, Uppsala University Introductory Linux Course Martin Dahlö UPPMAX Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University August, 2018 Outline Python basics get started with Python Data types Control

More information

Working with Sequences: Section 8.1 and 8.2. Bonita Sharif

Working with Sequences: Section 8.1 and 8.2. Bonita Sharif Chapter 8 Working with Sequences: Strings and Lists Section 8.1 and 8.2 Bonita Sharif 1 Sequences A sequence is an object that consists of multiple data items These items are stored consecutively Examples

More information

String Processing CS 1111 Introduction to Programming Fall 2018

String Processing CS 1111 Introduction to Programming Fall 2018 String Processing CS 1111 Introduction to Programming Fall 2018 [The Coder s Apprentice, 10] 1 Collections Ordered, Dup allow List Range String Tuple Unordered, No Dup Dict collection[index] Access an

More information

Chapter 8: More About Strings. COSC 1436, Summer 2018 Dr. Zhang 7/10/2018

Chapter 8: More About Strings. COSC 1436, Summer 2018 Dr. Zhang 7/10/2018 Chapter 8: More About Strings COSC 1436, Summer 2018 Dr. Zhang 7/10/2018 Creating Strings The str Class s1 = str() # Create an empty string s2 = str("welcome") # Create a string Welcome Python provides

More information

Introductory Linux Course. Python I. Pavlin Mitev UPPMAX. Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University

Introductory Linux Course. Python I. Pavlin Mitev UPPMAX. Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University Introductory Linux Course Python I Pavlin Mitev UPPMAX Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University August, 2017 Outline Python introduction Python basics get started with

More information

IPSL python tutorial: some exercises for beginners

IPSL python tutorial: some exercises for beginners 1 of 9 10/22/2013 03:55 PM IPSL python tutorial: some exercises for beginners WARNING! WARNING! This is the FULL version of the tutorial (including the solutions) WARNING! Jean-Yves Peterschmitt - LSCE

More information

Introduction to Python for Plone developers

Introduction to Python for Plone developers Plone Conference, October 15, 2003 Introduction to Python for Plone developers Jim Roepcke Tyrell Software Corporation What we will learn Python language basics Where you can use Python in Plone Examples

More information

Python - 2. Jim Eng

Python - 2. Jim Eng Python - 2 Jim Eng jimeng@umich.edu Lists Dictionaries Try... except Methods and Functions Classes and Objects Midterm Review Overview Patterns in programming - 1 Sequential steps Conditional steps Repeated

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Introductory Linux Course. Python I. Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University

Introductory Linux Course. Python I. Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University Introductory Linux Course Python I Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University nina.fischer@icm.uu.se August 26, 2016 Outline q Python introducjon q Python basics get started

More information

Introductory Linux Course. Python I. Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University

Introductory Linux Course. Python I. Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University Introductory Linux Course Python I Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University nina.fischer@icm.uu.se January 12, 2017 Outline q Python introducjon q Python basics get started

More information

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26, Part IV More on Python Compact Course @ Max-Planck, February 16-26, 2015 36 More on Strings Special string methods (excerpt) s = " Frodo and Sam and Bilbo " s. islower () s. isupper () s. startswith ("

More information

MULTIPLE CHOICE. Chapter Seven

MULTIPLE CHOICE. Chapter Seven Chapter Seven MULTIPLE CHOICE 1. Which of these is associated with a specific file and provides a way for the program to work with that file? a. Filename b. Extension c. File object d. File variable 2.

More information

Strings. Chapter 6. Python for Everybody

Strings. Chapter 6. Python for Everybody Strings Chapter 6 Python for Everybody www.py4e.com String Data Type A string is a sequence of characters A string literal uses quotes 'Hello' or "Hello" For strings, + means concatenate When a string

More information

Princeton University COS 333: Advanced Programming Techniques A Subset of Python 2.7

Princeton University COS 333: Advanced Programming Techniques A Subset of Python 2.7 Princeton University COS 333: Advanced Programming Techniques A Subset of Python 2.7 Program Structure # Print "hello world" to stdout. print 'hello, world' # Print "hello world" to stdout. def f(): print

More information

Duration: Six Weeks Faculty : Mr Sai Kumar, Having 10+ Yrs Experience in IT

Duration: Six Weeks Faculty : Mr Sai Kumar, Having 10+ Yrs Experience in IT Duration: Six Weeks Faculty : Mr Sai Kumar, Having 10+ Yrs Experience in IT Online Classes are also available Recorded class will be given if you miss any day interview tips and quiz at end of every module

More information

IntSet Documentation. Release David R. MacIver

IntSet Documentation. Release David R. MacIver IntSet Documentation Release 1.0.0 David R. MacIver October 29, 2015 Contents Python Module Index 3 i ii IntSet Documentation, Release 1.0.0 class intset.intset(wrapped) An IntSet is a compressed immutable

More information

iptools Release dev

iptools Release dev iptools Release 0.7.0-dev August 21, 2016 Contents 1 Using with Django INTERNAL_IPS 3 2 Python Version Compatibility 5 3 Installation 7 4 API 9 4.1 iptools..................................................

More information

Advanced Python. Executive Summary, Session 1

Advanced Python. Executive Summary, Session 1 Advanced Python Executive Summary, Session 1 OBJECT: a unit of data of a particular type with characteristic functionality (i.e., methods and/or use with operators). Everything in Python is an object.

More information

Sequence types. str and bytes are sequence types Sequence types have several operations defined for them. Sequence Types. Python

Sequence types. str and bytes are sequence types Sequence types have several operations defined for them. Sequence Types. Python Python Sequence Types Sequence types str and bytes are sequence types Sequence types have several operations defined for them Indexing Python Sequence Types Each element in a sequence can be extracted

More information

Pypeline Documentation

Pypeline Documentation Pypeline Documentation Release 0.2 Kyle Corbitt May 09, 2014 Contents 1 Contents 3 1.1 Installation................................................ 3 1.2 Quick Start................................................

More information

CS 115 Lecture 13. Strings. Neil Moore. Department of Computer Science University of Kentucky Lexington, Kentucky

CS 115 Lecture 13. Strings. Neil Moore. Department of Computer Science University of Kentucky Lexington, Kentucky CS 115 Lecture 13 Strings Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 29 October 2015 Strings We ve been using strings for a while. What can

More information

Introduction to String Manipulation

Introduction to String Manipulation Introduction to Computer Programming Introduction to String Manipulation CSCI-UA.0002 What is a String? A String is a data type in the Python programming language A String can be described as a "sequence

More information

Strings are actually 'objects' Strings

Strings are actually 'objects' Strings Strings are actually 'objects' Strings What is an object?! An object is a concept that we can encapsulate data along with the functions that might need to access or manipulate that data. What is an object?!

More information

Slicing. Open pizza_slicer.py

Slicing. Open pizza_slicer.py Slicing and Tuples Slicing Open pizza_slicer.py Indexing a string is a great way of getting to a single value in a string However, what if you want to use a section of a string Like the middle name of

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Part III Appendices 165

Part III Appendices 165 Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.

More information

Data structure and algorithm in Python

Data structure and algorithm in Python Data structure and algorithm in Python Array-Based Sequences Xiaoping Zhang School of Mathematics and Statistics, Wuhan University Table of contents 1. Python s Sequence Types 2. Low-Level s Arrays 3.

More information

Python Objects. Charles Severance. Python for Everybody

Python Objects. Charles Severance. Python for Everybody Python Objects Charles Severance Python for Everybody www.py4e.com Warning This lecture is very much about definitions and mechanics for objects This lecture is a lot more about how it works and less about

More information

SI Networked Computing: Storage, Communication, and Processing, Winter 2009

SI Networked Computing: Storage, Communication, and Processing, Winter 2009 University of Michigan Deep Blue deepblue.lib.umich.edu 2009-01 SI 502 - Networked Computing: Storage, Communication, and Processing, Winter 2009 Severance, Charles Severance, C. (2008, December 19). Networked

More information

Handling Strings and Bytes

Handling Strings and Bytes Chapter 9 Handling Strings and Bytes In this chapter, we present some of the most used methods in strings and bytes objects. Strings are extremely useful to manage most of the output generated from programs,

More information

Python. Executive Summary

Python. Executive Summary Python Executive Summary DEFINITIONS OBJECT: a unit of data of a particular type with characteristic functionality (i.e., methods and/or response to operators). Everything in Python is an object. "atomic"

More information

PySoundFile Documentation Release 0.6.0

PySoundFile Documentation Release 0.6.0 PySoundFile Documentation Release 0.6.0 Bastian Bechtold, Matthias Geier January 30, 2015 Contents 1 Breaking Changes 1 2 Installation 1 3 Read/Write Functions 2 4 Block Processing 2 5 SoundFile Objects

More information

python-twitch-stream Documentation

python-twitch-stream Documentation python-twitch-stream Documentation Release 0.0.dev1 Jonas Degrave October 26, 2017 Contents 1 Installation 3 2 Support 5 3 Contents 7 3.1 twitchstream.chat........................................ 7 3.2

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Generators Exceptions and IO Eric Kutschera University of Pennsylvania February 13, 2015 Eric Kutschera (University of Pennsylvania) CIS 192 February 13, 2015 1 / 24 Outline 1

More information

ENGR 102 Engineering Lab I - Computation

ENGR 102 Engineering Lab I - Computation ENGR 102 Engineering Lab I - Computation Week 07: Arrays and Lists of Data Introduction to Arrays In last week s lecture, 1 we were introduced to the mathematical concept of an array through the equation

More information

Chapter 6: List. 6.1 Definition. What we will learn: What you need to know before: Data types Assignments

Chapter 6: List. 6.1 Definition. What we will learn: What you need to know before: Data types Assignments Chapter 6: List What we will learn: List definition Syntax for creating lists Selecting elements of a list Selecting subsequence of a list What you need to know before: Data types Assignments List Sub-list

More information

Standard prelude. Appendix A. A.1 Classes

Standard prelude. Appendix A. A.1 Classes Appendix A Standard prelude In this appendix we present some of the most commonly used definitions from the standard prelude. For clarity, a number of the definitions have been simplified or modified from

More information

Module 3: Strings and Input/Output

Module 3: Strings and Input/Output Module 3: Strings and Input/Output Topics: Strings and their methods Printing to standard output Reading from standard input Readings: ThinkP 8, 10 1 Strings in Python: combining strings in interesting

More information

Lists How lists are like strings

Lists How lists are like strings Lists How lists are like strings A Python list is a new type. Lists allow many of the same operations as strings. (See the table in Section 4.6 of the Python Standard Library Reference for operations supported

More information

(IUCAA, Pune) kaustubh[at]iucaa[dot]ernet[dot]in.

(IUCAA, Pune)   kaustubh[at]iucaa[dot]ernet[dot]in. Basics of Python by Kaustubh Vaghmare (IUCAA, Pune) E-mail: kaustubh[at]iucaa[dot]ernet[dot]in 1 of 29 Thursday 13 February 2014 11:59 AM Topics to be Covered (Not in any specific order.) Basic I/O in

More information

Iterators & Generators

Iterators & Generators Iterators & Generators Sequences A sequence is something that you can: Index into Get the length of What are some examples of sequences? Sequences We ve been working with sequences all semester! Examples:

More information

6. Data Types and Dynamic Typing (Cont.)

6. Data Types and Dynamic Typing (Cont.) 6. Data Types and Dynamic Typing (Cont.) 6.5 Strings Strings can be delimited by a pair of single quotes ('...'), double quotes ("..."), triple single quotes ('''...'''), or triple double quotes ("""...""").

More information

Babu Madhav Institute of Information Technology, UTU 2015

Babu Madhav Institute of Information Technology, UTU 2015 Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?

More information

obfuscator Documentation

obfuscator Documentation obfuscator Documentation Release 1.1.5 Timothy McFadden July 17, 2015 Contents 1 Introduction 3 2 Install 5 3 Usage 7 4 Auto Generated API Documentation 9 4.1 obfuscator.file..............................................

More information

Exam 3. 1 True or False. CSCE 110. Introduction to Programming Exam 3

Exam 3. 1 True or False. CSCE 110. Introduction to Programming Exam 3 CSCE 110. Introduction to Programming Exam 3 Exam 3 Professor:Joseph Hurley Exam Version B 1 True or False Fill in the bubble for "A" if the answer is True. Fill in the bubble for "B" if the answer is

More information

Programming environments. Introduction to Python. Adrian Copie, Ph.D.

Programming environments. Introduction to Python. Adrian Copie, Ph.D. Programming environments Introduction to Python Adrian Copie, Ph.D.! email: adrian.copie@info.uvt.ro, adrian.copie@e-uvt.ro UVT: room 050B 1 2 Bibliography 3 Mark Lutz - Learning Python (O Reilly) Leaning

More information

18.1. CS 102 Unit 18. Python. Mark Redekopp

18.1. CS 102 Unit 18. Python. Mark Redekopp 18.1 CS 102 Unit 18 Python Mark Redekopp 18.2 Credits Many of the examples below are taken from the online Python tutorial at: http://docs.python.org/tutorial/introduction.html 18.3 Python in Context Two

More information

Python Companion to Data Science

Python Companion to Data Science Extracted from: Python Companion to Data Science Collect Organize Explore Predict Value This PDF file contains pages extracted from Python Companion to Data Science, published by the Pragmatic Bookshelf.

More information

Algorithms in Systems Engineering ISE 172. Lecture 5. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 5. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 5 Dr. Ted Ralphs ISE 172 Lecture 5 1 References for Today s Lecture Required reading Chapter 3 ISE 172 Lecture 5 2 Delving into the Lists As we have seen

More information

COLLEGE OF ENGINEERING, NASHIK-4

COLLEGE OF ENGINEERING, NASHIK-4 Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4 DEPARTMENT OF COMPUTER ENGINEERING Important PYTHON Questions 1. What is Python? Python is a high-level, interpreted, interactive and object-oriented

More information

Warcat Documentation. Release Christopher Foo

Warcat Documentation. Release Christopher Foo Warcat Documentation Release 2.2.4 Christopher Foo Apr 11, 2017 Contents 1 Readme 3 1.1 WARCAT: Web ARChive (WARC) Archiving Tool........................... 3 1.2 Quick Start................................................

More information

(IUCAA, Pune) kaustubh[at]iucaa[dot]ernet[dot]in 1 of 29 Thursday 16 October :50 PM

(IUCAA, Pune)   kaustubh[at]iucaa[dot]ernet[dot]in 1 of 29 Thursday 16 October :50 PM Basics of Python by Kaustubh Vaghmare (IUCAA, Pune) E-mail: kaustubh[at]iucaa[dot]ernet[dot]in 1 of 29 Thursday 16 October 2014 03:50 PM Topics to be Covered (Not in any specific order.) Basic I/O in Python

More information

Beyond Blocks: Python Session #1

Beyond Blocks: Python Session #1 Beyond Blocks: Session #1 CS10 Spring 2013 Thursday, April 30, 2013 Michael Ball Beyond Blocks : : Session #1 by Michael Ball adapted from Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike

More information

Worksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords

Worksheet 6: Basic Methods Methods The Format Method Formatting Floats Formatting Different Types Formatting Keywords Worksheet 1: Introductory Exercises Turtle Programming Calculations The Print Function Comments Syntax Semantics Strings Concatenation Quotation Marks Types Variables Restrictions on Variable Names Long

More information

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Python review. 1 Python basics. References. CS 234 Naomi Nishimura Python review CS 234 Naomi Nishimura The sections below indicate Python material, the degree to which it will be used in the course, and various resources you can use to review the material. You are not

More information

ISE 101 Introduction to Information Systems. Lecture 3 Objectives: While loops Strings

ISE 101 Introduction to Information Systems. Lecture 3 Objectives: While loops Strings ISE 101 Introduction to Information Systems Lecture 3 Objectives: While loops Strings While Loops Write a Python script that computes the sum of squares from 1 to 5. sum = 0; sum = sum + 1**2; sum = sum

More information

Data Structures. Lists, Tuples, Sets, Dictionaries

Data Structures. Lists, Tuples, Sets, Dictionaries Data Structures Lists, Tuples, Sets, Dictionaries Collections Programs work with simple values: integers, floats, booleans, strings Often, however, we need to work with collections of values (customers,

More information

CSE 410: Systems Programming

CSE 410: Systems Programming CSE 410: Systems Programming Input and Output Ethan Blanton Department of Computer Science and Engineering University at Buffalo I/O Kernel Services We have seen some text I/O using the C Standard Library.

More information

Introduction to Problem Solving and Programming in Python.

Introduction to Problem Solving and Programming in Python. Introduction to Problem Solving and Programming in Python http://cis-linux1.temple.edu/~tuf80213/courses/temple/cis1051/ Overview Python sequences Lists, Tuples, and Ranges Built-in operations Slicing

More information

Notebook. March 30, 2019

Notebook. March 30, 2019 Notebook March 30, 2019 1 Complex Data Types Some kinds of data can store other kinds of data. 1.1 Lists We ve actually seen the most common complex data type a few times before, I just haven t pointed

More information

msgpack Documentation

msgpack Documentation msgpack Documentation Release 0.4 Author 2017-11-04 Contents 1 API reference 3 Python Module Index 9 i ii MessagePack is a efficient format for inter language data exchange. Contents 1 2 Contents CHAPTER

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Iterators, Generators, Exceptions & IO Raymond Yin University of Pennsylvania September 28, 2016 Raymond Yin (University of Pennsylvania) CIS 192 September 28, 2016 1 / 26 Outline

More information

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College

The string Class. Lecture 21 Sections 2.9, 3.9, Robb T. Koether. Wed, Oct 17, Hampden-Sydney College The string Class Lecture 21 Sections 2.9, 3.9, 3.10 Robb T. Koether Hampden-Sydney College Wed, Oct 17, 2018 Robb T. Koether (Hampden-Sydney College) The string Class Wed, Oct 17, 2018 1 / 18 1 The String

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Object Oriented Programming Harry Smith University of Pennsylvania February 15, 2016 Harry Smith (University of Pennsylvania) CIS 192 Lecture 5 February 15, 2016 1 / 26 Outline

More information

python-snap7 Documentation

python-snap7 Documentation python-snap7 Documentation Release 0.1 Gijs Molenaar, Stephan Preeker February 28, 2014 Contents i ii python-snap7 Documentation, Release 0.1 Contents: Contents 1 python-snap7 Documentation, Release 0.1

More information

pybdg Documentation Release 1.0.dev2 Outernet Inc

pybdg Documentation Release 1.0.dev2 Outernet Inc pybdg Documentation Release 1.0.dev2 Outernet Inc April 17, 2016 Contents 1 Source code 3 2 License 5 3 Documentation 7 Python Module Index 15 i ii Bitloads, or bit payloads, are compact payloads containing

More information

CS2304: Python for Java Programmers. CS2304: Sequences and Collections

CS2304: Python for Java Programmers. CS2304: Sequences and Collections CS2304: Sequences and Collections Sequences In Python A sequence type in python supports: The in membership operator. The len() function. Slicing like we saw with strings, s[1:3]. And is iterable (for

More information

Programming Training. Main Points: - More Fundamental algorithms on Arrays. - Reading / Writing from files - Problem Solving

Programming Training. Main Points: - More Fundamental algorithms on Arrays. - Reading / Writing from files - Problem Solving Programming Training Main Points: - More Fundamental algorithms on Arrays. - Reading / Writing from files - Problem Solving Functions in Python A Python program is a sequence of a functions which can be

More information

PROGRAMMING, DATA STRUCTURES AND ALGORITHMS IN PYTHON

PROGRAMMING, DATA STRUCTURES AND ALGORITHMS IN PYTHON NPTEL MOOC PROGRAMMING, DATA STRUCTURES AND ALGORITHMS IN PYTHON Week 5, Lecture 3 Madhavan Mukund, Chennai Mathematical Institute http://www.cmi.ac.in/~madhavan Dealing with files Standard input and output

More information

CS 1110 Prelim 2 April 22, 2014

CS 1110 Prelim 2 April 22, 2014 CS 1110 Prelim 2 April 22, 2014 This 90-minute exam has 6 questions worth a total of 46 points. When permitted to begin, scan the whole test before starting. Budget your time wisely. Use the back of the

More information

COMP1730/COMP6730 Programming for Scientists. Strings

COMP1730/COMP6730 Programming for Scientists. Strings COMP1730/COMP6730 Programming for Scientists Strings Lecture outline * Sequence Data Types * Character encoding & strings * Indexing & slicing * Iteration over sequences Sequences * A sequence contains

More information

Python Review IPRE

Python Review IPRE Python Review 2 Jay Summet 2005-12-31 IPRE Outline Compound Data Types: Strings, Tuples, Lists & Dictionaries Immutable types: Strings Tuples Accessing Elements Cloning Slices Mutable Types: Lists Dictionaries

More information

Python: common syntax

Python: common syntax Lab 09 Python! Python Intro Main Differences from C++: True and False are capitals Python floors (always down) with int division (matters with negatives): -3 / 2 = -2 No variable data types or variable

More information

Flow Control: Branches and loops

Flow Control: Branches and loops Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Iterators, Generators, IO, and Exceptions Harry Smith University of Pennsylvania February 15, 2018 Harry Smith (University of Pennsylvania) CIS 192 Lecture 5 February 15, 2018

More information

The Big Python Guide

The Big Python Guide The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String

More information

Strings. Looping. dna = 'ATGTAGC' print(dna) In [1]: ATGTAGC. You can loop over the characters of a string using a for loop, as we saw on Tuesday:

Strings. Looping. dna = 'ATGTAGC' print(dna) In [1]: ATGTAGC. You can loop over the characters of a string using a for loop, as we saw on Tuesday: Strings A string is simply a sequence of characters. From a biological perspective, this is quite useful, as a DNA sequence is simply a string composed of only 4 letters, and thus easily manipulated in

More information

B. Including the Event Structure within a loop. C. Configuring a Timeout case within the Event Structure

B. Including the Event Structure within a loop. C. Configuring a Timeout case within the Event Structure Name: Date: CLAD Sample Exam 05 1. You must include the option to cancel when a user attempts to interactively close the front panel by selecting File>>Close. Which Event case allows this functionality?

More information

COMP 364: Classes, Objects, and Names

COMP 364: Classes, Objects, and Names COMP 364: Classes, Objects, and Names Carlos G. Oliver, Christopher Cameron September 13, 2017 1/26 Outline 1. 202 vs 364 2. Development Environment Recap 3. Basic Data Types 4. Variables 2/26 Your Development

More information

Composite Types. You will learn how to create new variables that are collections of other entities. Types Of Variables.

Composite Types. You will learn how to create new variables that are collections of other entities. Types Of Variables. Composite Types You will learn how to create new variables that are collections of other entities Types Of Variables Python variables Example composite A string (collection of characters) can be decomposed

More information

LISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University

LISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University LISTS WITH PYTHON José M. Garrido Department of Computer Science May 2015 College of Computing and Software Engineering Kennesaw State University c 2015, J. M. Garrido Lists with Python 2 Lists with Python

More information

python-lz4 Documentation

python-lz4 Documentation python-lz4 Documentation Release 2.0.2.dev12+gf16962a Jonathan Underwood Jul 31, 2018 Contents 1 Contents 1 1.1 Introduction............................................... 1 1.2 Install...................................................

More information

Question 13 1: (Solution, p 4) Describe the inputs and outputs of a (1-way) demultiplexer, and how they relate.

Question 13 1: (Solution, p 4) Describe the inputs and outputs of a (1-way) demultiplexer, and how they relate. Questions 1 Question 13 1: (Solution, p ) Describe the inputs and outputs of a (1-way) demultiplexer, and how they relate. Question 13 : (Solution, p ) In implementing HYMN s control unit, the fetch cycle

More information

UNIVERSITÀ DI PADOVA. < 2014 March >

UNIVERSITÀ DI PADOVA. < 2014 March > UNIVERSITÀ DI PADOVA < 2014 March > Easy-to-learn: Python has relatively few keywords, simple structure, and a clearly defined syntax. Easy-to-read: Python code is much more clearly defined and visible

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

PyVirtualDisplay Documentation

PyVirtualDisplay Documentation PyVirtualDisplay Documentation Release 0.2.1 ponty Dec 23, 2017 Contents 1 About 1 2 Basic usages 3 3 Installation 5 3.1 General................................................ 5 3.2 Ubuntu 14.04.............................................

More information

Python Review IPRE

Python Review IPRE Python Review Jay Summet 2005-12-31 IPRE Outline Compound Data Types: Strings, Tuples, Lists & Dictionaries Immutable types: Strings Tuples Accessing Elements Cloning Slices Mutable Types: Lists Dictionaries

More information

File Descriptors and Piping

File Descriptors and Piping File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors

More information

Python Programming. Lecture 1. January 25 th. University of Pennsylvania 2010, Adam Aviv CIS 192 Spring

Python Programming. Lecture 1. January 25 th. University of Pennsylvania 2010, Adam Aviv CIS 192 Spring Python Programming Lecture 1 January 25 th 2010, Adam Aviv CIS 192 Spring 2010 1 Welcome Where are you? Levine 100, Wu & Chen Auditorium 2/8 we will be in Heilmeir Hall (Towne 100) Who am I? Adam Aviv,

More information

Script language: Python Data structures

Script language: Python Data structures Script language: Python Data structures Cédric Saule Technische Fakultät Universität Bielefeld 3. Februar 2015 Immutable vs. Mutable Previously known types: int and string. Both are Immutable but what

More information

yaposib Documentation

yaposib Documentation yaposib Documentation Release 0.3.2 Christophe-Marie Duquesne December 28, 2015 Contents 1 Manual 3 1.1 Getting Started.............................................. 3 1.2 Reference API..............................................

More information

CS61A Lecture 15. Amir Kamil UC Berkeley February 25, 2013

CS61A Lecture 15. Amir Kamil UC Berkeley February 25, 2013 CS61A Lecture 15 Amir Kamil UC Berkeley February 25, 2013 Announcements HW5 due on Wednesday Trends project out Partners are required; find one in lab or on Piazza Will not work in IDLE New bug submission

More information

ENGR 102 Engineering Lab I - Computation

ENGR 102 Engineering Lab I - Computation ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;

More information

Computing with Numbers

Computing with Numbers Computing with Numbers Example output: Numeric Data Types Numeric Data Types Whole numbers are represented using the integer data type (int for short).values of type int can be positive or negative whole

More information

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems CSSE 120 Introduction to Software Development Exam 1 Format, Concepts, What you should be able to do, and Sample Problems Page 1 of 6 Format: The exam will have two sections: Part 1: Paper-and-Pencil o

More information

PySoundFile Documentation Release g8f1fecc

PySoundFile Documentation Release g8f1fecc PySoundFile Documentation Release 0.9.0-24-g8f1fecc Bastian Bechtold, Matthias Geier Aug 23, 2017 Contents 1 Breaking Changes 1 2 Installation 1 3 Read/Write Functions 2 4 Block Processing 2 5 SoundFile

More information

Chapter 10: Creating and Modifying Text Lists Modules

Chapter 10: Creating and Modifying Text Lists Modules Chapter 10: Creating and Modifying Text Lists Modules Text Text is manipulated as strings A string is a sequence of characters, stored in memory as an array H e l l o 0 1 2 3 4 Strings Strings are defined

More information