What is a class?

P

Paul McGuire

What is a class that is not a module?

Please stop posting these one-liner beginner questions. If you can
type it in one line, you can enter it on the Google.com or Ask.com
query page and get a wealth of *existing* information, from tutorials,
documentation, online presentations. If you are able to phrase such a
question, you are capable of doing a little research and
experimentation on your own.

These posts translate to "I'm too lazy to use Google, or too cheap to
buy a Python book, or too lazy to read it, or too impatient to do my
own experimenting - much better to just post on c.l.py and have the
answer spoon-fed to me!"

I refuse to spoon feed you the answer to this question when plenty of
supporting material is already available.

-- Paul
 
C

castironpi

Please stop posting these one-liner beginner questions.  If you can
type it in one line, you can enter it on the Google.com or Ask.com
query page and get a wealth of *existing* information, from tutorials,
documentation, online presentations.  If you are able to phrase such a
question, you are capable of doing a little research and
experimentation on your own.

These posts translate to "I'm too lazy to use Google, or too cheap to
buy a Python book, or too lazy to read it, or too impatient to do my
own experimenting - much better to just post on c.l.py and have the
answer spoon-fed to me!"

I refuse to spoon feed you the answer to this question when plenty of
supporting material is already available.

In the future, shall I assume that other readers here have no ideas
(on this, read *ever*), that haven't already been published? 'Cause I
have.

For instance, in this example, I've tried a few approaches that didn't
turn out well.

Do you want a comparison of existing solutions? Do you have a proof
that they exhaust the solution space?

I'm willing to address convention, in serial or parallel--- (change
subject to 'what goes on newsgroups'?), but it's not clear from fact
what assumption who has made.

Next time, why don't you say, "How much experience do you have?", or
"What level should I gear my answer toward?"
 
P

Paul McGuire

In the future, shall I assume that other readers here have no ideas
(on this, read *ever*), that haven't already been published?  'Cause I
have.

For instance, in this example, I've tried a few approaches that didn't
turn out well.
Fair game. Capture one of these classes (or better, distill it down
to a *small* example demonstrating the problem), tell us what you are
trying to achieve, post it, AND tell us what is "not turning out
well." (Your previous posts have done a poor job in providing one or
more of these elements.)
Do you want a comparison of existing solutions?  Do you have a proof
that they exhaust the solution space?
*I* don't want *any* such thing, especially on the topics of "what is
a class?" and "how is a class different from a module?", nor do I need
proof that the basic background info on this topic covers the
mainstream applications of classes and modules. These are basic OO
concepts in Python. Try googling "python object-oriented". And if
there were some esoteric aspect of "what is a class?" that you want to
pursue that might not be covered in the available material, I would
expect one to include that in the original post.
I'm willing to address convention, in serial or parallel--- (change
subject to 'what goes on newsgroups'?), but it's not clear from fact
what assumption who has made.
Since you did not elaborate on what your efforts were and the extent
they were undesirable (certainly useful info from someone honestly
interested in a helpful answer), I assumed you had made none.
Next time, why don't you say, "How much experience do you have?", or
"What level should I gear my answer toward?"
I put the onus on the poster to realize that the question they are
asking is in fact a basic concept, *especially* when the subject of
the question is captured in a built-in method, type, class, or
keyword. Surely you are aware that Python has been around for a
number of years, and that in all that time, it is entirely likely that
the topic of "what is a class?" has been covered, in any number of the
tutorials and docs so charitably written by many of the contributors
in this newsgroup.

Please stop asking those people to further expend their time repeating
this work just for your benefit. It is like arriving late to a
meeting, and asking everyone to stop and bring you up to speed on what
you missed, in effect saying, "My time is more valuable than yours, I
can't be bothered to arrive on time, or do even the simplest research
for myself."

-- Paul
 
C

castironpi

What is a class that is not a module?
Since you did not elaborate on what your efforts were and the extent
they were undesirable (certainly useful info from someone honestly
interested in a helpful answer), I assumed you had made none.

I agree. To one of my friends, there's plenty of information in the
context that isn't a newsgroup. So I'll state more about my
background.

Classes and modules are really similar. In Python they're really
*really* similar.

Actually, at this point, that observation may have more of a
subjective component than I'm used to asserting. I pause here for
corroboration and others' perspectives. Aren't they?
 
D

D'Arcy J.M. Cain

On Mar 5, 12:50 pm, (e-mail address removed) wrote:

I'm not sure why you change the address like this but could you please
include the full address. Those of us who identify the time wasters
would also like to drop the responses to their posts and changing the
address makes this impossible.
 
