Re: Subclassing by monkey-patching

2010-09-05 Thread Arnaud Delobelle
Jason writes: [...] > Is there a way I can write the subclass but then somehow... extend an > existing instance all at once rather than monkeypatch methods on one > by one? So I could take an existing instance of a FileMonitor and make > it an instance of my subclass? This would even allow me to o

Re: Subclassing by monkey-patching

2010-09-05 Thread Peter Otten
Arnaud Delobelle wrote: > Jason writes: > [...] >> Is there a way I can write the subclass but then somehow... extend an >> existing instance all at once rather than monkeypatch methods on one >> by one? So I could take an existing instance of a FileMonitor and make >> it an instance of my subcla

Re: Question about Reading Files

2010-09-05 Thread Peter Otten
genxtech wrote: > Hello. I am still really new to python and I have a project where I > am trying to use the data files from another program and write a new > program with new user interface and all. My first step was to open > one of the files in 'rb' mode and print the contents, but I am > unf

Python 2.7 module path problems on OS X

2010-09-05 Thread Nicholas Cole
Dear List, I have a horrible feeling that this is in some way related to the new user installation directory in 2.7,or some problem with the framework built, but I'm having great trouble with the module search path on 2.7. I usually install modules to install_lib = ~/Library/Python/$py_version_sh

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
On Sep 5, 3:53 pm, Peter Otten <__pete...@web.de> wrote: > >>> m = gio.File(".").monitor_directory() > >>> C = type(m) 'C' will not necessarily be 'gio.FileMonitor' — I think the internals of the GIO methods might further "subclass" it in some way depending on what underlying monitors are availabl

Re: Python 2.7 module path problems on OS X

2010-09-05 Thread Ned Deily
In article , Nicholas Cole wrote: > I have a horrible feeling that this is in some way related to the new > user installation directory in 2.7,or some problem with the framework > built, but I'm having great trouble with the module search path on > 2.7. > > I usually install modules to install

Re: Python 2.7 module path problems on OS X

2010-09-05 Thread Nicholas Cole
On Sun, Sep 5, 2010 at 10:20 AM, Ned Deily wrote: > I'm not sure why you think it is broken.  The Apple 2.6 and the > python.org 2.7 have different site-package directories in different > locations.  That is to be expected.  The Apple-supplied Python comes > with some additional packages pre-insta

Re: Network and socket programming in python

2010-09-05 Thread mblume
Am Sat, 04 Sep 2010 21:29:49 -0700 schrieb shivram: > > i want to learn network and socket programming but i would like to do > this in python.Reason behind this is that python is very simple and the > only language i know . > anybody can suggest me which book should i pick. the book should have >

High CPU utilization with Pylab

2010-09-05 Thread Madhur
I am trying to plot a runtime graph using pylab. But the very purpose of functionality is lost because of high CPU percentage hogged by plotting the graph. Here is the piece of code which I have written. def timerfunc(ulcm, dlcm): count=0 xaxis=[] yaxis=[] ion() while 1:

Re: Network and socket programming in python

2010-09-05 Thread geremy condra
On Sat, Sep 4, 2010 at 9:29 PM, shivram wrote: > i want to learn network and socket programming but i would like to do > this in python.Reason behind this is that python is very simple and > the only language i know . > anybody can suggest me which book should i pick. > the book should have follow

Re: Question about Reading Files

2010-09-05 Thread Mats Rauhala
On 2010-09-05, genxtech wrote: > I am using Fedora 13. When I run the file command the response is > that it is a 'data' file. If there are any tips on how to > programatically figure out the format, I would greatly appreciate it. I tried python-magic from the fedora repositories, but was unabl

Re: High CPU utilization with Pylab

2010-09-05 Thread David
Il Sun, 5 Sep 2010 03:05:54 -0700 (PDT), Madhur ha scritto: > Is there something which does not makes sense .? 1. How, a computer, is supposed to handle your infinite loop? 2. Running ghraphs shuold be handled in totally different way: look at the "stripcharting" demo in this zip http://agni.phy

Re: Subclassing by monkey-patching

2010-09-05 Thread Peter Otten
Jason wrote: > On Sep 5, 3:53 pm, Peter Otten <__pete...@web.de> wrote: >> >>> m = gio.File(".").monitor_directory() >> >>> C = type(m) > > 'C' will not necessarily be 'gio.FileMonitor' — I think the internals > of the GIO methods might further "subclass" it in some way depending > on what underl

Re: Speed-up for loops

