Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Guido van Rossum
Geez.

--Guido (mobile)

On Nov 1, 2016 8:10 PM, "Chris Angelico"  wrote:

> On Wed, Nov 2, 2016 at 11:09 AM, Steven D'Aprano 
> wrote:
> > I don't know when I would ever want to actually do this in practice, but
> > allowing the ?. operator to magically effect code outside of the
> > parentheses definitely counts as "spooky action at a distance". Guido's
> > rule of "everything to the right" is easy to reason about if "to the
> > right" ends where the parenthised expression ends.
> >
>
> We already expect "to the left" and "to the right" to end based on
> operator precedence rules. Parentheses are used to control operator
> precedence. It would surprise people *greatly* if they didn't bound
> the effect of the question mark.
>
> ChrisA
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Chris Angelico
On Wed, Nov 2, 2016 at 11:09 AM, Steven D'Aprano  wrote:
> I don't know when I would ever want to actually do this in practice, but
> allowing the ?. operator to magically effect code outside of the
> parentheses definitely counts as "spooky action at a distance". Guido's
> rule of "everything to the right" is easy to reason about if "to the
> right" ends where the parenthised expression ends.
>

We already expect "to the left" and "to the right" to end based on
operator precedence rules. Parentheses are used to control operator
precedence. It would surprise people *greatly* if they didn't bound
the effect of the question mark.

ChrisA
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-11-01 Thread Stephen J. Turnbull
MRAB writes:

 > That's a strange thing to do. It's more usual to use a _subscript_ to 
 > indicate an index: a₃ vs a³

Oh, we economic theorists do that too.  It's typically a
double-indexed array of parameters, where both rows and columns can be
meaningfully be treated as vectors.  So a₃ is the vector of
quantities of good 3 produced by all firms, while a³ is the vector of
quantities of all goods produced by firm 3.  Or in analysis of
international or interregional trade, there's an index indicating
which country exports which good to which importing country.  Some
people put the good index in the superscript and the two countries in
the subscript, others the opposite.  IIRC, mathematical physicist use
both subscript and superscript in tensor notation, nuclear physicists
use one for atomic number and the other for atomic weight (and thus
would expect both subscript and superscript to be treated lexically as
identifier components, not as expression components).

The point is not that polynomials are not the most common use of
superscript notation -- I don't care one way or the other.  It's that
there are many uses, important to those fields, that aren't
polynomials.

___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Steven D'Aprano
On Mon, Oct 31, 2016 at 05:44:07PM -0400, Random832 wrote:

> Right now, foo.bar.baz(bletch) is Call(Attribute(Attribute(Name('foo'),
> 'bar'), 'baz'), [Name('bletch')])), which is identical to
> (foo.bar).baz(bletch) or (foo.bar.baz)(bletch). These are treated,
> essentially, as postfix operators, where you can parenthesize any left
> part of the expression and leave its meaning [and its AST] unchanged.
> 
> Is the AST going to be unchanged, leading to the conclusion that the
> short-circuiting in (foo?.bar).baz will "reach outside of" the
> parentheses, and relying on the fact that wanting to do that with None
> is a silly thing to do in almost all cases?

I hope not. Even if it is "a silly thing to do in almost all cases", 
nevertheless it makes it hard to think about code if the ?. operator can 
reach outside of parentheses. If it can do that, just how far outside 
will it reach?

Besides, "almost all" is not "all". For example:

spam?.attr.__class__.__name__

(spam?.attr).__class__.__name__


I expect[1] that the first case would be equivalent to:

None if spam is None else spam.attr.__class__.__name__

and the second case would be equivalent to:

(None if spam is None else spam.attr).__class__.__name__


Concrete example: given spam = None, the first unparenthised version 
will return None, while the second parenthised version will return 
'NoneType'. 

I don't know when I would ever want to actually do this in practice, but 
allowing the ?. operator to magically effect code outside of the 
parentheses definitely counts as "spooky action at a distance". Guido's 
rule of "everything to the right" is easy to reason about if "to the 
right" ends where the parenthised expression ends.






[1] Actually I don't, or at least I didn't. I expected ?. to apply only 
to a single look-up. But Guido's description of the "everything to the 
right" rule seems like it will probably be more useful in practice and 
allow us to avoid writing long chains of spam?.eggs?.cheese?.tomato. So 
I'm changing my expectations.


