Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94805
| Date | 2015-07-31 18:15 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: How to re-write this bash script in Python? |
| References | <CAPTjJmoKYt3=fmz0q=azgVCXTs0YCfeiJZ3fYCSVe7cEzAHkPw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1111.1438330518.3674.python-list@python.org> (permalink) |
On 31Jul2015 17:47, Chris Angelico <rosuav@gmail.com> wrote: >On Fri, Jul 31, 2015 at 4:31 AM, <sutanu.das@gmail.com> wrote: >> #!/bin/bash [...] >> _year=$(date -d "-5 hour" +%Y) >> _month=$(date -d "-5 hour" +%m) [...] >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 ) >Also, file handling, searching, and text manipulation and so on can >usually be done more efficiently and readably in Python directly than >by piping things through grep and awk. Again, depends a bit on the data. But in the general case probably true. Cheers, Cameron Simpson <cs@zip.com.au>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to re-write this bash script in Python? Cameron Simpson <cs@zip.com.au> - 2015-07-31 18:15 +1000
csiph-web