2010-09-05 Thread BartC
"David Cournapeau" wrote in message news:mailman.455.1283665528.29448.python-l...@python.org... On Thu, Sep 2, 2010 at 7:02 PM, Michael Kreim wrote: imax = 10 a = 0 for i in xrange(imax): a = a + 10 print a Unfortunately my Python Code was much slower [than Matlab] and I do not

Re: Network and socket programming in python

2010-09-05 Thread simpu
On Sep 5, 3:29 pm, geremy condra wrote: > On Sat, Sep 4, 2010 at 9:29 PM, shivram wrote: > > i want to learn network and socket programming but i would like to do > > this in python.Reason behind this is that python is very simple and > > the only language i know . > > anybody can suggest me whic

Python [repair_cycorder_mov.py]

2010-09-05 Thread ctops.legal
Trying to learn Python for a specific purpose to repair a quicktime file that's corrupted, is it even possible to create a proof-of- concept python script that generates a valid 'moov' atom from a corrupt .mov video ?, "file size 1.3gb" (Kodak camera failed to finalize file). [IMG]http://a.images

Python script for repairing .mov file

2010-09-05 Thread ctops.legal
Trying to learn Python for a specific purpose to repair a quicktime file that's corrupted, is it even possible to create a proof-of- concept python script that generates a valid 'moov' atom from a corrupt .mov video ?, "file size 1.3gb" (Kodak camera failed to finalize file). Mac--> http://a.imag

Python script for repairing .mov file ?

2010-09-05 Thread ctops.legal
Trying to learn Python for a specific purpose to repair a quicktime file that's corrupted, is it even possible to create a proof-of- concept python script that generates a valid 'moov' atom from a corrupt .mov video ?, "file size 1.3gb" (Kodak camera failed to finalize file). Mac--> http://a.imag

Re: Python [repair_cycorder_mov.py]

2010-09-05 Thread Steven D'Aprano
On Sun, 05 Sep 2010 05:44:16 -0700, ctops.legal wrote: > Trying to learn Python for a specific purpose to repair a quicktime file > that's corrupted, is it even possible to create a proof-of- concept > python script that generates a valid 'moov' atom from a corrupt .mov > video ?, "file size 1.3g

ssh browser? where?

2010-09-05 Thread alex goretoy
why not ssh browser traffic? why use SSL certificate authorities which can't be trusted in the first place? Is SSH not proven to be secure? To this day I have not seen ssh module for say Apache web server, why not? I understand this maybe wrong list to ask this question, but I love you guys so mu

Re: ssh browser? where?

2010-09-05 Thread Thomas Jollans
On Sunday 05 September 2010, it occurred to alex goretoy to exclaim: > why not ssh browser traffic? why use SSL certificate authorities which > can't be trusted in the first place? > Is SSH not proven to be secure? > > To this day I have not seen ssh module for say Apache web server, why not? > >

Re: ssh browser? where?

2010-09-05 Thread alex goretoy
>>> If we were to use SSH on the web, which is certainly not the point of SSH, >>> we'd still need some kind of certificate authority to make the whole system >>> workable. Yeah, you are correct. I thought about that after having posted these questions. Even though it was SSH there still would be

Re: Speed-up for loops

2010-09-05 Thread Steven D'Aprano
On Fri, 03 Sep 2010 21:17:44 +0100, BartC wrote: > I'm not sure the Python developers were interested in getting fast > loops. > > For-loops which iterate between two numbers are amongst the easiest > things to make fast in a language. Yet originally you had to use: > > for i in range(N): I d

Re: Python script for repairing .mov file ?

2010-09-05 Thread Almar Klein
On 5 September 2010 14:54, ctops.legal wrote: > Trying to learn Python for a specific purpose to repair a quicktime > file that's corrupted, is it even possible to create a proof-of- > concept python script that generates a valid 'moov' atom from a > corrupt .mov video ?, "file size 1.3gb" (Koda

Re: Speed-up for loops

2010-09-05 Thread Steven D'Aprano
On Sun, 05 Sep 2010 12:28:47 +0100, BartC wrote: >> Getting the above kind of code fast requires the interpreter to be >> clever enough so that it will use native machine operations on a int >> type instead of converting back and forth between internal >> representations. > > Writing for i in xra

doctest annoyance/puzzle

2010-09-05 Thread Steven D'Aprano
I'm writing a "literate programming" document, example.txt, which mixes text and code in ReST format: This is my excellent module for making spam. It has one public function, ``make_spam``, which takes a single argument for how much spam to make: >>> from module import make_spam >>> ma