-- 
Steve
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread Pavel Velikhov
Hi David!

  I haven’t used blaze, but its looks quite similar to pandas, at least 
conceptually. Thanks for
the reference!

  The big difference with PythonQL is that we actually extend the syntax of 
Python with a few
constructs that are typically used in query languages (group by, order by, 
window, let clause). 
The language extension is quite small and easy to grasp, but its very powerful: 
you can use 
this language to easily formulate pretty complex queries is a rather simple way.

  So traditionally - a query language (PythonQL) is good at expressing complex 
things easily, but
then you need a lot of work from the optimizer and the database to turn it into 
an efficient plan. A
library like blaze or pandas is more of an “algebra” - its really a plan 
specification. It will usually
take much longer to memorize all the operators and ways of doing things in such 
a library and typically
you have to go back to the documentation to do things that differ slightly from 
what you typically do.

  Oh yeah, so far our execution engine is pretty simple and not too efficient, 
but we plan to fix this
in the future and be at least comparable to pandas performance (need to look at 
what’ s under the
hood in blaze).

 Of course this is my take (although I heard a few similar things from our 
early users). It would be
interesting to see how other folks compare the two approaches.

  Btw. we have built a library for working with pandas Dataframes, we could do 
it for blaze too, I suppose.



> On 1 Nov 2016, at 21:17, David Mertz  wrote:
> 
> How do you see this as different from Blaze 
> (http://blaze.readthedocs.io/en/latest/index.html 
> )?
> A
> 
> 
> On Nov 1, 2016 1:34 AM, "Pavel Velikhov"  > wrote:
> Hi Folks,
> 
>   We have released PythonQL, a query language extension to Python (we have 
> extended Python’s comprehensions with a full-fledged query language,
> drawing from the useful features of SQL, XQuery and JSONiq). Take a look at 
> the project here: http://www.pythonql.org  and lets 
> us know what you think!
> 
>   The way PythonQL currently works is you mark PythonQL files with a special 
> encoding and the system runs a preprocessor for all such files. We have
> an interactive interpreter and Jupyter support planned.
> 
> Best regards!
> PythonQL team
> ___
> Python-ideas mailing list
> Python-ideas@python.org 
> https://mail.python.org/mailman/listinfo/python-ideas 
> 
> Code of Conduct: http://python.org/psf/codeofconduct/ 
> 
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread David Mertz
How do you see this as different from Blaze (
http://blaze.readthedocs.io/en/latest/index.html)?
A

On Nov 1, 2016 1:34 AM, "Pavel Velikhov"  wrote:

> Hi Folks,
>
>   We have released PythonQL, a query language extension to Python (we have
> extended Python’s comprehensions with a full-fledged query language,
> drawing from the useful features of SQL, XQuery and JSONiq). Take a look
> at the project here: http://www.pythonql.org and lets us know what you
> think!
>
>   The way PythonQL currently works is you mark PythonQL files with a
> special encoding and the system runs a preprocessor for all such files. We
> have
> an interactive interpreter and Jupyter support planned.
>
> Best regards!
> PythonQL team
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-11-01 Thread MRAB

On 2016-11-01 07:10, Stephen J. Turnbull wrote:

Steven D'Aprano writes:

 > In other words, ² behaves as a unary postfix operator that squares
 > its argument. Likewise for ³, etc. You can even combine them: x³³
 > would be the same as x**33. There's more here:

I hope that's configurable.  I use superscripts to indicate an index
as often as I use them to indicate an exponent.

That's a strange thing to do. It's more usual to use a _subscript_ to 
indicate an index: a₃ vs a³


___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread Wes Turner
On Tuesday, November 1, 2016, Pavel Velikhov 
wrote:

> Hi Wes!
>
>   Right now we don’t push anything yet, we fetch everything into the
> Python’s runtime.
> But going forward the current idea is to push as much computation to the
> database as
> possible (most of the time the database will do a better job then our
> engine).
>
> If we run on top PySpark/Hadoop I think we should be able to completely
> translate 100% of
> PythonQL into these jobs.
>

That would be great; and fast.

A few more links that may be of use (in addition to ops._ in alchemy.py):

-
https://github.com/pythonql/pythonql/blob/master/Grammar.md#query-expressions
- https://github.com/cloudera/ibis/blob/master/ibis/expr/window.py


- http://www.ibis-project.org/faq.html#ibis-and-spark-pyspark
- https://github.com/cloudera/ibis/tree/master/ibis/spark
-
http://spark.apache.org/docs/latest/sql-programming-guide.html#datasets-and-dataframes
-
https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala
-
http://spark.apache.org/docs/latest/sql-programming-guide.html#datasets-and-dataframes


>
> On 1 Nov 2016, at 19:42, Wes Turner  > wrote:
>
> Cool!
>
> https://github.com/pythonql/pythonql/wiki/PythonQL-Intro-and-Tutorial
>
> How do I determine how much computation is pushed to the data? (Instead of
> pulling all the data and running the computation with one local node) ...
> https://en.wikipedia.org/wiki/Bulk_synchronous_parallel (MapReduce,)
>
> - http://pandas.pydata.org/pandas-docs/stable/io.html#sql-queries
> - http://pandas.pydata.org/pandas-docs/stable/generated/
> pandas.read_sql_query.html
> - https://github.com/yhat/pandasql/
> - http://docs.ibis-project.org/sql.html#common-column-expressions
> - https://github.com/cloudera/ibis/blob/master/ibis/sql/alchemy.py
>
> On Tuesday, November 1, 2016, Pavel Velikhov  > wrote:
>
>> Hi Folks,
>>
>>   We have released PythonQL, a query language extension to Python (we
>> have extended Python’s comprehensions with a full-fledged query language,
>> drawing from the useful features of SQL, XQuery and JSONiq). Take a look
>> at the project here: http://www.pythonql.org and lets us know what you
>> think!
>>
>>   The way PythonQL currently works is you mark PythonQL files with a
>> special encoding and the system runs a preprocessor for all such files. We
>> have
>> an interactive interpreter and Jupyter support planned.
>>
>> Best regards!
>> PythonQL team
>> ___
>> Python-ideas mailing list
>> Python-ideas@python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
>
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread Pavel Velikhov
Hi Wes!

  Right now we don’t push anything yet, we fetch everything into the Python’s 
runtime.
But going forward the current idea is to push as much computation to the 
database as
possible (most of the time the database will do a better job then our engine). 

If we run on top PySpark/Hadoop I think we should be able to completely 
translate 100% of 
PythonQL into these jobs. 

> On 1 Nov 2016, at 19:42, Wes Turner  wrote:
> 
> Cool!
> 
> https://github.com/pythonql/pythonql/wiki/PythonQL-Intro-and-Tutorial 
> 
> 
> How do I determine how much computation is pushed to the data? (Instead of 
> pulling all the data and running the computation with one local node) ... 
> https://en.wikipedia.org/wiki/Bulk_synchronous_parallel 
>  (MapReduce,)
> 
> - http://pandas.pydata.org/pandas-docs/stable/io.html#sql-queries 
> 
> - 
> http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql_query.html
>  
> 
> - https://github.com/yhat/pandasql/ 
> - http://docs.ibis-project.org/sql.html#common-column-expressions 
> 
> - https://github.com/cloudera/ibis/blob/master/ibis/sql/alchemy.py 
> 
> 
> On Tuesday, November 1, 2016, Pavel Velikhov  > wrote:
> Hi Folks,
> 
>   We have released PythonQL, a query language extension to Python (we have 
> extended Python’s comprehensions with a full-fledged query language,
> drawing from the useful features of SQL, XQuery and JSONiq). Take a look at 
> the project here: http://www.pythonql.org  and lets 
> us know what you think!
> 
>   The way PythonQL currently works is you mark PythonQL files with a special 
> encoding and the system runs a preprocessor for all such files. We have
> an interactive interpreter and Jupyter support planned.
> 
> Best regards!
> PythonQL team
> ___
> Python-ideas mailing list
> Python-ideas@python.org 
> https://mail.python.org/mailman/listinfo/python-ideas 
> 
> Code of Conduct: http://python.org/psf/codeofconduct/ 
> 
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread Wes Turner
Cool!

https://github.com/pythonql/pythonql/wiki/PythonQL-Intro-and-Tutorial

How do I determine how much computation is pushed to the data? (Instead of
pulling all the data and running the computation with one local node) ...
https://en.wikipedia.org/wiki/Bulk_synchronous_parallel (MapReduce,)

- http://pandas.pydata.org/pandas-docs/stable/io.html#sql-queries
-
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql_query.html
- https://github.com/yhat/pandasql/
- http://docs.ibis-project.org/sql.html#common-column-expressions
- https://github.com/cloudera/ibis/blob/master/ibis/sql/alchemy.py

On Tuesday, November 1, 2016, Pavel Velikhov 
wrote:

> Hi Folks,
>
>   We have released PythonQL, a query language extension to Python (we have
> extended Python’s comprehensions with a full-fledged query language,
> drawing from the useful features of SQL, XQuery and JSONiq). Take a look
> at the project here: http://www.pythonql.org and lets us know what you
> think!
>
>   The way PythonQL currently works is you mark PythonQL files with a
> special encoding and the system runs a preprocessor for all such files. We
> have
> an interactive interpreter and Jupyter support planned.
>
> Best regards!
> PythonQL team
> ___
> Python-ideas mailing list
> Python-ideas@python.org 
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Guido van Rossum
I personally find the ?keyword pattern has less appeal than ?, ?? or ?. .

On Tue, Nov 1, 2016 at 4:02 AM, Nick Coghlan  wrote:

> On 1 November 2016 at 20:28, Paul Moore  wrote:
> > On 1 November 2016 at 10:11, Nick Coghlan  wrote:
> >>
> >> I do think it would be worth covering the symbol+keyword option
> >> discussed in PEP 531 (i.e. "?else" instead of "??", but keeping "?.",
> >> and "?[")
> >
> > FWIW, I'm not keen on it.
> >
> > As a technical question, would it be treated in the syntax as a
> > keyword, which happened to be made up of a punctuation character
> > followed by letters, or as a ? symbol followed by a keyword?
>
> Combined keyword, rather than two distinct tokens.
>
> If you don't do that, you end up creating ambiguities for other
> possible uses of "?" (like the "." and "?[]" suggestions)
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Nick Coghlan
On 1 November 2016 at 20:28, Paul Moore  wrote:
> On 1 November 2016 at 10:11, Nick Coghlan  wrote:
>>
>> I do think it would be worth covering the symbol+keyword option
>> discussed in PEP 531 (i.e. "?else" instead of "??", but keeping "?.",
>> and "?[")
>
> FWIW, I'm not keen on it.
>
> As a technical question, would it be treated in the syntax as a
> keyword, which happened to be made up of a punctuation character
> followed by letters, or as a ? symbol followed by a keyword?

Combined keyword, rather than two distinct tokens.

If you don't do that, you end up creating ambiguities for other
possible uses of "?" (like the "." and "?[]" suggestions)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Paul Moore
On 1 November 2016 at 10:11, Nick Coghlan  wrote:
>
> I do think it would be worth covering the symbol+keyword option
> discussed in PEP 531 (i.e. "?else" instead of "??", but keeping "?.",
> and "?[")

FWIW, I'm not keen on it.

As a technical question, would it be treated in the syntax as a
keyword, which happened to be made up of a punctuation character
followed by letters, or as a ? symbol followed by a keyword? The
difference would be in how "? else" was treated. If the space is not
allowed, we have a unique situation in Python's grammar (where
whitespace between a symbol and a keyword is explicitly disallowed
rather than being optional). If it is allowed, I suspect a lot of
people would prefer to write "? else" and aesthetically the two seem
very different to me.

Paul
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Null coalescing operator

2016-11-01 Thread Nick Coghlan
On 1 November 2016 at 01:51, Mark E. Haase  wrote:
> Stephen J. Turnbull wrote:
>>
>> I gather you think you have a deadlock here.  The way to break it is
>> to just do it.  Pick a syntax and do the rewriting.  My memory of some
>> past instances is that many of the senior devs (especially Guido) will
>> "see through the syntax" to evaluate the benefits of the proposal,
>> even if they've said they don't particularly like the initially-
>> proposed syntax.
>
> I don't feel deadlocked, but I think you're right about committing to a
> syntax. So I updated the PEP, summarized here:
>
> Spelling a new operator as a keyword is difficult due to backward
> compatibility. It can be done (see PEP-308 and PEP-492) but requires extreme
> care.
> A keyword operator is considered less ugly than punctuation, but it makes
> assignment shortcut syntax very ugly. Assume the coalesce operator is "foo",
> then the assignment shortcut would be "x foo= y". This is unacceptable.
> If eliminate the possibility of a keyword and focus on punctuation, we find
> that most people think "??" — the syntax that exists in several other
> mainstream languages — is ugly and not Pythonic.
> However, any other punctuation spelling will be at least as ugly and will
> not have the benefit of being familiar to programmers who have seen null
> coalescing in other languages.
> Therefore, the most reasonable spelling is to borrow the same spelling that
> other languages use, e.g. "??", "?.", and "?[".
>
> I did go down the road of trying to create a new keyword, trying some
> mundane ideas ("foo else bar") and some more exotic ideas ("try foo then
> bar"), but I don't know if those syntaxes are even parseable, and as I
> worked through a bunch of examples, I realized that all of the keywords I
> was trying were very awkward in practical use, especially when combined with
> other expressions.

I do think it would be worth covering the symbol+keyword option
discussed in PEP 531 (i.e. "?else" instead of "??", but keeping "?.",
and "?[")

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Query Language extension to Python

2016-11-01 Thread Paul Moore
On 1 November 2016 at 08:33, Pavel Velikhov  wrote:
>   We have released PythonQL, a query language extension to Python (we have 
> extended Python’s comprehensions with a full-fledged query language,
> drawing from the useful features of SQL, XQuery and JSONiq). Take a look at 
> the project here: http://www.pythonql.org and lets us know what you think!
>
>   The way PythonQL currently works is you mark PythonQL files with a special 
> encoding and the system runs a preprocessor for all such files. We have
> an interactive interpreter and Jupyter support planned.

Nice!

Paul
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

[Python-ideas] Query Language extension to Python

2016-11-01 Thread Pavel Velikhov
Hi Folks,

  We have released PythonQL, a query language extension to Python (we have 
extended Python’s comprehensions with a full-fledged query language,
drawing from the useful features of SQL, XQuery and JSONiq). Take a look at the 
project here: http://www.pythonql.org and lets us know what you think!

  The way PythonQL currently works is you mark PythonQL files with a special 
encoding and the system runs a preprocessor for all such files. We have
an interactive interpreter and Jupyter support planned.

Best regards!
PythonQL team
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] More user-friendly version for string.translate()

2016-11-01 Thread Stephen J. Turnbull
Chris Barker writes:

 > pretty slick -- but any hope of it being as fast as a C implemented method?

I would expect not in CPython, but if "fast" matters, why are you
using CPython rather than PyPy or Cython?  If it matters *that* much,
you can afford to write your own C implementation.  But I doubt that
fast matters "that much" often enough to be worth maintaining yet
another string method in Python.  Byte-shoveling servers might want it
for bytes, though.

 > I've always figured that Python's rich string methods provided two things:
 > 
 > 1) single method call to do common things
 > 
 > 2) nice fast, pure C performance
 > 
 > so I think a "keep these" method would help with both of these
 > goals.

Sure, but the translate method already gives you that, and a lot more.

Note that when you're talking about working with Unicode characters,
no natural language activity I can imagine (not even translating
Buddhist texts, which involves a couple of Indian scripts as well as
Han ideographs) uses more than a fraction of defined characters.

So really translate with defaultdict is a specialized loop that
marries an algorithmic body (which could do things like look up the
original script or other character properties to decide on the
replacement for the generic case) with a (usually "small") table of
exceptions.  That seems like inspired design to me.

___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-11-01 Thread Stephen J. Turnbull
Steven D'Aprano writes:

 > In other words, ² behaves as a unary postfix operator that squares
 > its argument. Likewise for ³, etc. You can even combine them: x³³
 > would be the same as x**33. There's more here:

I hope that's configurable.  I use superscripts to indicate an index
as often as I use them to indicate an exponent.

___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/