473,776 Members | 1,606 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 6375

"Didier Morandi" <no@spam.com> wrote in message
news:c4******** ***@biggoron.ne rim.net...

What against-top-posting people do not WANT to understand is that the very first interest of posting is, to me, to get help or information.

So, you post your question and, by definition, you remember what it was (well, I hope so).

Then, you go back to the ng the day after and if you got an answer, you are interested in the answer, not to reread your post.


That's a very good point. One of the forums I read is Baen's Bar
(Baen Publishing) where the publisher has an ironclad rule that
responses to him *must* be top posted. He is absolutely not
going to hit the page down button to see whether there was
anything interesting in the response. If he doesn't see it where
his eyes are pointing, it might as well not exist. I suspect it's the
only way he gets through his mail to get anything done.

AFAIC, it doesn't matter whether you put your response at the
top or bottom; what matters to me is whether I can find what
you're talking about quickly. That means ruthless pruning of the
post so that old stuff gets deleted.

John Roth
Jul 18 '05 #111
On Wed, 31 Mar 2004 02:31:08 -0800, Michael
<mo*****@mlug.m issouri.edu> wrote:
top.
to
bottom
read
to
learn
to
you
forcing
be
would
this
No,


This is actually better than top-posting. At least the reading
direction is _consistently_ upwards, rather than requiring people to
leap forwards and back through the post in a desperate attempt to find
the clues they need.
--
Steve Horne

steve at ninereeds dot fsnet dot co dot uk
Jul 18 '05 #112
I find it surprising to see programmers arguing for top-posting. They
are arguing that exchanging the single author's time and brain cycles
for the time and cycles of many readers is a good trade-off. Perhaps
they just feel their time is infinitely more valuable than anyone
else's. I'm sure every top-poster present can think of vendors who
work from the point of view that their time and effort is more
valuable than the user's. The result of this philosophy is alienating
to users of software AND articles.

Didier Morandi said that the greatest reason for posting is so one may
"get help or information". I don't think that's really so, I think
that sould be further generalized to, one posts to communicate. If
one's goal is to communicate (perhaps to communicate a question, but
whatever), why wouldn't one stress clarity to the reader above
convenience to the author?

Top-posting is a mildly offensive presumption viewed in this light,
like telemarketing or squeegee kids.

Mike.
Jul 18 '05 #113
I belong to several newsgroups, some prefer top-posting, and some prefer
bottom posting. A few posters will spend the time to intersperse their
replies. And a few will even split a post into additional posts to reply
specifically to each question or comment that was made in a previous
post(pretty anal). Personally, I don't care how you post, it doesn't
irritate me a bit whether the post is top or bottom, replies interspersed,
or broken into multiple posts. My only real irritation, is the people that
feel that they have to include all the prior postings in the thread in their
post. I know what the thread's about, and if I want to see the previous
posts, I know how to go back and look at them. I'm just interested in the
answer(s). Period.

My point being?...There' s no "correct" way to reply to a post. Out of
courtesy, one follows the "standard" of the newsgroup one is participating
in. Complaining whether one top posts or bottom posts is just a waste of
time, and you, me, we, all know it. We just don't have anything better to
do but bitch, right?

This particular silly argument always has the same effect; it gets us
off-topic from the original post, and for those of us trying to follow that
topic, this is more irritating than whether one is "posting in the approved
manner". This thread was renamed to a different subject, but that was a
half-dozen rants later in the thread than it needed to be.

Get my point? Naw, too much to expect. I've wasted both your time and my
time with my own rant against your rants. :-)
A lot of you guys seem far more interested in starting arguments and keeping
them running, than you are discussing the pros and cons of Python and
providing helpful answers. Rein in your egos, no one, and I include myself,
has anything helpful to contribute in this kind of "dust-up".

Jul 18 '05 #114

"Michele Simionato" <mi************ ***@poste.it> wrote in message
news:95******** *************** ***@posting.goo gle.com...
Peter Hickman <pe***@semantic o.com> wrote in message

news:<40******* *************** @news.easynet.c o.uk>...
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.


Then maybe you should consider leaving c.l.py ?


Peter, while I am careful to quote, snip, and reply in a manner to make
coherent posts, I have been pretty tolerant of what others do. Indeed, I
don't remember ever commenting about top-posting before this week. (While
I may have, it has not been a priority issue for me.)

But when Mr. Hahn top-posted several sentences littered with several
unresolved references to 'this', 'you', 'suggestion', and something
'fragile', I 'rebelled', seeing how stupidly impolite was his implicit
demand that I spend several minutes scanning the previous post below to see
what he was talking about. End of tolerance. So I satirically, not
whiningly, top-posted a set of questions as to what the references referred
to.

If that drives you off c.l.p., so be it ;-) ... but I hope not.

Terry J. Reedy


Jul 18 '05 #115

"Didier Morandi" <no@spam.com> wrote in message
news:c4******** ***@biggoron.ne rim.net...
What against-top-posting people do not WANT to understand is that the very first interest of posting is, to me, to get help or information.

So, you post your question and, by definition, you remember what it was (well, I hope so).


SourceForge adds new comments to tracker items to the top of the comments
section. If you are are the original poster, and get a new report emailed
with every comment, and get and read them in order, then newest at top is,
I admit, helpful. BUT if you look at an old, unresolved, bug report with
several comments, perhaps to see if you can help, then the format is a
major nuisance. Read the original report at the top. Then jump down to
the bottom and back up to the top of the first comment and read down. Then
scan up to find the top of the second comment and read down. and so on.

The solution, to me, are more easily customizable information readers and
managers. Then one could have, for instance, a module specifically for
interacting with the SourceForge database, complete with user-preference
settings. (Does one exist now? that I don't know of?)

Terry J. Reedy


Jul 18 '05 #116
JanC <us*********@ja nc.invalid> wrote in message news:<Xn******* ***********@213 .119.4.35>...
"Mark Hahn" <ma**@prothon.o rg> schreef:
I really really try to remember to quote from below. If you go through my
posts you will see that I remember most of the time. The last few days I
have been reponding to four or five mailing lists after months of only
coding and my fingers are worn out.


then set your newsreader to reply afterwards instead of before, and if
it does not allow this, then switch to one that does, there are lots
of good free newsreaders that don't default to top posting ( yuk! ) or
that let you tell it to reply fromt he bottom.
Jul 18 '05 #117
Ville Vainio wrote:
>>"Didier " == Didier Morandi <no@spam.com> writes:

Didier> I do not read answers to questions I did not post, so I don't care
Didier> about "unlearn a lifetime of knowledge about narrative flow in
Didier> content".

So essentially Usenet should be a free Q&A automaton, where people
post questions and Usenet fairies go around answering them? Everybody
takes, nobody gives? I believe such service should cost you money...


Well, no. I should have said that I read questions about which I think I either
know the answer or I can share useful experience with the poster of the question.

D.

Jul 18 '05 #118
Mike Pelletier wrote:
.../..
Didier Morandi said that the greatest reason for posting is so one may
"get help or information".


Didier Morandi said that *his advice on* the greatest reason...

D.

Jul 18 '05 #119
>As I'm against capital punishement; twentyfive to life for top-posters,
I say.

+1
--dang
Jul 18 '05 #120

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
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
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
10061
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
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...
0
6722
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
5368
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
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.