You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old writing to a file - 2008-06-25, 18:44

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
hi to all
i want to make a file whose contents are constantly changing with a function whose output are simple integer numbers.
i am trying to write the output of the function in the file using f.write() but i am not sucessfull can anyone help me out.
thanks a lot


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

Forum Nokia Python Wiki


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

#2 Old Re: writing to a file - 2008-06-25, 18:47

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by gaba88 View Post
hi to all
i want to make a file whose contents are constantly changing with a function whose output are simple integer numbers.
i am trying to write the output of the function in the file using f.write() but i am not sucessfull can anyone help me out.
thanks a lot
If you could share your code, people might be able to help you.

And remember to post the code using the CODE(#) tabs

Best Regards,
Croozeus
Reply With Quote

#3 Old Re: writing to a file - 2008-06-25, 19:12

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
my code goes like this
Code:
def myfunction()
   whose output goes changing with a single click
input = myfunction()
logfile = open('c:\\test.txt','w')
logfile.write(input)
logfile.close()
but i am very sad that i am getting a error in that something like this:
argument 1 must be a string or read only character buffer not none.
my outputs are numbers


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

Forum Nokia Python Wiki


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

#4 Old Cool Re: writing to a file - 2008-06-25, 19:17

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Please post the code for myfunction()

Quote:
Originally Posted by gaba88 View Post
Code:
def myfunction()
   whose output goes changing with a single click
And by the way how do you "Click" ?

Best Regards,
Croozeus
Reply With Quote

#5 Old Re: writing to a file - 2008-06-25, 19:31

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
Oh my friend, use of keyword "input" is giving you an error. Try with some other like xyz

Code:
def myfunction()
   whose output goes changing with a single click
xyz = myfunction()
logfile = open('c:\\test.txt','w')
logfile.write(xyz)
logfile.close()


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#6 Old Re: writing to a file - 2008-06-25, 19:36

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
nice question croozeus
by a click means whenever i press a button in my keypad the output of myfunction changes.
hope you got it this time and that change i want to write it in a file.
waitin for ur reply


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

Forum Nokia Python Wiki


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

#7 Old Re: writing to a file - 2008-06-25, 19:43

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
Quote:
Originally Posted by gaba88 View Post
hope you got it this time and that change i want to write it in a file.
Hi GD (gabba88) (exoersist ) (gargidas19188)

Please post the code for myfunction()
Reply With Quote

#8 Old Re: writing to a file - 2008-06-25, 19:49

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 shubhendra View Post
Oh my friend, use of keyword "input" is giving you an error. Try with some other like xyz

Code:
def myfunction()
   whose output goes changing with a single click
xyz = myfunction()
logfile = open('c:\\test.txt','w')
logfile.write(xyz)
logfile.close()
hi subhendra
i am not using the text input as i shown it as an example only.


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

Forum Nokia Python Wiki


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

#9 Old Re: writing to a file - 2008-06-25, 20:05

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by croozeus View Post
If you could share your code, people might be able to help you.
Quote:
Originally Posted by croozeus View Post
Please post the code for myfunction()
Quote:
Originally Posted by bogdan.galiceanu View Post
Hi GD (gabba88) (exoersist ) (gargidas19188)

Please post the code for myfunction()
Best Regards,
Croozeus
Reply With Quote

#10 Old Re: writing to a file - 2008-06-25, 20:14

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
hi bogdan after all you got my real name
sorry for replying late my code goes like this"
Code:
import appuifw
import graphics
import e32

keyboard_state={}
last_keycode=0

def myfunction():
    canvas.clear()
    canvas.text((0,48),u'Last received keycode:', 0x008000)    
    f = canvas.text((0,60),u'%s'%(last_keycode))
    logfile = open('c://keylogger.txt','w')
    logfile.write(f)
    logfile.close()
make a note this is just the code for myfunction().
hope you all will help me
when i m makin a write to a file it give a error


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

Forum Nokia Python Wiki


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

#11 Old Re: writing to a file - 2008-06-25, 20:22

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by gaba88 View Post
Code:
import appuifw
import graphics
import e32

keyboard_state={}
last_keycode=0

def myfunction():
    canvas.clear()
    canvas.text((0,48),u'Last received keycode:', 0x008000)    
    f = canvas.text((0,60),u'%s'%(last_keycode))
    logfile = open('c://keylogger.txt','w')
    logfile.write(f)
    logfile.close()
Errors:

1) Where have you defined "canvas" ? Defining Canvas is missing.

2) You mixed up the slashes in the path. It should be \\ instead of //

3) You are trying to write the latest keypress on the canvas.

But again why do you want to write the canvas to the file
and you make last_keycode=0 so you want to write "0 " everywhere. Why do all this stuff then?

Does it make sense to any one?

Best Regards,
Croozeus
Reply With Quote

#12 Old Re: writing to a file - 2008-06-25, 20:25

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
Quote:
Originally Posted by croozeus View Post
Does it make sense to any one?
Definitely not to me.

gaba88, please try to build your code as logically as possible. And maybe you should add comments.
Reply With Quote

#13 Old Re: writing to a file - 2008-06-25, 20:35

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
I strongly recommend gabba88 to read the Mobile Python Book based on Rapid Prototyping of Applications on the Mobile Platform by Jürgen Scheible and Ville Tuulos.

Its a must read book for PyS60 developers, especially begineers.

Best Regards,
Croozeus
Reply With Quote

#14 Old Re: writing to a file - 2008-06-25, 23:06

Join Date: Feb 2008
Posts: 25
Location: Moscow Russia
Send a message via ICQ to Versoul Send a message via Skype™ to Versoul
Versoul
Offline
Registered User
gaba88 what you wont to do?if you wont only write last_keycode to file do so
Code:
import appuifw
import graphics
import e32

keyboard_state={}
last_keycode=0

def myfunction():
    canvas.clear()
    f=str(last_keycode)
    canvas.text((0,48),u'Last received keycode:'+f, 0x008000)    
    logfile = open('c://keylogger.txt','w')
    logfile.write(f)
    logfile.close()
if keycode in hex use f=last_keycode.decode('hex') or f=last_keycode.encode('hex')
Reply With Quote

#15 Old Re: writing to a file - 2008-06-26, 01:53

Join Date: Jun 2005
Posts: 382
y.a.k
Offline
Regular Contributor
@gaba

The error you mentioned earlier says you want to write a number to a file. You can't do that by directly passing a number to write() method. A file is a stream of bytes/chars, in ither words a string. Therefore you first have to convert your number to a string. The simpliest way is:
Code:
logfile.write(str(f))
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
Theme Studio 3.1 not creating themes zemm Themes/Carbide.ui 11 2008-10-18 09:41
Problem with pyobfuscate JOM Python 3 2008-06-20 23:47
Reading and writing to file rkuppala General Symbian C++ 6 2008-03-13 10:59
File reading & writing help, wav file redaing help shubhamlahoti Mobile Java General 6 2007-06-27 10:07
Writing descriptor to file without length property toshaga General Symbian C++ 1 2006-11-16 20:51

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