personal firewall software is blocking the connection

2010-09-05 Thread vsoler
I'am getting this annoying message all the time when using IDLE. ... personal firewall software is blocking the connection When I am editing a source *.py file and I click on F5 (run) I get the above message. What can I do? I am using Norton Internet Security. I try to find if 127.0.0.1 is blo

IDLE: personal firewall software is blocking the connection

2010-09-05 Thread vsoler
On 5 sep, 18:00, vsoler wrote: > I'am getting this annoying message all the time when using IDLE. > > ...  personal firewall software is blocking the connection > > When I am editing a source *.py file and I click on F5 (run) I get the > above message. > > What can I do? > > I am using Norton Inte

Re: Python [repair_cycorder_mov.py]

2010-09-05 Thread Albert Hopkins
On Sun, 2010-09-05 at 14:00 +, Steven D'Aprano wrote: > By the way, there's no need to send three messages in 10 minutes > asking > the same question, and adding FORM METHOD links to your post will > probably just get it flagged as spam by many people. Apparently it has, as I only got this

Re: Speed-up for loops

2010-09-05 Thread Stefan Behnel
Steven D'Aprano, 05.09.2010 17:00: Of course, a real optimizing compiler would realise that the Pascal code did nothing at all, and compile it all away to an empty a.out file... Which is just one of the reasons why this kind if "benchmark" provides no insight into anything that should have an

Re: doctest annoyance/puzzle

2010-09-05 Thread Stefan Schwarzer
Hi Steven, On 2010-09-05 17:30, Steven D'Aprano wrote: > I run the doctests with: > > python2.6 -m doctest examples.txt > > and the first example passes, but the second fails with NameError: > make_spam not defined. I run my doctests by calling doctest.testfile(filename) for each file in

Extracting item from list of tuples?

2010-09-05 Thread Roy Smith
I'm using httplib, and want to get the Location header from the response. The getheaders() method gives you back a list of (name, value) tuples. It would be a lot more convenient if it gave you back a dict, but it is what it is. Anyway, I came up with: location = [t[1] for t in headers i

Re: Speed-up for loops

