Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46188
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <avnesh.nitk@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'subject:file': 0.07; 'filename': 0.09; 'filenames': 0.09; 'subject:create': 0.09; 'subject:number': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'be:': 0.16; 'expression,': 0.16; 'imports': 0.16; 'numbered': 0.16; 'range,': 0.16; 'range.': 0.16; 'specifying': 0.16; 'substring': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'url:mailman': 0.30; '-0700,': 0.31; 'file': 0.32; 'regular': 0.32; 'url:python': 0.33; 'subject:with': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'done,': 0.36; 'sequence': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'subject:new': 0.38; 'pm,': 0.38; 'highest': 0.39; 'url:mail': 0.40; 'skip:n 30': 0.60; 'new': 0.61; 'email addr:gmail.com': 0.63; 'to:addr:gmail.com': 0.65; 'skip:n 40': 0.81; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0xJB2mptFxNeKkVqjDERNqhFHS7ktU7rZznm79v4dQo=; b=yH/NzAEYo9H+vmCGGTJ/n2SScHUnNCidNtwfnes/ugGs2nbYKycRZhUThhqPlQwYNB Bfejh6nldp17CN0HJ+o60R6kl7SJ66zbWDVY/VnitQMoZSxCSRZcxPZJCkZZ6fqpL+hf J995Wk/JT42gTtvvT8rPiJKUrG8mZ6Y/9mTgfA5NQKMwP2X4Urra21vzSqh5xxtGTbnN 6JAml7AW1I5OKZH7risaGJ9h5+seFPpc9KAsaAO+MV08iaHxCDKPQpWNu+q1q4CE2oUE CvpjrabiPN8hH4TwZbH89g8/cG/xIGmB/1B9vSmQAHkKX81Ss7+2hioYCjzDa582noFY mmjA== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.1.11 with SMTP id 11mr4659884igi.39.1369652427013; Mon, 27 May 2013 04:00:27 -0700 (PDT) |
| In-Reply-To | <knvdms$gvn$3@dont-email.me> |
| References | <3c99daa0-6f30-4cbf-b107-56021a324f7c@googlegroups.com> <knvdms$gvn$3@dont-email.me> |
| Date | Mon, 27 May 2013 16:30:26 +0530 |
| Subject | Re: How to create new python file with increament number, if doesn't exist? |
| From | Avnesh Shakya <avnesh.nitk@gmail.com> |
| To | Denis McMahon <denismfmcmahon@gmail.com> |
| Content-Type | multipart/alternative; boundary=e89a8f83a2436112f004ddb10e13 |
| Cc | python-list@python.org |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2245.1369652430.3114.python-list@python.org> (permalink) |
| Lines | 93 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369652430 news.xs4all.nl 15982 [2001:888:2000:d::a6]:40389 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46188 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Thanks
On Mon, May 27, 2013 at 4:19 PM, Denis McMahon <denismfmcmahon@gmail.com>wrote:
> On Mon, 27 May 2013 02:27:59 -0700, Avnesh Shakya wrote:
>
> > I want to create a new python file like 'data0.0.5', but if it is
> > already exist then it should create 'data0.0.6', if it's also exist
> > then next like 'data0.0.7'. I have done, but with range, please give
> > me suggestion so that I can do it with specifying range.
>
> Try and put your description into the sequence of instructions you want
> the computer follow.
>
> For this problem, my sequence of instructions would be:
>
> 1) Find the highest numbered existing file that matches the filename
> data0.0.[number]
>
> 2) Create a new file that is one number higher.
>
> Now the solution is easy. Find the list of filenames in the directory
> that match a suitable regular expression, take the numeric value of a
> substring of the filename for each file and find the highest, add one to
> it, then create the new file name.
>
> Something like the following (untested) with the relevant imports etc:
>
> nfn="data0.0."+str(max([int(f[8:])for f in os.listdir(p)if re.match
> ('^data0.0.[0-9]+$',f)])+1)
>
> --
> Denis McMahon, denismfmcmahon@gmail.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to create new python file with increament number, if doesn't exist? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-27 02:27 -0700
Re: How to create new python file with increament number, if doesn't exist? Denis McMahon <denismfmcmahon@gmail.com> - 2013-05-27 10:49 +0000
Re: How to create new python file with increament number, if doesn't exist? Avnesh Shakya <avnesh.nitk@gmail.com> - 2013-05-27 16:30 +0530
Re: How to create new python file with increament number, if doesn't exist? jt@toerring.de (Jens Thoms Toerring) - 2013-05-27 11:13 +0000
csiph-web