473,778 Members | 1,862 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
Michael <mo*****@mlug.m issouri.edu> writes:
I follow more than 300 mailing lists on a regular basis (I get around
3 gigs of mail a day just from these lists)
Given the time this must leave you to read, understand, and
thoughtfully reply to any given article ... I'll let you draw your own
conclusions about what effect this might have on the quality of your
contributions.
and I much prefer people that top-post.
.... yup, if you are really not interested in _understanding_ what is
going on, then top-posting is for you.
Of course the only people I really hate are those that quote text
without quoting it.. so it's all on the same level and you can't tell
what they wrote from what others have written.


They should be tortured without remorse.
Jul 18 '05 #131
"John Roth" <ne********@jhr othjr.com> writes:
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.


Look, y'all, email and usenet aren't all that dissimilar, in this
respect, from face-to-face conversation which has been
interrupted. Imagine you pick up a conversation whith someone, which
was interrupted a few minutes, hours, or days before.

Do you go up to your interlocutor, say whatever you wanted to say
next, and then recite (both sides of) the whole conversation you had
before? No.

Do you _first_ repeat (both sides of) the whole conversation you had
before, and at the very end (ten minutes later, or so) say whatever it
is that you wanted to say? No. Does your interlocutor then repeat
everything both of you have said so far once again, before adding his
new contribution? No.

Or, do you, re-establish context by saying something like "Concerning
your point about fubaring the frobnicators", and then make your point
("I would never fubar a frobnicator, without barzotting it first") ?

Then, maybe you wish to make a second point ... in which case you
would establish the relevant context again ("As for what you said
about pinging a pong"), and make your next point, relevant to the
context you just established ("When pinging a pong, you must take care
to pang it first").
I find that people who do not make the effort to quote the relevant
part(s) of messages to which they are replying, and do not make the
effort to put their replies close to (ie just after) the relevant
citations they have left in, more often than not, also fail to make
the effort to organize their own thoughts in their entire
consideration of the discussion.

Exchanges with top-posters are usually of a low quality: top-posting
makes it difficult to follow the thread ... but top-posters tend to
write codswallop more often that those who trim and organize their
replies carefully.

This is partly because the process of trimming the original post,
forces you to identfy the relevant points being made, which helps you
notice more clearly what is actually being said. Partly, it is because
if you post on usenet for more than a day and fail to notice that
top-posting sucks, then ... well, that says something about your
perspicacity.
Jul 18 '05 #132
Given the time this must leave you to read, understand, and
thoughtfully reply to any given article ... I'll let you draw your own
conclusions about what effect this might have on the quality of your
contribution s.

Actually I'm a major contributor to many lists. Obviously I just watch
most. Or decide a thread interests me at random points in whichI decide
to follow a list more closely for a few days. Also obvious, it's not
always the threads that have actual value that interest me.. since I've
participated in this one. I'm just amused to see this same argument
repeated pointlessly year after year.
... yup, if you are really not interested in _understanding_ what is
going on, then top-posting is for you.

I understand by having read the thread and remembered it. If I need a
context hint I can peek below but that is usually only needed with
complex interwoven threads. Which isn't the majority.. which is why I
think top-posting is good for a majority of messages but inline
bottom-posting is good other times. Use what is best for the given message.

Jul 18 '05 #133
R Baumann wrote:
one follows the "standard" of the newsgroup one is participating in.

No such thing, since there is no way to enforce these "standards" , and the
bottom-posters will always bottom post, and the top-posters will always top
post no matter where they are.

Complaining whether one top posts or bottom posts is just a waste of
time, and you, me, we, all know it.

Not always, sure there are the smart asses who top-post just to annoy people,
but a lot of top-posters do that because they are newbies and don't know that
it annoys so many people. Often they just need to find out how to change
their reader program's default, or simply discover that their reader does have
such an option.

this is more irritating than whether one is "posting in the approved manner".

No it isn't, as long as someone sticks "OT" in the subject line, I don't mind
anyone talking about something else. If its identified as off topic, I can
always skip it. Top-posting on the other hand, is annoying because its
unnatural for most of us. Most of us may not say anything, and most of the
time its not "serious", but IMO, top-posting is far more irritating then OT posts.

This thread was renamed to a different subject, but that was a
half-dozen rants later in the thread than it needed to be.

Why complain about this when you're obviously still participating in this
thread two *dozen* posts after "OT" was inserted?

Get my point? Naw, too much to expect. I've wasted both your time and my
time with my own rant against your rants. :-)

Yep, everyone has their pet peeve, but isn't it kinda obvious by now that
there are a *lot* more people peeved about top-posting than there are peeved
at OT posts. :)

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".