2010-09-05 Thread BartC
"Steven D'Aprano" wrote in message news:4c83b425$0$28657$c3e8...@news.astraweb.com... On Sun, 05 Sep 2010 12:28:47 +0100, BartC wrote: It would be nice if you could directly code low-level algorithms in it without relying on accelerators, and not have to wait two and a half minutes (or whatev

Re: Extracting item from list of tuples?

2010-09-05 Thread Thomas Jollans
On Sunday 05 September 2010, it occurred to Roy Smith to exclaim: > I'm using httplib, and want to get the Location header from the > response. The getheaders() method gives you back a list of (name, > value) tuples. It would be a lot more convenient if it gave you back a > dict, but it is what i

Re: Extracting item from list of tuples?

2010-09-05 Thread Philip Semanchuk
On Sep 5, 2010, at 1:09 PM, Roy Smith wrote: I'm using httplib, and want to get the Location header from the response. The getheaders() method gives you back a list of (name, value) tuples. It would be a lot more convenient if it gave you back a dict, but it is what it is. Anyway, I came

Re: Extracting item from list of tuples?

2010-09-05 Thread Peter Otten
Philip Semanchuk wrote: > > On Sep 5, 2010, at 1:09 PM, Roy Smith wrote: > >> I'm using httplib, and want to get the Location header from the >> response. The getheaders() method gives you back a list of (name, >> value) tuples. It would be a lot more convenient if it gave you >> back a >> dic

Re: Queue cleanup

2010-09-05 Thread John Nagle
On 9/4/2010 11:51 PM, Paul Rubin wrote: John Nagle writes: Unoptimized reference counting, which is what CPython does, isn't all that great either. The four big bottlenecks in Python are boxed numbers, attribute lookups, reference count updates, and the GIL. The performance hit of havin

Re: Python script for repairing .mov file ?

2010-09-05 Thread ctops.legal
On Sep 5, 8:54 am, "ctops.legal" wrote: > Trying to learn Python for a specific purpose to repair a quicktime > file that's corrupted, is it even  possible to create a proof-of- > concept python script that generates a valid 'moov' atom from a > corrupt .mov video ?, "file size 1.3gb" (Kodak camer

Re: Extracting item from list of tuples?

2010-09-05 Thread Philip Semanchuk
On Sep 5, 2010, at 1:45 PM, Peter Otten wrote: Philip Semanchuk wrote: On Sep 5, 2010, at 1:09 PM, Roy Smith wrote: I'm using httplib, and want to get the Location header from the response. The getheaders() method gives you back a list of (name, value) tuples. It would be a lot more conv

Re: Python script for repairing .mov file ?

2010-09-05 Thread ctops.legal
On Sep 5, 8:54 am, "ctops.legal" wrote: > Trying to learn Python for a specific purpose to repair a quicktime > file that's corrupted, is it even  possible to create a proof-of- > concept python script that generates a valid 'moov' atom from a > corrupt .mov video ?, "file size 1.3gb" (Kodak camer

Re: Speed-up for loops

2010-09-05 Thread Stefan Behnel
BartC, 05.09.2010 19:09: I've thought about it (writing an independent interpreter). But I don't know enough of the language, and a lot of it I don't understand (eg. OOP). Besides, I think the language itself deliberately makes it difficult to get it up to speed. Some of the reasons might be the

Re: Python 2.7 module path problems on OS X

2010-09-05 Thread Ned Deily
In article , Nicholas Cole wrote: > On Sun, Sep 5, 2010 at 10:20 AM, Ned Deily wrote: > > I'm not sure why you think it is broken.  The Apple 2.6 and the > > python.org 2.7 have different site-package directories in different > > locations.  That is to be expected.  The Apple-supplied Python c

Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Spencer Pearson
Hi! I'm writing a package with several files in it, and I've found that "isinstance" doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass( object ): pass if __name__ == '__main__': a = AClass() filetwo.is_acl

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Arnaud Delobelle
Spencer Pearson writes: > Hi! I'm writing a package with several files in it, and I've found > that "isinstance" doesn't work the way I expect under certain > circumstances. > > Short example: here are two files. > # fileone.py > import filetwo > > class AClass( object ): > pass > > if __name__

accessing a text file

2010-09-05 Thread Baba
level: beginner how can i access the contents of a text file in Python? i would like to compare a string (word) with the content of a text file (word_list). i want to see if word is in word_list. let's assume the TXT file is stored in the same directory as the PY file. def is_valid_word(word, wo

Re: accessing a text file

2010-09-05 Thread Nitin Pawar
may be something like this f = open ("file",r) data = f.read() f.close if word in data: print word, "is present in file" On Mon, Sep 6, 2010 at 3:17 AM, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i would like to compare a string (word) wit

Re: accessing a text file

2010-09-05 Thread Seth Rees
On 09/05/10 16:47, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i would like to compare a string (word) with the content of a text > file (word_list). i want to see if word is in word_list. let's assume > the TXT file is stored in the same director

Re: accessing a text file

2010-09-05 Thread Benjamin Kaplan
On Sun, Sep 5, 2010 at 5:47 PM, Baba wrote: > level: beginner > > how can i access the contents of a text file in Python? > > i would like to compare a string (word) with the content of a text > file (word_list). i want to see if word is in word_list. let's assume > the TXT file is stored in the s

Re: accessing a text file

2010-09-05 Thread MRAB
On 05/09/2010 22:47, Baba wrote: level: beginner how can i access the contents of a text file in Python? That's a very basic question. I suggest you read a tutorial such as "Dive Into Python": http://diveintopython.org/toc/index.html i would like to compare a string (word) with the con

Re: accessing a text file

2010-09-05 Thread Alexander Kapps
Baba wrote: level: beginner how can i access the contents of a text file in Python? i would like to compare a string (word) with the content of a text file (word_list). i want to see if word is in word_list. let's assume the TXT file is stored in the same directory as the PY file. def is_valid

include a file in a python program

2010-09-05 Thread bussiere bussiere
i've got a python.txt that contain python and it must stay as it (python.txt) how can i include it in my program ? import python.txt doesn't work is there a way : a) to make an include("python.txt") b) tell him to treat .txt as .py file that i can make an import python ? i'am using python3 Regards

Re: accessing a text file

2010-09-05 Thread Zhu Sha Zang
Em 05-09-2010 19:06, Alexander Kapps escreveu: > Baba wrote: >> level: beginner >> >> how can i access the contents of a text file in Python? >> >> i would like to compare a string (word) with the content of a text >> file (word_list). i want to see if word is in word_list. let's assume >> the TXT

Re: doctest annoyance/puzzle

