Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102752

Re: There has to be a better way to split this string!

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From srinivas devaki <mr.eightnoteight@gmail.com>
Newsgroups comp.lang.python
Subject Re: There has to be a better way to split this string!
Date Wed, 10 Feb 2016 07:34:02 +0530
Lines 59
Message-ID <mailman.16.1455069845.7749.python-list@python.org> (permalink)
References <56BA91B5.5090400@cajuntechie.org> <CACs7g=Do9gYJ=kY8HqRe+g=ak_O7E-WahXaP_x=za04U9tYQSQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de YSzhhbjJ5KJSiRl0ISo+dQQn2hPOMywpft/tma/ITftg==
Return-Path <mr.eightnoteight@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'assumed': 0.09; 'filename.': 0.09; 'object;': 0.09; 'pgp': 0.09; 'strftime': 0.09; 'subject:string': 0.09; 'url:github': 0.09; '+91': 0.15; 'everyone,': 0.15; 'message-----': 0.15; "skip:' 30": 0.15; '----- begin': 0.16; '2016': 0.16; '6:56': 0.16; 'hash:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sfxlen:0': 0.16; 'subject:There': 0.16; 'wrote:': 0.16; 'looked': 0.16; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'library': 0.20; 'student': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'junior': 0.22; 'parse': 0.22; 'trying': 0.22; 'am,': 0.23; 'feb': 0.23; 'wrote': 0.23; 'header:In-Reply-To:1': 0.24; 'signed': 0.24; 'external': 0.27; 'skip:m 30': 0.27; 'message-id:@mail.gmail.com': 0.27; 'module.': 0.27; 'idea': 0.28; "i'm": 0.30; 'extract': 0.33; 'file': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'indian': 0.36; 'skip:m 40': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'version': 0.38; 'received:209': 0.38; 'mailing': 0.38; 'why': 0.39; 'easily': 0.39; 'school': 0.62; 'soon': 0.65; 'reply': 0.68; 'mail.': 0.75; 'saw': 0.77; '(3rd': 0.84; 'mat': 0.84; 'ph:': 0.84; 'subject:this': 0.85
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=2sU6mKaCsS1U1x9rY7F9vGAPWNV00F/IQtzRbeybCao=; b=BLGxvD+Tdo5te28u1ZRk5kbQTGmwafuEQrWubGAXeX1Vxxi+xdLXmiHIUn2zhNcPi7 DoT8yF4WdpKn0+WU3IQQobO02XsgLbwXi8POFUZ/cz+Ort9FgSaPNYiS+eKxJObBWH5A z5zvHEtFWLJRbHMf/IUOqESLKQ0ytWGaTRJeLlxAzgurERkyXOJw2Y8bxnbdW7LEHUwp Ohr7I3/BnLjE9TN5IVr1LgeKcd0l1G89eZAQYeBpbjh7B2Uh34NxofD/ozJWDAxiKlaa 0UAWYBJradboSTXVV8HxgrExQ91iACwsu+S3ZD01a+VSPMQopiWW3NCvj2bFAZUwlpUz JdmQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2sU6mKaCsS1U1x9rY7F9vGAPWNV00F/IQtzRbeybCao=; b=QyAKu5/fK6DXsxxJ/KIyO2lMK5Kk42BqhewvkFAElubu1NfhgWfL3zxL08BnR8gPl8 5YaXpRZ9Z81noivxG8a/O3r2uouQmshqgqFaY+r+2weUHz2nRCt1QFdcYR7GXAE5Q/8R S8rYjpsVfH7BlqKVSlPHRLXaGUU7kHVZV+9ypYKYrw295FY5xEM4C3nYpdOU0YYJ/bho ofZvFmASEPRirVGzrwJYNpE7xhiSkH5IrrPIJjbcfkxMELM3uwBgO+CxFq6u/30L6Tnn dtCOuyopR6QSCyA0feGPME7PE0CpLgPYduvFUbjqdZ89NkYUDquCNMPppjM9sn+IbYKW Wh1g==
X-Gm-Message-State AG10YOSK6Y8b6x4oKxHwOa48s0hZVH5gJN1/Ipm/O1dxnaY0fO7ArCp5tJ+gfsP+vSjw/pXpjRSFomPEBoOc/w==
X-Received by 10.107.3.33 with SMTP id 33mr13871595iod.80.1455069842359; Tue, 09 Feb 2016 18:04:02 -0800 (PST)
In-Reply-To <CACs7g=Do9gYJ=kY8HqRe+g=ak_O7E-WahXaP_x=za04U9tYQSQ@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.21rc2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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>
Xref csiph.com comp.lang.python:102752

Show key headers only | View raw


On Feb 10, 2016 7:23 AM, "srinivas devaki" <mr.eightnoteight@gmail.com>
wrote:
>
>
> On Feb 10, 2016 6:56 AM, "Anthony Papillion" <anthony@cajuntechie.org>
wrote:
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA512
> >
> > Hello Everyone,
> >
> > I am using datetime.now() to create a unique version of a filename.
> > When the final file is named, it will look something like:
> >
> > myfile-2015-02-09-19-08-45-4223
> >
>
> You can easily do this(retrieving the tokens) using re module.
>
> In [33]: mat =
re.search(r'(\S+)-(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{4})',
'myfi-le-2015-02-09-19-08-45-4223')
>
> In [34]: mat
>
> Out[34]: <_sre.SRE_Match object; span=(0, 32),
match='myfi-le-2015-02-09-19-08-45-4223'>
>
> In [35]: mat.groups() Out[35]: ('myfi-le', '2015', '02', '09', '19',
'08', '45', '4223')
>
> In [36]: mat =
re.search(r'(\S+)-(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{4})',
'myfile-2015-02-09-19-08-45-4223')
> In [37]: mat
>
> Out[37]: <_sre.SRE_Match object; span=(0, 31),
match='myfile-2015-02-09-19-08-45-4223'> In [38]: mat.groups()
>
> Out[38]: ('myfile', '2015', '02', '09', '19', '08', '45', '4223')
>
> if you don't want fiddle with regex you can use parse module(
https://github.com/r1chardj0n3s/parse). but why use an external library
when stdlib already provides it? :)

I'm a stupid.
as soon as I saw strftime it looked like strptime and I assumed he is
trying to extract the tokens and wrote that stupid/unrelated mail.

PS: trying to read mailing list when you are half woke, is a bad idea and
trying reply to it is even bad idea.

Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: There has to be a better way to split this string! srinivas devaki <mr.eightnoteight@gmail.com> - 2016-02-10 07:34 +0530

csiph-web