Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Anthony Papillion Newsgroups: comp.lang.python Subject: Re: [SOLVED] There has to be a better way to split this string! Date: Tue, 9 Feb 2016 19:58:26 -0600 Lines: 24 Message-ID: References: <56BA91B5.5090400@cajuntechie.org> <56BA9505.40900@cajuntechie.org> <85mvr972vv.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de dfosugq5VpIACtV1+5TaPAzajdKwUiPz6HeVzncUN/Ng== Return-Path: 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; 'subject:: [': 0.03; 'think,': 0.05; 'filename': 0.07; 'filename,': 0.09; 'filename.': 0.09; 'subject:string': 0.09; 'from:addr:anthony': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:There': 0.16; 'wrote:': 0.16; 'looked': 0.16; 'pointer': 0.18; 'subject:] ': 0.19; '>>>': 0.20; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.26; "skip:' 10": 0.28; 'purposes.': 0.29; "i'm": 0.30; 'that.': 0.30; 'task': 0.30; 'source': 0.33; 'though.': 0.33; 'received:10.0': 0.34; 'library.': 0.35; 'something': 0.35; 'should': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'received:10': 0.37; 'thanks': 0.37; 'version': 0.38; 'enough': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'easy': 0.60; 'skip:u 10': 0.61; 'making': 0.62; 'skip:\xe2 10': 0.70; '8bit%:43': 0.72; 'original.': 0.84; 'received:10.0.2': 0.84; 'subject:this': 0.85 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: <85mvr972vv.fsf@benfinney.id.au> X-Zoho-Virus-Status: 1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102749 On 02/09/2016 07:47 PM, Ben Finney wrote: > Anthony Papillion writes: > >> On 02/09/2016 07:26 PM, Anthony Papillion wrote: >>> I am using datetime.now() to create a unique version of a filename. >>> […] >> >> Found the solution in strftime(). Exactly what I was looking for. > > For the task of making a unique filename, you should also consider the > ‘tempfile’ module in the standard library. I looked at tempfile. Unfortunately, the filename has to be both 'unique' and 'identifiable' to the original. So if I am using mydog.jpg as the source and I am adding something unique to it, it has to still have mydog.jpg in the filename. Tempfile, I think, doesn't allow an easy way to do that. So I'm just adding the exact date and time which is unique enough for my purposes. Thanks for the pointer though. Anthony