Re: Help the visibility of Python in computational science

2013-02-01 Thread dg . google . groups
On Friday, February 1, 2013 12:09:04 AM UTC-5, Chris Angelico wrote: > On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano > > wrote: > > > dg.google.gro...@thesamovar.net wrote: > > > > > >> If you could take one minute to make sure you > > >> are signed in to your Google+ account > > > > > >

Re: Help the visibility of Python in computational science

2013-01-31 Thread dg . google . groups
On Thursday, January 31, 2013 10:06:44 PM UTC-5, Terry Reedy wrote: > On 1/31/2013 8:05 PM, dg.google.gro...@thesamovar.net wrote: > > Here's the link to the article: > > http://www.scholarpedia.org/article/Brian_simulator > > 'Brian' is obviously a play on 'brain', with two letters transposed. Bu

Help the visibility of Python in computational science

2013-01-31 Thread dg . google . groups
Hi everyone, There is currently a competition running that could help give Python in computational science a bit of visibility. The competition is for the most popular recently published article on the Scholarpedia website, one of which is about a Python package "Brian" for computational neuroscie

CUDA

2009-01-29 Thread dg . google . groups
Hi all, Has anyone managed to get any of the Python CUDA libraries working on Windows using cygwin? Which one, and was anything special required? Thanks in advance for any advice. Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: type-checking support in Python?

2008-10-07 Thread dg . google . groups
I also wrote a units package which I'm using for a project of my own (a spiking neural network simulator package called 'Brian'), released separately as a package called Piquant which you can get at sourceforge: http://sourceforge.net/projects/piquant I'm also looking for people to help improve i

Re: How to tell if I'm being run from a shell or a module

2008-02-14 Thread dg . google . groups
On Feb 14, 11:06 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > It depends on what you mean by "an interactive shell"? If you start your > script with: > python -i whatever.py > is it an interactive shell or not? > > I tried these two criteria: > a) See if the __main__ module has a __file__ a

Re: How to tell if I'm being run from a shell or a module

2008-02-14 Thread dg . google . groups
Thanks for the replies, but it's not what I meant. What I want to be able to determine is whether or not the user is running from an interactive shell (like IPython or IDLE). Checking if __name__=='__main__' checks if the current module is the one being run, but suppose you have two modules A and B

How to tell if I'm being run from a shell or a module

2008-02-14 Thread dg . google . groups
Hi all, Is there any standard way to tell if the user is running from a module or from an interactive shell like IDLE or IPython? The best I've come up with so far is for a function to look at getouterframes(currentframe())[1][1] (the filename in the frame record of the frame that called the funct

Re: Adding properties to an instance

2008-02-07 Thread dg . google . groups
> > Does this mean that __setattr__ > > incurs the same performance penalty that overriding __getattribute__ > > would? > > Not quite AFAICT - there's less going on here. Also, getting an > attribute is (usually at least) more common than setting it. > > > Possibly I can live with this because I th

Re: Adding properties to an instance

2008-02-07 Thread dg . google . groups
> As a side note: the naming symetry between __getattr__ and __setattr__ > is a gotcha, since __setattr__ is mostly symetric to __getattribute__ - > IOW, customizing __setattr__ is a bit tricky. The naive approach, ie: Ah I see - so __setattr__ is called immediately whereas __getattr__ is only cal

Re: Adding properties to an instance

2008-02-06 Thread dg . google . groups
On Feb 6, 11:09 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > While this is technically possible (I tried a couple years ago), it > requires hacking the __getattribute__ method, which is something I > would not recommand, not only because it can be tricky, but mostly > because this is a very

Re: Adding properties to an instance

2008-02-06 Thread dg . google . groups
On Feb 6, 10:54 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > I'd suggest a small improvement: _A as a class name isn't very nice. > Replace the inner class statement with: > _A = type(self.__class__.__name__ + '_autoprops', (self.__class__,), {}) Ah yes, that's much nicer. > A problem wit

Adding properties to an instance

2008-02-06 Thread dg . google . groups
Hi all, So I understand that properties belong to a class not an instance, but nonetheless I want to add properties to an instance. I have a class which when an instance is created runs some fairly complicated code and produces a set of names which I'd like to be able to access via properties. At

explicit protocols and duck typing

2008-01-27 Thread dg . google . groups
Hi all, As I understand it, the idea behind duck typing is that you just take an object and if it has the methods you want to use you use it assuming it to be the right type of object. I'm interested in extending this idea a bit, but I feel the sort of thing I have in mind has already been thought

Re: Python self-evaluating strings

2008-01-27 Thread dg . google . groups
It's a bit cheap, but how about >>> from inspect import getsource >>> print getsource(getsource) or similarly def f(g): import inspect return inspect.getsource(g) print f(f) Dan -- http://mail.python.org/mailman/listinfo/python-list

Re: Just for fun: Countdown numbers game solver

2008-01-23 Thread dg . google . groups
Well I tried the NumPy array thing that I was talking about, to parallelise the problem, and there were some difficulties with it. Firstly, the pruning makes a really big difference to the speed, and you don't get that if you're trying to parallelise the problem because what is an equivalent calcul

Re: Just for fun: Countdown numbers game solver

2008-01-22 Thread dg . google . groups
Arnaud and Terry, Great solutions both of you! Much nicer than mine. I particularly like Arnaud's latest one based on folding because it's so neat and conceptually simple. For me, it's the closest so far to my goal of the most elegant solution. So anyone got an answer to which set of numbers give

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread dg . google . groups
Decided I may as well post my other solution while I'm at it. The neat trick here is redefining the add, mul, etc. functions so that they raise exceptions for example if x>y then add(x,y) raises an exception which is handled by the search algorithm to mean don't continue that computation - this sto

Re: Just for fun: Countdown numbers game solver

2008-01-21 Thread dg . google . groups
Hi all, It's great how many different sorts of solutions (or almost solutions) this puzzle has generated. Speedwise, for reference my solution posted above takes about 40 seconds on my 1.8GHz laptop, and the less elegant version (on my webpage linked to in the original post) takes about 15 seconds

Re: Just for fun: Countdown numbers game solver

2008-01-20 Thread dg . google . groups
Hi Marek, That's a really nice solution (and ultrafast). Unfortunately I realise I stated the problem imprecisely. You're only allowed to use each number once (otherwise there's a trivial solution for every problem, i.e. x/x + x/x + x/x + ... + x/x repeated y times for target y given any source n

Just for fun: Countdown numbers game solver

2008-01-20 Thread dg . google . groups
Ever since I learnt to program I've always loved writing solvers for the Countdown numbers game problem in different languages, and so now I'm wondering what the most elegant solution in Python is. If you don't know the game, it's simple: you're given six randomly chosen positive integers, and a t

Re: Magic function

2008-01-14 Thread dg . google . groups
Hi Rüdiger, Thanks for your message. I liked your approach and I've been trying something along exactly these sorts of lines, but I have a few problems and queries. The first problem is that the id of the frame object can be re-used, so for example this code (where I haven't defined InstanceTrac

Re: Magic function

2008-01-12 Thread dg . google . groups
Thanks everyone for the comments. I had previously thought about the possibility of the classes keeping track of their instances. I guess this could probably be done quite transparently with a decorator too (as we have many different types of objects being collected together). The only issue is th

Magic function

2008-01-11 Thread dg . google . groups
Hi all, I'm part of a small team writing a Python package for a scientific computing project. The idea is to make it easy to use for relatively inexperienced programmers. As part of that aim, we're using what we're calling 'magic functions', and I'm a little bit concerned that they are dangerous c