They do not; omitting the drive letter makes the path relative to the
current drive (and since it doesn't start with a directory specifier,
the current directory).
Hmm. Let's confirm:
True
Yep, it's official. "Implicit File Path Resolution"
I need to author a PyWart on this soon!
Why? Why, oh why? If there's a problem, it'll be signalled
with an exception.
Except when there's a problem that won't be signaled by an
EXCEPTION, but will be signaled by EMOTIONS; like for
instance removing the wrong directory or truncating the
wrong file because of a typo in your source code.
OPPS! :-'(
Testing that the path exists opens you up to race
problems, so you won't see anything now, but some day your
code will be in a concurrent situation and you'll get
unexpected exceptions. Why not just expect the exception?
Because today i'm not facing a concurrent situation, so i'm
not going to bother and protect from it. Just like i'm not
facing a snake bite, so i won't bother to lug around a vial
of antidote. Your attempts to discredit me via hypothetical
scenarios is entertaining however.
This one's arguable. How often do you use the 'file'
builtin? I've worked with files in Python innumerable
times, and I don't remember the last time I used 'file'.
Yes, avoid shadowing important builtins like 'list' and
'int', but 'id' and 'file' aren't that big a deal.
My first concern is with the OP adopting "self documenting"
names. Shadowing file is merely ensuring that the OP knows
"file" is a builtin. Shadowing any builtin can create very
difficult bugs to track. This is the point the OP should
remember.
They won't float around forever. The garbage collector
will get to them.
That depends on how they are stored. You make too many
assumptions Chris. I don't have an problems with GC's, but
i'm not about to write sloppy code and "assume" the GC is
going to swoop in and save me like a feline trapped in a
tree.
So? Exception thrown, traceback printed to console,
process terminated cleanly. I'm not seeing a problem here.
Now you're just trolling!
def firstdev(file):
in_file = open("desktop/%s.txt") % file
indata = in_file.read()
out_file = open("desktop/newfolder/%s.txt", 'w') % file
Just from reading that code NO ONE could know for sure if
"newfolder" even existed BEFORE the OP tried to open the
"out_file". Maybe the OP thinks that missing sub-directories
are auto-created by the open function, but there's no way to
know for sure, hence my comment.
Technically true. However, most modern OSes will accept a
slash. There'll be a few situations where that's not true,
but the OP an happily just use slashes for simplicity.
Many a developer have lived to regret those words.
PS: I thought Steven was the official "devils advocate"
around here? Hmm. I guess everyone needs a day off.