473,796 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

suggestion for Python

I find your language very nice, it is actually more than three quarters
of what I had been dreaming for years a programming language should be.
But I mourn the passing of APL, another interpreted language. I like
interpreted languages, for they can be used in calculator mode, testing
function after function without bothering to code long protocols in the
language and outside it.

One suggestion I would propose would be to make common operators
distributive by enclosing them in square brackets. For instance:
[1, 3, 5, 7][*] [1, 2, 1, 3] would be equivalent to
[[1, 3, 5, 7][i] * [1, 2, 1, 3][i] for i in range(3)]
In APL the common operators were implicitly distributive over vectors,
but it is not possible for Python due to the more evident concatenation
meaning of + and *. The map function does the job for a user
defined-function, as would do in this instance something like
map(multiply, [1, 3, 5, 7], [1, 2, 1, 3]), but it is cumbersome to
redefine simple operations.

The same brackets enclosing the operator with a point could be used to
define outer product: [1, 3, 5] [*.] [1, 3, 2] would be equivalent to
the result:
[[1, 3, 5], [3, 9, 15], [2, 6, 10]] (a regular matrix shorter to list
than to express in the Python way). The same brackets enclosing two
operators separated by a point would do the job of the vector or matrix
product:
[1, 3, 5, 7] [+.*] [1, 2, 1, 2] would thus be
sum (map(multiply, [1, 3, 5, 7], [1, 2, 1, 2]))

I give very straightforward examples, but it is easy to imagine that
those operators thus enclosed would not only apply to simple lists, but
to matrices and tree-like structures defined as lists of lists, provided
they have a common structural basis.

One problem with Python is the necessity to define very short functions
to enable operators to be the object of function of functions such as
map. Another problem is that common operators cannot be easily
redifined onto larger mathematical objects one might conceive and could
be defined by the means of classes. This could be solved by setting
that such functions named as add, mult, div, defined as two-parameter
functions, would automatically correspond to the dyadic +, *, /, etc.

And conversely, any name of a two-parameter function, let it be
hypothenuse, would signify when enclosed in parentheses the
corresponding dyadic operators.

so that 3(hypothenuse)4 would be 5

This would give Python all the advantages of late APL and much more, for
APL could process only regular data structures such as matrices whereas
Python is so good with data more to be encountered in real life such as
ill-formatted texts to be divided in chapters, sections and subsections
in order to fit in a certain software, just to name one intance, by the
means of the use of reg exps and tree-processing.

Thanks for your attention. The sole objection to the development I
propose for Python would be a certain loss of readability for persons
not acquainted with the language, but reg exps are not that readable
neither and yet what would we do without them?
Jul 18 '05 #1
3 1998
It's an interesting thought, certainly. I like the conciseness
involved. APL certainly looked like an interesting language,
although I never took the opportunity to really play with it.

Have you looked at the NumPy extension? It does a
great deal in the area of mathematical functionality.

John Roth

"François Miville-Dechêne" <fm******@sympa tico.ca> wrote in message
news:ma******** *************** *************@p ython.org...
I find your language very nice, it is actually more than three quarters
of what I had been dreaming for years a programming language should be.
But I mourn the passing of APL, another interpreted language. I like
interpreted languages, for they can be used in calculator mode, testing
function after function without bothering to code long protocols in the
language and outside it.

One suggestion I would propose would be to make common operators
distributive by enclosing them in square brackets. For instance:
[1, 3, 5, 7][*] [1, 2, 1, 3] would be equivalent to
[[1, 3, 5, 7][i] * [1, 2, 1, 3][i] for i in range(3)]
In APL the common operators were implicitly distributive over vectors,
but it is not possible for Python due to the more evident concatenation
meaning of + and *. The map function does the job for a user
defined-function, as would do in this instance something like
map(multiply, [1, 3, 5, 7], [1, 2, 1, 3]), but it is cumbersome to
redefine simple operations.

