Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-24-2011, 08:18 PM   #1
Registered: Apr 2006
Distribution: Sabayon linux 5.1
Posts: 182

Rep: Reputation: 15
python displaying list contents in scrollable window error

i have two sections of code

def file_ok_sel(self, w):
                  print "%s" % self.filew.get_filename()
works fine here>>>self.contents = "\n".join(self.list)
this code enters the filename and path like so /home/bludiescript/

second code

def search_entry(self, widget):
         search =
         top = '/home/bludiescript/tv-shows'
                for dirpath, dirnames, filenames in os.walk(top):
                        for filename in filenames:
                                if re.findall(search, filename):
                                   #print os.path.join([dirpath, filename],)
                                   self.list.append(os.path.join([dirpath, filename],))
          gives an error here>>>>>>self.contents = "\n".join(self.list)
                                   print self.list
when the self.list prints entries look as so ['/home/bludiescript/tv-shows/japanesse/steins gate', '[HorribleSubs] Steins;Gate - 10 [720p].mkv']

error =   file "./" , line 77 in search_entry 
          self.contents = "/n".join(self.list) line 
          typeerror sequence item o: expecting string, list found
so why doesn't this line work where it is ?
Old 09-24-2011, 08:44 PM   #2
LQ Guru
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1005Reputation: 1005Reputation: 1005Reputation: 1005Reputation: 1005Reputation: 1005Reputation: 1005Reputation: 1005
I would uncomment the following:
#print os.path.join([dirpath, filename],)
After doing so, I would see what dirpath and filename contain, since technically according to your error output, it says that a list is being found, instead of a string, which in that case, what it needs.


Old 09-25-2011, 01:38 AM   #3
Registered: Apr 2006
Distribution: Sabayon linux 5.1
Posts: 182

Original Poster
Rep: Reputation: 15
yes it does work when i un comment the line but thats not what i need it to do. id like it to print to the list self.list and have self.list be set as the text in the scrollable window by way of self.contents


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python script using tar from a list returns error: has no attribute 'startswith' linux1103 Linux - Newbie 3 04-05-2011 07:17 PM
[SOLVED] awk code help for displaying file contents ashok.g Programming 13 12-14-2009 12:55 AM
my cd contents file names not displaying morethan 8 digits. AMajeed AIX 5 08-08-2007 09:56 AM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 04:02 AM
win_c, floppy, cdrom are not displaying contents clockworkorange Linux - General 13 12-28-2001 10:40 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration