Re: [Tutor] How do I call a variable within an input () function?

2015-02-05 Thread DaveA
On February 5, 2015 6:57:06 PM EST, Edgar Figueroa wrote: >Hello group. I'm trying to call the variable "name" within my input () You're not needing to call it, but to use it. The simplest answer is just to print the prompt separately, and just call input (). Next option is to build a st

Re: [Tutor] How do I call a variable within an input () function?

2015-02-05 Thread Alan Gauld
On 05/02/15 23:57, Edgar Figueroa wrote: name = input("Hello. What's your name? ") print("\nHello", name, ". Nice to meet you.") favFood1 = input("\n", name, ", what's your favorite food? ") Obviously it isn't working. You need to construct a single string argument. There are several option

Re: [Tutor] How do I call a variable within an input () function?

2015-02-05 Thread Danny Yoo
On Thu, Feb 5, 2015 at 3:57 PM, Edgar Figueroa wrote: > Hello group. I'm trying to call the variable "name" within my input () > function. > Here's what I have: > name = input("Hello. What's your name? ") > print("\nHello", name, ". Nice to meet you.") > favFood1 = input("\n", name, ", what's yo

[Tutor] How do I call a variable within an input () function?

2015-02-05 Thread Edgar Figueroa
Hello group. I'm trying to call the variable "name" within my input () function. Here's what I have: name = input("Hello. What's your name? ") print("\nHello", name, ". Nice to meet you.") favFood1 = input("\n", name, ", what's your favorite food? ") Obviously it isn't working. It tells me I hav

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Steven D'Aprano
On Thu, Feb 05, 2015 at 11:30:38AM -0600, boB Stepp wrote: > Python 2.4.4, Solaris 10. > > a_list = [item1, item2, item3] > for item in a_list: > print 'Item number', ???, 'is:', item > > Is there an easy, clever, Pythonic way (other than setting up a > counter) to replace ??? with the curren

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Alan Gauld
On 05/02/15 18:37, Timo wrote: Op 05-02-15 om 18:48 schreef Alan Gauld: try: >>> help( enumerate() ) Should be >>> help(enumerate) True, good catch! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 12:25 PM, Mark Lawrence wrote: > > We're now at 3.4 with 3.5 close to its first alpha release, so any > particular reason that even 2.6 doesn't seem relevant to you? No axe to > grind, just plain old fashioned curiosity :) > We are not allowed to install or upgrade software

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] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Timo
Op 05-02-15 om 18:48 schreef Alan Gauld: try: >>> help( enumerate() ) Should be >>> help(enumerate) Timo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Mark Lawrence
On 05/02/2015 18:03, boB Stepp wrote: On Thu, Feb 5, 2015 at 11:48 AM, Alan Gauld wrote: On 05/02/15 17:30, boB Stepp wrote: Python 2.4.4, Solaris 10. a_list = [item1, item2, item3] for item in a_list: print 'Item number', ???, 'is:', item Is there an easy, clever, Pythonic way (other

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 11:48 AM, Alan Gauld wrote: > On 05/02/15 17:30, boB Stepp wrote: >> >> Python 2.4.4, Solaris 10. >> >> a_list = [item1, item2, item3] >> for item in a_list: >> print 'Item number', ???, 'is:', item >> >> Is there an easy, clever, Pythonic way (other than setting up a >

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
On Thu, Feb 5, 2015 at 11:45 AM, Zachary Ware wrote: > On Thu, Feb 5, 2015 at 11:30 AM, boB Stepp wrote: >> Python 2.4.4, Solaris 10. >> >> a_list = [item1, item2, item3] >> for item in a_list: >> print 'Item number', ???, 'is:', item >> >> Is there an easy, clever, Pythonic way (other than s

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Alan Gauld
On 05/02/15 17:30, boB Stepp wrote: Python 2.4.4, Solaris 10. a_list = [item1, item2, item3] for item in a_list: print 'Item number', ???, 'is:', item Is there an easy, clever, Pythonic way (other than setting up a counter) to replace ??? with the current index of item in a_list? try:

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Zachary Ware
On Thu, Feb 5, 2015 at 11:30 AM, boB Stepp wrote: > Python 2.4.4, Solaris 10. > > a_list = [item1, item2, item3] > for item in a_list: > print 'Item number', ???, 'is:', item > > Is there an easy, clever, Pythonic way (other than setting up a > counter) to replace ??? with the current index of

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

[Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread boB Stepp
Python 2.4.4, Solaris 10. a_list = [item1, item2, item3] for item in a_list: print 'Item number', ???, 'is:', item Is there an easy, clever, Pythonic way (other than setting up a counter) to replace ??? with the current index of item in a_list? -- boB ___

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