The same brackets enclosing the operator with a point could be used to
define outer product: [1, 3, 5] [*.] [1, 3, 2] would be equivalent to
the result:
[[1, 3, 5], [3, 9, 15], [2, 6, 10]] (a regular matrix shorter to list
than to express in the Python way). The same brackets enclosing two
operators separated by a point would do the job of the vector or matrix
product:
[1, 3, 5, 7] [+.*] [1, 2, 1, 2] would thus be
sum (map(multiply, [1, 3, 5, 7], [1, 2, 1, 2]))

I give very straightforward examples, but it is easy to imagine that
those operators thus enclosed would not only apply to simple lists, but
to matrices and tree-like structures defined as lists of lists, provided
they have a common structural basis.

One problem with Python is the necessity to define very short functions
to enable operators to be the object of function of functions such as
map. Another problem is that common operators cannot be easily
redifined onto larger mathematical objects one might conceive and could
be defined by the means of classes. This could be solved by setting
that such functions named as add, mult, div, defined as two-parameter
functions, would automatically correspond to the dyadic +, *, /, etc.

And conversely, any name of a two-parameter function, let it be
hypothenuse, would signify when enclosed in parentheses the
corresponding dyadic operators.

so that 3(hypothenuse)4 would be 5

This would give Python all the advantages of late APL and much more, for
APL could process only regular data structures such as matrices whereas
Python is so good with data more to be encountered in real life such as
ill-formatted texts to be divided in chapters, sections and subsections
in order to fit in a certain software, just to name one intance, by the
means of the use of reg exps and tree-processing.

Thanks for your attention. The sole objection to the development I
propose for Python would be a certain loss of readability for persons
not acquainted with the language, but reg exps are not that readable
neither and yet what would we do without them?

Jul 18 '05 #2
François Miville-Dechêne wrote:
I find your language very nice, it is actually more than three
quarters
of what I had been dreaming for years a programming language should
be.
But I mourn the passing of APL, another interpreted language. I like
interpreted languages, for they can be used in calculator mode,
testing
function after function without bothering to code long protocols in
the
language and outside it.


The meat of this suggestion is what PEP 225 is about:

http://www.python.org/peps/pep-0225.html

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Nothing is true -- all is permissible.
\__/ Hassan i Sabbah
Jul 18 '05 #3
François Miville-Dechêne wrote:
I find your language very nice, it is actually more than three quarters
of what I had been dreaming for years a programming language should be.
But I mourn the passing of APL, another interpreted language. I like
Having worked a LOT with both APL and APL2 around 1977-1986, I don't
really mourn them at all (except when I'm in my cups, sometimes, but
then I'm mostly mourning the fact that 20 years ago I was younger:-).

One suggestion I would propose would be to make common operators
distributive by enclosing them in square brackets. For instance:
[1, 3, 5, 7][*] [1, 2, 1, 3] would be equivalent to
[[1, 3, 5, 7][i] * [1, 2, 1, 3][i] for i in range(3)]
In APL the common operators were implicitly distributive over vectors,
but it is not possible for Python due to the more evident concatenation
meaning of + and *. The map function does the job for a user
defined-function, as would do in this instance something like
map(multiply, [1, 3, 5, 7], [1, 2, 1, 3]), but it is cumbersome to
redefine simple operations.
import operator
map(operator.mu l, [1,3,5,7], [1,2,1,3])

and you're done. Or, to taste,

[ a*b for a, b in zip([1,3,5,7], [1,2,1,3]) ]

One problem with Python is the necessity to define very short functions
to enable operators to be the object of function of functions such as
Yes, we do lack a _good_ syntax for "codeblock literals" -- about a
month ago we were discussing possibilities quite actively here.
map. Another problem is that common operators cannot be easily
redifined onto larger mathematical objects one might conceive and could
be defined by the means of classes. This could be solved by setting
that such functions named as add, mult, div, defined as two-parameter
functions, would automatically correspond to the dyadic +, *, /, etc.
Standard library module operator has those. But I'm not sure what you
mean by "redefined onto larger mathematical objects" -- you can get
operator overloading on any type by defining __add__ __mul__ etc.

And conversely, any name of a two-parameter function, let it be
hypothenuse, would signify when enclosed in parentheses the
corresponding dyadic operators.

so that 3(hypothenuse)4 would be 5
Yep, Haskell has something like that, except that instead of
yet another overloading for parentheses (which have too many
already!-) it uses `...` which in Python are an unfortunate and
useless duplciate for repr(...). However to make sense you need
to be able to define priority and associativity and that gets hairy.

This would give Python all the advantages of late APL and much more, for
APL could process only regular data structures such as matrices whereas
APL2 could have arrays with each row a different length, which helped.
Python is so good with data more to be encountered in real life such as
ill-formatted texts to be divided in chapters, sections and subsections
in order to fit in a certain software, just to name one intance, by the
means of the use of reg exps and tree-processing.

Thanks for your attention. The sole objection to the development I
propose for Python would be a certain loss of readability for persons
not acquainted with the language, but reg exps are not that readable
neither and yet what would we do without them?


They're in a separate standard library module -- the criteria are laxer.
Getting into core Python demands passing MUCH stricter tests on all scores.
Alex

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1025
by: John Benson | last post by:
Hi, I find myself plowing through much more collateral Pythonia trying to keep up with my favorite topics appearing on the list, given the recent explosion in activity. I'd like to suggest that the following boilerplate be moved from before the topics to after the topics: (begin quote) Send Python-list mailing list submissions to python-list@python.org
0
6381
by: Brian van den Broek | last post by:
Hi all, There have been a few posts over the last month or so expressing a bit of exasperation with the "rising tide of newbie's". (Or, more accurately, the rising tide of questions from newbie's not trying to follow ESR's advice.) A month or so ago (in a thread found here: http://tinyurl.com/5bj8j), I suggested that it might help the situation if there were a python.org wiki page that amounted to a "Welcome to the Python community;...
7
4389
by: Petr Prikryl | last post by:
Hi, Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". Current situation: try... (Python 2.4 (#60, ...)) >>> i = 1 >>> i
3
1460
by: flexibal | last post by:
hi there. i didnt know if i should post it at python-dev or here, so i'll start here. i'd like to suggest a new language feature for python that allows you to explicitly declare a variable. as we all know, just doing v = 5 declares a new variable named 'v'... but we are people, and we do make typos... and it's very disturbing to find your program crashing after
11
1840
by: Jorge Godoy | last post by:
Hi! I'm needing a parser to retrieve some information from source code -- including parts of code -- from Fortran, to use in a project with a documentation system. Any recommendations on a Python app or parser that I could use for that?
3
335
by: Sori Schwimmer | last post by:
0) Sorry, I don't know how to post a reply in the same thread. 1) Grant Edwards wrote: > The "i += 1" line is almost certainly wrong. You're certainly write, as I acknowledged in a follow up "suggestion for (re)try statement - correction' 2) Rocco Morreti wrote: > What is so repugnant about the equivalent, currently valid way of writing it? Nothing "repugnant". We have in almost all procedural
4
1212
by: John Salerno | last post by:
I apologize for the slightly off-topic nature, but I thought I'd just throw this out there for anyone working on text editors or IDEs with auto-completion. I think it should be a feature, when an item is selected for auto-completion in a drop-down box, that pressing the spacebar (in addition to tab or enter) will automatically finish the word and add a space. This is how Microsoft's new IDEs for .NET work, and I found it very helpful to...
32
2192
by: =?ISO-8859-1?Q?Szabolcs_Horv=E1t?= | last post by:
I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean again. The result should be 0, but of course it will differ from 0 slightly because of rounding errors. However, I noticed that the simple Python program below gives a result of ~ 10^-14, while an equivalent Mathematica program (also using...
6
987
by: Jean-Paul Calderone | last post by:
On Mon, 13 Oct 2008 08:56:34 -0700 (PDT), azrael <jura.grozni@gmail.comwrote: Adding a random new attribute to arbitrary objects any time they happen to end up in a for loop would be catastrophically terrible. Consider the enumerate builtin, instead. .... print i, e .... 0 a 1 b
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.