Re: Implementing file reading in C/Python

2009-01-09 Thread Rhamphoryncus
On Jan 9, 2:14 pm, Marc 'BlackJack' Rintsch wrote: > On Fri, 09 Jan 2009 15:34:17 +, MRAB wrote: > > Marc 'BlackJack' Rintsch wrote: > > >> def iter_max_values(blocks, block_count): > >>     for i, block in enumerate(blocks): > >>         histogram = defaultdict(int) > >>         for byte in b

Re: multiprocessing and SIGINT

2009-01-09 Thread Gabriel Genellina
En Fri, 09 Jan 2009 03:04:58 -0200, akineko escribió: (2) test program with multiprocessing Both processes receives SIGINT. OS apparently distributes the SIGINT event to processes associated with the terminal. Yes, to avoid that, the child process has to detach itself from the terminal. I'd

Re: Free Download - Microsoft Windows 7 Beta

2009-01-09 Thread M�ta-MCI (MVP)
Hi! I downloaded W7 two days ago, directly on MSDN (Microsoft), and not on a bizarre, unknown site, and doubtful. Python 2.6 run OK. But the problem (well known) with Python 2.6.1 is always present. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Mocking `from foo import *` functions

2009-01-09 Thread hsoft
On Jan 10, 4:21 am, Silfheed wrote: > So I'm in the current testing situation: > > sender.py: > - > def sendEmails(): >    return "I send emails" > > alerter.py: > - > from sender import * > def DoStuffAndSendEmails(): >   doStuff() >   sendEmails() > > I'm trying to write

Re: Detecting open files and forcing closure

2009-01-09 Thread Rhodri James
On Sat, 10 Jan 2009 03:06:03 -, Andrew Robert wrote: The usual scenario is that a user will leave a PDF open and then go home for the evening. They are simply viewing and not modifying the file. When the XCOPY executes, it signals a failure and subsequent scheduler job abend. What

Re: "python -3" not working as expected

2009-01-09 Thread John Machin
On Jan 10, 2:55 pm, Benjamin wrote: > On Jan 8, 11:35 pm, John Machin wrote: > > > Actually, don't bother now; I've fixed it up in the trunk. > > > Would you mind giving a pointer to where or what your fix is? The > > reason for asking is that Thorsten's suggestion is ambiguous: warn > > about s

Re: "python -3" not working as expected

2009-01-09 Thread Benjamin
On Jan 8, 11:35 pm, John Machin wrote: > On Jan 9, 1:56 pm, Benjamin wrote: > > > On Jan 8, 4:21 pm, Thorsten Kampe wrote: > > > > * Terry Reedy (Thu, 08 Jan 2009 17:04:04 -0500) > > > > Since you are, I believe, at least the second person to report being bit > > > > by this confusion, please op

Re: Mocking `from foo import *` functions

2009-01-09 Thread Rob Williscroft
Silfheed wrote in news:c73b304b-f601-4bb5-89c1-3ee667eeb7d9 @l37g2000vba.googlegroups.com in comp.lang.python: > So I'm in the current testing situation: > > sender.py: > - > def sendEmails(): >return "I send emails" > > alerter.py: > - > from sender import * > def Do

Re: Common path all PyObjects take on destruction?

2009-01-09 Thread Carl Banks
On Jan 9, 6:39 pm, Ryan Stutsman wrote: > I've added a field to all PyObjects in the interpreter which is of type > PyObject*.  Most of the time this pointer is NULL but occassionally I > want to track some information in there.  The problem I'm running into > is that I can add a reference to a Py

Re: Mocking `from foo import *` functions

