translationstring Documentation

Size: px
Start display at page:

Download "translationstring Documentation"

Transcription

1 translationstring Documentation Release 1.4.dev0 Pylons Developers August 29, 2017

2

3 Contents 1 Translation Strings Using The TranslationString Class Using the TranslationStringFactory Class Translation 7 3 Pluralization 9 4 Chameleon Translate Function Support 11 5 API Documentation 13 6 Glossary 17 7 Index and Glossary 19 Python Module Index 21 i

4 ii

5 A library used by various Pylons Project packages for internationalization (i18n) duties. This package provides a translation string class, a translation string factory class, translation and pluralization primitives, and a utility that helps Chameleon templates use translation facilities of this package. It does not depend on Babel, but its translation and pluralization services are meant to work best when provided with an instance of the babel.support.translations class. Contents 1

6 2 Contents

7 CHAPTER 1 Translation Strings While you write your software, you can insert specialized markup into your Python code that makes it possible for the system to translate text values into the languages used by your application s users. This markup generates a translation string. A translation string is an object that behave mostly like a normal Unicode object, except that it also carries around extra information related to its job as part of a higher-level system s translation machinery. Note: Using a translation string can be thought of as equivalent to using a lazy string object in other i18n systems. Using The TranslationString Class The most primitive way to create a translation string is to use the translationstring.translationstring callable: 1 from translationstring import TranslationString 2 ts = TranslationString('Add') This creates a Unicode-like object that is a translationstring.translationstring. Note: For people familiar with Zope internationalization, a TranslationString is a lot like a zope. i18nmessageid.message object. It is not a subclass, however. The first argument to translationstring.translationstring is the msgid; it is required. It represents the key into the translation mappings provided by a particular localization. The msgid argument must be a Unicode object or an ASCII string. The msgid may optionally contain replacement markers. For instance: 1 from translationstring import TranslationString 2 ts = TranslationString('Add ${number}') 3

8 Within the string above, ${stuff} is a replacement marker. It will be replaced by whatever is in the mapping for a translation string when the translationstring.translationstring.interpolate() method is called. The mapping may be supplied at the same time as the replacement marker itself: 1 from translationstring import TranslationString 2 ts = TranslationString('Add ${number}', mapping={'number':1}) You can also create a new translation string instance with a mapping using the standard python %-operator: 1 from translationstring import TranslationString 2 ts = TranslationString('Add ${number}') % {'number': 1} You may interpolate a translation string with a mapping: 1 from translationstring import TranslationString 2 ts = TranslationString('Add ${number}', mapping={'number':1}) 3 result = ts.interpolate() The above result will be Add 1. Any number of replacement markers can be present in the msgid value, any number of times. Only markers which can be replaced by the values in the mapping will be replaced at translation time. The others will not be interpolated and will be output literally. Replacement markers may also be spelled without squiggly braces: 1 from translationstring import TranslationString 2 ts = TranslationString('Add $number', mapping={'number':1}) The Add $number msgid above is equivalent to Add ${number}. A translation string should also usually carry a domain. The domain represents a translation category to disambiguate it from other translations of the same msgid, in case they conflict. 1 from translationstring import TranslationString 2 ts = TranslationString('Add ${number}', mapping={'number':1}, 3 domain='form') The above translation string named a domain of form. A translator function (see Translation) will often use the domain to locate the right translator file on the filesystem which contains translations for a given domain. In this case, if it were trying to translate to our msgid to German, it might try to find a translation from a gettext file within a translation directory like this one: locale/de/lc_messages/form.mo In other words, it would want to take translations from the form.mo translation file in the German language. Finally, the TranslationString constructor accepts a default argument. If a default argument is supplied, it replaces usages of the msgid as the default value for the translation string. When default is None, the msgid value passed to a TranslationString is used as an implicit message identifier. Message identifiers are matched with translations in translation files, so it is often useful to create translation strings with opaque message identifiers unrelated to their default text: 1 from translationstring import TranslationString 2 ts = TranslationString('add-number', default='add ${number}', 3 domain='form', mapping={'number':1}) When a default value is used, the default may contain replacement markers and the msgid should not contain replacement markers. 4 Chapter 1. Translation Strings

