Re: Overriding a global

2011-12-11 Thread Peter Otten
Roy Smith wrote: > I've got a code pattern I use a lot. In each module, I create a logger > for the entire module and log to it all over: > > logger = logging.getLogger('my.module.name') > > class Foo: >def function(self): > logger.debug('stuff') > logger.debug('other stuff') >

Verbose and flexible args and kwargs syntax

2011-12-11 Thread Eelco Hoogendoorn
Throwing an idea for a PEP out there: It strikes me that the def func(*args, **kwargs) syntax is rather unpytonic. It certainly did not have that 'for line in file' pythonic obviousness for me as a beginner. Plus, asterikses are impossible to google for, so finding out what exactly they do mor

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Chris Angelico
On Sun, Dec 11, 2011 at 9:49 PM, Eelco Hoogendoorn wrote: > Problems im still wrestling with: the same syntax could not be used when > calling a function; that lack of symmetry would make things more confusing, > not less. That symmetry is a large factor, IMHO. I can write a wrapper function like

Re: How to get a correct entry in the menu for a Python application on Mac OS X

2011-12-11 Thread Detlev Offenbach
I got it working by creating a symbolic link to the Python interpreter to be used in my application package and using this symbolic link to start the main Python script. Gregory Ewing wrote: > Detlev Offenbach wrote: >> I am fairly new to Mac OS X and would like to know, what I have to do >> t

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Duncan Booth
Chris Angelico wrote: > Either way, it's a perfect parallel, and that's very useful for > noticing errors. > > With a keyworded syntax, that's going to be a lot harder. If it used keywords then you could keep symmetry quite easily: def anyargs(arglist args, argdict kwargs): return

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Chris Angelico
On Sun, Dec 11, 2011 at 11:39 PM, Duncan Booth wrote: > Chris Angelico wrote: > If it used keywords then you could keep symmetry quite easily: > >    def anyargs(arglist args, argdict kwargs): >        return wrappedfunc(arglist args, argdict kwargs) > > and you would have the advantage of two ne

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Christian Heimes
Am 11.12.2011 13:39, schrieb Duncan Booth: >> Another issue: You suggest being able to use "attrdict" or some other >> dict subclass. This means that, rather than being a language >> construct, this will involve a name lookup. And what happens if you >> have a class that subclasses both list and di

Verbose and flexible args and kwargs syntax

2011-12-11 Thread Eelco Hoogendoorn
Yes, that's just a strict keywordification of the * and ** symbols. The same argument could be made for eliminating the standard algebraic + operator and replacing it with a keyword "__add__". I don't think that's worthwhile. Well, its not quite the same in the sense that algebraic operator

Verbose and flexible args and kwargs syntax

2011-12-11 Thread Eelco Hoogendoorn
As for syntax; what about coopting/integrating with the function annotation syntax? so: def func(args: list, kwargs: attrdict) and correspondingly in the function call? a, b:tuple = someiterable? I guess a rule that interprets every function argument annotated as a subclass of list or dict a

Using python on OS X Lion

2011-12-11 Thread Johann Spies
I have recently upgraded my Snow Leopard to Lion and now I am having all problems with python on my system e.g.: I have install PIL with easy_install but when I do import PIL Python cannot find the pil library. Installing psycopg2 in the same way was successful and I can use psycopg2 without a p

Re: [OT] Book authoring

2011-12-11 Thread Johann Spies
Have a look at Markdown + pandoc. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python on OS X Lion

2011-12-11 Thread Ned Deily
In article , Johann Spies wrote: > I have recently upgraded my Snow Leopard to Lion and now I am having all > problems with python on my system e.g.: > > I have install PIL with easy_install but when I do > > import PIL > > Python cannot find the pil library. Installing psycopg2 in the same w

unittest. customizing tstloaders / discover()

2011-12-11 Thread Gelonida N
Hi, I'd like to have a custom test loder, which will filter out certain tests or which just searches tests in certain directories. I'd like to use regular expresions as include / exclude rules and I would like to have another filter function, which would check for the existence of certain metavar

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Steven D'Aprano
On Sun, 11 Dec 2011 11:49:23 +0100, Eelco Hoogendoorn wrote: > Throwing an idea for a PEP out there: > > It strikes me that the def func(*args, **kwargs) syntax is rather > unpytonic. It certainly did not have that 'for line in file' pythonic > obviousness for me as a beginner. Plus, asterikses a

Documentation for python-evolution - where?

2011-12-11 Thread tinnews
I'm trying to use the python evolution (as in Gnome Evolution) module but I can't find any documetation beyond the odd trivial example and the API documentation at http://doc.conduit-project.org/evolution-python/ (or similar places presumably). The trouble with the API documentation is that it te

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Terry Reedy
On 12/11/2011 5:49 AM, Eelco Hoogendoorn wrote: Plus, asterikses are impossible to google for, so finding out what exactly > they do more or less forces you to write a forum post about it. There are other means of finding information than Google. Really. 1. A couple of years ago, I wrote a ver

