On 02/22/2015 09:38 PM, Dave Angel wrote:
On 02/22/2015 08:13 PM, jkuplin...@gmail.com wrote:

OK (1) sorry about for/from

That's not what you should be sorry about.  You should be sorry you
didn't use cut&paste.

(2) print() sounds nice, but fact is , no matter what I try, i always
get C:\\apps instead of c:\apps. So in this sense print() doesn't help
much. Obviously i'm doing something wrong -- which is what you perhaps
call shotgun debugging; but that's why i'm asking.


You probably are getting confused about the difference between str() and
repr().  If you print the repr() of a string, it'll add quotes around
it, and escape the unprintable codes.  So it'll double the backslash. It
also turns a newline into  \n, and tabs into \t, and so on.  Very useful.

That's also what happens when you print a list that contains strings.
The individual elements of the list are converted using repr().  Watch
for the quotes to get a strong hint about what you're seeing.

If you don't get a positive handle on how string literals relate to
string variables, and on str() and repr(), and print(), you'll be
jumping around the problem instead of solving it.

Two other things I should have pointed out here. The debugger uses repr() to display things, when you have an unassigned expression.

And you can solve a lot of problems by just using a forward slash for a directory separator. The forward slash is just as correct in most circumstances within a program. It's mainly on the command line that forward slash takes on a different meaning.



Back to your original problem, which had you trying to use
subprocess.call to change the current directory.  Current directory is
effectively (or actually) depending on the OS involved) an environment
variable, and changes made in a child process are not magically returned
to the parent.

But even though there is an os.chdir() in Python, you really shouldn't
use it.  Long experience of many people show that you're better off
manipulating the directories you need explicitly, converting any
directory that's relative to something other than the current one, to an
absolute.



--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to