| Reply | « Previous Thread | Next Thread » |
|
hi I want to create a code to search joker files in lists but I dont know how can I do it
I created a code Code:
import appuifw
import e32
import os
def tr(x):return x.decode('utf-8')
imagedir=('C:\\Nokia\\Images\\')
imagedir2='E:\\Images\\'
files=map(tr,os.listdir(imagedir))
files2=map(tr,os.listdir(imagedir2))
files.extend(files2)
index=appuifw.selection_list(files)
print files[index]
in this code I only want to see files endswith .png or .jpg in the selection list? is there a way to do this? thanks. |
|
Use something like this
Code:
jpg1=files[index].split('.')
jpg2=jpg[1]
if jpg2=="jpg":
code
elif jpg2=="png":
more code
![]() |
|
I would use list compherension instead of map():
Code:
files = [x.decode('utf8') for x in os.listdir(imagedir) if os.path.splitext(x)[-1].lower() in ('.jpg', '.png')]
@Dansco Your code will fail if the filename is "this.is.some.picture.jpg" for example. You would have to use jpg[-1] instead of jpg[1] to get the extension. But it is always a good practice to use the os.path.splitext() function. Why reinventing the wheel? |
|
y.a.k and Dansco thanks a lot I found the answer in y.a.k's code
|
|
Quote:
![]() |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Pinyin mode for Search box | dgaur | Symbian User Interface | 0 | 2008-05-06 10:45 |
| Carbide.ui bugs on N73 ME | zhvihti | Themes/Carbide.ui | 8 | 2007-06-05 09:30 |
| 6680 and bluetooth service profiles | ceruault | Mobile Java Networking & Messaging & Security | 1 | 2005-10-08 23:24 |
| search in a List class | pvermeulen | Mobile Java General | 3 | 2004-07-13 21:32 |
| Phone List Search & then Phone Call | Nokia_Archive | Browsing and Mark-ups | 1 | 2002-05-16 02:46 |