Re: MATLAB to Python?

2010-11-22 Thread MATLABdude
On Nov 23, 9:43 am, Arnaud Delobelle wrote: > T0_orig is a list and you are trying to multiply this list by a float > (m**-1) Yes, yes of course. Thanks! :) This works: ---8<---8<---8<--- T0_orig = [5, 50, 500, 5000] for counter in T0_orig: T0 = (L**2)/(D*pi**2)*counter a

Re: MATLAB to Python?

2010-11-22 Thread Arnaud Delobelle
MATLABdude writes: > On Nov 22, 11:11 am, Peter Otten <__pete...@web.de> wrote: >> Try numpy.arange() instead: >> >>> numpy.arange(0, 1, .1) >> array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9]) > > Thanks! It worked. > > What's wrong with the following code? > ---8<---8<---8<---

Re: MATLAB to Python?

2010-11-22 Thread MATLABdude
On Nov 22, 11:11 am, Peter Otten <__pete...@web.de> wrote: > Try numpy.arange() instead: > >>> numpy.arange(0, 1, .1) > array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9]) Thanks! It worked. What's wrong with the following code? ---8<---8<---8<--- T0_orig = [5, 50, 500, 5000]

Re: CGI FieldStorage instances?

2010-11-22 Thread Gnarlodious
Let me rephrase the question. Say I have a query string like this: ?view=Data&item=9875 What I want to do is simply invoke process "view" with variable "Data". This would replace my existing query string mess which looks like this: if 'view' in form and 'item' in form: HTML=view(Data, item(9

Re: bug? mmap doesn't like 0-length files

2010-11-22 Thread Nobody
On Mon, 22 Nov 2010 20:33:08 -0500, Neal Becker wrote: > I don't see anything in linux man-page about the underlying C mmap function > not accepting 0-length files. My mmap(2) manpage says: ERRORS ... EINVAL (since Linux 2.6.12) length was 0. -- http://mail.pyth

Re: Reading bz2 file into numpy array

2010-11-22 Thread Nobody
On Mon, 22 Nov 2010 11:37:22 +0100, Peter Otten wrote: >> is there a convenient way to read bz2 files into a numpy array? > > Try > f = bz2.BZ2File(filename) > data = numpy.fromstring(f.read(), numpy.float32) That's going to hurt if the file is large. You might be better off either extracting

Re: bug? mmap doesn't like 0-length files

2010-11-22 Thread Cameron Simpson
On 23Nov2010 13:59, I wrote: | On 22Nov2010 20:33, Neal Becker wrote: | | mmap.mmap (f.fileno(), 0, prot=mmap.PROT_READ) | | error: [Errno 22] Invalid argument [...] | | I don't see anything in linux man-page about the underlying C mmap function | | not accepting 0-length files. It's worth noti

Re: bug? mmap doesn't like 0-length files

2010-11-22 Thread Cameron Simpson
On 22Nov2010 20:33, Neal Becker wrote: | mmap.mmap (f.fileno(), 0, prot=mmap.PROT_READ) | error: [Errno 22] Invalid argument | | According to http://docs.python.org/library/mmap.html, mmap on _windows_ | doesn't accept 0-length file. But this was tested on linux. Is this a bug? | | I don't

Re: Round Trip: C to Python to C Module

2010-11-22 Thread bobicanprogram
On Nov 19, 11:05 am, Eric Frederich wrote: > I have a proprietary software PropSoft that I need to extend. > They support extensions written in C that can link against PropLib to > interact with the system. > > I have a Python C module that wraps a couple PropLib functions that I > call PyProp.>Fr

Re: File Reading In Mac

2010-11-22 Thread Ned Deily
In article <66e4164c-e81d-4a65-b847-c5ef900fa...@a37g2000yqi.googlegroups.com>, dilip raghavan wrote: > I have been trying to read contents from a file in MAC. > I wrote the code > > filename = "test.rtf" > FileHandle = open(filename,'r') > > fileStr = FileHandle.read() > print fileSt

bug? mmap doesn't like 0-length files

2010-11-22 Thread Neal Becker
mmap.mmap (f.fileno(), 0, prot=mmap.PROT_READ) error: [Errno 22] Invalid argument According to http://docs.python.org/library/mmap.html, mmap on _windows_ doesn't accept 0-length file. But this was tested on linux. Is this a bug? I don't see anything in linux man-page about the underlying C

File Reading In Mac

2010-11-22 Thread dilip raghavan
Hello , I have been trying to read contents from a file in MAC. I wrote the code filename = "test.rtf" FileHandle = open(filename,'r') fileStr = FileHandle.read() print fileStr FileHandle.close() When I see the output I see a lot of junk. The junk is like a lot of question marks, the fo

Re: How to install uTidylib, easy_install problem

2010-11-22 Thread Sridhar Ratnakumar
On 2010-11-22, at 4:22 PM, goldtech wrote: > I'm using activepython 2.6 on XP. I am trying to install uTidylib 0.2 > with easy_install. I like uTidylib more vs. newer modules.and want to > use it. I get output below. How do I install it? I do see it in > http://pypi.python.org/simple/uTidylib/ >

Re: Glob in python which supports the ** wildcard

2010-11-22 Thread Martin v. Loewis
Am 22.11.2010 22:43, schrieb Martin Lundberg: > Hi, > > I want to be able to let the user enter paths like this: > > apps/name/**/*.js > > and then find all the matching files in apps/name and all its > subdirectories. However I found out that Python's glob function > doesn't support the recursi

How to install uTidylib, easy_install problem

2010-11-22 Thread goldtech
I'm using activepython 2.6 on XP. I am trying to install uTidylib 0.2 with easy_install. I like uTidylib more vs. newer modules.and want to use it. I get output below. How do I install it? I do see it in http://pypi.python.org/simple/uTidylib/ Thanks. C:\Documents and Settings\user1>easy_install

Re: Need advices regarding the strings (str, unicode, coding) used as interface for an external library.

2010-11-22 Thread Terry Reedy
On 11/22/2010 3:25 PM, jmfauth wrote: I'm planning to build an external lib. This lib will exchange a lot of strings between the lib and the "core Python code" of applications. Are you planning to exchange indirectly via disk files or directly via memory buffers? This pretty much amounts to

Re: Glob in python which supports the ** wildcard

2010-11-22 Thread Kurt Mueller
Hi, Am 22.11.2010 um 23:05 schrieb Stefan Sonnenberg-Carstens: > Am 22.11.2010 22:43, schrieb Martin Lundberg: >> I want to be able to let the user enter paths like this: >> apps/name/**/*.js >> and then find all the matching files in apps/name and all its >> subdirectories. However I found out t

Re: Glob in python which supports the ** wildcard

2010-11-22 Thread Kurt Mueller
HI, Am 22.11.2010 um 23:05 schrieb Stefan Sonnenberg-Carstens: > Am 22.11.2010 22:43, schrieb Martin Lundberg; >> >> I want to be able to let the user enter paths like this: >> apps/name/**/*.js >> and then find all the matching files in apps/name and all its >> subdirectories. However I found o

Re: Scheme as a virtual machine?

2010-11-22 Thread Raffael Cavallaro
On 2010-11-22 11:25:34 -0500, scattered said: And you don't think that [JH] could write a book about Haskell if he honestly came to think that it were a superior all-aroung language? Until he actually does, he has a financial interest in trash-talking Haskell. This makes anything he says abou

Re: Glob in python which supports the ** wildcard

2010-11-22 Thread Stefan Sonnenberg-Carstens
Am 22.11.2010 22:43, schrieb Martin Lundberg: Hi, I want to be able to let the user enter paths like this: apps/name/**/*.js and then find all the matching files in apps/name and all its subdirectories. However I found out that Python's glob function doesn't support the recursive ** wildcard.

Glob in python which supports the ** wildcard

2010-11-22 Thread Martin Lundberg
Hi, I want to be able to let the user enter paths like this: apps/name/**/*.js and then find all the matching files in apps/name and all its subdirectories. However I found out that Python's glob function doesn't support the recursive ** wildcard. Is there any 3rd party glob function which do su

Re: Python recursively __getattribute__

2010-11-22 Thread Roman Dolgiy
On Nov 22, 7:57 pm, Terry Reedy wrote: > On 11/22/2010 10:46 AM, Roman Dolgiy wrote: > > > Hello, > > > I need to implement such behavior: > > > obj.attr1.attr2.attr3 -->  obj.attr1__attr2__attr3 > > obj.attr1.attr2.attr3 is parsed as ((obj.attr1).attr2).attr3, > so this cannot work in general but

Need advices regarding the strings (str, unicode, coding) used as interface for an external library.

2010-11-22 Thread jmfauth
I'm planning to build an external lib. This lib will exchange a lot of strings between the lib and the "core Python code" of applications. I wish this lib to be modern, 100% unicode compliant. It will be developped for Python 2.7 and for Python 3. In an early phase, technically, it will be develop

Re: unittests with different parameters

2010-11-22 Thread Ben Finney
Ulrich Eckhardt writes: > Let's say I have two flags invert X and invert Y. Now, for testing these, I > would write one test for each combination. What I have in the test case is > something like this: > > def test_invert_flags(self): > """test flags to invert coordinates""" > tests

Re: unittests with different parameters

2010-11-22 Thread Ulrich Eckhardt
Ian Kelly wrote: > On 11/22/2010 4:38 AM, Ulrich Eckhardt wrote: >> Also, I'd rather construct the error message from the data >> instead of maintaining it in different places, because >> manually keeping those in sync is another, errorprone burden. > > I'm not sure I follow the problem you're de

Re: Python recursively __getattribute__

2010-11-22 Thread Terry Reedy
On 11/22/2010 10:46 AM, Roman Dolgiy wrote: Hello, I need to implement such behavior: obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3 obj.attr1.attr2.attr3 is parsed as ((obj.attr1).attr2).attr3, so this cannot work in general but only if attr1 and attr2 are known to not be 'final' names.

Re: Scheme as a virtual machine?

2010-11-22 Thread toby
On Nov 22, 12:28 pm, namekuseijin wrote: > On 22 nov, 14:47, Howard Brazee wrote: > > > On Mon, 22 Nov 2010 08:14:40 -0800 (PST), toby > > > wrote: > > >This is a good (if familiar) observation. Teaching children (or young > > >people with little exposure to computers) how to program in various

Re: Scheme as a virtual machine?

2010-11-22 Thread markhanif...@gmail.com
On Nov 22, 8:45 am, Raffael Cavallaro wrote: > On 2010-11-22 08:12:27 -0500, markhanif...@gmail.com said: > > > All opinions are biased. > > All opinions show some bias. Not all opinions represent what is usually > called a "conflict of interest." > Maybe, but in the case of regulars on newsgroup

Re: Scheme as a virtual machine?

2010-11-22 Thread namekuseijin
On 22 nov, 14:47, Howard Brazee wrote: > On Mon, 22 Nov 2010 08:14:40 -0800 (PST), toby > > wrote: > >This is a good (if familiar) observation. Teaching children (or young > >people with little exposure to computers) how to program in various > >paradigms could produce interesting primary evidenc

Re: unittests with different parameters

2010-11-22 Thread Ian Kelly
On 11/22/2010 4:38 AM, Ulrich Eckhardt wrote: Let's say I have two flags invert X and invert Y. Now, for testing these, I would write one test for each combination. What I have in the test case is something like this: def test_invert_flags(self): """test flags to invert coordinates"""

Re: Python recursively __getattribute__

2010-11-22 Thread Andreas Waldenburger
On Mon, 22 Nov 2010 08:41:49 -0800 (PST) Roman Dolgiy wrote: > On Nov 22, 6:04 pm, Andreas Waldenburger > wrote: > > On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy > > wrote: > > > > > Hello, > > > > > I need to implement such behavior: > > > > > obj.attr1.attr2.attr3 --> obj.attr1__attr

Re: Scheme as a virtual machine?

2010-11-22 Thread Tamas K Papp
On Mon, 22 Nov 2010 08:25:34 -0800, scattered wrote: > On Nov 22, 9:45 am, Raffael Cavallaro > wrote: >> On 2010-11-22 08:12:27 -0500, markhanif...@gmail.com said: >> >> > All opinions are biased. >> >> All opinions show some bias. Not all opinions represent what is usually >> called a "conflict

Re: Scheme as a virtual machine?

2010-11-22 Thread Howard Brazee
On Mon, 22 Nov 2010 08:14:40 -0800 (PST), toby wrote: >This is a good (if familiar) observation. Teaching children (or young >people with little exposure to computers) how to program in various >paradigms could produce interesting primary evidence. Pity that this >isn't examined widely and system

Re: Python recursively __getattribute__

2010-11-22 Thread Roman Dolgiy
On Nov 22, 6:04 pm, Andreas Waldenburger wrote: > On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy > wrote: > > > Hello, > > > I need to implement such behavior: > > > obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3 > > It looks like I have to override obj's class __getattribute__ and als

Re: Scheme as a virtual machine?

2010-11-22 Thread scattered
On Nov 22, 9:45 am, Raffael Cavallaro wrote: > On 2010-11-22 08:12:27 -0500, markhanif...@gmail.com said: > > > All opinions are biased. > > All opinions show some bias. Not all opinions represent what is usually > called a "conflict of interest." Since JH makes his living selling > tools and trai

Re: print line number and source filename

2010-11-22 Thread Wei Sun
Here is what you want for printing python source filename: print __file__ > On Tuesday, June 22, 2010 12:44 PM Peng Yu wrote: > I want to print filename and line number for debugging purpose. So far > I only find how to print the line number but not how to print > filename. > > import inspect >

Re: Scheme as a virtual machine?

2010-11-22 Thread toby
On Nov 22, 10:57 am, Howard Brazee wrote: > On Mon, 22 Nov 2010 05:38:53 +0100, Ertugrul S ylemez > wrote: > > >Haskell is a simple language with a comparably small specification. > >It's not as simple as Common Lisp, but it's simple.  Note that simple > >doesn't mean easy.  Haskell is certainly

Re: Python recursively __getattribute__

2010-11-22 Thread Andreas Waldenburger
On Mon, 22 Nov 2010 07:46:47 -0800 (PST) Roman Dolgiy wrote: > Hello, > > I need to implement such behavior: > > obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3 > It looks like I have to override obj's class __getattribute__ and also > use python descriptors somehow. > > Any help will be muc

Re: Scheme as a virtual machine?

2010-11-22 Thread Howard Brazee
On Mon, 22 Nov 2010 05:38:53 +0100, Ertugrul Söylemez wrote: >Haskell is a simple language with a comparably small specification. >It's not as simple as Common Lisp, but it's simple. Note that simple >doesn't mean easy. Haskell is certainly more difficult to learn than >other languages, which e

Python recursively __getattribute__

2010-11-22 Thread Roman Dolgiy
Hello, I need to implement such behavior: obj.attr1.attr2.attr3 --> obj.attr1__attr2__attr3 It looks like I have to override obj's class __getattribute__ and also use python descriptors somehow. Any help will be much appreciated. http://stackoverflow.com/questions/4247036/python-recursively-geta

Re: Scheme as a virtual machine?

2010-11-22 Thread Andreas Waldenburger
On 22 Nov 2010 06:26:34 GMT Steven D'Aprano wrote: > On Sun, 21 Nov 2010 23:57:21 -0500, Steve Holden wrote: > > > Perhaps we could take this thread to alt.small.minded.bickering now? > > Alas, my ISP doesn't carry that newsgroup. Where else can I get my > mindless off-topic bitching if not f

Re: unittests with different parameters

2010-11-22 Thread Roy Smith
In article , Ulrich Eckhardt wrote: > > Yet another possibility is to leave it the way you originally wrote it > > and not worry about the fact that the loop aborts on the first failure. > > Let it fail, fix it, then re-run the test to find the next failure. > > Perhaps not as efficient as findi

Re: Scheme as a virtual machine?

2010-11-22 Thread Raffael Cavallaro
On 2010-11-22 08:12:27 -0500, markhanif...@gmail.com said: All opinions are biased. All opinions show some bias. Not all opinions represent what is usually called a "conflict of interest." Since JH makes his living selling tools and training for certain languages, he has a severe conflict of

Re: unittests with different parameters

2010-11-22 Thread Ulrich Eckhardt
Richard Thomas wrote: [batch-programming different unit tests] > You could have a parameter to the test method and some custom > TestLoader that knows what to do with it. Interesting, thanks for this suggestion, I'll look into it! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amt

Re: unittests with different parameters

2010-11-22 Thread Ulrich Eckhardt
Roy Smith wrote: > Writing one test method per parameter combination, as you suggested, is > a reasonable approach, especially if the number of combinations is > reasonably small. The number of parameters and thus combinations are unfortunately rather large. Also, sometimes that data is not static

Error Starting Python(Django) App using Apache+Mod_Wsgi

2010-11-22 Thread Anurag Chourasia
All, I have a problem in starting my Python(Django) App using Apache and Mod_Wsgi I am using Django 1.2.3 and Python 2.6.6 running on Apache 2.2.17 with Mod_Wsgi 3.3 When I try to access the app from Web Browser, I am getting these errors. [Mon Nov 22 09:45:25 2010] [notice] Apache/2.2.17 (Unix

Re: unittests with different parameters

2010-11-22 Thread Roy Smith
In article , Ulrich Eckhardt wrote: > def test_invert_flags(self): > """test flags to invert coordinates""" > tests = [((10, 20), INVERT_NONE, (10, 20)), >((10, 20), INVERT_X, (-10, 20)), >((10, 20), INVERT_Y, (10, -20))] > for input, flags, ex

Re: unittests with different parameters

2010-11-22 Thread Richard Thomas
On Nov 22, 11:38 am, Ulrich Eckhardt wrote: > Hi! > > I'm writing tests and I'm wondering how to achieve a few things most > elegantly with Python's unittest module. > > Let's say I have two flags invert X and invert Y. Now, for testing these, I > would write one test for each combination. What I

Re: Scheme as a virtual machine?

2010-11-22 Thread markhanif...@gmail.com
On Nov 21, 10:38 pm, Ertugrul Söylemez wrote: > "Jon Harrop" wrote: > > "Ertugrul Söylemez" wrote in message > >news:20101014052650.510e8...@tritium.streitmacht.eu... > > > > That's nonsense. > > > Actually namekuseijin is right. You really need to persevere and > > familiarize yourself with som

Re: Some syntactic sugar proposals

2010-11-22 Thread Andreas Löscher
> if x in range(a, b): #wrong! > it feels so natural to check it that way, but we have to write > if a <= x <= b > I understand that it's not a big deal, but it would be awesome to have > some optimisations - it's clearly possible to detect things like that > "wrong" one and fix it in a byt

unittests with different parameters

2010-11-22 Thread Ulrich Eckhardt
Hi! I'm writing tests and I'm wondering how to achieve a few things most elegantly with Python's unittest module. Let's say I have two flags invert X and invert Y. Now, for testing these, I would write one test for each combination. What I have in the test case is something like this: def test

Re: multiple times subprocess fails on windows

2010-11-22 Thread kvbik
To be more specific, I have something like this in rvirtualenv itself (that's the pokus.py file): import os os.system("echo 128") I generate a batch file like this (that's the pokus.bat file): @echo off pokus.py And after that, I run the pokus.bat file from a test (that's the run.py file): fro

Accepting a SAML 2 Assertion

2010-11-22 Thread raghu bg
Hello, I am working on providing a SSO solution to a customer who acts as an identity provider. He already has IDP on his side to generate SAML 2 assertions with user first name , last name and time stamp as parameters. Our task is to accept this assertion which is signed, decrypt it and send it

Re: building a web interface

2010-11-22 Thread Jean-Michel Pichavant
Shel wrote: Hello, I am pretty new to all this. I have some coding experience, and am currently most comfortable with Python. I also have database design experience with MS Access, and have just created my first mySQL db. So right now I have a mySQL db structure and some Python code. My end go

Re: Reading bz2 file into numpy array

2010-11-22 Thread Peter Otten
Johannes Korn wrote: > I tried: > > from bz2 import * > from numpy import * > fd = BZ2File(filename, 'rb') > read_data = fromfile(fd, float32) > > but BZ2File doesn't seem to produce a transparent filehandle. > is there a convenient way to read bz2 files into a numpy array? Try import numpy i

Reading bz2 file into numpy array

2010-11-22 Thread Johannes Korn
Hi, is there a convenient way to read bz2 files into a numpy array? I tried: from bz2 import * from numpy import * fd = BZ2File(filename, 'rb') read_data = fromfile(fd, float32) but BZ2File doesn't seem to produce a transparent filehandle. Kind regards! Johannes -- http://mail.python.org/mai

Re: MATLAB to Python?

2010-11-22 Thread Peter Otten
MATLABdude wrote: > On Nov 17, 10:53 am, Arnaud Delobelle wrote: >> I guess that the step is supposed to be h, so you should write: >> xx = range(-kappa, kappa+1, h) > > This is what I have in the source code: > ---8<---8<---8<---8<--- > h = 0.105069988414 > xx = range(-kappa, kappa+1, h) > ---

Re: MATLAB to Python?

2010-11-22 Thread Chris Rebert
On Mon, Nov 22, 2010 at 12:47 AM, MATLABdude wrote: > On Nov 17, 10:53 am, Arnaud Delobelle wrote: >> I guess that the step is supposed to be h, so you should write: >>     xx = range(-kappa, kappa+1, h) > > This is what I have in the source code: > ---8<---8<---8<---8<--- > h =  0.105069988414 >

Re: MATLAB to Python?

2010-11-22 Thread MATLABdude
On Nov 17, 10:53 am, Arnaud Delobelle wrote: > I guess that the step is supposed to be h, so you should write: >     xx = range(-kappa, kappa+1, h) This is what I have in the source code: ---8<---8<---8<---8<--- h = 0.105069988414 xx = range(-kappa, kappa+1, h) ---8<---8<---8<---8<--- This is w

Re: Weibull distr. random number generation

2010-11-22 Thread Dimos
Hello Mark, Exactly, thanks very much! Dimos --- On Sat, 11/20/10, Mark Dickinson wrote: > From: Mark Dickinson > Subject: Re: Weibull distr. random number generation > To: python-list@python.org > Date: Saturday, November 20, 2010, 7:09 PM > On Nov 19, 3:21 pm, Dimos > wrote: > > I would li