On Wed, Feb 9, 2011 at 11:56 PM, Shawn Matlock <matl...@odscompanies.com> wrote: > Hello All, > > I’m doing something wrong. > This prints a list of data source names: > > # List all data sources > dataSourceList = AdminConfig.list('DataSource') # .split(ls) > if verbose == 'True': > print 'DEBUG Data Source List: ' > print dataSourceList >
[snip] > > I expected this to print each data source name in the list. Instead, it is > printing each character: > > # Modify the data sources so that the aged timeout is set correctly. > for dataSource in dataSourceList: > print 'DataSource: %s' % dataSource > time.sleep(5) > > DataSource: " > DataSource: F > DataSource: a > DataSource: c > DataSource: e > > First off, please use plain text formatting when sending emails to this list. I like fancy colors as much as the next guy, but html emails screw up my replies like there's no tomorrow, making me spend extra work to format everything correctly. The problem is that dataSourceList is not, as the name implies, a list, but a string. Iterating over strings happens on a character basis. If you re-add the .split() that was commented out, you should get a list. The split method splits the string at the specified character. To split the string on newlines you can do split('\n') on linux or split('\r\n') on windows. Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor