Re: [Tutor] Nested for loops, possibly?

2015-02-06 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/02/15 18:46, DaveA wrote: > You don't need much class understanding at all for this. Something > like: > > class Job: def __init__(self, retain, srcpath, suffix, syncpath, > snappath, ...): self.retain = retain = datetime.timedelta (days = > r

Re: [Tutor] Nested for loops, possibly?

2015-02-05 Thread DaveA
On February 5, 2015 12:33:56 PM EST, Bob Williams wrote: >-BEGIN PGP SIGNED MESSAGE- >Hash: SHA1 > >On 05/02/15 14:59, DaveA wrote: >> >> Sorry my last message was in html, and indentation trashed . I just installed k9 on my tablet and hadn't yet found the setting for text-only. Le

Re: [Tutor] Nested for loops, possibly?

2015-02-05 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/02/15 14:59, DaveA wrote: > > > On February 5, 2015 8:27:29 AM EST, Bob Williams > wrote: >> Hi, >> >> My script is running under Python 3.4.1 on a 64bit openSUSE >> linux system. It is a backup script making calls to rsync and >> btrfs-tools

Re: [Tutor] Nested for loops, possibly?

2015-02-05 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/02/15 13:57, Mark Lawrence wrote: > On 05/02/2015 13:27, Bob Williams wrote: > >> >> I would like to reduce all those repeated calls to do_sync() in >> main(), for example, to one by putting the *_srcpath and >> *_*syncpath variables into list

Re: [Tutor] Nested for loops, possibly?

2015-02-05 Thread DaveA
On February 5, 2015 8:27:29 AM EST, Bob Williams wrote: >Hi, > >My script is running under Python 3.4.1 on a 64bit openSUSE linux >system. It is a backup script making calls to rsync and btrfs-tools, >and backing up several different paths. Here is the script, my question >follows below: > >**C

Re: [Tutor] Nested for loops, possibly?

2015-02-05 Thread Mark Lawrence
On 05/02/2015 13:27, Bob Williams wrote: I would like to reduce all those repeated calls to do_sync() in main(), for example, to one by putting the *_srcpath and *_*syncpath variables into lists (eg. source_list and sync_list) and using a for loop to get the first item out of each list, then

[Tutor] Nested for loops, possibly?

2015-02-05 Thread Bob Williams
Hi, My script is running under Python 3.4.1 on a 64bit openSUSE linux system. It is a backup script making calls to rsync and btrfs-tools, and backing up several different paths. Here is the script, my question follows below: **Code** import datetime import glob import os, os.path import subpro

Re: [Tutor] Nested for loops

2013-11-28 Thread Rafael Knuth
> Do you understand how that works? Yep. It's crystal clear now. Thank you. It took a while till I got it, though ;-) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Nested for loops

2013-11-27 Thread Dave Angel
On Wed, 27 Nov 2013 17:08:11 +0100, Rafael Knuth wrote: for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) #3 Round: n = 4 x = 3 When n is 4, the inner loop will test 2, then 3. But since n% x is zero for values 4 and 2, it will print, then b

Re: [Tutor] Nested for loops

2013-11-27 Thread Andreas Perstinger
Rafael Knuth wrote: >I am trying to figure out how exactly variables in nested loops are >generated, and don't get it 100% right yet. Here's my code: Maybe it's easier if you look at a simpler example like: for i in range(4): for j in range(4): print("i: {}, j: {}".format(i, j)) Do

Re: [Tutor] Nested for loops

2013-11-27 Thread Joel Goldstick
On Wed, Nov 27, 2013 at 11:08 AM, Rafael Knuth wrote: > Hej there, > > I am trying to figure out how exactly variables in nested loops are > generated, and don't get it 100% right yet. Here's my code: > > for n in range(2, 10): > for x in range(2, n): > if n % x == 0: > pri

[Tutor] Nested for loops

2013-11-27 Thread Rafael Knuth
Hej there, I am trying to figure out how exactly variables in nested loops are generated, and don't get it 100% right yet. Here's my code: for n in range(2, 10): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: print