2009-01-09 Thread MRAB
Silfheed wrote: So I'm in the current testing situation: sender.py: - def sendEmails(): return "I send emails" alerter.py: - from sender import * def DoStuffAndSendEmails(): doStuff() sendEmails() I'm trying to write a test fn that will test DoStuffAndSendEmails(

Mocking `from foo import *` functions

2009-01-09 Thread Silfheed
So I'm in the current testing situation: sender.py: - def sendEmails(): return "I send emails" alerter.py: - from sender import * def DoStuffAndSendEmails(): doStuff() sendEmails() I'm trying to write a test fn that will test DoStuffAndSendEmails() (as well as it's

Re: why cannot assign to function call

2009-01-09 Thread rurpy
Rhodri James wrote: > On Sat, 10 Jan 2009 00:21:27 -, wrote: >> IIRC, Someone posted here that his experience was >> that 12-year old kids (presumably without programming >> experience) had no problem with Python and references >> when described as "names given to an object". (From >> memory,

Re: Jython 2.5 Beta1 Released!

2009-01-09 Thread Matthew Nuzum
On Fri, Jan 9, 2009 at 3:37 PM, Frank Wierzbicki wrote: > On behalf of the Jython development team, I'm pleased to announce that > Jython 2.5b1 is available for download: > http://downloads.sourceforge.net/jython/jython_installer-2.5b1.jar. > See the installation instructions here: > http://www.jy

Re: Detecting open files and forcing closure

2009-01-09 Thread Andrew Robert
MRAB wrote: Andrew Robert wrote: Hi Everyone, We have a process that does a copy of a share from one location to another. This usually works fine but can occasionally bomb if a file is opened by a user somewhere. Is there a way to code detection of open files and force a close? The files in

Re: Detecting open files and forcing closure

2009-01-09 Thread MRAB
Andrew Robert wrote: Hi Everyone, We have a process that does a copy of a share from one location to another. This usually works fine but can occasionally bomb if a file is opened by a user somewhere. Is there a way to code detection of open files and force a close? The files in question are

Re: why cannot assign to function call

2009-01-09 Thread rurpy
Mark Wooding wrote: > ru...@yahoo.com wrote: > >> If one accepts that there are a "lot" of people who post in here that >> clearly are surprised by Python's assignment semantics, > > But one should not accept that. One might accept that there are many > who post who claim that they are surprised

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Steven D'Aprano wrote: > Er, perhaps you missed that I was replying to Joe Strout. Yes, evidently. My apologies for the mix up! -- [mdw], who obviously should put the keyboard down now. -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Joe Strout wrote: > No, actually, that was me. rurpy's list was something like C, FORTRAN, > Perl, and VBA. My mistake -- I failed to read the quoting properly. Apologies to all. We still dealt with C. Fortran (to give it its modern spelling) has a similar data model to C, but passes argume

Re: why cannot assign to function call

2009-01-09 Thread Rhodri James
On Sat, 10 Jan 2009 00:21:27 -, wrote: Joe Strout wrote: ru...@yahoo.com wrote: [snip] Pointers are passed and assigned by value, just as other types (disputedly except arrays) are. One can then use that pointer to manually effect pass-(the-value-pointed-to)-by-reference, or sharing, e

Detecting open files and forcing closure

2009-01-09 Thread Andrew Robert
Hi Everyone, We have a process that does a copy of a share from one location to another. This usually works fine but can occasionally bomb if a file is opened by a user somewhere. Is there a way to code detection of open files and force a close? The files in question are typically PDF files

Re: download timeout vs. socket timeout

2009-01-09 Thread MRAB
p. wrote: i'm using urllib2 in python 2.4 wondering how people typically deal with the case in which a download is too slow. setting the socket timeout only covers those cases where there is no response in the socket for whatever the timeout period is. what if, however, i'm getting bits back but

Re: download timeout vs. socket timeout

2009-01-09 Thread Gabriel Genellina
En Sat, 10 Jan 2009 00:07:15 -0200, p. escribió: i'm using urllib2 in python 2.4 wondering how people typically deal with the case in which a download is too slow. setting the socket timeout only covers those cases where there is no response in the socket for whatever the timeout period is. wh

download timeout vs. socket timeout

2009-01-09 Thread p.
i'm using urllib2 in python 2.4 wondering how people typically deal with the case in which a download is too slow. setting the socket timeout only covers those cases where there is no response in the socket for whatever the timeout period is. what if, however, i'm getting bits back but want simply

Re: Python 2.6 fails on compiling > Bug report

2009-01-09 Thread googler . 1 . webmaster
Hi! :) >Sorry, there were a few line wrap-arounds in the diff file due to long >lines but the changes for the four significant lines should be easy to >do manually. Hadn't done that before but I found a ressource how to read that syntax. x86_64 would be enough. i test that again. Thank you. :) -

Re: Python 2.6 fails on compiling > Bug report

2009-01-09 Thread Ned Deily
In article , googler.1.webmas...@spamgourmet.com wrote: > May the diff file is wrong? on my system it doesn't work. > Well, set the -enable-universalsdk= path occurs that error. Sorry, there were a few line wrap-arounds in the diff file due to long lines but the changes for the four significant

Re: Implementing file reading in C/Python

2009-01-09 Thread John Machin
On Jan 9, 9:56 pm, mk wrote: > The factor of 30 indeed does not seem right -- I have done somewhat > similar stuff (calculating Levenshtein distance [edit distance] on words > read from very large files), coded the same algorithm in pure Python and > C++ (using linked lists in C++) and Python ver

Re: why cannot assign to function call

2009-01-09 Thread Grant Edwards
On 2009-01-10, Joe Strout wrote: > Mark Wooding wrote: > >> As an aside, I don't notice anywhere near as much confusion in Lisp and >> Scheme groups, which might be surprising since Lisp and Scheme have >> precisely the same data model, argument passing convention, and >> assignment semantics, as

Re: why cannot assign to function call

2009-01-09 Thread Steven D'Aprano
On Fri, 09 Jan 2009 21:03:39 +, Mark Wooding wrote: > Steven D'Aprano wrote: > >> Python doesn't do the same thing as C. It actually passes the same >> value to the function, without copying it. >> >> Why oh why do you keep insisting that Python is no different from C? > > I'm beginning to

how to remove 'FFFD' character

2009-01-09 Thread webcomm
Does anyone know a way to remove the 'FFFD' character with python? You can see the browser output I'm dealing with here: http://webcomm.webfactional.com/htdocs/fffd.JPG I deleted a big chunk out of the middle of that JPG to protect sensitive data. I don't know what the character encoding of this

Re: Python 2.6 fails on compiling > Bug report

2009-01-09 Thread googler . 1 . webmaster
hi, thanks for your help. May the diff file is wrong? on my system it doesn't work. Well, set the -enable-universalsdk= path occurs that error. Hmm. that is really a disaster, isn't it :( hm. -- http://mail.python.org/mailman/listinfo/python-list

Common path all PyObjects take on destruction?

2009-01-09 Thread Ryan Stutsman
I've added a field to all PyObjects in the interpreter which is of type PyObject*. Most of the time this pointer is NULL but occassionally I want to track some information in there. The problem I'm running into is that I can add a reference to a PyObject inside any of my PyObjects, but it seems

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread John Machin
On Jan 10, 9:52 am, webcomm wrote: > On Jan 9, 5:21 pm, John Machin wrote: > > > Thanks. Would you mind spending a few minutes more on this so that we > > can see if it's a problem that can be fixed easily, like the one that > > Chris Mellon reported? > > Don't mind at all.  I'm now working with

Re: spawning pyhon apps...

2009-01-09 Thread Mark Wooding
bruce wrote: > toying with an idea.. trying to figure out a good/best way to spawn > multiple python scripts from a parent python app. i'm trying to figure > out how to determine when all child apps have completed, or to > possibly determine if any of the child processes have died/halted.. You d

Re: why cannot assign to function call

2009-01-09 Thread Benjamin Kaplan
On Fri, Jan 9, 2009 at 7:11 PM, Joe Strout wrote: > Mark Wooding wrote: > > > .NET isn't a language at all: >> rather, it's a virtual machine, runtime system, class library and family >> of languages each of which may have idiosyncratic semantics. >> > > But they don't, AFAIK -- they all have th

Re: why cannot assign to function call

2009-01-09 Thread rurpy
Joe Strout wrote: > ru...@yahoo.com wrote: > >>> I never claimed that you *couldn't* have copy semantics in C; you can do >>> almost anything you want in C (or C++). But the *normal* usage of an >>> array is via a pointer, in which case the semantics are exactly the same >>> as in Python, Java, RE

Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
Mark Wooding wrote: As an aside, I don't notice anywhere near as much confusion in Lisp and Scheme groups, which might be surprising since Lisp and Scheme have precisely the same data model, argument passing convention, and assignment semantics, as Python has. Nor is there anywhere near as muc

Re: spawning pyhon apps...

2009-01-09 Thread Jason Scheirer
On Jan 9, 4:07 pm, "bruce" wrote: > thanks jason > > or i could also, simply iterate through a loop of the names of the "child > processes" i want to spawn, using the names in the subprocess.popen, and > then proceeding with the rest of your example.. > > question though... if i have a child a

Re: Problem with -3 switch

2009-01-09 Thread John Machin
On Jan 10, 6:58 am, Carl Banks wrote: > On Jan 9, 12:36 pm, "J. Cliff Dyer" wrote: > > > > > > > On Fri, 2009-01-09 at 13:13 -0500, Steve Holden wrote: > > > Aivar Annamaa wrote: > > > >> As was recently pointed out in a nearly identical thread, the -3 > > > >> switch only points out problems tha

RE: spawning pyhon apps...

2009-01-09 Thread bruce
thanks jason or i could also, simply iterate through a loop of the names of the "child processes" i want to spawn, using the names in the subprocess.popen, and then proceeding with the rest of your example.. question though... if i have a child app that's hanging.. how do i kill it. or is th

Re: Why can't I store a DLL in a module library Zip file?

2009-01-09 Thread Martin v. Löwis
> It's almost like shared libraries are disallowed from the module > library Zip format. Correct. That's a limitation of the Windows operating system, which can load DLLs only from plain, regular files. Python can load .py files from zip files because it implements the loading itself. For DLL load

Re: spawning pyhon apps...

2009-01-09 Thread Jason Scheirer
On Jan 9, 3:43 pm, "bruce" wrote: > hi jason > > forgive me... but in your sample: >         my_popenobjects = [subprocess.Popen("foo.py", "--filename=file >         %i.txt"%x) for x in xrange(10)] > are you spawning 'foo.py' 10 times? that can't be right! > so just what is "foo.py" used for?

Why can't I store a DLL in a module library Zip file?

2009-01-09 Thread Uberman
I'm using Python 2.5.1, and I'm trying to use the module library as a Zip file (for example, with python25_d.dll, the module library file would be called python25_d.zip). This works for the basic modules that come with Python (os, sys, site, etc.), and it even seems to work when I place my own Pyt

Re: spawning pyhon apps...

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 3:43 PM, bruce wrote: > hi jason > > forgive me... but in your sample: >my_popenobjects = [subprocess.Popen("foo.py", "--filename=file >%i.txt"%x) for x in xrange(10)] > are you spawning 'foo.py' 10 times? that can't be right! Indeed, it probably ought t

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread MRAB
MRAB wrote: webcomm wrote: On Jan 8, 8:39 pm, "James Mills" wrote: Send us a sample of this file in question... Here's a sample with some dummy data from the web service: http://webcomm.webfactional.com/htdocs/data.zip That's the zip created in this line of my code... f = open('data.zip', '

Re: Python 2.6 fails on compiling > Bug report

2009-01-09 Thread Ned Deily
In article <07832575-9b98-4a03-a181-4470a5a00...@35g2000pry.googlegroups.com>, googler.1.webmas...@spamgourmet.com wrote: > hm... any ideas? Have you tried specifying one of the universal SDKs, i.e. /Developer/SDKs/MacOSX10.n.sdk? That's what the "official" python.org builds do. The build s

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
ru...@yahoo.com wrote: > If one accepts that there are a "lot" of people who post in here that > clearly are surprised by Python's assignment semantics, But one should not accept that. One might accept that there are many who post who claim that they are surprised by Python's assignment semant

RE: spawning pyhon apps...

2009-01-09 Thread bruce
hi jason forgive me... but in your sample: my_popenobjects = [subprocess.Popen("foo.py", "--filename=file %i.txt"%x) for x in xrange(10)] are you spawning 'foo.py' 10 times? that can't be right! so just what is "foo.py" used for? what am i missing... it looks like the my_popen

Re: spawning pyhon apps...

2009-01-09 Thread Jason Scheirer
On Jan 9, 2:47 pm, "bruce" wrote: > hi... > > toying with an idea.. trying to figure out a good/best way to spawn multiple > python scripts from a parent python app. i'm trying to figure out how to > determine when all child apps have completed, or to possibly determine if > any of the child proce

Re: redirecting stderr back..

2009-01-09 Thread rh0dium
On Jan 9, 3:42 pm, Robert Kern wrote: > Christian Heimes wrote: > > rh0dium schrieb: > >> Hi All, > > >> Can someone tell me how to redirect stderr back to the console once > >> you've moved it? > > > sys.stderr = sys.__stderr__ > > > or better: > > > orig_stderr = sys.stderr > > try: > >     sys.

Re: multiprocessing vs thread performance

2009-01-09 Thread Gabriel Genellina
En Wed, 07 Jan 2009 23:05:53 -0200, James Mills escribió: Does anybody know any tutorial for python 2.6 multiprocessing? Or bunch of good example for it? I am trying to break a loop to run it over multiple core in a system. And I need to return an integer value as the result of the proce

Re: redirecting stderr back..

2009-01-09 Thread rh0dium
On Jan 9, 3:52 pm, Christian Heimes wrote: > Robert Kern schrieb: > > > > > Christian Heimes wrote: > >> rh0dium schrieb: > >>> Hi All, > > >>> Can someone tell me how to redirect stderr back to the console once > >>> you've moved it? > > >> sys.stderr = sys.__stderr__ > > >> or better: > > >> ori

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread MRAB
webcomm wrote: On Jan 8, 8:39 pm, "James Mills" wrote: Send us a sample of this file in question... Here's a sample with some dummy data from the web service: http://webcomm.webfactional.com/htdocs/data.zip That's the zip created in this line of my code... f = open('data.zip', 'wb') If I op

Re: spawning pyhon apps...

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 2:47 PM, bruce wrote: > hi... > > toying with an idea.. trying to figure out a good/best way to spawn multiple > python scripts from a parent python app. i'm trying to figure out how to > determine when all child apps have completed, or to possibly determine if > any of the

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread John Machin
On Jan 10, 8:56 am, webcomm wrote: > On Jan 9, 4:12 pm, "Chris Mellon" wrote: > > > It would really help if you could post a sample file somewhere. > > Here's a sample with some dummy data from the web > service:http://webcomm.webfactional.com/htdocs/data.zip > > That's the zip created in this l

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread webcomm
On Jan 9, 5:21 pm, John Machin wrote: > Thanks. Would you mind spending a few minutes more on this so that we > can see if it's a problem that can be fixed easily, like the one that > Chris Mellon reported? > Don't mind at all. I'm now working with a zip file with some dummy data I downloaded fr

Re: redirecting stderr back..

2009-01-09 Thread Christian Heimes
Robert Kern schrieb: > Christian Heimes wrote: >> rh0dium schrieb: >>> Hi All, >>> >>> Can someone tell me how to redirect stderr back to the console once >>> you've moved it? >> >> sys.stderr = sys.__stderr__ >> >> or better: >> >> orig_stderr = sys.stderr >> try: >> sys.stderr = open(...) >>

spawning pyhon apps...

2009-01-09 Thread bruce
hi... toying with an idea.. trying to figure out a good/best way to spawn multiple python scripts from a parent python app. i'm trying to figure out how to determine when all child apps have completed, or to possibly determine if any of the child processes have died/halted.. parent app spawn chi

Re: redirecting stderr back..

2009-01-09 Thread Robert Kern
Christian Heimes wrote: rh0dium schrieb: Hi All, Can someone tell me how to redirect stderr back to the console once you've moved it? sys.stderr = sys.__stderr__ or better: orig_stderr = sys.stderr try: sys.stderr = open(...) ... finally: sys.stderr = orig_stderr He's not reas

Re: redirecting stderr back..

2009-01-09 Thread Christian Heimes
rh0dium schrieb: > Hi All, > > Can someone tell me how to redirect stderr back to the console once > you've moved it? sys.stderr = sys.__stderr__ or better: orig_stderr = sys.stderr try: sys.stderr = open(...) ... finally: sys.stderr = orig_stderr Christian -- http://mail.python.o

redirecting stderr back..

2009-01-09 Thread rh0dium
Hi All, Can someone tell me how to redirect stderr back to the console once you've moved it? import os,sys se = os.open("/tmp/mod.log", os.O_WRONLY|os.O_APPEND|os.O_CREAT) sys.stderr.write("Foobar\n") Foobar os.dup2(se, 2) cmds = os.popen("ls alaksjdf") sys.stderr.write("Foobar\n") Foobar An

redirecting stderr back..

2009-01-09 Thread rh0dium
Hi All, Can someone tell me how to redirect stderr back to the console once you've moved it? import os,sys se = os.open("/tmp/mod.log", os.O_WRONLY|os.O_APPEND|os.O_CREAT) sys.stderr.write("Foobar\n") Foobar os.dup2(se, 2) cmds = os.popen("ls alaksjdf") sys.stderr.write("Foobar\n") Foobar An

Re: Implementing file reading in C/Python

2009-01-09 Thread Grant Edwards
On 2009-01-09, Marc 'BlackJack' Rintsch wrote: > On Fri, 09 Jan 2009 15:34:17 +, MRAB wrote: > >> Marc 'BlackJack' Rintsch wrote: >> >>> def iter_max_values(blocks, block_count): >>> for i, block in enumerate(blocks): >>> histogram = defaultdict(int) >>> for byte in block:

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread John Machin
On Jan 10, 2:22 am, webcomm wrote: > On Jan 9, 5:42 am, John Machin wrote: > > > And here's a little gadget that might help the diagnostic effort; it > > shows the archive size and the position of all the "magic" PKnn > > markers. In a "normal" uncommented archive, EndArchive_pos + 22 == > > arch

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread webcomm
On Jan 9, 5:00 pm, webcomm wrote: > If I unzip it like this... > popen("unzip data.zip") > ...then the bad characters are 'FFFD' characters as described and > pictured > here...http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > trying again to post the link re: FFFD chara

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread webcomm
On Jan 8, 8:39 pm, "James Mills" wrote: > Send us a sample of this file in question... Here's a sample with some dummy data from the web service: http://webcomm.webfactional.com/htdocs/data.zip That's the zip created in this line of my code... f = open('data.zip', 'wb') If I open the file it co

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 4:12 pm, "Chris Mellon" wrote: > It would really help if you could post a sample file somewhere. Here's a sample with some dummy data from the web service: http://webcomm.webfactional.com/htdocs/data.zip That's the zip created in this line of my code... f = open('data.zip', 'wb') If I

Re: drive a desktop app from python?

2009-01-09 Thread Ricardo Aráoz
James Stroud wrote: > Tim Arnold wrote: >> Hi, I don't even know what to google for on this one. I need to drive >> a commercial desktop app (on windows xp) since the app doesn't have a >> batch interface. It's intended to analyze one file at a time and >> display a report. >> >> I can get the thi

Re: Printed Documentation

2009-01-09 Thread Robert Kern
Tim Arnold wrote: just a datapoint, but I used lulu.com to print the latex sources (525 pages) hardbound for a cost of $25 US. Did they handle the LaTeX fonts well? The last time I looked at Lulu, they claimed that there were some font issues with PDFs made by LaTeX. -- Robert Kern "I have

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Steven D'Aprano wrote: > Python doesn't do the same thing as C. It actually passes the same value > to the function, without copying it. > > Why oh why do you keep insisting that Python is no different from C? I'm beginning to think that you're not bothing to read what I'm writing, but I'll as

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Jan 2009 15:34:17 +, MRAB wrote: > Marc 'BlackJack' Rintsch wrote: > >> def iter_max_values(blocks, block_count): >> for i, block in enumerate(blocks): >> histogram = defaultdict(int) >> for byte in block: >> histogram[byte] += 1 >> >>

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Chris Mellon
On Fri, Jan 9, 2009 at 3:08 PM, Chris Mellon wrote: > On Fri, Jan 9, 2009 at 2:32 PM, webcomm wrote: >> On Jan 9, 3:15 pm, Steve Holden wrote: >>> webcomm wrote: >>> > Hi, >>> > In python, is there a distinction between unzipping bytes and >>> > unzipping a binary file to which those bytes have

Re: string split

2009-01-09 Thread Leland
On Jan 9, 12:57 pm, "Jerry Hill" wrote: > On Fri, Jan 9, 2009 at 3:39 PM, Benjamin Kaplan > > > This looks like a CSV file to me. If that is the case, it is easier to use > > the built-in csv module than to try to write your own parser. > > It should be as easy as this: > > import csv > > testfile

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Chris Mellon
On Fri, Jan 9, 2009 at 2:32 PM, webcomm wrote: > On Jan 9, 3:15 pm, Steve Holden wrote: >> webcomm wrote: >> > Hi, >> > In python, is there a distinction between unzipping bytes and >> > unzipping a binary file to which those bytes have been written? >> >> > The following code is, I think, an exa

Re: Where's Psyco now?

2009-01-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Jan 2009 12:37:38 -0800, Roger wrote: > If that's the case where's the point of diminishing returns on using > psyco? Why would it not be useful in a general setting? There is some overhead involved with the runtime analysis and compiling. Functions that are only called once usually

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Aaron Brady wrote: > Possible compromise. You can think of functions as mutation-only. > You pass the object, and it gets a new (additional) name. The old > name doesn't go in. Huh? That doesn't explain circular data structures at all, unless your idea of `name' is unrelated to the identifi

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-09 Thread Terry Reedy
Bruno Desthuilliers wrote: To be more exact: there's no "default __nonzero__". In Py3, '__nonzero__' has been renamed to __bool__. All objects are instances of class object, which indeed has no __bool__ method to be a default (it does have default __hash__ and __eq__, etc). > The boolean val

Re: string split

2009-01-09 Thread Jerry Hill
On Fri, Jan 9, 2009 at 3:39 PM, Benjamin Kaplan > This looks like a CSV file to me. If that is the case, it is easier to use > the built-in csv module than to try to write your own parser. It should be as easy as this: import csv testfile = open('testfile.csv', 'w') testdata = """100-01001-001,"

Re: string split

2009-01-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Jan 2009 12:39:22 -0800, Leland wrote: > It seems work this way, but is there more elegant way to do this? Yes, the `csv` module in the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread John Machin
On Jan 10, 5:32 am, Scott David Daniels wrote: > webcomm wrote: > >  I tried Scott's getzip() function yesterday... I > > stumbled upon it in my searches.  It didn't seem to help in my case, > > though it did produce a different error:  ValueError, substring not > > found.  Not sure what that

Re: string split

2009-01-09 Thread Benjamin Kaplan
On Fri, Jan 9, 2009 at 3:26 PM, Leland wrote: > Hi, > > I have some formatted strings that I'd like to split and get the > meaningful data, here is the example of the string format. The big > difference of these two line are the second double quote set at the > second line > 100-01001-001,"Diode,

string split

2009-01-09 Thread Leland
Hi, I have some formatted strings that I'd like to split and get the meaningful data, here is the example of the string format. The big difference of these two line are the second double quote set at the second line 100-01001-001,"Diode,Small Signal,SOT-23",1,D46, 100-01004-001,"Diode,High Voltage

Re: Where's Psyco now?

2009-01-09 Thread Roger
On Jan 9, 2:21 pm, "Chris Rebert" wrote: > On Fri, Jan 9, 2009 at 10:41 AM, Vicent wrote: > > Hello. This is my first message to the list. > > > In this article written in 2002 > > >http://www.ibm.com/developerworks/library/l-psyco.html > > > they talk about Psyco as a module that makes it possib

string split

2009-01-09 Thread Leland
Hi, I have some formatted strings that I'd like to split and get the meaningful data, here is the example of the string format. The big difference of these two line are the second double quote set at the second line 100-01001-001,"Diode,Small Signal,SOT-23",1,D46, 100-01004-001,"Diode,High Voltage

Re: mac osx how to use a specific python environment

2009-01-09 Thread Markus Falb
On Wed, 07 Jan 2009 10:07:18 -0500, Philip Semanchuk wrote: > On Jan 7, 2009, at 7:27 AM, marco kuhn wrote: > >> hi, >> >> I would like to use a specific python environment in a script . The >> script is load as a plugin by a program which offer a python api . The >> python environment is build i

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 3:15 pm, Steve Holden wrote: > webcomm wrote: > > Hi, > > In python, is there a distinction between unzipping bytes and > > unzipping a binary file to which those bytes have been written? > > > The following code is, I think, an example of writing bytes to a file > > and then unzipping..

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
[Sigh. I must apologize for the length of this article. I can't, alas, see a satisfactory way of trimming it. The doubly-quoted stuff later on was by me.] Steven D'Aprano wrote: > I'm pretty sure that no other pure-Python coder has manipulated > references either. They've manipulated objects

RE: Python Apache Handler

2009-01-09 Thread Sells, Fred
Mod_python works, but if you are doing anything significant look into one of the many frameworks like turbogears or django. More structure to learn but less code when all is said and done. > -Original Message- > From: python-list-bounces+frsells=adventistcare@python.org > [mailto:pyth

Re: why cannot assign to function call

2009-01-09 Thread Joe Strout
ru...@yahoo.com wrote: I never claimed that you *couldn't* have copy semantics in C; you can do almost anything you want in C (or C++). But the *normal* usage of an array is via a pointer, in which case the semantics are exactly the same as in Python, Java, REALbasic, .NET, etc. Arrays are th

string split

2009-01-09 Thread Leland
Hi, I have some formatted strings that I'd like to split and get the meaningful data, here is the example of the string format. The big difference of these two line are the second double quote set at the second line 100-01001-001,"Diode,Small Signal,SOT-23",1,D46, 100-01004-001,"Diode,High Voltage

Re: BadZipfile "file is not a zip file"

2009-01-09 Thread webcomm
On Jan 9, 1:32 pm, Scott David Daniels wrote: > I'd certainly try to figure out if the archive was mis-handled > somewhere along the way.   Quite possible that I'm mishandling something, or the service provider is mishandling something. Probably the former. Please see this more recent thread...

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread MRAB
webcomm wrote: Hi, In python, is there a distinction between unzipping bytes and unzipping a binary file to which those bytes have been written? Python's zipfile module can only read and write zip files; it can't compress or decompress data as a bytestring. The following code is, I think, an

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread Steve Holden
webcomm wrote: > Hi, > In python, is there a distinction between unzipping bytes and > unzipping a binary file to which those bytes have been written? > > The following code is, I think, an example of writing bytes to a file > and then unzipping... > > decoded = base64.b64decode(datum) > #datum i

Re: why cannot assign to function call

2009-01-09 Thread rurpy
Joe Strout wrote: > ru...@yahoo.com wrote: > a = array (1,2,3) b = a a[1] = 4 print b C, C++, VBA, Fortran, Perl: 1, 2, 3 Python: 1, 4, 3 >>> You are mistaken >> >> I don't think so. >> See http://groups.google.com/group/comp.lang.python/msg/f99d5a0d8f86

Re: Problem with -3 switch

2009-01-09 Thread Carl Banks
On Jan 9, 12:36 pm, "J. Cliff Dyer" wrote: > On Fri, 2009-01-09 at 13:13 -0500, Steve Holden wrote: > > Aivar Annamaa wrote: > > >> As was recently pointed out in a nearly identical thread, the -3 > > >> switch only points out problems that the 2to3 converter tool can't > > >> automatically fix. C

Re: distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
On Jan 9, 2:49 pm, webcomm wrote: > decoded = base64.b64decode(datum) > #datum is a base64 encoded string of data downloaded from a web > service > f = open('data.zip', 'wb') > f.write(decoded) > f.close() > x = zipfile.ZipFile('data.zip', 'r') Sorry, that code is not what I mean to paste. This

distinction between unzipping bytes and unzipping a file

2009-01-09 Thread webcomm
Hi, In python, is there a distinction between unzipping bytes and unzipping a binary file to which those bytes have been written? The following code is, I think, an example of writing bytes to a file and then unzipping... decoded = base64.b64decode(datum) #datum is a base64 encoded string of data

Re: eval('07') works, eval('08') fails, why?

2009-01-09 Thread Grant Edwards
On 2009-01-09, Dennis Lee Bieber wrote: > On Thu, 08 Jan 2009 09:46:26 -0600, Grant Edwards > declaimed the following in comp.lang.python: > > >> Heathkit Z80 stuff used octal notation too. > > Octal worked well for the old 8080 and derivative processors as > there were only 7 registers and

Re: Implementing file reading in C/Python

2009-01-09 Thread Grant Edwards
On 2009-01-09, Sion Arrowsmith wrote: > Grant Edwards wrote: >>On 2009-01-09, Johannes Bauer wrote: >>> I've come from C/C++ and am now trying to code some Python because I >>> absolutely love the language. However I still have trouble getting >>> Python code to run efficiently. Right now I hav

Re: Where's Psyco now?

2009-01-09 Thread Chris Rebert
On Fri, Jan 9, 2009 at 10:41 AM, Vicent wrote: > Hello. This is my first message to the list. > > In this article written in 2002 > > http://www.ibm.com/developerworks/library/l-psyco.html > > they talk about Psyco as a module that makes it possible to accelerate > Python. > > Is it still a state-

Re: sftp with no password from python

2009-01-09 Thread Jorge Mazzonelli
You should try the paramiko package for that (http://www.lag.net/paramiko/) A google search on that package & SFTP got me this example: http://commandline.org.uk/python/sftp-python/ Cheers Jorge On Fri, Jan 9, 2009 at 1:20 PM, loial wrote: > On 8 Jan, 18:49, Mike Hjorleifsson wrote: > > On Ja

  1   2   3   >