Re: unittest. customizing tstloaders / discover()

2011-12-11 Thread Thomas Bach
Gelonida N writes: > I'd like to use regular expresions as include / exclude rules > and I would like to have another filter function, which would check for > the existence of certain metavariabels in test suite files Did you have a look at nose? I'm using it and it supports include/exclude rule

Verbose and flexible args and kwargs syntax

2011-12-11 Thread Eelco Hoogendoorn
No more so than any other form of punctuation. Plus and minus + - may be so common that just about everyone knows it, but how about | == @ % and even . (dot)? None of these things will be obvious to newbies who have never programmed before. Oh well. Some things you just have to learn. Y

Verbose and flexible args and kwargs syntax

2011-12-11 Thread Eelco Hoogendoorn
There are other means of finding information than Google. Really. This is really only a very minor point in my argument, so I dont want to put the focus on this. But really, no. Googling 'myprogramminglanguage conceptimtryingtofigureout' is my first, second and third line of defence. Yes,

What happened to module.__file__?

2011-12-11 Thread Steven D'Aprano
I've just started using a Debian system, instead of the usual RedHat based systems I'm used to, and module.__file__ appears to have disappeared for some (but not all) modules. On Fedora: [steve@orac ~]$ python -E Python 2.6.2 (r262:71600, Aug 21 2009, 12:22:21) [GCC 4.4.1 20090818 (Red Hat 4.4

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Chris Angelico
On Mon, Dec 12, 2011 at 10:53 AM, Eelco Hoogendoorn wrote: > Googling 'myprogramminglanguage conceptimtryingtofigureout' is my first, > second and third line of defence. Yes, I could read the reference manual > from top to bottom, and if I already knew about the existence of your > article then im

Re: Documentation for python-evolution - where?

2011-12-11 Thread Chris Angelico
On Mon, Dec 12, 2011 at 9:28 AM, wrote: > I'm trying to use the python evolution (as in Gnome Evolution) module > but I can't find any documetation beyond the odd trivial example and > the API documentation at http://doc.conduit-project.org/evolution-python/ > (or similar places presumably). One

Re: Verbose and flexible args and kwargs syntax

2011-12-11 Thread Steven D'Aprano
On Mon, 12 Dec 2011 00:44:38 +0100, Eelco Hoogendoorn wrote: >> No more so than any other form of punctuation. Plus and minus + - may >> be so common that just about everyone knows it, but how about | == @ % >> and even . (dot)? None of these things will be obvious to newbies who >> have never

Re: What happened to module.__file__?

2011-12-11 Thread MRAB
On 12/12/2011 00:21, Steven D'Aprano wrote: I've just started using a Debian system, instead of the usual RedHat based systems I'm used to, and module.__file__ appears to have disappeared for some (but not all) modules. On Fedora: [steve@orac ~]$ python -E Python 2.6.2 (r262:71600, Aug 21 2009,

calling python (matplotlib) from c++

2011-12-11 Thread someone
Hi all, I want to call python (matplotlib) from C++. I use ubuntu linux and compile with "-lpython2.7". Besides that, I have this line included: #include I can then do something like this: Py_Initialize(); PyRun_SimpleString("print ' '"); PyRun_SimpleString("print ' '"); PyRun_Simpl

Re: unittest. customizing tstloaders / discover()

2011-12-11 Thread Gelonida N
On 12/12/2011 12:27 AM, Thomas Bach wrote: > Gelonida N writes: > >> I'd like to use regular expresions as include / exclude rules >> and I would like to have another filter function, which would check for >> the existence of certain metavariabels in test suite files > > Did you have a look at n

Outputting raw MIDI in realtime on Linux

2011-12-11 Thread Nick Irvine
I'm trying to output raw, realtime MIDI data (as in note on, note off, etc) in Linux from Python, and I want the easiest way to do it. I've been banging my head on the wall about this for quite some time. The reason for this is to reinvent the old vkeybd application, but it's just me screwing aro

Re: Outputting raw MIDI in realtime on Linux

2011-12-11 Thread alex23
On Dec 12, 12:14 pm, Nick Irvine wrote: > What do people use to output live MIDI on Linux, assuming it's > possible? Hey Nick, I've yet to try this myself although it's long been on my to-do list. There are a couple of packages on PyPI that emit MIDI: http://pypi.python.org/pypi?%3Aaction=searc

Re: Dynamic variable creation from string

2011-12-11 Thread alex23
On Dec 11, 4:42 pm, Nobody wrote: > If just you're trying to avoid getting a repetitive strain injury in your > right-hand little finger from typing all the [''], you could turn > the keys into object attributes, e.g.: > >         class DictObject: >             def __init__(self, d): >          

db agnostic admin for Flask?

2011-12-11 Thread est
Hi guys Are there any db agnostic admin for Flask/Django? Imagine you need CRUD lots of data from Mongodb, Redis, ini file or even remote sources, if such admin allows aggregate data regardless of DB types or syntax, it would be super useful. Anything like this exists? or should I start build on

Re: I love the decorator in Python!!!

2011-12-11 Thread alex23
On Dec 9, 8:08 pm, Robert Kern wrote: > On 12/9/11 5:02 AM, alex23 wrote: > > The 3rd party 'decorator' module takes care of issues like docstrings > > &  function signatures. I'd really like to see some of that > > functionality in the stdlib though. > > Much of it is: > >    http://docs.python.o

Working with Descriptors

2011-12-11 Thread Emeka
Hello All, How do I get the __set__ to work here? import random class Die(object): def __init__(self, sides=6): self.sides = sides def __get__(self, instance, owner): return int(random.random() * self.sides) + 1 def __set__(self, instance, value): instance._

subprocess question

2011-12-11 Thread jyoung79
Wondering if anyone could shed some light on the subprocess module? I'll admit I'm not that great at the shell. If I was wanting to get the size of the trash (on OS X), I could use: >>> os.system('du -sh ~/.Trash/') 11M/Users/jay/.Trash/ 0 Which gives me what I want. However, I've been r

Re: Dynamic variable creation from string

2011-12-11 Thread Ethan Furman
alex23 wrote: On Dec 11, 4:42 pm, Nobody wrote: If just you're trying to avoid getting a repetitive strain injury in your right-hand little finger from typing all the [''], you could turn the keys into object attributes, e.g.: class DictObject: def __init__(self, d):

Re: Working with Descriptors

2011-12-11 Thread Ian Kelly
On Sun, Dec 11, 2011 at 9:32 PM, Emeka wrote: > > Hello All, > > How do I get the __set__ to work here? > > import random > > class Die(object): >     def __init__(self, sides=6): >     self.sides = sides > >     def __get__(self, instance, owner): >     return int(random.random() * self.s

Re: I love the decorator in Python!!!

2011-12-11 Thread 88888 Dihedral
On Monday, December 12, 2011 11:36:07 AM UTC+8, alex23 wrote: > On Dec 9, 8:08 pm, Robert Kern wrote: > > On 12/9/11 5:02 AM, alex23 wrote: > > > The 3rd party 'decorator' module takes care of issues like docstrings > > > &  function signatures. I'd really like to see some of that > > > functional

Re: subprocess question

2011-12-11 Thread Andrew Berg
On 12/11/2011 10:39 PM, jyoun...@kc.rr.com wrote: > And another question - why can't I use the tilde as a shortcut to the home > directory? Because subprocess doesn't use the shell (which is what expands the tilde to the invoking user's home directory). I recommend using os.path.join and os.enviro

Re: tracking variable value changes

2011-12-11 Thread alex23
Andrea Crotti wrote: > Not sure if it's exactly pure python but Traits can actually do > thishttps://github.com/enthought/traits At an attribute level, absolutely, but not at the variable level like the OP is requesting. It's a great package, though :) -- http://mail.python.org/mailman/listinf

Re: subprocess question

2011-12-11 Thread Chris Rebert
On Sun, Dec 11, 2011 at 8:39 PM, wrote: > Wondering if anyone could shed some light on the subprocess module?  I'll > admit I'm not that great at the shell. > > If I was wanting to get the size of the trash (on OS X), I could use: > os.system('du -sh ~/.Trash/') >  11M    /Users/jay/.Trash/

Re: I love the decorator in Python!!!

2011-12-11 Thread alex23
On Dec 12, 2:51 pm, 8 Dihedral wrote: > To wrap a function properly is different from the 1-line lampda. > > This is really functional programming. > > Every function can be decorated to change into a different one easily. > > There is  a method to replace every return action  of a python func

Cannot use multiprocessing and zip together on windows

2011-12-11 Thread Leo Jay
Hi All, I have a file p.zip, there is a __main__.py in it, and the content of __main__.py is: from multiprocessing import Process import os def f(): print 'in f, pid:', os.getpid() if __name__ == '__main__': print 'pid:', os.getpid() p = Process(target=f) p.start() p.join() On

Plot all contents in a two dimension list in a loop?

2011-12-11 Thread huisky
Hi, say I have two lists a and b, which are both in two dimensions. I wanna to plot all curves by using pylab.plot(a[i],b[i]) in a loop for the range of the length(a). I got quite a lot of figures, but only the first one with the plot i want. how to eliminate those blank figures poping out? Rgds