M

Mike Driscoll

I'm not sure why you change the address like this but could you please
include the full address. Those of us who identify the time wasters
would also like to drop the responses to their posts and changing the
address makes this impossible.


What are you talking about? I didn't change the address at all. I'm
not even sure what you mean. Are you talking about the post subject
line (which I have never touched in any post)? If you're talking about
the OP's email address, that's Google's fault for cropping them.

Mike
 
P

Paul McGuire

Classes and modules are really similar.  In Python they're really
*really* similar.

Actually, at this point, that observation may have more of a
subjective component than I'm used to asserting.  I pause here for
corroboration and others' perspectives.  Aren't they?

If all you use classes for is for the purpose of a namespace, and all
of the methods in the class are just staticmethods, then you have used
a class to replicate a module, and they aren't just really, *really*
similar, they are the pretty much the same (at least BEHAVIORALLY
speaking).

But you can't do this:

import Zmodule
zobject = Zmodule()

If you are really using the OO model, and creating instances of
classes, then you *have* to use a class, a module wont cut it. I'd
say, the less you use a class as an instance factory, the more similar
that class is to a module.

And you can't do this:

class Zclass:

import Zclass

If Zclass is not defined in your local script, you *have* to know what
module it is in, as in:

from zpackage.zmodule import Zclass

I have seen modules compared to classes that implement a Singleton
pattern. In this case, a class is being used in an intentionally
degenerate way, such that it creates only one instance. When doing
this in Python, one has the choice of replicating the standard pattern
with a class, or more simply, just using a module. (Python's language/
object model also permits another option, usually referred to as the
Borg implementation, in which many Python names bind to many Python
instances, but all share the same underlying object state. But this
is tangential to your question.)

In general I would say the similarity is a behavioral one, an artifact
of the language implementation. Modules are for code packaging and
namespace definition, classes are for type definition and object
modeling.

For more discussions about how similar classes are to modules, you
might google for "Python singleton".

-- Paul
 
C

castironpi

Er, all of them?

I'm curious what classes you think are modules.

Thank you for your time in entertaining my questions so far.

Functions are first-class objects.
Modules are first-class objects.
Classes are first-class objects.

There's even a ModuleType in 'types'.
{'__module__', '__weakref__'}

How superficial are the differences?
 
B

Ben Finney

D'Arcy J.M. Cain said:
I'm not sure why you change the address like this but could you
please include the full address.

It's a misfeature of Google's mail interface. The poster to whom
you're responding could choose a different mail interface, but you'll
have a difficult time convincing them of that.
Those of us who identify the time wasters would also like to drop
the responses to their posts and changing the address makes this
impossible.

Not at all. AFAIK the messages from Google mail correctly include the
'In-Reply-To' field or the 'References' field in the message header.
So, you can know by those fields whether a message is part of a thread
you've previously identified.
 
D

D'Arcy J.M. Cain

What are you talking about? I didn't change the address at all. I'm
not even sure what you mean. Are you talking about the post subject
line (which I have never touched in any post)? If you're talking about
the OP's email address, that's Google's fault for cropping them.

I'm talking about castironpi. I find his posts a waste of my time so I
have them filtered out along with a few others and I also filter out
responses by searching for his address in the body so changing it
defeats that. However, if it is something that you have no control over
I apologize for the noise.
 
D

D'Arcy J.M. Cain

Not at all. AFAIK the messages from Google mail correctly include the
'In-Reply-To' field or the 'References' field in the message header.
So, you can know by those fields whether a message is part of a thread
you've previously identified.

I don't want to have to tag every thread. I just want to *plonk*
certain posters.

Anyway, I'll live with Google's failings I guess.
 
C

castironpi

Yes they are.

Both are namespaces. The very last line of the Zen of Python says:
Namespaces are one honking great idea -- let's do more of those!

Where to begin?
 
M

Mike Driscoll

I'm talking about castironpi. I find his posts a waste of my time so I
have them filtered out along with a few others and I also filter out
responses by searching for his address in the body so changing it
defeats that. However, if it is something that you have no control over
I apologize for the noise.

No problem. I wish I could use something other than Google Groups when
I'm at work, but we currently have NNTP disabled...and I haven't found
a good workaround yet.

Mike
 
C

Carl Banks

I don't want to have to tag every thread. I just want to *plonk*
certain posters.

Anyway, I'll live with Google's failings I guess.

Sounds like you need better filtering.

A decent news filter should be able not only kill a poster, but also
all followups to that poster recursively.

(No, I don't know of any that do that either.)


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top