473,776 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prothon Prototypes vs Python Classes

Playing with Prothon today, I am fascinated by the idea of eliminating
classes in Python. I'm trying to figure out what fundamental benefit
there is to having classes. Is all this complexity unecessary?

Here is an example of a Python class with all three types of methods
(instance, static, and class methods).

# Example from Ch.23, p.381-2 of Learning Python, 2nd ed.

class Multi:
numInstances = 0
def __init__(self):
Multi.numInstan ces += 1
def printNumInstanc es():
print "Number of Instances:", Multi.numInstan ces
printNumInstanc es = staticmethod(pr intNumInstances )
def cmeth(cls, x):
print cls, x
cmeth = classmethod(cme th)

a = Multi(); b = Multi(); c = Multi()

Multi.printNumI nstances()
a.printNumInsta nces()

Multi.cmeth(5)
b.cmeth(6)
Here is the translation to Prothon.

Multi = Object()
with Multi:
.numInstances = 0
def .__init__(): # instance method
Multi.numInstan ces += 1
def .printNumInstan ces(): # static method
print "Number of Instances:", Multi.numInstan ces
def .cmeth(x): # class method
print Multi, x

a = Multi(); b = Multi(); c = Multi()

Multi.printNumI nstances()
a.printNumInsta nces()

Multi.cmeth(5)
b.cmeth(6)
Note the elimination of 'self' in these methods. This is not just a
syntactic shortcut (substiting '.' for 'self') By eliminating this
explicit passing of the self object, Prothon makes all method forms
the same and eliminates a lot of complexity. It's beginning to look
like the complexity of Python classes is unecessary.

My question for the Python experts is -- What user benefit are we
missing if we eliminate classes?

-- Dave

Jul 18 '05
145 6374

"Gerrit" <ge****@nl.linu x.org> wrote in message
news:ma******** *************** *************** @python.org...
John Roth wrote:
As far as rendering programs, the most obvious
culprit is OE, which for all of its defects and security
problems, is still one of the most used mail and newsgroup
clients out there.


<pre>
T h e r e i s a s o l u t i o n ; - )
</pre>

1. This only works if you are using html, which is
strongly discouraged (but still depressingly prevalent)

2. The OE problem is on the recipient's side, not
on the sender's side.

John Roth

Gerrit.

--
Weather in Twenthe, Netherlands 30/03 13:55 UTC:
15.0°C wind 5.8 m/s E (57 m above NAP)
--
here will soon be Gerrit Holl's very own signature
Jul 18 '05 #81
Gerrit wrote:
only one. I think it is the wrong answer to say that people shouldn't
bitch about top-posting - it _does_ annoy people (including me and Aahz).
Will you please reign in you ego and qualify your statement 'it annoys
*SOME* people'. I find all the bitching about top posting to be a
greater distraction than top posting itself!
There are conventions on usenet (and mailing lists), and they are there
with reason. I would like to kindly ask you to try to do more
'bottom-posting'. It makes your postings easier and prettier to read.
I find bottom posting to be a real pain as when I look at a new message
it defaults to showing me the top of the message and I then have to
scroll through pages of quoted posts that I have already read just to
read one or two lines stuck at the bottom.
Really, it does - please try it...


It also doesn't, so once you have worked out how to keep both parties
happy, perhaps 'middle posting' would be a working compromise, you can
get on to curing cancer and bringing peace to the middle east.

I have never left a group because of the trolls.
I have never left a group because of the noobies.
I have left a group because of the constant whining about top posting.

People who whine on about 'top posting' are the sort of people who draft
'clean desk' policies. If you want to whine about top posting then start
alt.whine.top.p osting and have fun.
Jul 18 '05 #82
At some point, Michael <mo*****@mlug.m issouri.edu> wrote:
You're contradicting yourself. In a prior post, you said that if you
had a crappy editor, then change it. Now you're saying that you
think you would have to press the space bar or the backspace key
multiple times, and you're not going to give up that crappy editor
for one that works properly.

