Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Sun, Jul 8, 2012 at 3:42 PM, wrote: > Thanks for pointing out the mistakes. Your points are right. So I am trying > to revise it, > > file_open=open("/python32/doc1.txt","r") > for line in file_open: > line_word=line.split() > print (line_word) Yep. I'd be inclined to renam

Re: how to compile pygtk in python2.7?

2012-07-08 Thread contro opinion
it's so strange when i input hisroty 506 cd /home/tiger/pygtk-2.24.0 507 PYTHON=/usr/local/bin/python2.7 ./configure --prefix=/usr 508 echo $? #i get 0 ,it means success?? 509 make 510 echo $? #i get 0 ,it means success?? 511 make install 512 echo $?

Re: how to compile pygtk in python2.7?

2012-07-08 Thread Chris Angelico
On Sun, Jul 8, 2012 at 6:26 PM, contro opinion wrote: > it's so strange > when i input > hisroty > > 506 cd /home/tiger/pygtk-2.24.0 > 507 PYTHON=/usr/local/bin/python2.7 ./configure --prefix=/usr > 508 echo $? #i get 0 ,it means success?? > 509 make > 510 echo $? #

Re: Socket code not executing properly in a thread (Windows)

2012-07-08 Thread Andrew D'Angelo
"John Nagle" wrote in message news:jta1v7$v0b$1...@dont-email.me... >We have no idea what IRC module you're using. I am sending plain text to the socket, sorry for not mentioning it before. At the simplest level, it appears that when the code runs in Windows, data is not sent to a socket

Re: how to compile pygtk in python2.7?

2012-07-08 Thread contro opinion
1.PYTHON=/usr/local/bin/python2.7 ./configure --prefix=/usr the output is : checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking

Re: how to compile pygtk in python2.7?

2012-07-08 Thread contro opinion
2.make the output is : Could not write method GdkFont.text_width_wc: No ArgType for const-GdkWChar* Could not write method GdkFont.char_width_wc: No ArgType for GdkWChar Could not write method GdkFont.text_extents_wc: No ArgType for const-GdkWChar* Could not write method Gdk

Re: Socket code not executing properly in a thread (Windows)

2012-07-08 Thread Thomas Jollans
On 07/08/2012 11:03 AM, Andrew D'Angelo wrote: > Also, running the sned to socket code inside the main loop would not work, > as the main loop pauses until it recieves data from the socket (an IRC > message), which is why I didn't put the SMS code in the main loop in the > first place. http://

How to safely maintain a status file

2012-07-08 Thread Richard Baron Penman
Hello, I want my script to generate a ~1KB status file several times a second. The script may be terminated at any time but the status file must not be corrupted. When the script is started next time the status file will be read to check what needs to be done. My initial solution was a thread tha

Re: How to safely maintain a status file

2012-07-08 Thread Christian Heimes
Am 08.07.2012 13:29, schrieb Richard Baron Penman: > My initial solution was a thread that writes status to a tmp file > first and then renames: > > open(tmp_file, 'w').write(status) > os.rename(tmp_file, status_file) You algorithm may not write and flush all data to disk. You need to do addition

Re: How to safely maintain a status file

2012-07-08 Thread Michael Hrivnak
What are you keeping in this status file that needs to be saved several times per second? Depending on what type of state you're storing and how persistent it needs to be, there may be a better way to store it. Michael On Sun, Jul 8, 2012 at 7:53 AM, Christian Heimes wrote: > Am 08.07.2012 13:2

Re: Discussion on some Code Issues

2012-07-08 Thread subhabangalore
On Sunday, July 8, 2012 1:33:25 PM UTC+5:30, Chris Angelico wrote: > On Sun, Jul 8, 2012 at 3:42 PM, wrote: > > Thanks for pointing out the mistakes. Your points are right. So I am trying > > to revise it, > > > > file_open=open("/python32/doc1.txt","r") > > for line in file_open: > > l

Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Mon, Jul 9, 2012 at 3:05 AM, wrote: > On Sunday, July 8, 2012 1:33:25 PM UTC+5:30, Chris Angelico wrote: >> On Sun, Jul 8, 2012 at 3:42 PM, wrote: >> > file_open=open("/python32/doc1.txt","r") >> Also, as has already been mentioned: keeping your data files in the >> Python binaries directory

Re: Discussion on some Code Issues

2012-07-08 Thread Roy Smith
In article , Chris Angelico wrote: > open("doc1.txt","r") > > Python will look for a file called doc1.txt in the directory you run > the script from (which is often going to be the same directory as your > .py program). Well, to pick a nit, the file will be looked for in the current working d

Re: Discussion on some Code Issues

2012-07-08 Thread MRAB
On 08/07/2012 18:17, Chris Angelico wrote: On Mon, Jul 9, 2012 at 3:05 AM, wrote: On Sunday, July 8, 2012 1:33:25 PM UTC+5:30, Chris Angelico wrote: On Sun, Jul 8, 2012 at 3:42 PM, wrote: > file_open=open("/python32/doc1.txt","r") Also, as has already been mentioned: keeping your data files

Re: How to safely maintain a status file

2012-07-08 Thread Laszlo Nagy
On Sun, 8 Jul 2012 21:29:41 +1000, Richard Baron Penman declaimed the following in gmane.comp.python.general: and then on startup read from tmp_file if status_file does not exist. But this seems awkward. It also violates your requirement -- since the "crash" could take place with a par

Tkinter.event.widget: handler gets name instead of widget.

