×

Discussion Board

Results 1 to 7 of 7

Thread: Newbie trouble

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    12

    Newbie trouble

    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

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Newbie trouble

    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.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    12

    Re: Newbie trouble

    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.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Newbie trouble

    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

  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Newbie trouble

    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 05:18.

  6. #6
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: Newbie trouble

    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
    Pankaj Nathani
    www.croozeus.com

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    12

    Re: Newbie trouble

    Thanks again!

    You guys really helping me with learning to use pys60.

    Really appreciate it. selection list seems like a good idea

Similar Threads

  1. newbie here... need help...
    By maalvin15 in forum Symbian
    Replies: 3
    Last Post: 2007-11-12, 00:48
  2. newbie Carbide questions
    By pollyp in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2007-10-09, 22:42
  3. Newbie Bluetooth GPS Trouble
    By ajr in forum General Development Questions
    Replies: 2
    Last Post: 2007-03-06, 14:55
  4. newbie in trouble with invoking php page
    By gorbius in forum Mobile Java General
    Replies: 3
    Last Post: 2006-04-21, 00:54
  5. Need help newbie in big trouble
    By tonysmiff in forum Symbian
    Replies: 1
    Last Post: 2004-01-21, 10:18

Posting Permissions

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