Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'mrab': 0.05; 'paths': 0.07; 'string': 0.09; 'editor.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:extra': 0.09; 'windows,': 0.09; "'/'": 0.16; 'igor': 0.16; 'literals': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'replace': 0.24; '15,': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'dec': 0.30; 'values.': 0.31; 'text': 0.33; 'raw': 0.33; 'skip:s 30': 0.35; 'convert': 0.35; 'late': 0.35; 'but': 0.35; 'there': 0.35; 'done': 0.36; 'so,': 0.37; 'too': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'realized': 0.68; 'or:': 0.84; 'received:myvzw.com': 0.84; 'those?': 0.84; 'recover': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Eliminate "extra" variable Date: Sun, 15 Dec 2013 21:58:24 -0500 References: <52A25D94.9040404@islandtraining.com> <20131208125823.241112db@bigbox.christie.dr> <20131208161858.1365f2d7@bigbox.christie.dr> <20131215061720.2fbb394d@bigbox.christie.dr> <20131215062923.184bf636@bigbox.christie.dr> <52AE5037.5000300@mrabarnett.plus.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 191.sub-70-208-160.myvzw.com In-Reply-To: User-Agent: Groundhog Newsreader for Android X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387162635 news.xs4all.nl 2840 [2001:888:2000:d::a6]:40191 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61987 On Sun, 15 Dec 2013 18:43:53 -0800, Igor Korot wrote: > On Sun, Dec 15, 2013 at 4:58 PM, MRAB wrote: > > When writing paths on Windows, it's a good idea to use raw string > > literals or slashes instead of backslashes: > > > > conn = sqlite3.connect(r'c:\Documents and > > Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types = > > sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) > > > > or: > > > > conn = sqlite3.connect('c:/Documents and > > Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types = > > sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) > So, how do I convert my string to one of those? > I realized I can just do replace '/' to '\', but is there a better alternative? The "conversion" is done with a text editor. The string literals you had were just wrong. By the time they have been turned into strings it's too late to algorithmically recover your intended string values. -- DaveA