Re: classes and standard modules

From: phansen (peter_at_engcorp.com)
Date: 09/17/04


Date: Fri, 17 Sep 2004 08:36:48 -0400

Brad Tilley wrote:
> I don't understand classes very well... maybe some day. Is it just me or
> are they supposed to be difficult to understand? They make my head hurt.

They're not really that hard. Classes are nothing more than
_templates_ for blobs of data with associated functions. When
you instantiate a class (i.e. create an instance) you just get
one of those blobs of data, matching the pattern defined by the
template. You can call those associated functions and they
already know how to work on the data in the blob.

If you have a C background, think of classes as being structs with
a bunch of functions that are designed to work with those structs.

> Anyway, because I don't understand classes well, I avoid using them.
> However, many modules in the standard library are implemented as
> classes: sgmllib, HTMLParser, etc. Is it possible to use these modules
> without getting into OO programming and inheritance and all the other
> lofty, theoretical CS concepts that small script writers, like me, don't
> really need?

Well, for any of those, you just create one of the blobs of data,
say like "server = smtplib.SMTP('myhost')", and now you have a blob
with the name "server". You want to call one of those functions?
Instead of passing the data in the argument list as you do with
regular functions, you use the syntactic sugar form that looks like
this: "server.sendmail(...)".

This description needs you to know about blobs of data and functions,
neither of which are very lofty or theoretical, I think. :)

-Peter



Relevant Pages

  • Re: Blob in Access
    ... My first use of BLOBs in Access was with aserver back end, ... the server was capable of storing all the pictures, ... store in the shared back-end as BLOBs, but with "many" documents, increasing ...
    (comp.databases.ms-access)
  • Re: Pushing Blob content through Replication
    ... large BLOBS using replication. ... Microsoft SQL Server MVP ... I support the Professional Association for SQL Server ...
    (microsoft.public.sqlserver.replication)
  • [OT] Re: Whats the best possible email failover solution
    ... > idea since that means keeping large blobs of non-relational data floating ... During my research of the IMAP protocol, ... be fetched independently of the other MIME parts. ... every current IMAP server that I'm aware of has to break emails ...
    (freebsd-questions)
  • =?iso-8859-1?q?WebService_Axis:_kann_der_Client_eine_zip-Datei_an_den_Server_=FCbergeben
    ... Metodenaufruf eine zip-Datei an den Server übergibt. ... WSDL - Definition kann ich nur einfache/primitive Datentypen übergeben ... Blobs übergeben plus ein xml-File. ...
    (de.comp.lang.java)
  • Re: Where are files stored?
    ... They are not stored within the physical folder structure on the server but ... rather they are stored in the database as BLOBs ... Gary A. Bushey ...
    (microsoft.public.sharepoint.windowsservices)