9 Using the TranslationStringFactory Class Another way to generate a translation string is to use the translationstring. TranslationStringFactory object. This object is a translation string factory. Basically a translation string factory presets the domain value of any translation string generated by using it. For example: 1 from translationstring import TranslationStringFactory 2 _ = TranslationStringFactory('bfg') 3 ts = _('add-number', default='add ${number}', mapping={'number':1}) Note: We assigned the translation string factory to the name _. This is a convention which will be supported by translation file generation tools. After assigning _ to the result of a translationstring.translationstringfactory(), the subsequent result of calling _ will be a translationstring.translationstring instance. Even though a domain value was not passed to _ (as would have been necessary if the translationstring.translationstring constructor were used instead of a translation string factory), the domain attribute of the resulting translation string will be bfg. As a result, the previous code example is completely equivalent (except for spelling) to: 1 from translationstring import TranslationString as _ 2 ts = _('add-number', default='add ${number}', mapping={'number':1}, 3 domain='bfg') You can set up your own translation string factory much like the one provided above by using the translationstring.translationstringfactory class. For example, if you d like to create a translation string factory which presets the domain value of generated translation strings to form, you d do something like this: 1 from translationstring import TranslationStringFactory 2 _ = TranslationStringFactory('form') 3 ts = _('add-number', default='add ${number}', mapping={'number':1}) Note: For people familiar with Zope internationalization, a TranslationStringFactory is a lot like a zope. i18nmessageid.messagefactoy object. It is not a subclass, however. Pickleability Translation strings may be pickled and unpickled Using the TranslationStringFactory Class 5

10 6 Chapter 1. Translation Strings

11 CHAPTER 2 Translation translationstring provides a function named translationstring.translator() which is used to create a translator object. It is called like so: 1 import gettext 2 from translationstring import Translator 3 translations = gettext.translations(.. the right arguments...) 4 translator = Translator(translations) The translations argument is required; it should be an object supporting at least the Python gettext. NullTranslations API but ideally the babel.support.translations API, which has support for domain lookups like dugettext. The callable returned accepts three arguments: a translation string tstring (required), domain (optional), and mapping (optional). When called, it will translate the tstring translation string to a unicode object using the translations object provided and interpolate the result. 1 from gettext import translations 2 from translationstring import Translator 3 from translationstring import TranslationString 4 5 t = translations(.. the right arguments...) 6 translator = Translator(t) 7 ts = TranslationString('Add ${number}', domain='foo', mapping={'number':1}) 8 translator(ts) If translations is None, the result of interpolation of the msgid or default value of the translation string is returned. The translation function can also deal with plain Unicode objects. The optional domain argument can be used to specify or override the domain of the tstring argument (useful when tstring is a normal string rather than a translation string). The optional mapping argument can specify the interpolation mapping, useful when the tstring argument is not a translation string. If tstring is a translation string its mapping data, if present, is combined with the data from the mapping argument. 7

12 1 from gettext import translations 2 from translationstring import Translator 3 from translationstring import TranslationString 4 5 t = translations(.. the right arguments...) 6 translator = Translator(t) 7 translator('add ${number}', domain='foo', mapping={'number':1}) The translationstring.translator() function accepts an additional optional argument named policy. policy should be a callable which accepts three arguments: translations, tstring and domain. It must perform the actual translation lookup. If policy is None, the translationstring.dugettext_policy() policy will be used. 8 Chapter 2. Translation

13 CHAPTER 3 Pluralization translationstring.pluralizer() provides a gettext plural forms pluralization service. It is called like so: 1 import gettext 2 from translationstring import Pluralizer 3 translations = gettext.translations(.. the right arguments...) 4 pluralizer = Pluralizer(translations) The translations argument is required; it should be an object supporting at least the Python gettext. NullTranslations API but ideally the babel.support.translations API, which has support for domain lookups like dungettext. The object returned will be a callable which has the following signature: 1 def pluralizer(singular, plural, n, domain=none, mapping=none): 2 """ Pluralize """ The singular and plural arguments passed may be translation strings or unicode strings. n represents the number of elements. domain is the translation domain to use to do the pluralization, and mapping is the interpolation mapping that should be used on the result. The pluralizer will return the plural form or the singular form, translated, as necessary. Note: if the objects passed are translation strings, their domains and mappings are ignored. The domain and mapping arguments must be used instead. If the domain is not supplied, a default domain is used (usually messages). If translations is None, a gettext.nulltranslations object is created for the pluralizer to use. The translationstring.pluralizer() function accepts an additional optional argument named policy. policy should be a callable which accepts five arguments: translations, singular and plural, n and domain. It must perform the actual pluralization lookup. If policy is None, the translationstring. dungettext_policy() policy will be used. 9

14 10 Chapter 3. Pluralization

15 CHAPTER 4 Chameleon Translate Function Support translationstring.chameleontranslate() is a function which returns a callable suitable for use as the translate argument to various PageTemplate* constructors. 1 from chameleon.zpt.template import PageTemplate 2 from translationstring import ChameleonTranslate 3 from translationstring import Translator 4 import gettext 5 6 translations = gettext.translations(...) 7 translator = Translator(translations) 8 translate = ChameleonTranslate(translate) 9 pt = PageTemplate('<html></html>', translate=translate) The translator provided should be a callable which accepts a single argument translation_string ( a translationstring.translationstring instance) which returns a unicode object as a translation; usually the result of calling translationstring.translator(). translator may also optionally be None, in which case no translation is performed (the msgid or default value is returned untranslated). 11

16 12 Chapter 4. Chameleon Translate Function Support

17 CHAPTER 5 API Documentation class TranslationString The constructor for a translation string. A translation string is a Unicode-like object that has some extra metadata. This constructor accepts one required argument named msgid. msgid must be the message identifier for the translation string. It must be a unicode object or a str object encoded in the default system encoding. Optional keyword arguments to this object s constructor include domain, default, and mapping. domain represents the translation domain. By default, the translation domain is None, indicating that this translation string is associated with the default translation domain (usually messages). default represents an explicit default text for this translation string. Default text appears when the translation string cannot be translated. Usually, the msgid of a translation string serves double duty as its default text. However, using this option you can provide a different default text for this translation string. This feature is useful when the default of a translation string is too complicated or too long to be used as a message identifier. If default is provided, it must be a unicode object or a str object encoded in the default system encoding (usually means ASCII). If default is None (its default value), the msgid value used by this translation string will be assumed to be the value of default. mapping, if supplied, must be a dictionary-like object which represents the replacement values for any translation string replacement marker instances found within the msgid (or default) value of this translation string. context represents the translation context. By default, the translation context is None. After a translation string is constructed, it behaves like most other unicode objects; its msgid value will be displayed when it is treated like a unicode object. Only when its ugettext method is called will it be translated. Its default value is available as the default attribute of the object, its translation domain is available as the domain attribute, and the mapping is available as the mapping attribute. The object otherwise behaves much like a Unicode string. interpolate(translated=none) Interpolate the value translated which is assumed to be a Unicode object containing zero or more 13

18 replacement markers ($foo or ${bar}) using the mapping dictionary attached to this instance. If the mapping dictionary is empty or None, no interpolation is performed. If translated is None, interpolation will be performed against the default value. TranslationStringFactory(factory_domain) Create a factory which will generate translation strings without requiring that each call to the factory be passed a domain value. A single argument is passed to this class constructor: domain. This value will be used as the domain values of translationstring.translationstring objects generated by the call of this class. The msgid, mapping, and default values provided to the call method of an instance of this class have the meaning as described by the constructor of the translationstring. TranslationString ChameleonTranslate(translator) When necessary, use the result of calling this function as a Chameleon template translate function (e.g. the translate argument to the chameleon.zpt.template.pagetemplate constructor) to allow our translation machinery to drive template translation. A single required argument translator is passsed. The translator provided should be a callable which accepts a single argument translation_string ( a translationstring.translationstring instance) which returns a unicode object as a translation. translator may also optionally be None, in which case no translation is performed (the msgid or default value is returned untranslated). Translator(translations=None, policy=none) Return a translator object based on the translations and policy provided. translations should be an object supporting at least the Python gettext.nulltranslations API but ideally the babel. support.translations API, which has support for domain lookups like dugettext. policy should be a callable which accepts three arguments: translations, tstring and domain. It must perform the actual translation lookup. If policy is None, the translationstring. dugettext_policy() policy will be used. The callable returned accepts three arguments: tstring (required), domain (optional) and mapping (optional). When called, it will translate the tstring translation string to a unicode object using the translations provided. If translations is None, the result of interpolation of the default value is returned. The optional domain argument can be used to specify or override the domain of the tstring (useful when tstring is a normal string rather than a translation string). The optional mapping argument can specify or override the tstring interpolation mapping, useful when the tstring argument is a simple string instead of a translation string. dugettext_policy(translations, tstring, domain, context) A translator policy function which assumes the use of a babel.support.translations translations object, which supports the dugettext API; fall back to ugettext. ugettext_policy(translations, tstring, domain, context) A translator policy function which unconditionally uses the ugettext API on the translations object. Pluralizer(translations=None, policy=none) Return a pluralizer object based on the translations and policy provided. translations should be an object supporting at least the Python gettext.nulltranslations API but ideally the babel. support.translations API, which has support for domain lookups like dugettext. policy should be a callable which accepts five arguments: translations, singular and plural, n and domain. It must perform the actual pluralization lookup. If policy is None, the translationstring. dungettext_policy() policy will be used. The object returned will be a callable which has the following signature: def pluralizer(singular, plural, n, domain=none, mapping=none): Chapter 5. API Documentation

19 The singular and plural objects passed may be translation strings or unicode strings. n represents the number of elements. domain is the translation domain to use to do the pluralization, and mapping is the interpolation mapping that should be used on the result. Note that if the objects passed are translation strings, their domains and mappings are ignored. The domain and mapping arguments must be used instead. If the domain is not supplied, a default domain is used (usually messages). dungettext_policy(translations, singular, plural, n, domain, context) A pluralizer policy function which assumes the use of the babel.support.translations class, which supports the dungettext API; falls back to ungettext. ungettext_policy(translations, singular, plural, n, domain, context) A pluralizer policy function which unconditionally uses the ungettext API on the translations object. 15

