Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86185
| Return-Path | <davea@davea.name> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'string': 0.09; 'converted': 0.09; 'debugger': 0.09; 'escape': 0.09; 'newline': 0.09; 'strings.': 0.09; 'things,': 0.09; 'variable,': 0.09; 'changes': 0.15; '\\n,': 0.16; 'explicitly,': 0.16; 'expression.': 0.16; 'hint': 0.16; 'jumping': 0.16; 'literals': 0.16; 'repr()': 0.16; 'separator.': 0.16; 'slash': 0.16; 'str()': 0.16; 'tabs': 0.16; 'variables,': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'trying': 0.19; 'pointed': 0.19; 'command': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'directory.': 0.24; "shouldn't": 0.24; 'string,': 0.24; '(or': 0.24; 'environment': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; "doesn't": 0.30; 'converting': 0.30; 'relative': 0.30; 'returned': 0.30; "i'm": 0.30; 'getting': 0.31; 'about.': 0.31; 'quotes': 0.31; 'probably': 0.32; 'sense': 0.34; 'problem': 0.35; 'display': 0.35; 'something': 0.35; '(2)': 0.35; 'one,': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'really': 0.36; 'much.': 0.36; 'doing': 0.36; "didn't": 0.36; 'should': 0.36; 'positive': 0.37; 'wrong': 0.37; 'two': 0.37; 'list': 0.37; 'problems': 0.38; 'solving': 0.38; 'handle': 0.38; 'to:addr :python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'dave': 0.60; 'solve': 0.60; 'most': 0.60; 'matter': 0.61; "you're": 0.61; 'back': 0.62; "you'll": 0.62; 'email addr:gmail.com': 0.63; 'show': 0.63; 'different': 0.65; 'forward': 0.65; 'charset:windows-1252': 0.65; 'within': 0.65; 'effectively': 0.66; 'between': 0.67; 'received:74.208': 0.68; 'useful.': 0.68; 'nice,': 0.84; 'received:74.208.4.194': 0.84; 'relate': 0.84; 'try,': 0.84; 'angel': 0.91 |
| Date | Sun, 22 Feb 2015 22:07:14 -0500 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: calling subprocess |
| References | <edfc56d5-8696-49d0-8b71-69044bbab1f5@googlegroups.com> <mailman.19035.1424643724.18130.python-list@python.org> <4e828264-5445-42fc-a647-c56f80fc86ab@googlegroups.com> <54EA929F.70509@davea.name> |
| In-Reply-To | <54EA929F.70509@davea.name> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:QHXOssr0M4xsJbFSmbgrKRagniULWwauO2xoNR/ifbb 3fR2IDwSXJAycD2j/bOWTuz+SGuYlUTUPAEaqUiXhwSMHwZ5wO 75cRQSM5Pzbto22eV1ViMq4X3nfVO1GDJaPF6nhWhcSkBNn/gC A5QFf4oUi7jKUx27uVGwE6U1qu31I2ujg0TRvEbXNiffC2qO5m lnu0mRXgUWyVfaZTtUcqXRaSwi1hi2HvOfLVc95iZCmyhSPvfQ 4rLMklqXpvn60im23SpnsC3TvfXwMxK/LfK8SNRNLTMy3qhsI2 17DImssUd8Y2cGG0aqxlLY2cY4HB7nAyTV2v6PWSuoB0CErXKP N+rMFo6mBRfmiBmfElfE= |
| X-UI-Out-Filterresults | notjunk:1; |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.19047.1424660848.18130.python-list@python.org> (permalink) |
| Lines | 53 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424660848 news.xs4all.nl 2867 [2001:888:2000:d::a6]:50180 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:86185 |
Show key headers only | View raw
On 02/22/2015 09:38 PM, Dave Angel wrote: > On 02/22/2015 08:13 PM, jkuplinsky@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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
calling subprocess jkuplinsky@gmail.com - 2015-02-22 14:06 -0800
Re: calling subprocess Tim Golden <mail@timgolden.me.uk> - 2015-02-22 22:14 +0000
Re: calling subprocess Chris Angelico <rosuav@gmail.com> - 2015-02-23 09:21 +1100
Re: calling subprocess jkuplinsky@gmail.com - 2015-02-22 17:13 -0800
Re: calling subprocess Chris Angelico <rosuav@gmail.com> - 2015-02-23 12:31 +1100
Re: calling subprocess Dave Angel <davea@davea.name> - 2015-02-22 21:38 -0500
Re: calling subprocess Dave Angel <davea@davea.name> - 2015-02-22 22:07 -0500
csiph-web