Re: Re: When is File/Dir.exists?() false?

Mukhsein Johari <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
--- Mark Hahn <[email protected]> wrote: > Mukhsein
Johari wrote:
> > I was reading the File and Dir objects. It's
> pretty
> > nice overall. Just a few questions:
> >
> > As per the subject, when does exists?() return
> False?
> 
> When the actually file or directory the path refers
> to does not exist.
> 
> > When you instantiate the File object, it
> implicitly
> > means it exists, right?
> 
> No.  The File and Dir objects can be created without
> opening files or
> creating directories.  This is different than
> Python.  For a File you leave
> the mode string empty to mean create the object
> without opening the file.
> The Dir constructor never creates a directory.  You
> have to use Dir.make()
> to create a directory.

So...if the file is non-existent, what actually
happens when you do:

myFileObject.read() and write()? close()?

And what about accessing file attributes?

> > I'm just wondering when this
> > would be used.
> 
>     # make sure directory exists before using
>      if not dir.exists?():
>           dir.make()
> 

Once you have instantiated the dir obj, can you change
the path of the dir object?

>      if not dir.exists?():
>           dir.make()

if it gives exception (say you do not have permission
to make that dir) what do you do with the dir object?
Destroy it and make another?

I'm feeling a bit uneasy about file and dir objects
that don't refer to existing files and dirs. I can't
put my finger on why though. It just doesn't seem
useful to me. Could you show a simple use-case?



________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.