An editor is crappy if it inserts anything other than what you type
into the code. If I press tab and four spaces are inserted that is
crap. If I press 'A' and 'a' is inserted that is crap. To me, it
sounds as if this entire issue is caused by crappy editors that think
they know better than the programmers. If you want a smart alec paper
clip telling you what to do when you're editing code then feel free to
do so but I just want raw access to my code.


Does your backspace key insert a backspace character (^H), also?

--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)phy sics(dot)mcmast er(dot)ca
Jul 18 '05 #83
A2. People that bitch about top-posting.


Mark - I really find it a bit difficult to read your postings. I keep
scrolling to below to see whether there is still more to come - because you
do sometimes quote others and then answer below. When I see quoting in a
message, I automatically assume there's more to come, and I am not the
only one. I think it is the wrong answer to say that people shouldn't
bitch about top-posting - it _does_ annoy people (including me and Aahz).
There are conventions on usenet (and mailing lists), and they are there
with reason. I would like to kindly ask you to try to do more
'bottom-posting'. It makes your postings easier and prettier to read.

Really, it does - please try it...

The 'standard' I've seen worked out in about a decade of watching this
exact argument.. when responding to individual parts of someones message
then post your reply directly underneath the section you're replying to.
If you're making a short response to the entire message it's okay to top
post. Of course, either bottom or top posting, clip any text in the
previous messages you aren't directly responding to.

Jul 18 '05 #84
Michael <mo*****@mlug.m issouri.edu> wrote in message news:<40******* *******@mlug.mi ssouri.edu>...
They're planning to remove tab indention support in 3.0? I for one would
be pissed off at such a change.


