[Python-Dev] Sub-claasing pathlib.Path seems impossible

2015-05-02 Thread Christophe Bal
Hello.

In this post
<http://stackoverflow.com/questions/29850801/simple-subclassing-pathlib-path-does-not-work/29854141#29854141>,
I have noticed a problem with the following code.

from pathlib import Path
> class PPath(Path):
> def __init__(self, *args, **kwargs):
> super().__init__(*args, **kwargs)
>
> test = PPath("dir", "test.txt")
>
>
This gives the following error message.



> Traceback (most recent call last):
>   File "/Users/projetmbc/test.py", line 14, in 
> test = PPath("dir", "test.txt")
>   File "/anaconda/lib/python3.4/pathlib.py", line 907, in __new__
> self = cls._from_parts(args, init=False)
>   File "/anaconda/lib/python3.4/pathlib.py", line 589, in _from_parts
> drv, root, parts = self._parse_args(args)
>   File "/anaconda/lib/python3.4/pathlib.py", line 582, in _parse_args
> return cls._flavour.parse_parts(parts)AttributeError: type object 'PPath' 
> has no attribute '_flavour'
>
>
This breaks the sub-classing from Python point of view. In the post
<http://stackoverflow.com/questions/29850801/simple-subclassing-pathlib-path-does-not-work/29854141#29854141>,
I give a hack to sub-class Path but it's a bit Unpythonic.

*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
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[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
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] When should pathlib stop being provisional?

2016-04-07 Thread Christophe Bal
As a simple user, pathlib simplifies playing with paths. A lot of things
are easy to do. For example, Pathlib / "subfile" is so useful.

I also have a subclass of pathlib.Path on github that makes easy seeking
for files and directories.

So keep alive pathlib !
Le 6 avr. 2016 13:06, "Paul Moore"  a écrit :

On 6 April 2016 at 00:45, Guido van Rossum  wrote:
> This does sound like it's the crucial issue, and it is worth writing
> up clearly the pros and cons. Let's draft those lists in a thread
> (this one's fine) and then add them to the PEP. We can then decide to:
>
> - keep the status quo
> - change PurePath to inherit from str
> - decide it's never going to be settled and kill pathlib.py
>
> (And yes, I'm dead serious about the latter, rather Solomonic option.)

By the way, even if there's no solution that satisfies everyone to the
"inherit from str" question, I'd still be unhappy if pathlib
disappeared from the stdlib. It's useful for quick admin scripts that
don't justify an external dependency. Those typically do quite a bit
of path manipulation, and as such benefit from the improved API of
pathlib over os.path.

+1 on making (and documenting) a final decision on the "inherit from
str" question
-1 on removing pathlib just because that decision might not satisfy everyone

Paul
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/projetmbc%40gmail.com
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com