You Are Here:

Community: Developer Discussion Boards

#1 Old Newbie trouble - 2008-03-23, 16:35

Join Date: Feb 2008
Posts: 12
IreStep
Offline
Registered User
Hi All,

i have a little program that gets a url from urllib and saves the html content to a file. i then want to search for certain words in that file.

here is my code to search for the words.
Code:
list = ["yes","no","maybe"]

for i in range(0,len(list)):
   f = file(u"c:\\Users\\Desktop\\test3.txt", "r")
   for line in f:
      if list[i] in line:
         score = score + 1
   i = i + 1
the html code is definitely in the file and works when i test it in PyDev. yet when i try on my phone i cant get it to work.

The error i get is:

if list[i] in line:
Type error: 'in<string>' requires
character as left operand.

Any help?? Thank you.

i dont know why it works in PyDev but not on emulator
Reply With Quote

#2 Old Re: Newbie trouble - 2008-03-23, 17:25

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
Quote:
Originally Posted by IreStep View Post
Hi All,

i have a little program that gets a url from urllib and saves the html content to a file. i then want to search for certain words in that file.

here is my code to search for the words.
Code:
list = ["yes","no","maybe"]

for i in range(0,len(list)):
   f = file(u"c:\\Users\\Desktop\\test3.txt", "r")
   for line in f:
      if list[i] in line:
         score = score + 1
   i = i + 1
the html code is definitely in the file and works when i test it in PyDev. yet when i try on my phone i cant get it to work.

The error i get is:

if list[i] in line:
Type error: 'in<string>' requires
character as left operand.

Any help?? Thank you.

i dont know why it works in PyDev but not on emulator
Hello IreStep,

The error is due to the fact that PyS60, unlike Python, can't determine if a string is in a string (I don't know why), only if a character is in a string.
I've come up with this alternative, I hope it helps:

Code:
list = ["yes","no","maybe"]

for i in range(len(list)):
	f = file("c:\\python\\test3.txt", "r")
	for line in f:
      		j=0
		while(j<=len(line)):
			if((list[i]==line[j:j+2]) or (list[i]==line[j:j+3]) or(list[i]==line[j:j+5])):
         			score+=1
			j+=1
Basically what it does is search every "piece" of every line in the file and checks if it is the same as the elements in list.
You may adapt it to the needs of your program.
Reply With Quote

#3 Old Re: Newbie trouble - 2008-03-26, 02:12

Join Date: Feb 2008
Posts: 12
IreStep
Offline
Registered User
Thank you i will try get it to suit my application in future.

One more question.. im about to attempt to implement some sort of user profile recognition for my app.

i dont want a login screen or anything like that but what way would you gifted pys60 developers recommend for keeping track of who is using the app and when etc.

Database is obvious choice.. or is it??

Thank you all again.
Reply With Quote

#4 Old Re: Newbie trouble - 2008-03-26, 03:28

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by IreStep View Post
Thank you i will try get it to suit my application in future.

One more question.. im about to attempt to implement some sort of user profile recognition for my app.

i dont want a login screen or anything like that but what way would you gifted pys60 developers recommend for keeping track of who is using the app and when etc.

Database is obvious choice.. or is it??

Thank you all again.
hi Irestep
i have a idea to track the apps one is using we can take a snapshots which must be running in the background of the actual application. the snapshots will be stored automatically in the phone. and after analysing that snapshots one can easily know trace one.
hope u r satisfied plz give a feedback.
thanx


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#5 Old Re: Newbie trouble - 2008-03-26, 05:32

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
Quote:
Originally Posted by IreStep View Post
Thank you i will try get it to suit my application in future.

One more question.. im about to attempt to implement some sort of user profile recognition for my app.

i dont want a login screen or anything like that but what way would you gifted pys60 developers recommend for keeping track of who is using the app and when etc.

Database is obvious choice.. or is it??

Thank you all again.
I hope I understood your question.
A database is a good idea. You might try a simple approach, like writing the times at which the application is opened/closed in a text file. And if you make a login screen, you can add the user names to the text file too.
Last edited by bogdan.galiceanu : 2008-03-26 at 06:18.
Reply With Quote

#6 Old Re: Newbie trouble - 2008-03-26, 09:26

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Online
Forum Nokia Champion
Quote:
Originally Posted by IreStep View Post
Thank you i will try get it to suit my application in future.

One more question.. im about to attempt to implement some sort of user profile recognition for my app.

i dont want a login screen or anything like that but what way would you gifted pys60 developers recommend for keeping track of who is using the app and when etc.

Database is obvious choice.. or is it??

Thank you all again.
If you don't want a login screen, you can just have a selection list at the start of the application from which the user selects his identity and then as my fellow Champion Bogdan suggested, you could have the time + identity written to a text file which will act as the database for your application.

Best Regards
Croozeus
Reply With Quote

#7 Old Re: Newbie trouble - 2008-03-26, 10:27

Join Date: Feb 2008
Posts: 12
IreStep
Offline
Registered User
Thanks again!

You guys really helping me with learning to use pys60.

Really appreciate it. selection list seems like a good idea
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie here... need help... maalvin15 General Symbian C++ 3 2007-11-12 01:48
newbie Carbide questions pollyp Carbide.c++ IDE and plug-ins 2 2007-10-09 23:42
Newbie Bluetooth GPS Trouble ajr General Discussion 2 2007-03-06 15:55
newbie in trouble with invoking php page gorbius Mobile Java General 3 2006-04-21 01:54
Need help newbie in big trouble tonysmiff General Symbian C++ 1 2004-01-21 11:18

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia