Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45649 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2013-05-21 17:56 +1000 |
| Last post | 2013-05-21 19:18 +1000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to run a python script twice randomly in a day? Chris Angelico <rosuav@gmail.com> - 2013-05-21 17:56 +1000
Re: How to run a python script twice randomly in a day? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-21 11:21 +0300
Re: How to run a python script twice randomly in a day? Chris Angelico <rosuav@gmail.com> - 2013-05-21 19:18 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-21 17:56 +1000 |
| Subject | Re: How to run a python script twice randomly in a day? |
| Message-ID | <mailman.1908.1369122996.3114.python-list@python.org> |
On Tue, May 21, 2013 at 11:12 AM, Cameron Simpson <cs@zip.com.au> wrote: > Ok, good. Some minor remarks: > > Personally, I always use: > > #!/bin/sh > > instead of requiring bash. All UNIX systems have sh, bash is only > common. And even when present, it may not be in /bin. /bin/sh is > always there, and unless you're doing something quite unusual, it > works just fine. Also, on many systems, /bin/sh is a much lighter interpreter than bash (eg Debian uses dash). It's more efficient to use that when you can, even if you use bash for your login shell. > On 20May2013 15:05, Avnesh Shakya <avnesh.nitk@gmail.com> wrote: > | but when I m using like > | > | import random > | a = random.randrange(0, 59) > | */a * * * * bash /home/avin/cronJob/test.sh > | then it's showing error becose of varable 'a', so now how can i take > | variable? You put that into your crontab? I do not think this means what you think it means; cron does not execute arbitrary Python code. > - randrange() is like other python ranges: it does not include the end value. > So your call picks a number from 0..58, not 0..59. > Say randrange(0,60). Think "start, length". Nitpick: It's not start, length; it's start, stop-before. If the start is 10 and the second argument is 20, you'll get numbers from 10 to 19. But your conclusion is still accurate :) ChrisA (two Princess Bride references in as many threads, doing well!)
[toc] | [next] | [standalone]
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
|---|---|
| Date | 2013-05-21 11:21 +0300 |
| Message-ID | <qotwqqsrbe4.fsf@ruuvi.it.helsinki.fi> |
| In reply to | #45649 |
Chris Angelico writes: > > On 20May2013 15:05, Avnesh Shakya wrote: > > So your call picks a number from 0..58, not 0..59. > > Say randrange(0,60). Think "start, length". > > Nitpick: It's not start, length; it's start, stop-before. If the > start is 10 and the second argument is 20, you'll get numbers from > 10 to 19. But your conclusion is still accurate :) I've sometimes named the latter index "past", as in just past the range. I'm also happy to call it just "end". The inclusive-style names might be "first" and "last", so "past" is "last + 1". The length of the range from "start" to "end" is "end - start" without a "pest" term that is either -1 or +1 though I forget which; two consecutive ranges are from b to m, then from m to e; an empty range is from b to b.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-21 19:18 +1000 |
| Message-ID | <mailman.1915.1369127915.3114.python-list@python.org> |
| In reply to | #45651 |
On Tue, May 21, 2013 at 6:21 PM, Jussi Piitulainen <jpiitula@ling.helsinki.fi> wrote: > Chris Angelico writes: > >> > On 20May2013 15:05, Avnesh Shakya wrote: >> > So your call picks a number from 0..58, not 0..59. >> > Say randrange(0,60). Think "start, length". >> >> Nitpick: It's not start, length; it's start, stop-before. If the >> start is 10 and the second argument is 20, you'll get numbers from >> 10 to 19. But your conclusion is still accurate :) > > I've sometimes named the latter index "past", as in just past the > range. I'm also happy to call it just "end". The inclusive-style names > might be "first" and "last", so "past" is "last + 1". > > The length of the range from "start" to "end" is "end - start" without > a "pest" term that is either -1 or +1 though I forget which; two > consecutive ranges are from b to m, then from m to e; an empty range > is from b to b. Agreed. The inclusive-exclusive range is by far the most useful. There's unfortunately a massive case of lock-in here, but Scripture references would be ever so much more convenient as inc-exc. For instance, today in family devotions we read Galatians 2:1 - 2:21. At a glance, do you know whether that's the entire chapter? What if it were written as Galatians 2 to Galatians 3? Simple! ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web