I don't think you need to worry. AFAIK Python 3 is the mythological
if-I-could-turn-back-the-clock-and-undo-all-my-mistakes version
of Python, which Guido probably won't have time to work with
until his son is big enough to help him. (He'll be 3 in November.)
It will have little regard for backward compatibility, and if it
does appear sooner than expected, you can expect Python 2.x to be
maintaned in parallel for a long time.
Jul 18 '05 #85
I don't think you need to worry. AFAIK Python 3 is the mythological
if-I-could-turn-back-the-clock-and-undo-all-my-mistakes version
of Python, which Guido probably won't have time to work with
until his son is big enough to help him. (He'll be 3 in November.)
It will have little regard for backward compatibility, and if it
does appear sooner than expected, you can expect Python 2.x to be
maintaned in parallel for a long time.

That's good. I was thinking that if they actually took out tab support
I'd have to fork the code base and keep applying a patch that added tab
support back in. Not to hard I think but not the kind of thing I like to do.

Overall I dislike features being removed, once added as
non-experimental. I think if a languages authors want to do major
changes like that which will break compatibility it's better to create a
new language. Even if the two languages are highly similar. Otherwise
you end up into weird issues like Perl where new versions take forever
and if they are released as many people are annoyed as are pleased. Call
them a family of languages if you like. So prehaps we could see the
language Monty with some of Guido's new and improved ideas.
Jul 18 '05 #86
I don't think you need to worry. AFAIK Python 3 is the mythological
if-I-could-turn-back-the-clock-and-undo-all-my-mistakes version
of Python, which Guido probably won't have time to work with
until his son is big enough to help him. (He'll be 3 in November.)
It will have little regard for backward compatibility, and if it
does appear sooner than expected, you can expect Python 2.x to be
maintaned in parallel for a long time.

That's good. I was thinking that if they actually took out tab support
I'd have to fork the code base and keep applying a patch that added tab
support back in. Not to hard I think but not the kind of thing I like to do.

Overall I dislike features being removed, once added as
non-experimental. I think if a languages authors want to do major
changes like that which will break compatibility it's better to create a
new language. Even if the two languages are highly similar. Otherwise
you end up into weird issues like Perl where new versions take forever
and if they are released as many people are annoyed as are pleased. Call
them a family of languages if you like. So prehaps we could see the
language Monty with some of Guido's new and improved ideas.

Jul 18 '05 #87
On 30 Mar 2004 12:37:25 -0800, ma****@thinkwar e.se (Magnus Lyck?)
wrote:
I don't think you need to worry. AFAIK Python 3 is the mythological
if-I-could-turn-back-the-clock-and-undo-all-my-mistakes version
of Python, which Guido probably won't have time to work with
until his son is big enough to help him. (He'll be 3 in November.)
It will have little regard for backward compatibility, and if it
does appear sooner than expected, you can expect Python 2.x to be
maintaned in parallel for a long time.


Maybe Prothon will *become* Python 3.0 That could happen quicker than
migrating all the Python libraries to Prothon. Open source is an
amazing phenomenon!

Nothing like a little kick-in-the-butt competition to stimulate
progress. :>)

-- Dave

Jul 18 '05 #88
Peter Hickman wrote:
Gerrit wrote:
only one. I think it is the wrong answer to say that people shouldn't
bitch about top-posting - it _does_ annoy people (including me and Aahz).

Will you please reign in you ego and qualify your statement 'it annoys
*SOME* people'.


Well, it seems that it annoys *most* people here. BTW, I was about to do
the same... (Mark, if you read us : your work seems pretty interesting,
so do *yourself* a favor and make your posts more readable !-).
I find all the bitching about top posting to be a
greater distraction than top posting itself!
So please stop bitching about people bitching about top-posting.
There are conventions on usenet (and mailing lists), and they are there
with reason. I would like to kindly ask you to try to do more
'bottom-posting'. It makes your postings easier and prettier to read.


I find bottom posting to be a real pain as when I look at a new message
it defaults to showing me the top of the message and I then have to
scroll through pages of quoted posts that I have already read just to
read one or two lines stuck at the bottom.


If you have to do so, then the poster didn't get point : only quote
what's needed.

(snip)

I have never left a group because of the trolls.
I have never left a group because of the noobies.
I have left a group because of the constant whining about top posting.
May I suggest you to count how many messages Mark posted here before
someone kindly suggested that he could help everyone by doing a simple
thing ? If that's what you call 'constant whining', then you are the troll.
People who whine on about 'top posting' are the sort of people who draft
'clean desk' policies. If you want to whine about top posting then start
alt.whine.top.p osting and have fun.


Après vous, mon cher.

Bruno

Jul 18 '05 #89
Carl Banks wrote:
William Park wrote:

(snip)
This space-vs-tab war is just insane. I wish Prothon/Python would use
block terminator, if only to kill this silly trollings.

Right. Then we can have "does the brace go on the same line or the
next line" wars.


lol !

Jul 18 '05 #90

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

Similar topics

0
1400
by: Mark Hahn | last post by:
I would like to announce a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like meta-classes...
0
1314
by: Mark Hahn | last post by:
Ben Collins and I have developed a new interpreted object-oriented language very closely based on Python, that is Prototype-based, like Self (http://research.sun.com/research/self/language.html) instead of class-based like Python. I have named the language Prothon, short for PROtotype pyTHON. You can check it out at http://prothon.org. The prototype scheme makes object oriented computing very simple and complicated things like...
28
3306
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
7
3563
by: Michele Simionato | last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self or other prototype-based languages. Still, from the discussion on the mailing list, I have got the strong impression that you do not actually need to fork Python in order to implement prototypes. It seems to me that Python metaclasses + descriptors are more than powerful enough to implementing prototypes in pure Python. I wrote a module that implements part of what...
49
2628
by: Mark Hahn | last post by:
As we are addressing the "warts" in Python to be fixed in Prothon, we have come upon the mutable default parameter problem. For those unfamiliar with the problem, it can be seen in this Prothon code sample where newbies expect the two function calls below to both print : def f( list= ): print list.append!(1) f() # prints
20
1814
by: Mark Hahn | last post by:
Prothon is pleased to announce another major release of the language, version 0.1.2, build 710 at http://prothon.org. This release adds many new features and demonstrates the level of maturity that Prothon has reached. The next release after this one in approximately a month will be the first release to incorporate the final set of frozen Prothon 1.0 language features and will be the Alpha release. You can see the set of features still...
0
9628
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
10289
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...
0
10120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
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...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5367
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...
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.