LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-27-2012, 02:37 AM   #1
devilboy09
Member
 
Registered: Nov 2011
Location: Iran
Distribution: Debian, CentOS, LFS, CloudLinux
Posts: 377

Rep: Reputation: 10
python -> bookmark


i'm going to add the bookmark feature to my web browser that i'm writing with python.
my thought is to save the url paths to a file so in the future i could retrieve them.
how can i save urls in a file without erasing the file every time i open the file for writing?
 
Old 02-27-2012, 07:06 AM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi.

Read here.
 
Old 02-27-2012, 07:54 AM   #3
devilboy09
Member
 
Registered: Nov 2011
Location: Iran
Distribution: Debian, CentOS, LFS, CloudLinux
Posts: 377

Original Poster
Rep: Reputation: 10
actually i read it before.
here's my code:
Code:
def entry_add_icon_press(self, widget, event, pos):
		book_file = open("/home/devilboy/browser/bookmark.txt", "a")
		url_path = self.text.get_text()
		book_file.write(url_path) 
		book_file.close()
self.text.connect("icon-press", self.entry_add_icon_press)
the problem that i have now is when i add urls to the bookmark file, theose url will append at the end of the previous url and not in the new line.how can i fix that ?
 
Old 02-27-2012, 08:15 AM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Code:
book_file.write(url_path+'\n')
 
1 members found this post helpful.
Old 02-27-2012, 09:01 AM   #5
devilboy09
Member
 
Registered: Nov 2011
Location: Iran
Distribution: Debian, CentOS, LFS, CloudLinux
Posts: 377

Original Poster
Rep: Reputation: 10
thank you so much.
 
  


Reply



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
OK to copy over bookmark & bookmark.bat Chrome files from Windows? zensunni Linux - Newbie 2 09-12-2010 03:52 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
Bookmark Hell Randux Linux - Software 13 07-12-2006 03:06 AM
Bookmark problem RMB Mandriva 1 11-22-2004 09:50 AM
Firefox Bookmark Manager - What are bookmark seperator names for? SBing Linux - Software 2 06-21-2004 02:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:57 AM.

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