20 16 Chapter 5. API Documentation

21 CHAPTER 6 Glossary Babel A collection of tools for internationalizing Python applications. Chameleon chameleon is templating language written and maintained by Malthe Borch. Gettext The GNU gettext library, used by the translationstring locale translation machinery. Message Identifier An unchanging string that is the identifier for a particular translation string. For example, you may have a translation string which has the default the fox jumps over the lazy dog, but you might give this translation string a message identifier of foxdog to reduce the chances of minor spelling or wording changes breaking your translations. The message identifier of a translation string is represented as its msgid argument. Translation Directory A translation directory is a gettext translation directory. It contains language folders, which themselves contain LC_MESSAGES folders, which contain.mo files. Each.mo file represents a set of translations for a language in a translation domain. The name of the.mo file (minus the.mo extension) is the translation domain name. Translation Domain A string representing the context in which a particular translation was made. For example the word java might be translated differently if the translation domain is programming-languages than would be if the translation domain was coffee. Every translation string has an associated translation domain. Translation String An instance of translationstring.translationstring, which is a class that behaves like a Unicode string, but has several extra attributes such as domain, msgid, and mapping for use during translation. Translation strings are usually created by hand within software, but are sometimes created on the behalf of the system for automatic template translation. For more information, see API Documentation. A factory for generating translation string objects which predefines a translation do- Translation String Factory main. Translator A callable which receives a translation string and returns a translated Unicode object for the purposes of internationalization. 17

22 18 Chapter 6. Glossary

23 CHAPTER 7 Index and Glossary Glossary genindex modindex search 19

24 20 Chapter 7. Index and Glossary

25 Python Module Index t translationstring, 13 21

26 22 Python Module Index

27 Index B Babel, 17 C Chameleon, 17 ChameleonTranslate() (in module translationstring), 14 D dugettext_policy() (in module translationstring), 14 dungettext_policy() (in module translationstring), 15 G Gettext, 17 I interpolate() (TranslationString method), 13 M Message Identifier, 17 P Pluralizer() (in module translationstring), 14 T Translation Directory, 17 Translation Domain, 17 Translation String, 17 Translation String Factory, 17 TranslationString (class in translationstring), 13 translationstring (module), 13 TranslationStringFactory() (in module translationstring), 14 Translator, 17 Translator() (in module translationstring), 14 U ugettext_policy() (in module translationstring), 14 ungettext_policy() (in module translationstring), 15 23

gettext.js Documentation

gettext.js Documentation gettext.js Documentation Release 1.0 Jonas Obrist Jan 26, 2018 Contents 1 Installation 3 1.1 Installation................................................ 3 2 Usage 5 2.1 Workflow.................................................

More information

gettext.js Documentation

gettext.js Documentation gettext.js Documentation Release 1.0 Jonas Obrist Jul 23, 2017 Contents 1 Installation 3 1.1 Dependencies............................................... 3 1.2 Installation................................................

More information

Final thoughts on functions F E B 2 5 T H

Final thoughts on functions F E B 2 5 T H Final thoughts on functions F E B 2 5 T H Ordering functions in your code Will the following code work? Here the function is defined after the main program that is calling it. print foo() def foo(): return

More information

pylatexenc Documentation

pylatexenc Documentation pylatexenc Documentation Release 1.2 Philippe Faist Apr 28, 2017 Contents: 1 Simple Parser for LaTeX Code 3 1.1 The main LatexWalker class....................................... 3 1.2 Exception Classes............................................

More information

pynojo Documentation Release unknown pynojo development team

pynojo Documentation Release unknown pynojo development team pynojo Documentation Release unknown pynojo development team November 05, 2013 Contents i ii Welcome! This documentation is generated on November 05, 2013 for pynojo unknown. Contents: Contents 1 2 Contents

More information

Release 0.8. Repoze Developers

Release 0.8. Repoze Developers pyramid b eakerdocumentation Release 0.8 Repoze Developers July 04, 2015 Contents 1 Overview 1 2 Installation 3 3 Setup 5 4 Usage 7 4.1 Session management........................................... 7

More information

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes GIS 4653/5653: Spatial Programming and GIS More Python: Statements, Types, Functions, Modules, Classes Statement Syntax The if-elif-else statement Indentation and and colons are important Parentheses and

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

The Lokalize Handbook. Nick Shaforostoff

The Lokalize Handbook. Nick Shaforostoff Nick Shaforostoff 2 Contents 1 Introduction 5 2 Editor 6 2.1 Main Window........................................ 6 2.2 Toolbars........................................... 7 2.3 Shortcut keys........................................

More information

WTForms-Appengine Documentation

