Re: file seek is slow

2010-03-11 Thread CHEN Guang
Metalone wrote: > I just tried the seek test with Cython. > Cython fseek() : 1.059 seconds. 30% slower than 'C' > Python f.seek : 1.458 secondds. 80% slower than 'C'. > > It is amazing to me that Cython generates a 'C' file that is 1478 > lines. > PythoidC ( http://pythoidc.googlecode.com )

Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-11 Thread Paul Rubin
"Zooko O'Whielacronx" writes: > Every couple of years I run into a problem where some Python code that > worked well at small scales starts burning up my CPU at larger scales, > and the underlying issue turns out to be the idiom of accumulating > data by string concatenation. I usually use Strin

Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-11 Thread Martin v. Loewis
> I’m sorry everyone. I didn’t realise I had installed the 64-bit > version of Python. Well, at least someone else might find have the > same problem. But I think that there is going to be a bit of a rough > patch as everyone moves over to 64-bit. Expect that move to take a few more years. 64-bit

StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-11 Thread Zooko O'Whielacronx
Folks: Every couple of years I run into a problem where some Python code that worked well at small scales starts burning up my CPU at larger scales, and the underlying issue turns out to be the idiom of accumulating data by string concatenation. It just happened again (http://foolscap.lothar.com/t

execute bash builtins in python

2010-03-11 Thread alex goretoy
hi, i'm trying to write a section of my program that needs to run bash builtin alias and declare, i've googled and tried every type of example i could find no to avail. this is what I've tried below and it doesn't work, is there a way for me to execute a bah builin from python? what i need is to ta

Re: bypass UAC control through python script (to be run from batchfile)

2010-03-11 Thread Michel Claveau - MVP
Hi ! Install a resident soff (script) by task-planified, in Administrator rights. Then, call this script from current work, for bypass UAC. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: inspect.stack() and frame

2010-03-11 Thread Gabriel Genellina
En Thu, 11 Mar 2010 21:03:07 -0300, Félix-Antoine Fortin escribió: On Mar 11, 6:22 pm, "Alf P. Steinbach" wrote: * F lix-Antoine Fortin: > Given this code : > # Experience with frame > import sys > import inspect > def foo(): > stack = inspect.stack() > print "foo frame : " + str(he

ANNOUNCE: RSON v 0.02 available

2010-03-11 Thread Patrick Maupin
RSON (Readable Serial Object Notation) is a superset of JSON that is suitable for files that humans have to edit and diff. The current release is decoder-only, but the decoder will read files encoded by JSON encoders such as json or simplejson. The current release consists of a single Python modu

Any downsides to UPX-ing my 32-bit Python 2.6.4 EXE/PYD/DLL files?

2010-03-11 Thread python
Are there any downsides to UPX-ing my 32-bit Python 2.6.4 development environment EXE/PYD/DLL files? The reason I'm asking is that I frequently use a custom PY2EXE script that UPX's copies of these files on every build. Yes, I could get fancy and try to cache UPXed files, but I think a simpler, s

Re: Can't define __call__ within __init__?

2010-03-11 Thread Steven D'Aprano
On Thu, 11 Mar 2010 07:56:59 -0500, Neal Becker wrote: > The example I showed was just a toy problem. The real problem is I > expect to call a function many times, and I want to avoid the overhead > of the 'if blah' everytime. Unless the __call__ methods are very small, the overhead of one extra

Re: Can't define __call__ within __init__?

2010-03-11 Thread Steven D'Aprano
On Thu, 11 Mar 2010 08:20:14 -0800, Steve Howell wrote: >> (2) special methods like __call__ are only called on the class, not the >> instance, so you can't give each instance its own method. >> >> > Are you sure about that? This program prints 1, 2, 1, 2. The rules for classic classes are diffe

Re: Reverse engineering CRC?

2010-03-11 Thread Lawrence D'Oliveiro
In message <7vlamef7g...@mid.individual.net>, Gregory Ewing wrote: > I'm going by the fact that the application reports a > "CRC mismatch" when it's wrong. I can't be sure that what > it calls a "CRC" is really a true CRC, but it's more than > a simple sum, because changing one bit in the file res

Re: Reverse engineering CRC?

2010-03-11 Thread Lawrence D'Oliveiro
In message , Dave Angel wrote: > However, if there's anything in there about how to derive the polynomial > algorithm from (a few) samples I missed it entirely. Given that CRC is all just a sequence of xor operations, what happens if you xor various pairs of CRCs together, wouldn’t that cancel

Re: My four-yorkshireprogrammers contribution

2010-03-11 Thread Albert van der Horst
In article <7vdo8sfre...@mid.individual.net>, Gregory Ewing wrote: >MRAB wrote: > >> By the standards of just a few years later, that's not so much a >> microcomputer as a nanocomputer! > >Although not quite as nano as another design published >in EA a couple of years earlier, the EDUC-8: > > h

Re: Docstrings considered too complicated

2010-03-11 Thread Albert van der Horst
In article , Grant Edwards wrote: >On 2010-03-03, Grant Edwards wrote: >> On 2010-03-03, Gregory Ewing wrote: >>> Grant Edwards wrote: >>> Just a mediocre copy of the CP/M filesystem, which was in turn copied from DEC's RSTS or RSX. >>> >>> It was actually an improvement over CP/M's f

Re: file seek is slow

2010-03-11 Thread Steve Holden
Metalone wrote: > I just tried the seek test with Cython. > Cython fseek() : 1.059 seconds. 30% slower than 'C' > Python f.seek : 1.458 secondds. 80% slower than 'C'. > > It is amazing to me that Cython generates a 'C' file that is 1478 > lines. > And what response are you seeking to your amaze

Re: EOFError: EOF when reading a line

2010-03-11 Thread Gabriel Genellina
En Thu, 11 Mar 2010 06:12:02 -0300, Mihir Patel escribió: I am trying to use the subprocess to send the data to child process. I am not sure why i keep getting "EOFError: EOF when reading a line" command_line = 'python test_input.py' p =subprocess.Popen(command_line, shell=True, stdin=subpr

Re: inspect.stack() and frame

2010-03-11 Thread Félix-Antoine Fortin
On Mar 11, 6:22 pm, "Alf P. Steinbach" wrote: > * F lix-Antoine Fortin: > > > Given this code : > > # Experience with frame > > import sys > > import inspect > > > def foo(): > >     stack = inspect.stack() > >     print "foo frame : " + str(hex(id(sys._getframe( > > hex returns a string. appl

Re: pivot() equivalent

2010-03-11 Thread MRAB
gundlach wrote: I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in which this was argued t

Re: pivot() equivalent

2010-03-11 Thread John Posner
On 3/11/2010 6:16 PM, gundlach wrote: I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in

Re: Bluetooth

2010-03-11 Thread PythonAB
On 10 mrt 2010, at 16:17, Jeff Peck wrote: > On 3/7/2010 1:26 PM, PythonAB wrote: >> >> Hello, >> >> >> I'm writing a script that has to connect a bluetooth device >> with a 3D application. >> On my search for a bluetooth module i ran into this: >> http://www.python.org/download/releases/2.4/n

Re: inspect.stack() and frame

2010-03-11 Thread Alf P. Steinbach
* Félix-Antoine Fortin: Given this code : # Experience with frame import sys import inspect def foo(): stack = inspect.stack() print "foo frame : " + str(hex(id(sys._getframe( hex returns a string. applying str is therefore redundant. def foo2(): inspect.stack() print "f

Re: Parsing Email Headers

2010-03-11 Thread T
Thanks for your suggestions! Here's what seems to be working - it's basically the same thing I originally had, but first checks to see if the line is blank response, lines, bytes = M.retr(i+1) # For each line in message for line in lines:

pivot() equivalent

2010-03-11 Thread gundlach
I *know* this already exists, but I can't remember where: def pivot(func, seq): # I know, a good implementation shouldn't call func() twice per item return ( (x for x in seq if func(x)), (x for x in seq if not func(x)) ) I feel like I read a thread in which this was argued to death, and I can

Re: Platform Requirement Checker (was Does this already exists?: A module that checks if the used platform is supported)

2010-03-11 Thread MRAB
Martin P. Hellwig wrote: On 03/11/10 01:37, Gabriel Genellina wrote: En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig escribió: Before I start reinventing a squared wheel, I have the following question: Is there already a (standard) module that wraps around the various os/sys information

Re: Parsing Email Headers

2010-03-11 Thread MRAB
T wrote: On Mar 11, 3:13 pm, MRAB wrote: T wrote: All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain

inspect.stack() and frame

2010-03-11 Thread Félix-Antoine Fortin
Given this code : # Experience with frame import sys import inspect def foo(): stack = inspect.stack() print "foo frame : " + str(hex(id(sys._getframe( def foo2(): inspect.stack() print "foo2 frame : " + str(hex(id(sys._getframe( def bar(): print "bar frame : " + str(

Re: file seek is slow

2010-03-11 Thread Metalone
I just tried the seek test with Cython. Cython fseek() : 1.059 seconds. 30% slower than 'C' Python f.seek : 1.458 secondds. 80% slower than 'C'. It is amazing to me that Cython generates a 'C' file that is 1478 lines. #Cython code import time cdef int SEEK_SET = 0 cdef extern from "stdio.h"

Re: Where can I find documentation for data[:,9]

2010-03-11 Thread Cal Who
"Martin P. Hellwig" wrote in message news:hnbq8q$vg...@news.eternal-september.org... > On 03/11/10 22:08, Cal Who wrote: > >> Thanks, that helped a lot. >> >> I'm having trouble knowing what to search for to find documenatation. For >> example, is print a Python command, a numpy command or a j

Platform Requirement Checker (was Does this already exists?: A module that checks if the used platform is supported)

2010-03-11 Thread Martin P. Hellwig
On 03/11/10 01:37, Gabriel Genellina wrote: En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig escribió: Before I start reinventing a squared wheel, I have the following question: Is there already a (standard) module that wraps around the various os/sys information which checks if the platf

Re: Parsing Email Headers

2010-03-11 Thread T
On Mar 11, 3:13 pm, MRAB wrote: > T wrote: > > All I'm looking to do is to download messages from a POP account and > > retrieve the sender and subject from their headers.  Right now I'm 95% > > of the way there, except I can't seem to figure out how to *just* get > > the headers.  Problem is, cer

Re: Where can I find documentation for data[:,9]

2010-03-11 Thread Martin P. Hellwig
On 03/11/10 22:08, Cal Who wrote: Thanks, that helped a lot. I'm having trouble knowing what to search for to find documenatation. For example, is print a Python command, a numpy command or a java command? I like to read the documentation even if the command is working for me. Thanks again

Re: Where can I find documentation for data[:,9]

2010-03-11 Thread Cal Who
"Robert Kern" wrote in message news:mailman.631.1268335358.23598.python-l...@python.org... > On 2010-03-11 13:01 PM, Cal Who wrote: >> data = readdata( 'data/input.dat', delimiter = ',' ) >> >> input = data[:, :9]#nine data columns >> >> >> >> Where can I find documentation for the >> >> data[:

Re: Reverse engineering CRC?

2010-03-11 Thread Gregory Ewing
Steve Howell wrote: Hi Greg. I would at least flip one bit at a time on the first byte of your data to see if the transformation is bitwise. I'm actually making good progress on this -- it turns out there *is* a way of deducing the polynomial by looking at the effect of single-bit flips. It's

Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-11 Thread Astley Le Jasper
@Robin Thanks. I thought that this seemed to be a general python thing because it was effecting both installs. However, after also reading Martin's comments ... @Martin > This is somewhat imprecise: is it > a) that your CPU is AMD64, and thus supports 64-bit mode, or > b) that *in addition*, your

Re: Parsing Email Headers

2010-03-11 Thread Grant Edwards
On 2010-03-11, T wrote: > All I'm looking to do is to download messages from a POP account and > retrieve the sender and subject from their headers. Right now I'm 95% > of the way there, except I can't seem to figure out how to *just* get > the headers. The headers are saparated from the body by

Re: Visual Python programming and decompilers?

2010-03-11 Thread Stef Mientki
On 11-03-2010 19:38, Ludolph wrote: Hi Guys At work I have been exposed to a Agile Platform called OutSystems. It allows you to visually program your web applications http://i.imgur.com/r2F0i.png and I find the idea very intriguing. Although not as low level as you want, http://mientki.ruh

Re: Visual Python programming and decompilers?

2010-03-11 Thread geremy condra
On Thu, Mar 11, 2010 at 1:38 PM, Ludolph wrote: > Hi Guys > > At work I have been exposed to a Agile Platform called OutSystems. It > allows you to visually program your web applications > http://i.imgur.com/r2F0i.png and I find the idea very intriguing. > > So I have started to play around with t

Re: Parsing Email Headers

2010-03-11 Thread MRAB
T wrote: All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain email clients also include headers in the me

Re: importing modules from subdirs

2010-03-11 Thread Alex Hall
Halfway there. It imports now, but it says that the module does not have functions which I know it does have. I will just leave it all in one folder for now and play with organization after I get the project working better. On 3/11/10, Steve Holden wrote: > Alex Hall wrote: >> Hi all, >> The manu

Parsing Email Headers

2010-03-11 Thread T
All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain email clients also include headers in the message body

Re: Where can I find documentation for data[:,9]

2010-03-11 Thread Robert Kern
On 2010-03-11 13:01 PM, Cal Who wrote: data = readdata( 'data/input.dat', delimiter = ',' ) input = data[:, :9]#nine data columns Where can I find documentation for the data[:,9] in the code above. Been looking and found many examples but would like to know the definition. When asking q

Where can I find documentation for data[:,9]

2010-03-11 Thread Cal Who
data = readdata( 'data/input.dat', delimiter = ',' ) input = data[:, :9]#nine data columns Where can I find documentation for the data[:,9] in the code above. Been looking and found many examples but would like to know the definition. I need to skip the first column and then read 9 I wou

Re: file seek is slow

2010-03-11 Thread Metalone
I am assuming that Python delegates the f.seek call to the seek call in the MS C runtime library msvcrt.dll. Does anybody know a nice link to the Python source like was posted above for the BSD 'C' library? Ok, I ran some more tests. C, seek: 0.812 seconds // test from original post

Re: I get the error: ImportError: No module named ffnet

2010-03-11 Thread Cal Who
I found out I had something installed wrong. " Cal Who" wrote in message news:hnb339$g2...@news.eternal-september.org... > > > I have the .py file in Eclipse > #...@pydevcodeanalysisignore > from ffnet import ffnet, mlgraph > topology = mlgraph( (2, 3, 1) ) > nn = ffnet(topology) > > I select Ru

Re: Python 2.6 and modules dbi AND odbc

2010-03-11 Thread Kev Dwyer
On Wed, 10 Mar 2010 16:17:29 -0800, robert somerville wrote: > hi; > i am trying to get some legacy python code (which i no nothing about) > working with tries to import dbi and odbc (the import fails ...) it > looks like these modules are deprecated ?? if so is there a work around > , if not dep

Re: Get a method instance through 'getattr' but not superclass's method

2010-03-11 Thread Gabriel Genellina
En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat escribió: I am using getattr to get a method instance from a class. But it also returns methods from the superclass. How to detect if an attribute is from superclass? You may look it up directly in the class dictionary (__dict__) -- Ga

Visual Python programming and decompilers?

2010-03-11 Thread Ludolph
Hi Guys At work I have been exposed to a Agile Platform called OutSystems. It allows you to visually program your web applications http://i.imgur.com/r2F0i.png and I find the idea very intriguing. So I have started to play around with the idea on how will I be able to visually represent Python co

Re: Python Script to get Info from Site not working

2010-03-11 Thread Gabriel Genellina
En Wed, 10 Mar 2010 23:26:05 -0300, Jimbo escribió: On Mar 11, 12:38 pm, "Gabriel Genellina" wrote: En Wed, 10 Mar 2010 20:06:41 -0300, Jimbo escribió: > I found a semi Python & internet tutorial here if anyone else would > like ithttp://www.upriss.org.uk/python/session6.html Replace the l

unable to run wxPython script: dll errors

2010-03-11 Thread Alex Hall
Hi all, I am trying to run a file that should pop up a dialog. The dialog is fine (I used XRCed to create it and running it from within that editor brings up the dialog I want). When I run my file, though, I get this traceback: C:\Users\Alex>c:\python26\python.exe i:\arm\dictionary.py Traceback (m

Re: use of multiple versions of python

2010-03-11 Thread David Robinow
On Thu, Mar 11, 2010 at 12:40 AM, Bujji wrote: > hi all, > I have installed python 2.6 in addition to python 2.5 in my system > Now for some modules(while installing ) it needs to use python 2.6 > how can i do that > in case of easy_install what should i do to it to use python 2.6 You should have

Re: importing modules from subdirs

2010-03-11 Thread Steve Holden
Alex Hall wrote: > Hi all, > The manual says, for modules in a project stored in subdirectories, you can > do: > import folderName.module > > I have a couple questions, though: > 1. Do I then have to call functions from module like > folder.module.function, or can I still use the normal module.fu

Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-11 Thread Martin v. Loewis
>> I have a Windows 7 (64bit AMD) machine This is somewhat imprecise: is it a) that your CPU is AMD64, and thus supports 64-bit mode, or b) that *in addition*, your Windows 7 installation is a 64-bit installation, or c) that *in addition*, your Python installation is also a 64-bit installation

Re: importing modules from subdirs

2010-03-11 Thread Gary Herron
Alex Hall wrote: Hi all, The manual says, for modules in a project stored in subdirectories, you can do: import folderName.module I have a couple questions, though: 1. Do I then have to call functions from module like folder.module.function, or can I still use the normal module.function? Ei

importing modules from subdirs

2010-03-11 Thread Alex Hall
Hi all, The manual says, for modules in a project stored in subdirectories, you can do: import folderName.module I have a couple questions, though: 1. Do I then have to call functions from module like folder.module.function, or can I still use the normal module.function? 2. When I try to do this,

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread mk
kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced programming issues? I'm surprised nobody mentio

Re: Named loops for breaking

2010-03-11 Thread bartc
James Harris wrote: On 10 Mar, 06:29, "Gabriel Genellina" wrote: En Tue, 09 Mar 2010 18:41:10 -0300, Daniel Klein escribi : Basically I'm wondering if there are any plans to implemented named loops in Python, so I can tell a break command to break out of a specific loop in the case of nested

Re: I get the error: ImportError: No module named ffnet

2010-03-11 Thread Cal Who
I ran this: import sys from pprint import pprint as pp pp(sys.path) The output included: 'E:\\Program Files\\Python26', 'E:\\Program Files\\Python26\\DLLs', 'E:\\Program Files\\Python26\\lib', 'E:\\Program Files\\Python26\\lib\\lib-tk', 'E:\\Program Files\\Python26\\lib\\plat-win', 'E:\\

Re: Behavior of default parameter in a function

2010-03-11 Thread Gary Herron
This is addressed in the FAQ. http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects jitendra gupta wrote: def foo(x = [0]): x[0] = x[0] + 1 return x[0] def soo(x = None): if x is None: x = [0] x[0] = x[0] + 1 return x[0] >>> foo() 1 >>>foo() #See the behavi

Re: Can't define __call__ within __init__?

2010-03-11 Thread Peter Otten
Steve Howell wrote: > On Mar 10, 7:18 pm, Steven D'Aprano > wrote: >> (2) special methods like __call__ are only called on the class, not the >> instance, so you can't give each instance its own method. > Are you sure about that? This program prints 1, 2, 1, 2. You are using a classic class

bypass UAC control through python script (to be run from batchfile)

2010-03-11 Thread rizwanahme...@gmail.com
Hi here is my problem. i want to install a program through python script. The python scripts is called from a batch file. The UAC control is not allowing the python script to install a msi (installer). I need to somehow by pass the UAC control. i dont want to turn it off permanently. Once i have

Re: Insert missing keys using defaultdict

2010-03-11 Thread Gnarlodious
On Mar 11, 9:20 am, George Sakkis wrote: > > How do create a dict assigning every missing key with a default > > string? > > "%(Text)s" % > defaultdict(lambda:'_MISSING_', plistDict) Brilliant, I love Python. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-11 Thread Robin Becker
On 11/03/2010 13:55, Astley Le Jasper wrote: I have a Windows 7 (64bit AMD) machine and am having quite a lot of problems installing Reportlabs and Pil. I wondered if anyone else has had the same issues and what the best way of dealing with it. So far I've tried: 1. Reportlabs / Pil 32 installe

Re: Insert missing keys using defaultdict

2010-03-11 Thread George Sakkis
On Mar 11, 5:02 pm, Gnarlodious wrote: > I am trying to grok this documentation but need > help:http://docs.python.org/library/collections.html#defaultdict-examples > > In a perfect world the dict looks like this: > plistDict={'Style':'ExternalURL', 'Ref':'http://Gnarlodious.com/', > 'Tip':'Open

Re: Can't define __call__ within __init__?

2010-03-11 Thread Steve Howell
On Mar 10, 7:18 pm, Steven D'Aprano wrote: > On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote: > > Want to switch __call__ behavior.  Why doesn't this work?  What is the > > correct way to write this? > > > class X (object): > >     def __init__(self, i): > >         if i == 0: > >          

Re: show image in python

2010-03-11 Thread mohamed issolah
hey #!/usr/bin/python 2 import PIL 3 import numpy 4 import Image import ImageOps import sys def Matimg(path): """transforme image en matrice""" Img = Image.open(str(path)) Img1 = ImageOps.grayscale(Img) largeur,hauteur = Img1.size i

Insert missing keys using defaultdict

2010-03-11 Thread Gnarlodious
I am trying to grok this documentation but need help: http://docs.python.org/library/collections.html#defaultdict-examples In a perfect world the dict looks like this: plistDict={'Style':'ExternalURL', 'Ref':'http://Gnarlodious.com/', 'Tip':'Opens in a new window', 'Text':'Gnarlodious.com'} Let's

Re: NoSQL Movement?

2010-03-11 Thread dkeeney
On Mar 8, 12:14 pm, Duncan Booth wrote: > You've totally missed the point. It isn't the size of the data you have > today that matters, it's the size of data you could have in several years' > time. > > Maybe today you've got 10 users each with 10 megabytes of data, but you're > aspiring to becom

Re: Can't define __call__ within __init__?

2010-03-11 Thread MRAB
Andre Engels wrote: On Thu, Mar 11, 2010 at 2:30 PM, Steve Holden wrote: The example I showed was just a toy problem. The real problem is I expect to call a function many times, and I want to avoid the overhead of the 'if blah' everytime. This is a premature optimization. First, make it wor

Re: Ideas for creating processes

2010-03-11 Thread bobicanprogram
On Mar 10, 4:52 pm, J wrote: > I'm working on a project and thought I'd ask for a suggestion on how > to proceed (I've got my own ideas, but I wanted to see if I was on the > right track) > > For now, I've got this: > > def main(): > ## get our list of directories to refresh > releases=sys.arg

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread Kevin Walzer
On 3/10/10 10:19 AM, kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced programming issues? ~K I have

I get the error: ImportError: No module named ffnet

2010-03-11 Thread Cal Who
I have the .py file in Eclipse #...@pydevcodeanalysisignore from ffnet import ffnet, mlgraph topology = mlgraph( (2, 3, 1) ) nn = ffnet(topology) I select RunAs / Python Run I get the error from ffnet import ffnet, mlgraph ImportError: No module named ffnet In the folder Python26\lib\site-pack

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread Steve Howell
On Mar 11, 7:05 am, kj wrote: > In Chris Withers > writes: > > >kj wrote: > > >> Subject line pretty much says it all: is there a book like "Effective > >> Java" > >oxymoronic, no? > >Sorry, couldn't resist ;-) > > I hear you, but still: read "Effective Java" some day; it will make > you a bett

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread kj
In Chris Withers writes: >kj wrote: >> >> >> Subject line pretty much says it all: is there a book like "Effective >> Java" >oxymoronic, no? >Sorry, couldn't resist ;-) I hear you, but still: read "Effective Java" some day; it will make you a better programmer, whatever your language pref

Re: show image in python

2010-03-11 Thread Philip Semanchuk
On Mar 10, 2010, at 5:03 PM, mohamed issolah wrote: Hey, This is my program 1 #!/usr/bin/python 2 import PIL 3 import numpy 4 import Image 5 import ImageOps 6 import sys 7 8 def Matimg(path): 9 """transforme image en matrice""" 10 Img = Image.open(str(path)) 11

Need advice on starting a Python group

2010-03-11 Thread gb345
I'm hoping to get advice from anyone with prior experience setting up a Python group. A friend of mine and I have been trying to start a scientific-programming-oriented Python group in our school (of medecine and bio research), with not much success. The main problem is attendance. Even thou

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread Stefan Behnel
James Harris, 11.03.2010 09:30: On 10 Mar, 15:19, kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced

Re: Can't define __call__ within __init__?

2010-03-11 Thread Andre Engels
On Thu, Mar 11, 2010 at 2:30 PM, Steve Holden wrote: >> The example I showed was just a toy problem.  The real problem is >> I expect to call a function many times, and I want to avoid the overhead of >> the 'if blah' everytime. >> > This is a premature optimization. First, make it work. Then (if

Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-11 Thread Astley Le Jasper
I have a Windows 7 (64bit AMD) machine and am having quite a lot of problems installing Reportlabs and Pil. I wondered if anyone else has had the same issues and what the best way of dealing with it. So far I've tried: 1. Reportlabs / Pil 32 installers - I've tried using these but they can't find

Re: Interacting With Another Script

2010-03-11 Thread Victor Subervi
On Wed, Mar 10, 2010 at 10:16 PM, alex23 wrote: > Victor Subervi wrote: > > > There's a program (vpopmail) that has commands which, when called, > request > > > input ("email address", "password", etc.) from the command line. I > would > > > like to build a TTW interface for my clients to use th

Re: Can't define __call__ within __init__?

2010-03-11 Thread Steve Holden
Neal Becker wrote: > Steven D'Aprano wrote: > >> On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote: >> >>> Want to switch __call__ behavior. Why doesn't this work? What is the >>> correct way to write this? >>> >>> class X (object): >>> def __init__(self, i): >>> if i == 0: >>>

Re: Get a method instance through 'getattr' but not superclass's method

2010-03-11 Thread Radhakrishna Bhat
Thanks. I just have to check in that string if method1 is from present in subclass's __dict__ or not. This is important for me because in my code, I am dynamically calling methods of 2 classes where one is superclass of the other. And I was getting duplicate results because of this problem. -Radha

Re: a newbie's question

2010-03-11 Thread Jean-Michel Pichavant
PEYMAN ASKARI wrote: Hello I need some help dynamically reloading modules. As it turns out, it is not as simple as calling reload, as outlined here http://pyunit.sourceforge.net/notes/reloading.html Is there builtin support for this? The example they gave does not seem to work for me, and I

Re: Can't define __call__ within __init__?

2010-03-11 Thread Neal Becker
Steven D'Aprano wrote: > On Wed, 10 Mar 2010 08:12:14 -0500, Neal Becker wrote: > >> Want to switch __call__ behavior. Why doesn't this work? What is the >> correct way to write this? >> >> class X (object): >> def __init__(self, i): >> if i == 0: >> def __call__ (self)

Re: a newbie's question

2010-03-11 Thread PEYMAN ASKARI
Hello I need some help dynamically reloading modules. As it turns out, it is not as simple as calling reload, as outlined here http://pyunit.sourceforge.net/notes/reloading.html Is there builtin support for this? The example they gave does not seem to work for me, and I am unclear as to what Py

Re: Get a method instance through 'getattr' but not superclass's method

2010-03-11 Thread Steve Holden
Radhakrishna Bhat wrote: > I am using getattr to get a method instance from a class. But it also > returns methods from the superclass. How to detect if an attribute is > from superclass? > You could try, if x is in instance, looking to see whether the name is defined in x.__class__.__dict__. >>

Re: Python Script to get Info from Site not working

2010-03-11 Thread Steve Holden
Jimbo wrote: > On Mar 11, 12:38 pm, "Gabriel Genellina" > wrote: >> En Wed, 10 Mar 2010 20:06:41 -0300, Jimbo escribió: >> >>> I found a semi Python & internet tutorial here if anyone else would >>> like ithttp://www.upriss.org.uk/python/session6.html >>> My script is meant to find which radio bu

Re: logging: local functions ==> loss of lineno

2010-03-11 Thread Peter Otten
Hellmut Weber wrote: > Logging works very well giving the filename and line number of the point > where it is called. As long as I use the loggers directly. > BUT when I have to wrap the logger call in some other function, I always > get file name and line number of the call of the logger inside t

Re: logging: local functions ==> loss of lineno

2010-03-11 Thread Jean-Michel Pichavant
Hellmut Weber wrote: Hi Vinay Sajip, I'm very glad discoverd your logging module ;-) (That's what I would have liked 25 years ago when I was working as a technical software developper!) Now I'm writing just some personal tools, I like python and want to use logging on a regular basis. Loggi

How to handle file uploads with http.server

2010-03-11 Thread Neil Blue
Hello, I have a basic http.server instance running (class HTTPHandler(http.server.BaseHTTPRequestHandler), with python 3.1, and I would like to upload files with multipart forms. def do_POST(self): ctype, pdict = cgi.parse_header(self.headers['Content-Type']) if ctype=='multipart/

Multiple import of the same module under different names

2010-03-11 Thread George Sakkis
The import mechanism is not very smart in identifying whether two modules imported under different name are actually the same module, at least when dealing with implicit relative imports and sys.path manipulation. However, at least in cases of plain file modules, the module's __file__ would be adeq

Re: Behavior of default parameter in a function

2010-03-11 Thread Shashank Singh
quoting from docs:http://docs.python.org/reference/compound_stmts.html *Default parameter values are evaluated when the function definition is executed.* This means that the expression is evaluated once, when the function is defined, and that that same “pre-computed” value is used for each call. T

Behavior of default parameter in a function

2010-03-11 Thread jitendra gupta
def foo(x = [0]): x[0] = x[0] + 1 return x[0] def soo(x = None): if x is None: x = [0] x[0] = x[0] + 1 return x[0] >>> foo() 1 >>>foo() #See the behavior incremented by one 2 >>>foo([1]) # but here based on given number 2 >>>foo() 3 >>>foo([1]) 2 >>>foo() 4 >>>soo() 1 >>>soo() 1 >>>soo([1]) 2 >

EOFError: EOF when reading a line

2010-03-11 Thread Mihir Patel
I am trying to use the subprocess to send the data to child process. I am not sure why i keep getting "EOFError: EOF when reading a line" i am using Python 2.4.3, GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on 64bit linux ,centos Thanks output : = Traceback (most recent call last): File "test_

Re: pexpect and logging integration

2010-03-11 Thread Lars Stavholm
It works like a charm, thank you! /Lars Jean-Michel Pichavant wrote: > Lars Stavholm wrote: >> Hi all, >> >> has anyone managed to integrate pexpect and logging? >> >> I.e., I'd like to be able to pick up the dialog, >> commands sent and responses received, in my logging. >> I know about the pexpe

Re: Anything like "Effective Java" for Python?

2010-03-11 Thread James Harris
On 10 Mar, 15:19, kj wrote: > Subject line pretty much says it all: is there a book like "Effective > Java" for Python.  I.e. a book that assumes that readers are > experienced programmers that already know the basics of the language, > and want to focus on more advanced programming issues? I don