I've seen this complaint a thousand times too, and it never makes a
difference. You're basically asking people to stop being human, which is why
we designated "OT" as a warning for others that the conversation has drifted
far afield. However, we never did adopt "TP" so top-posters could warn
others, mainly because top-posting is not seen as inevitable, irresistible
human behavior, it is of course simply an example of laziness (or ignorance),
nothing more. While laziness is inevitable in some humans, its still not
accepted behavior. People arguing with one another is perfectly natural, and
has been going on for millenia, but for most of the world, its written
conversations are done top-to-bottom, not bottom-to-top.
Jul 18 '05 #134
What makes you think people who top post don't also put a lot of effort
into carefully organizing their replies and trimming the original post
down to the most relevant points?

Jacek Generowicz <ja************ **@cern.ch> wrote:
top-posters tend to write codswallop more often that those who trim
and organize their replies carefully.

This is partly because the process of trimming the original post,
forces you to identfy the relevant points being made

Jul 18 '05 #135
Jacek Generowicz wrote:
Markus Wankus <ma************ **************@ hotmail.com> writes:

Right. So if we'd all just settle on top-posting things wouldn't be
so bad after all. It's all you bottom-posters that are screwing
things up for the rest of us. ;o)

Did you actually _understand_ what he wrote? Yes, I did notice the
smiley, but I also noticed the apparent complete failure to get the
point.


Geez..you can't even joke about this apparently. OK. Whatever. I'm
easy. I *did* get the point BTW...
Even if _everyone_ top-posts, then the reading direction is still
inconsisitent and requires the reader to jump back and-forth, to
understand what is going on.
Yes.
Please _think_ about it. It really doesn't take very much thought to
understand that top-posting sucks, but it does require some. More than
top-posters seem to be able to muster, it seems.


Alright.

--

MAN! There are some passionate individuals here. In fact, a few
minutes after my lighthearted post I received a flood of IP spoofing
attacks on my router (you know who you are). Man! Take it easy, grab a
beer (or whatever tickles your fancy) and chill. Code something - that
usually helps me. Just don't use VB or C++. ;o)

Markus.
Jul 18 '05 #136
In article <sl************ ****@gate.notch arles.ca>,
Joe Mason <jo*@notcharles .ca> wrote:
In article <69************ **************@ posting.google. com>, has wrote:
Joe Mason <jo*@notcharles .ca> wrote in message
news:<sl******* *********@gate. notcharles.ca>. ..
In article <69************ **************@ posting.google. com>, has wrote:
> # Library pseudocode
>
> _fooRegistry = []
>
> obj _Foo: # prototype object
> # Foo's code goes here
>
> def Foo(): # constructor function
> newFoo = _Foo.copy()
> _fooRegistry.ap pend(newFoo)
> return newFoo
>
>
> Dirt simple with not an ounce of class metaprogramming in sight.

Is Foo() the standard syntax for making a new _Foo object? If this is a
new wrapper you just created, then it's no different than adding a
register() method - the user has to know that something different is
being done.

If Foo() is the standard syntax, and you're just overriding the
implementation here, does that get inherited? If so, this missed the
condition that only some of the descendants should get added to the
registry. If not - well, inheriting the constructor seems like the more
useful behaviour in general, so why not?
Don't think you've quite got the point of prototype-based OO yet.
There's no real 'standard syntax' for making objects; nor is there any
inheritance, classes, metaclasses, or instances. To create a new
object from scratch, execute the code that defines it. Alternatively,
duplicate an existing object.


There certainly is a standard syntax for making objects. I need to know
how to "duplicate an existing object". Is it "obj.dup()" ?
"obj.clone( )"? "duplicate obj"? Most probably, the language (or
standard library) defines one of these, and I expect most objects to be
duplicated in the same way.

It can be a bit more subtle than that in a prototype based system, since
there are two things that are different, but have nearly identical
results, but could both be considered "duplicate an object".

