Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #1222

Brython 2.0 (Python in the browser)

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <news@google.com>
X-Original-To python-announce@python.org
Delivered-To python-announce-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'operator': 0.03; 'broken': 0.04; 'syntax': 0.04; 'cpython': 0.05; 'python)': 0.05; 'url:bitbucket': 0.05; 'subject:Python': 0.06; '(using': 0.07; 'attribute': 0.07; 'fixes': 0.07; 'javascript,': 0.07; 'json': 0.07; 'versions,': 0.07; 'string': 0.09; 'alias': 0.09; 'arguments': 0.09; 'attributes': 0.09; 'callback': 0.09; 'dan': 0.09; 'namespace': 0.09; 'sake': 0.09; 'python': 0.11; 'bug': 0.12; 'translation': 0.12; 'changes': 0.15; '(x,': 0.16; 'base64': 0.16; 'bitbucket': 0.16; 'consequence,': 0.16; 'imports': 0.16; 'kiko': 0.16; 'libraries.': 0.16; 'namespace,': 0.16; 'namespace.': 0.16; 'pierre': 0.16; 'precedence': 0.16; 'received:eu': 0.16; 'script,': 0.16; 'tags.': 0.16; 'ternary': 0.16; 'skip:= 10': 0.16; 'code.': 0.18; 'library': 0.18; 'module': 0.19; 'import': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; 'error': 0.23; '(by': 0.24; 'instance,': 0.24; 'server.': 0.24; 'source': 0.25; 'script': 0.25; '2.0': 0.26; 'define': 0.26; 'defined': 0.27; 'values': 0.27; 'point': 0.28; 'function': 0.29; 'character': 0.29; "doesn't": 0.30; 'included': 0.31; 'code': 0.31; '(used': 0.31; 'attracting': 0.31; 'clicked': 0.31; 'default,': 0.31; 'developers.': 0.31; 'disabled': 0.31; 'once,': 0.31; 'skip:= 20': 0.31; 'skip:= 40': 0.31; 'file': 0.32; 'class': 0.32; 'community': 0.33; 'updated': 0.34; 'core': 0.34; 'subject:the': 0.34; 'subject: (': 0.35; "can't": 0.35; 'received:209.85': 0.35; 'classes': 0.35; 'definition': 0.35; 'editor': 0.35; 'late': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'add': 0.35; 'version': 0.36; 'gallery': 0.36; 'interaction': 0.36; 'opposed': 0.36; 'raising': 0.36; 'done': 0.36; 'entry': 0.36; 'method': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'wrong': 0.37; 'received:209': 0.37; 'button': 0.38; 'growing': 0.38; 'implement': 0.38; 'version,': 0.38; 'window': 0.38; 'files': 0.38; 'issue': 0.38; 'previous': 0.38; 'hosted': 0.39; 'called': 0.40; 'improved': 0.60; 'most': 0.60; 'from:no real name:2**0': 0.61; 'french': 0.61; 'introduced': 0.61; 'browser': 0.61; 'course': 0.61; 'complete': 0.62; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'default': 0.69; 'to:addr:comp- lang-python-announce': 0.70; 'online': 0.71; 'url:info': 0.73; 'inline': 0.74; 'goal': 0.75; 'to:addr:moderators.isc.org': 0.77; 'browser.': 0.78; '=====': 0.84; 'adapted': 0.84; 'client-side': 0.84; 'compiles': 0.84; 'demos': 0.84; 'faster.': 0.84; 'glenn': 0.84; 'pyjamas': 0.84; 'respectively': 0.84
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=path:newsgroups:date:complaints-to:injection-info:nntp-posting-host :user-agent:mime-version:message-id:subject:from:injection-date:to :content-type:content-transfer-encoding; bh=40LfcDH9j4KHmB2Gfdihov8gKEyHzM6Tbn+aZNKUhUc=; b=l70Bud7QXaR0ysxZD5d/mjMFL35M3M54yD/IvFUA32c+CAbAVLkH+3Jct8FURBkS/I PkRb+jIy1Pg89I3O+4SGRSLCtj7Cpe0EUt5Zj504nfOmN66gNg96Ifqm95m+Pdtoy9ha LtqxrF0GKnSkjb7mjaVxU3EaHFHZMtIyTP0jJ+1C5RF3XsvAQQGEKxHY60V9OBj2PSQu zu04QDI7QN1fgiDn+jiE8rlAlRRuT6tJZXAyB7lVs3X/k9LCmnl/FrMsrMClnRh3Xr0k bEjoqxbmMX4BI6n0v1AgQv5n0Gcc9HqCvWMp0S7AJDWujORp4i8cHRe/FnF2PFa+wwMc pkWQ==
X-Received by 10.224.55.19 with SMTP id s19mr4067813qag.0.1392410300453; Fri, 14 Feb 2014 12:38:20 -0800 (PST)
X-Received by 10.182.103.195 with SMTP id fy3mr88655obb.1.1392410300279; Fri, 14 Feb 2014 12:38:20 -0800 (PST)
Newsgroups comp.lang.python.announce
Date Fri, 14 Feb 2014 12:38:20 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2.14.205.27; posting-account=cEyVOAoAAAAQ26Zg5AgQClqyybEKp-yz
User-Agent G2/1.0
MIME-Version 1.0
Subject Brython 2.0 (Python in the browser)
From pierre.quentel@gmail.com
Injection-Date Fri, 14 Feb 2014 20:38:20 +0000
To comp-lang-python-announce@moderators.isc.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Mailman-Approved-At Sun, 16 Feb 2014 10:00:11 +0100
X-BeenThere python-announce-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id Announcement-only list for the Python programming language <python-announce-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-announce-list/>
List-Post <mailto:python-announce-list@python.org>
List-Help <mailto:python-announce-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=subscribe>
Approved python-announce-list@python.org
Message-ID <mailman.7045.1392541212.18130.python-announce-list@python.org> (permalink)
Lines 113
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392541212 news.xs4all.nl 2829 [2001:888:2000:d::a6]:48227
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python.announce:1222

Show key headers only | View raw


Hi,

Brython (Browser Python) is an implementation of Python 3 in the browser. Its goal is to be able to write client-side programs in Python instead of Javascript, with code inside tags <script type="text/python>...</script>. As opposed to solutions such as Pyjamas or Py2JS, the translation from Python to Javascript is done in the browser, it doesn't require a precompilation by a Python program

Launched late 2012, Brython is attracting a growing community of Python developers. Version 2.0 supports most of the CPython syntax and improves the interaction with Javascript libraries. The complete changelog is detailed below

The main entry point is the Brython site at http://www.brython.info, with an online editor and demos
Development is hosted by Bitbucket : https://bitbucket.org/olemis/brython/src
Join us on the Google group : https://groups.google.com/forum/?fromgroups=#!forum/brython

- Pierre


Changes in Brython version 2.0-20140209-164925
==============================================

Backwards-incompatible change
=============================
For the sake of namespace isolation, by default, the name of functions and classes defined in Brython are no more available in Javascript global namespace. As a consequence, functions can't be called as event callbacks from HTML tags. For instance, if a function echo() is defined in a Brython script, the following inline code :

    <button onclick="echo()">

will result in a Javascript error such as "name echo is not defined" when the button is clicked

The solution is to define the event callback inside Brython code. The button must have an id :

    <button id="echo">

and the Brython code must include the line

    doc["echo"].bind("click",echo)

Alternatively, to force the name "echo" into the global Javascript namespace, add it as an attribute of the window object :

    from browser import window
    window.echo = echo

Features
========
- namespace isolation : in previous versions, the names defined in Brython core scripts were included in the global Javascript namespace, raising risks of conflict with names defined in Javascript programs or libraries. In this version, the only names included in the global Javascript namespace are __BRYTHON__ (used internally) and brython(), the function called on page load
- implement sys.implementation with values adapted for Brython
- allow syntax del (x, y, z)
- use Dan McDougall's pyminifier to reduce size of py_VFS.js
- make_dist generates a script brython_dist.js that can be used as a standalone distribution on a centralised server.

Demos
=====
- add drop files demo (by Glenn Linderman) and French Python course (using module slideshow) to the gallery

Imports
=======
- improved version of py_VFS.js by Billy Earney. py_VFS compiles the standard library to make imports faster. Now packs Python source with JSON instead of base64

Built-in modules
================
- browser : add attributes "window" and "document" as alias of respectively "win" and "doc"
- add a module browser/slideshow for PowerPoint-like slideshows in Brython, using a custom file format

Bug fixes
=========
- issue #174 : string format character % has wrong precedence
- issue #175 : Functions should return None by default
- issue #183 : re.findall() broken
- issue #198 : operator precedence not defined for << and >>
- issue #206 : add <noscript> in case Javascript is disabled
- issue #208 : bug with try / else
- issue #209 : bug in ternary operator
- function definions must be evaluated only once, upon function definition
- bug with del a[:]
- bug with dir() called without arguments
- bug in map()
- bug with "func(x=1,)" ; "return +x" ; "func(10*-x)"
- bug in divmod and round
- bug in local_storage method keys()
- add attribute __doc__ to class and instance methods

Documentation
=============
- updated with the changes introduced in this version
- add documentation for the built-in module javascript
- translation in Spanish updated by Kiko Correoso

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

Brython 2.0 (Python in the browser) pierre.quentel@gmail.com - 2014-02-14 12:38 -0800

csiph-web