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


Groups > comp.lang.python > #94806

Re: How to re-write this bash script in Python?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'subject:Python': 0.05; 'bash': 0.07; 'correct.': 0.07; 'rewrite': 0.07; 'variable,': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'spec': 0.09; 'subject:script': 0.09; 'worse': 0.09; 'python': 0.10; 'python.': 0.11; 'decent': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'simpson': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '31,': 0.22; 'assuming': 0.22; 'header:In-Reply-To:1': 0.24; 'command': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'converting': 0.27; 'environment': 0.29; 'convert': 0.29; 'guess': 0.31; 'probably': 0.31; 'received:google.com': 0.35; 'but': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'support,': 0.37; 'subject:-': 0.39; 'rather': 0.39; 'still': 0.40; 'your': 0.60; 'between': 0.65; 'believe': 0.66; 'cameron': 0.66; 'jul': 0.72; 'actually,': 0.84; 'chrisa': 0.84; 'lacks': 0.84; 'subject:write': 0.84; 'subject:this': 0.85; 'to:none': 0.91; 'simulation': 0.91
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:cc :content-type; bh=/YpHfJdyXqZ0olhvdaLshQoRniQG1FoXj3CX30xDPr0=; b=lhJHI7rZ86bW74Czce/bEI6AIwLV8qorR3UsrAz8BczcbdqNuMSU7c0/BXDOGGJKoG mIKQbcO+h0csSPEkCei0EbawicUFRhGOFEe8+T/yJn4vltuCC9VSuTx+rtgWD2ql6GcH jebmx5pNh5fConJ7VV4V83XkvDbQLKiGt7lAIxQvAHUIvxrjF69pFSIYPQBcGA79ibnK Es7m3bZS80ZpLXbeqKzbmOeH3p0mM3DrCnC2STxebfNIBm2dxnp3+TmMJQkt40/0EmUC NZdlwaOTh34/iiMYA+bejs31ORZzYjvIlMcevUrbeX96q+55w7UoBSKndLK1g6KVRXcn OSzg==
MIME-Version 1.0
X-Received by 10.107.163.16 with SMTP id m16mr2621975ioe.31.1438331198130; Fri, 31 Jul 2015 01:26:38 -0700 (PDT)
In-Reply-To <20150731081503.GA12474@cskk.homeip.net>
References <CAPTjJmoKYt3=fmz0q=azgVCXTs0YCfeiJZ3fYCSVe7cEzAHkPw@mail.gmail.com> <20150731081503.GA12474@cskk.homeip.net>
Date Fri, 31 Jul 2015 18:26:38 +1000
Subject Re: How to re-write this bash script in Python?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.1112.1438331201.3674.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1438331201 news.xs4all.nl 2846 [2001:888:2000:d::a6]:36120
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94806

Show key headers only | View raw


On Fri, Jul 31, 2015 at 6:15 PM, Cameron Simpson <cs@zip.com.au> wrote:
>> For example, bash lacks
>> decent timezone support, so I can well believe random832's guess that
>> your five-hour offset is a simulation of that; but Python can do much
>> better work with timezones, so you can get that actually correct.
>
>
> Actually, bash has no timezone support but the date command _does_, and
> probably neither better nor worse than Python. All one has to do is set the
> TZ environment variable, eg (untested):
>
>  _year_gmt=$( TZ=GMT date +%Y )

That's assuming that it's converting against the current system
timezone. I don't know how you'd use `date` to convert between two
arbitrary timezones. But anyway, still justification to rewrite from
original spec rather than reimplementing the five-hour hack.

ChrisA

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


Thread

Re: How to re-write this bash script in Python? Chris Angelico <rosuav@gmail.com> - 2015-07-31 18:26 +1000
  Convert between timezones (was: How to re-write this bash script in Python?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-31 12:35 +0200
    Re: Convert between timezones Akira Li <4kir4.1i@gmail.com> - 2015-08-01 03:39 +0300

csiph-web