WTForms-Appengine Documentation WTForms-Appengine Documentation Release 0.1.1dev WTForms Team June 10, 2016 Contents 1 WTForms-Appengine 3 1.1 Model Forms............................................... 3 1.2 Datastore-backed Fields.........................................

More information

OstrichLib Documentation

OstrichLib Documentation OstrichLib Documentation Release 0.0.0 Itamar Ostricher May 10, 2016 Contents 1 utils package 3 1.1 collections utils module......................................... 3 1.2 path utils module.............................................

More information

Dogeon Documentation. Release Lin Ju

Dogeon Documentation. Release Lin Ju Dogeon Documentation Release 1.0.0 Lin Ju June 07, 2014 Contents 1 Indices and tables 7 Python Module Index 9 i ii DSON (Doge Serialized Object Notation) is a data-interchange format,

More information

CSE : Python Programming. Decorators. Announcements. The decorator pattern. The decorator pattern. The decorator pattern

CSE : Python Programming. Decorators. Announcements. The decorator pattern. The decorator pattern. The decorator pattern CSE 399-004: Python Programming Lecture 12: Decorators April 9, 200 http://www.seas.upenn.edu/~cse39904/ Announcements Projects (code and documentation) are due: April 20, 200 at pm There will be informal

More information

redis-lua Documentation

redis-lua Documentation redis-lua Documentation Release 2.0.8 Julien Kauffmann October 12, 2016 Contents 1 Quick start 3 1.1 Step-by-step analysis........................................... 3 2 What s the magic at play here?

More information

Sherlock Documentation

Sherlock Documentation Sherlock Documentation Release 0.3.0 Vaidik Kapoor May 05, 2015 Contents 1 Overview 3 1.1 Features.................................................. 3 1.2 Supported Backends and Client Libraries................................

More information

C# Programming for Developers Course Labs Contents

C# Programming for Developers Course Labs Contents C# Programming for Developers Course Labs Contents C# Programming for Developers...1 Course Labs Contents...1 Introduction to C#...3 Aims...3 Your First C# Program...3 C# The Basics...5 The Aims...5 Declaring

More information

The State of Python. and the web. Armin Ronacher

The State of Python. and the web. Armin Ronacher The State of Python and the web Armin Ronacher // @mitsuhiko Who am I Armin Ronacher (@mitsuhiko) Founding Member of the Pocoo Team we're doing Jinja2, Werkzeug, Flask, Pygments, Sphinx and a bunch of

More information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 2 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA

More information

PIC 20A The Basics of Java

PIC 20A The Basics of Java PIC 20A The Basics of Java Ernest Ryu UCLA Mathematics Last edited: November 1, 2017 Outline Variables Control structures classes Compilation final and static modifiers Arrays Examples: String, Math, and

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

Lecture 02, Fall 2018 Friday September 7

Lecture 02, Fall 2018 Friday September 7 Anatomy of a class Oliver W. Layton CS231: Data Structures and Algorithms Lecture 02, Fall 2018 Friday September 7 Follow-up Python is also cross-platform. What s the advantage of Java? It s true: Python

More information

Tornado-Babel Documentation

Tornado-Babel Documentation Tornado-Babel Documentation Release 0.1 Openlabs Technologies & Consulting (P) Limited July 20, 2015 Contents 1 Installation 3 2 Date Formatting 5 3 Using Translations 7 3.1 Making translatable applications.....................................

More information

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function SFU CMPT 379 Compilers Spring 2015 Assignment 4 Assignment due Thursday, April 9, by 11:59pm. For this assignment, you are to expand your Bunting-3 compiler from assignment 3 to handle Bunting-4. Project

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Appendix B Boost.Python

Appendix B Boost.Python Financial Modelling in Python By S. Fletcher & C. Gardner 2009 John Wiley & Sons Ltd Appendix B Boost.Python The Boost.Python library provides a framework for seamlessly wrapping C++ classes, functions

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164 Spring 2005 P. N. Hilfinger Project #2: Static Analyzer for Pyth Due: Wednesday, 6 April

More information

Basic Object-Oriented Concepts. 5-Oct-17

Basic Object-Oriented Concepts. 5-Oct-17 Basic Object-Oriented Concepts 5-Oct-17 Concept: An object has behaviors In old style programming, you had: data, which was completely passive functions, which could manipulate any data An object contains

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

solrq Documentation Release Michał Jaworski

solrq Documentation Release Michał Jaworski solrq Documentation Release 1.1.1 Michał Jaworski Mar 27, 2017 Contents 1 solrq 1 2 usage 3 2.1 quick reference.............................................. 4 3 contributing 7 4 testing 9 5 Detailed

More information

Pizco Documentation. Release 0.1. Hernan E. Grecco

Pizco Documentation. Release 0.1. Hernan E. Grecco Pizco Documentation Release 0.1 Hernan E. Grecco Nov 02, 2017 Contents 1 Design principles 3 2 Pizco in action 5 3 Contents 7 3.1 Getting Started.............................................. 7 3.2 Futures..................................................

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

STATS Data Analysis using Python. Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak

STATS Data Analysis using Python. Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak STATS 700-002 Data Analysis using Python Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak Recap Previous lecture: Hadoop/MapReduce framework in general Today s lecture: actually

More information

pytest-benchmark Release 2.5.0

pytest-benchmark Release 2.5.0 pytest-benchmark Release 2.5.0 September 13, 2015 Contents 1 Overview 3 1.1 pytest-benchmark............................................ 3 2 Installation 7 3 Usage 9 4 Reference 11 4.1 pytest_benchmark............................................

More information

ZeroVM Package Manager Documentation

ZeroVM Package Manager Documentation ZeroVM Package Manager Documentation Release 0.2.1 ZeroVM Team October 14, 2014 Contents 1 Introduction 3 1.1 Creating a ZeroVM Application..................................... 3 2 ZeroCloud Authentication

More information

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

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

Modules:Context-Sensitive Keyword

Modules:Context-Sensitive Keyword Document Number: P0924r1 Date: 2018-11-21 To: SC22/WG21 EWG Reply to: Nathan Sidwell nathan@acm.org / nathans@fb.com Re: Merging Modules, p1103r2 Modules:Context-Sensitive Keyword Nathan Sidwell The new

More information

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

Overview of the Ruby Language. By Ron Haley

Overview of the Ruby Language. By Ron Haley Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,

More information

CSE341, Fall 2011, Lecture 26 Summary

CSE341, Fall 2011, Lecture 26 Summary CSE341, Fall 2011, Lecture 26 Summary Standard Disclaimer: This lecture summary is not necessarily a complete substitute for attending class, reading the associated code, etc. It is designed to be a useful

More information

Object-oriented programming in...

Object-oriented programming in... Programming Languages Week 12 Object-oriented programming in... College of Information Science and Engineering Ritsumeikan University plan this week intro to Java advantages and disadvantages language

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 1 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) WHO

More information

django-openid Documentation

django-openid Documentation django-openid Documentation Release 2.0a Simon Willison September 27, 2017 Contents 1 Installation 3 2 Accepting OpenID 5 2.1 Redirecting somewhere else....................................... 6 2.2 Requesting

More information

CNRS ANF PYTHON Objects everywhere

CNRS ANF PYTHON Objects everywhere CNRS ANF PYTHON Objects everywhere Marc Poinot Numerical Simulation Dept. Outline Python Object oriented features Basic OO concepts syntax More on Python classes multiple inheritance reuse introspection

More information

3 ADT Implementation in Java

3 ADT Implementation in Java Object-Oriented Design Lecture 3 CS 3500 Spring 2010 (Pucella) Tuesday, Jan 19, 2010 3 ADT Implementation in Java Last time, we defined an ADT via a signature and a specification. We noted that the job

More information

CacheControl Documentation

CacheControl Documentation CacheControl Documentation Release 0.12.4 Eric Larson May 01, 2018 Contents 1 Install 3 2 Quick Start 5 3 Tests 7 4 Disclaimers 9 4.1 Using CacheControl........................................... 9 4.2

More information

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python

Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python Outline Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer Universität des Saarlandes October 6th, 2009 Outline Outline Today s Topics: 1 More Examples 2 Cool Stuff 3 Text Processing

More information

alphafilter Documentation

alphafilter Documentation alphafilter Documentation Release 0.6 coordt September 09, 2013 CONTENTS i ii alphafilter Documentation, Release 0.6 Contents: CONTENTS 1 alphafilter Documentation, Release 0.6 2 CONTENTS CHAPTER ONE

More information

Definition of DJ (Diminished Java)

Definition of DJ (Diminished Java) Definition of DJ (Diminished Java) version 0.5 Jay Ligatti 1 Introduction DJ is a small programming language similar to Java. DJ has been designed to try to satisfy two opposing goals: 1. DJ is a complete

More information

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration

STATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration STATS 507 Data Analysis in Python Lecture 2: Functions, Conditionals, Recursion and Iteration Functions in Python We ve already seen examples of functions: e.g., type()and print() Function calls take the

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

Python Mock Tutorial Documentation

Python Mock Tutorial Documentation Python Mock Tutorial Documentation Release 0.1 Javier Collado Nov 14, 2017 Contents 1 Introduction 3 2 Mock 5 2.1 What is a mock object?.......................................... 5 2.2 What makes mock

More information

Tornado-Babel Documentation

Tornado-Babel Documentation Tornado-Babel Documentation Release 0.1 Openlabs Technologies & Consulting (P) Limited February 12, 2013 CONTENTS i ii Tornado-Babel Documentation, Release 0.1 Tornado-Babel adds i18n and l10n support

More information

COMP 110/L Lecture 19. Kyle Dewey

COMP 110/L Lecture 19. Kyle Dewey COMP 110/L Lecture 19 Kyle Dewey Outline Inheritance extends super Method overriding Automatically-generated constructors Inheritance Recap -We talked about object-oriented programming being about objects

More information

semidbm Documentation

semidbm Documentation semidbm Documentation Release 0.4.0 James Saryerwinnie Jr September 04, 2013 CONTENTS i ii semidbm is a pure python implementation of a dbm, which is essentially a persistent key value store. It allows

More information

Mastering Python Decorators

Mastering Python Decorators Mastering Python Decorators One of the hallmarks of good Python is the judicious use of decorators to optimize, simplify and add new functionality to existing code. Decorators are usually seen as an advanced

More information

I18N Messages and Logging

I18N Messages and Logging I18N Messages and Logging by John Mazzitelli 12/06/2006 For many a software developer, the mere mention of a requirement to support internationalization (aka i18n) is sure to elicit groans. Writing code

More information

PrettyPandas Documentation

PrettyPandas Documentation PrettyPandas Documentation Release 0.0.4 Henry Hammond Mar 26, 2018 Contents 1 Features 3 2 Installation 5 3 Contributing 7 4 Contents 9 4.1 Quick Start................................................

More information

Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM

Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM 1 of 18 9/6/2010 9:40 PM Flash CS4 Professional ActionScript 3.0 Language Reference Language Reference only Compiler Errors Home All Packages All Classes Language Elements Index Appendixes Conventions

More information

Intro. Classes & Inheritance

Intro. Classes & Inheritance Intro Functions are useful, but they're not always intuitive. Today we're going to learn about a different way of programming, where instead of functions we will deal primarily with objects. This school

More information

Connexion Documentation

Connexion Documentation Connexion Documentation Release 0.5 Zalando SE Nov 16, 2017 Contents 1 Quickstart 3 1.1 Prerequisites............................................... 3 1.2 Installing It................................................

More information

LECTURE 26. Documenting Python

LECTURE 26. Documenting Python LECTURE 26 Documenting Python DOCUMENTATION Being able to properly document code, especially large projects with multiple contributors, is incredibly important. Code that is poorly-documented is sooner

More information

funcsigs Documentation

funcsigs Documentation funcsigs Documentation Release 0.4 Aaron Iles December 20, 2013 Contents i ii CHAPTER 1 The Funcsigs Package funcsigs is a backport of the PEP 362 function signature features from Python 3.3 s inspect

More information

Principles of Programming Languages. Objective-C. Joris Kluivers

Principles of Programming Languages. Objective-C. Joris Kluivers Principles of Programming Languages Objective-C Joris Kluivers joris.kluivers@gmail.com History... 3 NeXT... 3 Language Syntax... 4 Defining a new class... 4 Object identifiers... 5 Sending messages...

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Object-Oriented

More information

Subtyping (Dynamic Polymorphism)

Subtyping (Dynamic Polymorphism) Fall 2018 Subtyping (Dynamic Polymorphism) Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References PFPL - Chapter 24 Structural Subtyping - Chapter 27 Inheritance TAPL (pdf) - Chapter

More information

Perl. Many of these conflict with design principles of languages for teaching.

Perl. Many of these conflict with design principles of languages for teaching. Perl Perl = Practical Extraction and Report Language Developed by Larry Wall (late 80 s) as a replacement for awk. Has grown to become a replacement for awk, sed, grep, other filters, shell scripts, C

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

databuild Documentation

databuild Documentation databuild Documentation Release 0.0.10 Flavio Curella May 15, 2015 Contents 1 Contents 3 1.1 Installation................................................ 3 1.2 Quickstart................................................

More information

Casting in C++ (intermediate level)

Casting in C++ (intermediate level) 1 of 5 10/5/2009 1:14 PM Casting in C++ (intermediate level) Casting isn't usually necessary in student-level C++ code, but understanding why it's needed and the restrictions involved can help widen one's

More information

2. The object-oriented paradigm!

2. The object-oriented paradigm! 2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of

More information

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018 Inheritance and Inheritance and Pieter van den Hombergh Thijs Dorssers Stefan Sobek Java Inheritance Example I Visibility peekabo Constructors Fontys Hogeschool voor Techniek en Logistiek January 11, 2018

More information

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which

More information

Logistics. Final Exam on Friday at 3pm in CHEM 102

Logistics. Final Exam on Friday at 3pm in CHEM 102 Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create

More information

Objects. say something to express one's disapproval of or disagreement with something.

Objects. say something to express one's disapproval of or disagreement with something. Objects say something to express one's disapproval of or disagreement with something. class Person: def init (self, name, age): self.name = name self.age = age p1 = Person("John", 36) class Person: def

More information

1 Strings (Review) CS151: Problem Solving and Programming