2012-07-08 Thread Frederic Rentsch
Hi widget wizards, The manual describes the "event" attribute "widget" as "The widget which generated this event. This is a valid Tkinter widget instance, not a name. This attribute is set for all events." Ans so it is--has been until on the latest occasion "event.widget" was not t

Re: Confusing datetime.datetime

2012-07-08 Thread Damjan
Because x1 and x2 have different time zones. The tzinfo field in x2 is equal to TZ and has a UTC offset of 1 hour. The tzinfo field in x1 contains the DST version of that timezone, with a UTC offset of 2 hours, because Skopje is currently on DST. I think you want: x2 = TZ.localize(datetime(x1.y

Re: How to safely maintain a status file

2012-07-08 Thread Christian Heimes
Am 08.07.2012 22:57, schrieb Laszlo Nagy: > But even if the rename operation is atomic, there is still a race > condition. Your program can be terminated after the original status file > has been deleted, and before the temp file was renamed. In this case, > you will be missing the status file (alt

Re: Discussion on some Code Issues

2012-07-08 Thread Chris Angelico
On Mon, Jul 9, 2012 at 4:17 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> open("doc1.txt","r") >> >> Python will look for a file called doc1.txt in the directory you run >> the script from (which is often going to be the same directory as your >> .py program). > > Well, to pic

Re: Discussion on some Code Issues

2012-07-08 Thread Steven D'Aprano
On Mon, 09 Jul 2012 07:54:47 +1000, Chris Angelico wrote: > It's like > the difference between reminder text on a Magic: The Gathering card and > the actual entries in the Comprehensive Rules. Perfect example is the > "Madness" ability - the reminder text explains the ability, but uses > language

Re: stuck in files!!

2012-07-08 Thread alex23
On Jul 6, 9:53 pm, Chirag B wrote: > i want to kno how to link two applications using python for eg:notepad > txt file and some docx file. like i wat to kno how to take path of > those to files and run them simultaneously.like if i type something in > notepad it has to come in wordpad whenever i r

how can I make it work?

2012-07-08 Thread self.python
it's a finder using threading to accelerate but it never works.. and I have no idea why it doesn't work:( it doesn't work too after changing threading to multiprocessing.. how can I make it work? or at least I know what's the problem... plz help the poor newbie... import os,threading,multipr

Re: how can I make it work?

2012-07-08 Thread MRAB
On 09/07/2012 03:02, self.python wrote: it's a finder using threading to accelerate but it never works.. and I have no idea why it doesn't work:( it doesn't work too after changing threading to multiprocessing.. how can I make it work? or at least I know what's the problem... plz help the poor ne

Re: something go wrongly

2012-07-08 Thread Lefavor, Matthew (GSFC-582.0)[MICROTEL LLC]
If you do want an in-place extension, you could try: aList=[1,2,3,4,5,6,7,8,9,10] xList=[1,2,3] print "The concatenated lists are:", aList + bList Though you need to remember that neither aList nor bList is altered in this situation! Matthew Lefavor NASA GSFC [Microtel, LLC] Mail Code 699.0/Or

Re: how can I make it work?

2012-07-08 Thread self.python
2012년 7월 9일 월요일 오전 11시 2분 41초 UTC+9, self.python 님의 말: > it's a finder using threading to accelerate but it never works.. > and I have no idea why it doesn't work:( > it doesn't work too after changing threading to multiprocessing.. > how can I make it work? or at least I know what's the problem...

Re: how can I make it work?

2012-07-08 Thread self.python
2012년 7월 9일 월요일 오전 11시 41분 32초 UTC+9, self.python 님의 말: > 2012년 7월 9일 월요일 오전 11시 2분 41초 UTC+9, self.python 님의 말: > > it's a finder using threading to accelerate but it never works.. > > and I have no idea why it doesn't work:( > > it doesn't work too after changing threading to multiprocessing.. >

Re: How to safely maintain a status file

2012-07-08 Thread Plumo
> What are you keeping in this status file that needs to be saved > several times per second?  Depending on what type of state you're > storing and how persistent it needs to be, there may be a better way > to store it. > > Michael This is for a threaded web crawler. I want to cache what URL's are

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-08 Thread Terry Reedy
On 7/8/2012 5:19 PM, Frederic Rentsch wrote: Hi widget wizards, The manual describes the "event" attribute "widget" as "The widget which generated this event. This is a valid Tkinter widget instance, not a name. This attribute is set for all events." Same in 3.3, with nice example of u

Re: How to safely maintain a status file

2012-07-08 Thread Plumo
> > and then on startup read from tmp_file if status_file does not exist. > > But this seems awkward. > >         It also violates your requirement -- since the "crash" could take > place with a partial "temp file". Can you explain why? My thinking was if crash took place when writing the temp fil

Re: how can I make it work?

2012-07-08 Thread Terry Reedy
On 7/8/2012 10:02 PM, self.python wrote: it's a finder using threading to accelerate Threading with Python does not accelerate unless all but one of the treads are i/o bound. You need multiple processes to use multiple cores in parallel. -- Terry Jan Reedy -- http://mail.python.org/mailm

Re: How to safely maintain a status file

2012-07-08 Thread Plumo
> Windows doesn't suppport atomic renames if the right side exists.  I > suggest that you implement two code paths: > > if os.name == "posix": >     rename = os.rename > else: >     def rename(a, b): >         try: >             os.rename(a, b) >         except OSError, e: >             if e.errno