In general, you don't want to _duplicate_ the object, but rather use
that object as "prototype" for the new object.

First, you can make a new object that has all the same
slots/properties/attributes as the first object - let's just call that
"clone" for now (and we'll assume single inheritence, via a slot called
"__parent")
print obj.__parent None obj.a = 1
obj.foo = def (): print "a=",self.a obj.foo() a=1 obj1 = obj.clone()
print obj1.__parent None obj.a = 2 # change something in the original object
print obj1.a # unchanged in the "clone" 1 obj1.foo() a=1

and we'll make the second object that has first object as the __parent
(and we'll pretend that the syntax is "new <some expression>"
obj2 = new obj1
print obj2.__parent <obj1> obj2.foo()

a=2 # since it inherits from obj1

(obviously, the object doesn't actually retain the binded local variable
name)

If we looked at these three objects in a debugger:

obj = <Object 0x1> { __parent: None, a: 1, foo: <Method 0x2> }
obj1 = <Object 0x3> { __parent: None, a: 2, foo: <Method 0x2> }
obj2 = <Object 0x4> { __parent: <Object 0x1> }

If we hadn't changed obj1.a, both obj1 and obj2 would behave identically
to obj (they all have the same properties, same behavior), even though
internally, they are fairly different (obj1 is independant of obj, while
obj2 is completely dependant on obj). Since both "data" and "behavior"
is inherited, this is different from traditional class/instance
organization (where an instance shares its behavior (methods) with all
other instances, but has private data). This also makes the issue of
"obj2.a = 5" important, since at that point obj2 would normally get it's
own value of "a" (and otherwise would inherit the value of obj.a), and
you'd want a clean way to alter obj.a from a method in obj2
("obj2.__parent .a = 3" would work, this is where directed resends are
used in Self).

In general, you want obj2 (since it inherits everything from obj, much
like an instance "inherits" stuff from its superclass), but both are
useful.
Jul 18 '05 #137
In article <ga************ *************** *@news.mpls.vis i.com>, Glenn Andreas wrote:
There certainly is a standard syntax for making objects. I need to know
how to "duplicate an existing object". Is it "obj.dup()" ?
"obj.clone( )"? "duplicate obj"? Most probably, the language (or
standard library) defines one of these, and I expect most objects to be
duplicated in the same way.
It can be a bit more subtle than that in a prototype based system, since
there are two things that are different, but have nearly identical
results, but could both be considered "duplicate an object".

In general, you don't want to _duplicate_ the object, but rather use
that object as "prototype" for the new object.

First, you can make a new object that has all the same
slots/properties/attributes as the first object - let's just call that
"clone" for now (and we'll assume single inheritence, via a slot called
"__parent")


<snip example>
and we'll make the second object that has first object as the __parent
(and we'll pretend that the syntax is "new <some expression>"


<snip other example>

This is certainly how Self does it. Other prototype based languages
(such as Io) do not make this distinction. In Io, you use "clone" to
make a new object whose parent is the object it was cloned from, and
that's it.

Joe
Jul 18 '05 #138
Roy Smith <ro*@panix.co m> wrote:
Jacek Generowicz <ja************ **@cern.ch> wrote:
top-posters tend to write codswallop more often that those who trim
and organize their replies carefully.

This is partly because the process of trimming the original post,
forces you to identfy the relevant points being made


What makes you think people who top post don't also put a lot of effort
into carefully organizing their replies and trimming the original post
down to the most relevant points?


Bitter, hard-earned experience. Some people do so, as you demonstrated,
but IMB,H-EE the vast majority do not.

Another problem that occurs when some people top-post and some do not is
that the conversation thread quickly becomes unreadable unless someone
takes the time to rearrange it into a consistent form (as I did in
composing this reply).

--
Robin Munn
rm***@pobox.com
Jul 18 '05 #139
In article <25************ **************@ posting.google. com>,
Magnus Lyck? <ma****@thinkwa re.se> wrote:
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.


Not quite. Python 3000 is the mythical version; Python 3.0 is expected
to appear some day. While there will be many changes that are not
backward compatible, your "little regard" is unlikely to be true: Guido
*likes* Python.
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/

"usenet imitates usenet" --Darkhawk
Jul 18 '05 #140

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
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...
0
10122
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...
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?
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
3627
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.