1 Strings (Review) CS151: Problem Solving and Programming 1 Strings (Review) Strings are a collection of characters. quotes. this is a string "this is also a string" In python, strings can be delineated by either single or double If you use one type of quote

More information

pyprika Documentation

pyprika Documentation pyprika Documentation Release 1.0.0 Paul Kilgo February 16, 2014 Contents i ii Pyprika is a Python library for parsing and managing recipes. Its major features are: Support for recognizing a human-friendly

More information

Component Adaptation + Open Protocols = The PyProtocols Package

Component Adaptation + Open Protocols = The PyProtocols Package Component Adaptation + Open Protocols = The PyProtocols Package Release 1.0a0 Phillip J. Eby October 10, 2004 Email: pje@telecommunity.com Abstract The Python Protocols package provides framework developers

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:

More information

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)

More information

logstack Documentation

logstack Documentation logstack Documentation Release 0.1 Remi Rampin Apr 08, 2017 Contents 1 Getting started 1 2 Contents 3 2.1 Reference................................................. 3 2.2 Internal reference.............................................

More information

Introduction to Perl 6 Documentation

Introduction to Perl 6 Documentation Introduction to Perl 6 Documentation Release 0.5.1 Suman Khanal and Ashish Khanal Oct 05, 2018 Contents 1 Introduction 3 2 Running Perl 6 notebook 5 2.1 Docker way................................................

More information

Confuse. Release 0.1.0

Confuse. Release 0.1.0 Confuse Release 0.1.0 July 02, 2016 Contents 1 Using Confuse 3 2 View Theory 5 3 Validation 7 4 Command-Line Options 9 5 Search Paths 11 6 Your Application Directory 13 7 Dynamic Updates 15 8 YAML Tweaks

More information

IHIH Documentation. Release Romain Dartigues

IHIH Documentation. Release Romain Dartigues IHIH Documentation Release 0.1.1 Romain Dartigues December 11, 2016 Contents 1 Why? 3 2 Table of contents 5 2.1 Source documentation.......................................... 5 2.2 Examples.................................................

More information

4 CoffeeStrainer Virtues and Limitations

4 CoffeeStrainer Virtues and Limitations In this chapter, we explain CoffeeStrainer s virtues and limitations and the design decisions that led to them. To illustrate the points we want to make, we contrast CoffeeStrainer with a hypothetical,

More information

django-conduit Documentation

django-conduit Documentation django-conduit Documentation Release 0.0.1 Alec Koumjian Apr 24, 2017 Contents 1 Why Use Django-Conduit? 3 2 Table of Contents 5 2.1 Filtering and Ordering.......................................... 5

More information

LECTURE 2. Python Basics

LECTURE 2. Python Basics LECTURE 2 Python Basics MODULES ''' Module fib.py ''' from future import print_function def even_fib(n): total = 0 f1, f2 = 1, 2 while f1 < n: if f1 % 2 == 0: total = total + f1 f1, f2 = f2, f1 + f2 return

More information

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++ Comp Sci 1570 Introduction to C++ Outline 1 Outline 1 Outline 1 switch ( e x p r e s s i o n ) { case c o n s t a n t 1 : group of statements 1; break ; case c o n s t a n t 2 : group of statements 2;

More information

Functions and Decomposition

Functions and Decomposition Unit 4 Functions and Decomposition Learning Outcomes Design and implement functions to carry out a particular task. Begin to evaluate when it is necessary to split some work into functions. Locate the

More information

SPARK-PL: Introduction

SPARK-PL: Introduction Alexey Solovyev Abstract All basic elements of SPARK-PL are introduced. Table of Contents 1. Introduction to SPARK-PL... 1 2. Alphabet of SPARK-PL... 3 3. Types and variables... 3 4. SPARK-PL basic commands...

More information

HTML 5 Form Processing

HTML 5 Form Processing HTML 5 Form Processing In this session we will explore the way that data is passed from an HTML 5 form to a form processor and back again. We are going to start by looking at the functionality of part

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Best Practice for Creation and Maintenance of a SAS Infrastructure

Best Practice for Creation and Maintenance of a SAS Infrastructure Paper 2501-2015 Best Practice for Creation and Maintenance of a SAS Infrastructure Paul Thomas, ASUP Ltd. ABSTRACT The advantage of using metadata to control and maintain data and access to data on databases,

More information

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered

More information

Functional abstraction

Functional abstraction Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered

More information

Review 2. Classes and Subclasses

Review 2. Classes and Subclasses Review 2 Classes and Subclasses Class Definition class (): """Class specification""" class variables (format: Class.variable) initializer ( init ) special method definitions

More information

Interfaces. An interface forms a contract between the object and the outside world.

Interfaces. An interface forms a contract between the object and the outside world. Interfaces An interface forms a contract between the object and the outside world. For example, the buttons on the television set are the interface between you and the electrical wiring on the other side

More information