[Python-Dev] Translate Python language

2015-11-11 Thread Christophe Bal
Hello.

I'm a french teacher and I would like to use Python with young child but
I've a big problem. All the keyword are in english. So I would like to know
if there is a way to hack the AST tools such as to use french keywords and
then translate a list of french keywords to their english regular version.

Where should I start ? My idea is not to build a new language but simply
translate words using an hacked version of the AST tools.

Hoping to be clear and I do not pollute the message in this list.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a "Lycée" **and **Python **amateur developer*
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread Paul Moore
On 11 November 2015 at 15:13, Christophe Bal  wrote:
> Hello.
>
> I'm a french teacher and I would like to use Python with young child but
> I've a big problem. All the keyword are in english. So I would like to know
> if there is a way to hack the AST tools such as to use french keywords and
> then translate a list of french keywords to their english regular version.
>
> Where should I start ? My idea is not to build a new language but simply
> translate words using an hacked version of the AST tools.
>
> Hoping to be clear and I do not pollute the message in this list.

Do you really just mean keywords? Most of the English words used in
Python (for example "open") aren't actually keywords but are names of
functions defined in the builtins and/or standard library. Those are
not exposed as distinct objects in the AST, but are simply name
lookups.

If you do mean just keywords, then you could probably relatively
simply hack the Python interpreter code to use different names for the
keywords, and build your own translated copy of Python. I don't know
the details, though. But in practice this wouldn't really help your
student, as there would still be many English words they would
encounter and need to understand (at least in the context of the code
they are writing).

My understanding is that most non-English speaking teachers tend to
accept that their students simply need to treat the keywords and
function names used in typical programming languages (Python included)
as things they just have to learn. But I suspect most students are
typically older than your young child.

Sorry I can't be more help.
Paul
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread Donald Stufft
On November 11, 2015 at 11:19:07 AM, Paul Moore (p.f.mo...@gmail.com) wrote:
> On 11 November 2015 at 15:13, Christophe Bal wrote:
> > Hello.
> >
> > I'm a french teacher and I would like to use Python with young child but
> > I've a big problem. All the keyword are in english. So I would like to know
> > if there is a way to hack the AST tools such as to use french keywords and
> > then translate a list of french keywords to their english regular version.
> >
> > Where should I start ? My idea is not to build a new language but simply
> > translate words using an hacked version of the AST tools.
> >
> > Hoping to be clear and I do not pollute the message in this list.
> 
> Do you really just mean keywords? Most of the English words used in
> Python (for example "open") aren't actually keywords but are names of
> functions defined in the builtins and/or standard library. Those are
> not exposed as distinct objects in the AST, but are simply name
> lookups.
> 

You might be able to use an encoding to do this.

-
Donald Stufft
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA


___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread Brett Cannon
On Wed, 11 Nov 2015, 10:55 Christophe Bal  wrote:

Hello.

I'm a french teacher and I would like to use Python with young child but
I've a big problem. All the keyword are in english. So I would like to know
if there is a way to hack the AST tools such as to use french keywords and
then translate a list of french keywords to their english regular version.

Where should I start ? My idea is not to build a new language but simply
translate words using an hacked version of the AST tools.

You actually need a new grammar for the parser as the AST comes from that.
Then you may be able to build the AST.

-brett


Hoping to be clear and I do not pollute the message in this list.

*Christophe BAL*

*Enseignant** de **mathématiques* *en** Lycée **et **développeur** Python
amateur*

*---*

*French math teacher in a "Lycée" **and **Python **amateur developer*

___
Python-Dev mailing list
Python-Dev@python.org
https ://
mail.python.org
/mailman/
listinfo
/
python-dev

Unsubscribe: https
://

mail.python.org

/mailman/options/

python-dev
/
brett

%40python.org

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread Nir Soffer
On Wed, Nov 11, 2015 at 5:13 PM, Christophe Bal  wrote:

> Hello.
>
> I'm a french teacher and I would like to use Python with young child but
> I've a big problem. All the keyword are in english. So I would like to know
> if there is a way to hack the AST tools such as to use french keywords and
> then translate a list of french keywords to their english regular version.
>
> Where should I start ? My idea is not to build a new language but simply
> translate words using an hacked version of the AST tools.
>
> Hoping to be clear and I do not pollute the message in this list.
>

I did this in 2006 for Hebrew - we had Hebrew Python dialect, with
Hebrew turtle module and interactive shell.

You can try to reuse this:
https://github.com/nirs/hpy

Nir


>
>
> *Christophe BAL*
> *Enseignant de mathématiques en Lycée **et développeur Python amateur*
> *---*
> *French math teacher in a "Lycée" **and **Python **amateur developer*
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/nirsof%40gmail.com
>
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread M.-A. Lemburg
On 11.11.2015 17:20, Donald Stufft wrote:
> On November 11, 2015 at 11:19:07 AM, Paul Moore (p.f.mo...@gmail.com) wrote:
>> On 11 November 2015 at 15:13, Christophe Bal wrote:
>>> Hello.
>>>
>>> I'm a french teacher and I would like to use Python with young child but
>>> I've a big problem. All the keyword are in english. So I would like to know
>>> if there is a way to hack the AST tools such as to use french keywords and
>>> then translate a list of french keywords to their english regular version.
>>>
>>> Where should I start ? My idea is not to build a new language but simply
>>> translate words using an hacked version of the AST tools.
>>>
>>> Hoping to be clear and I do not pollute the message in this list.
>>
>> Do you really just mean keywords? Most of the English words used in
>> Python (for example "open") aren't actually keywords but are names of
>> functions defined in the builtins and/or standard library. Those are
>> not exposed as distinct objects in the AST, but are simply name
>> lookups.
>>
> 
> You might be able to use an encoding to do this.

Or use Andrew Dalke's fun project LOLPython as basis:

http://www.dalkescientific.com/writings/diary/archive/2007/06/01/lolpython.html

It uses a parser which then translates the source code
into regular Python source code, which it then runs.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Nov 11 2015)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...   http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...   http://zope.egenix.com/

2015-10-23: Released mxODBC Connect 2.1.5 ... http://egenix.com/go85

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
  http://www.malemburg.com/

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [Python-checkins] cpython (2.7): Backport early-out 91259f061cfb to reduce the cost of bb1a2944bcb6

2015-11-11 Thread Benjamin Peterson


On Tue, Oct 6, 2015, at 19:12, raymond.hettinger wrote:
> https://hg.python.org/cpython/rev/37aee118e1a3
> changeset:   98578:37aee118e1a3
> branch:  2.7
> parent:  98572:60c44a09c5fc
> user:Raymond Hettinger 
> date:Tue Oct 06 23:12:02 2015 -0400
> summary:
>   Backport early-out 91259f061cfb to reduce the cost of bb1a2944bcb6
> 
> files:
>   Modules/_collectionsmodule.c |  6 +-
>   1 files changed, 5 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
> --- a/Modules/_collectionsmodule.c
> +++ b/Modules/_collectionsmodule.c
> @@ -651,6 +651,9 @@
>  Py_ssize_t n;
>  PyObject *item;
>  
> +if (Py_SIZE(deque) == 0)
> +return;
> +

dequeue is not varsized in Python 2.7, so using Py_SIZE() is incorrect.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com