473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

assignments - want a PEP

>From time to time I still use my old Mathematica system. The
Mathematica language has some nice properties. The one I like best is
the possibility to create symbols from nothing. Translated into the
Python realm following creations are possible:
a a

That's it. Just make an 'a' as a pure symbol. The reason for those
symbols is late evaluation. Most of the time an expression should be
transformed and simplified before it is finally evaluated using
concrete numbers or other stuff. I tried to mimic this in Python using
a Symbol() class:
a = Symbol()
a a

So 'a' would be a Symbol object that is represented by the name "a" not
by the standard format information that tells us that a is some member
of class Symbol(). Starting with Symbol() subclsses of Symbol() e.g
Expr() could overload operators like __add__, __mul__ etc. in order to
create new symbolic objects:
a,b = Expr(),Expr()
(a+b)/c

a+b
---
c

The availability of Symbol() would make it easy to create a Computer
Algebra System ( CAS ) in Python, just using standard Python operators.

Unfortunately it is not possible to implement Symbol() in an elegant
way. Symbol() has to retrieve somehow it's own name from the
environment where the name is created, but no assignment/name binding
event is accessible to Python objects.

I want to propose making name binding accessible by introducing an
__assign__ method which is called, whenever an object is bound to a
name. By default the __assign__ method does nothing at all but can be
implemented by custom classes.

def __assign__(self,own_name):
# do somtehing with me and my name

Instead of changing the behaviour of the current assignment operator
"=" one could think about introduction of a new assignment ":=" that is
connected to the __assign__ method of custom classes if available.

What do You think?

Regards,
Kay

Jul 18 '05 #1
0 813

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

Similar topics

1
by: svilen | last post by:
hi. this was named but it is misleading. i want to have the order of setting items in intrinsic dicts (keyword args, or class attributes, etc). which is, a prdered dict trhat matches the...
15
by: Josef Meile | last post by:
Hi, Textually from the highlights of python 2.4: "Assigning to None - the compiler now treats assigning to None as a SyntaxError." I think in general assignments to built-in types,...
4
by: Jacek Generowicz | last post by:
I am dealing with an application which reads in configurations by calling (a wrapper around) execfile. Any configuration file may itself execfile other configuration files in the same manner. I...
3
by: bearophileHUGS | last post by:
The current version of ShedSkin (http://shedskin.sourceforge.net/ experimental Python to C++ compiler) is rather alpha, and the development work is focused on debugging and implementing some more...
21
by: Paul Steckler | last post by:
Here's some code that's giving me differing results, depending on the compiler. typedef foo { int A,B; } FOO; int main() {
7
by: dm | last post by:
Hi, I'd like to know if the C standard can guarantee that an assignment to/from a variable will be atomic, that is will occur in a single indivisible instruction. For example, if I have the...
8
by: Fredrik Tolf | last post by:
Hi list! I'm relatively new to Python, and one thing I can't seem to get over is the lack of in-expression assignments, as present in many other languages. I'd really like to know how Python...
0
by: Simon Burton | last post by:
I've been doing a little c programming again (ouch!) and it's just hit me why python does not allow assignment inside expressions (as in c): because it is absolutely essential that all assignments...
6
by: Erik | last post by:
Hello, For many years ago I implemented my own string buffer class, which works fine except assignments - it copies the char* buffer instead of the pointer. Therefore in function calls I pass...
17
by: Brian Blais | last post by:
Hello, I have a couple of classes where I teach introductory programming using Python. What I would love to have is for the students to go through a lot of very small programs, to learn the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.