Newbie Newbie, we are all Newbie to something 
Author Message
 Newbie Newbie, we are all Newbie to something

Hi,

Recently I have done the following :

newLang= me.addLanguage(Python)
python_list["me"]= "greg"

try:
        newLang.readdoc()
except UnderstandingError:
        python_list["me"].sendmessage("help needed!")

--- Question start here ---
I'm new to python and partially new to OOP (small experience in C++). I'm
fluent in C, shell script, awk, and some other programming language.

I'm currently reading the Python Reference Manual and I got a small
question regarding the __del__() statement in a class definition.
I understand his utility when you don't have a garbage collector and
memory management. In this case, it is important to have del statement to
free object properly. But what if you have ?
In the same topic, do we have to explicitly close an open file before
exiting:  
a/ a function
        EG:     def blahblah():
                        f= open(some file)
                        ...
                        f.close()
b/ the interpreter
        EG:     >>> f = open(some file)
                >>> ...
                >>> f.close()
                >>> CTRL-D

Or is this automatically handled by Python. I guess the close function is
given to be used, not to generate some stupid mail like this one.

Sorry for my newbyness ...

Greg

--
Life is not fair
But the root password helps
--

Gregoire Welraeds

Perceval Development team
-------------------------------------------------------------------------------
Perceval Technologies sa/nv     Tel: +32-2-6409194              
Rue Tenbosch, 9                 Fax: +32-2-6403154              


URL: http://www.*-*-*.com/
-------------------------------------------------------------------------------



Tue, 13 Aug 2002 03:00:00 GMT  
 Newbie Newbie, we are all Newbie to something

Quote:

> I'm currently reading the Python Reference Manual and I got a small
> question regarding the __del__() statement in a class definition.

Well, Python, the language, does not gurantee *anything* about memory
freeing and __del__ calling except that it will not delete an object
as long as any reachable object references it, and that it will not call
the __del__ method as long as any reachable object references it.

CPython, the implementation (well, one of the implementations, anyway),
deletes an object as soon as there are no references to it, and it calls
it's __del__ method right before that. (I'm not talking about what happens
if the __del__ resurrects an object. It's a user bug.)

Hence

f = open("file")
del f

Closes the file *in the current C implementation*. It does not close
the file, e.g., in JPython.

have-I-confused-you-enough-yet-ly y'rs, Z.
--

INTERNET: Learn what you know.
Share what you don't.



Tue, 13 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Not a newbie, but a newbie question...

2. Does a variable exist? NEWBIE NEWBIE NEW

3. Newbie wants newbie friend

4. newbie BRAND newbie!

5. Newbie Question (Was: Newbie Question...)

6. Newbie Pythom + Newbie Com = Way confussed

7. Trivial Newbie Question (Newbie)

8. Newbie - Missing something obvious ???

9. Old-timer newbie needs books or something...

10. Veeeery newbie needs help to putpixel something in 13h

11. Old-timer newbie needs books or something...

12. newbie: on winnt - Do I something wrong, or is there just nothing

 

 
Powered by phpBB® Forum Software