possibly a dumb question

Adonis deltapigz at telocity.com
Sat Jun 29 21:47:32 EDT 2002


an addition:
why not use a function blah blah, yes, but this is going to be a modularized
project, essentially i want to load some user made modules which will be
classes and will be loaded into python dynamically. like a memory resident
cgi server skipping the use of pipes.

Adonis

"Adonis" <deltapigz at telocity.com> wrote in message
news:3d1e6251$1_3 at nopics.sjc...
> sure:
>
> class foo:
>     def __init__(self, value):
>         return value
> x = foo(0)
> print x ;yeilds 0
>
> i know the code provided is wrong, but its the general idea.
>
> Adonis
>
>
> "Peter Hansen" <peter at engcorp.com> wrote in message
> news:3D1E6415.8128F3F8 at engcorp.com...
> > Adonis wrote:
> > >
> > > can a class return a value? i have treid to google this, but have
found
> > > myself short of an answer, i know i could place it in a member and
> retrieve
> > > it or through a function, but im trying to simplify my life.. just a
> > > little..
> >
> > You probably don't actually mean a class.  I think you mean an object,
> > which is an instance of a class.  (If I've got that wrong, I think
> > we need clarification of the question.)
> >
> > If that's the case, there's still one more problem left. :-)
> > "Returning a value" is a concept related to calling a method
> > or function.  It doesn't have any particular meaning if you
> > ask "can an object return a value?" unless you mean something
> > like "can a method of an object return a value?".  That is
> > certainly possible, although I'm not this is what you wanted,
> > either:
> >
> > >>> class MyClass:
> > ...    def myMethod(self):
> > ...        return 'spam'
> > ...
> > >>> c = MyClass()
> > >>> print 'Green eggs and %s.' % c.myMethod()
> > Green eggs and spam.
> >
> > Can you ask the question in a different way, or show an example
> > of what you were hoping to do?
> >
> > -Peter
>
>





More information about the Python-list mailing list