2010-09-05 Thread Steven D'Aprano
On Sun, 05 Sep 2010 18:41:15 +0200, Stefan Schwarzer wrote: > Hi Steven, > > On 2010-09-05 17:30, Steven D'Aprano wrote: >> I run the doctests with: >> >> python2.6 -m doctest examples.txt >> >> and the first example passes, but the second fails with NameError: >> make_spam not defined. > > I

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Carl Banks
On Sep 5, 1:19 pm, Spencer Pearson wrote: > Hi! I'm writing a package with several files in it, and I've found > that "isinstance" doesn't work the way I expect under certain > circumstances. > > Short example: here are two files. > # fileone.py > import filetwo > > class AClass( object ): >   pas

Re: include a file in a python program

2010-09-05 Thread Steven D'Aprano
On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote: > i've got a python.txt that contain python and it must stay as it > (python.txt) Why? Is it against the law to change it? *wink* > how can i include it in my program ? > import python.txt doesn't work You could write a custom impor

Re: include a file in a python program

2010-09-05 Thread Roy Smith
In article , bussiere bussiere wrote: > i've got a python.txt that contain python and it must stay as it (python.txt) > > how can i include it in my program ? > import python.txt doesn't work > is there a way : > a) to make an include("python.txt") > b) tell him to treat .txt as .py file that i

Re: include a file in a python program

2010-09-05 Thread Roy Smith
In article <4c8423d3$0$28657$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > fp = open("python.txt") > text = fp.read() > fp.close() > exec(text) > But keep in mind that the contents of python.txt will be executed as if > you had typed it yourself. If you don't trust the source with your

Re: include a file in a python program

2010-09-05 Thread MRAB
On 05/09/2010 23:57, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) how can i include it in my program ? import python.txt doesn't work is there a way : a) to make an include("python.txt") b) tell him to treat .txt as .py file that i can ma

Re: include a file in a python program

2010-09-05 Thread Terry Reedy
On 9/5/2010 6:57 PM, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) If you are working for someone who is such an idiot as to impose such a condition on you, you have our condolences. how can i include it in my program ? import python.

Re: include a file in a python program

2010-09-05 Thread Terry Reedy
On 9/5/2010 7:12 PM, Steven D'Aprano wrote: fp = open("python.txt") text = fp.read() fp.close() exec(text) But keep in mind that the contents of python.txt will be executed as if you had typed it yourself. If you don't trust the source with your life (or at least with the contents of your compu

Re: include a file in a python program

2010-09-05 Thread Steven D'Aprano
On Mon, 06 Sep 2010 00:27:13 +0100, MRAB wrote: > import imp > python = imp.load_source("python", "python.txt") Nice! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Dave Angel
On 2:59 PM, Carl Banks wrote: On Sep 5, 1:19 pm, Spencer Pearson wrote: Hi! I'm writing a package with several files in it, and I've found that "isinstance" doesn't work the way I expect under certain circumstances. Short example: here are two files. # fileone.py import filetwo class AClass(

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
On Sep 5, 6:56 pm, Peter Otten <__pete...@web.de> wrote: > Does it have to be gio.FileMonitor? pyinotify can automatically add new > subdirectories out of the box. Well, since it's for a core part of the software, I'd like it to be cross platform — not in the sense of Windows/Mac, but FreeBSD, Sol

Re: Question about Reading Files

2010-09-05 Thread genxtech
On Sep 5, 4:16 am, Peter Otten <__pete...@web.de> wrote: > genxtech wrote: > > Hello.  I am still really new to python and I have a project where I > > am trying to use the data files from another program and write a new > > program with new user interface and all.  My first step was to open > > on

Re: Subclassing by monkey-patching

2010-09-05 Thread Jason
On Sep 6, 8:57 am, Jason wrote: > But it's looking more and more like I should give up > that particular goal. ...but on the other hand I just knocked together a pyinotify threaded watch system in about 50 lines. It's tempting to tell users of other platforms to write their own and submit a p

Re: Class changes in circular imports when __name__ == '__main__'

2010-09-05 Thread Carl Banks
On Sep 5, 5:07 pm, Dave Angel wrote: > On 2:59 PM, Carl Banks wrote: > > All of this gets a lot more complicated when packages are involved. > > Perhaps a better answer would be to import __main__ from the second module. Then what if the module is imported from a different script? It'll try to i

MAKE UPTO $5000 P/M $2000 IN FIRST 30 DAYS! NO INV

2010-09-05 Thread jameser
MAKE UPTO $5000 P/M $2000 IN FIRST 30 DAYS! NO INV Generate $50 to $100 whenever you have a couple of hours free time to spare. You could make $50 or more in the next 2 hours. Starting right Now!Today! GET PAID TO: Take online surveys and make from $5 to $75, or more Participate in focus groups a