Re: Parallelization in Python 2.6

2009-08-18 Thread Stefan Behnel
Dennis Lee Bieber wrote: > On Tue, 18 Aug 2009 13:45:38 -0700 (PDT), Robert Dailey wrote: >> Really, all I'm trying to do is the most trivial type of >> parallelization. Take two functions, execute them in parallel. This >> type of parallelization is called "embarrassingly parallel", and is >> the

Re: Read C++ enum in python

2009-08-18 Thread AggieDan04
On Aug 18, 6:03 pm, Ludo wrote: > Hello, > > I work in a very large project where we have C++ packages and pieces of > python code. > > I've been googleing for days but what I find seems really too > complicated for what I want to do. > > My business is, in python, to read enum definitions provide

Re: define class over 2 files

2009-08-18 Thread greg
naveen wrote: Is it possible to split up a class definition over multiple files? Not exactly, but you can do variations of this: ... [subclass a class] Multiple inheritance can also be useful: # A_Part1.py class A_Part1: ... # A_Part2.py class A_Part2: ... # A.py from A_Part1 impo

Re: Changing Python Opcodes

2009-08-18 Thread greg
Sreejith K wrote: I know this is not the best way to do it. But I have to do it at least to make it *hard* to decompile the python bytecode. So I compiled Python from source changing some opcode values It probably wouldn't be all that hard for someone to figure this out. A possible avenue of a

Re: Need cleanup advice for multiline string

2009-08-18 Thread Mensanator
On Aug 18, 6:36�am, Jean-Michel Pichavant wrote: > MRAB wrote: > > Carl Banks wrote: > >> On Aug 17, 10:03 am, Jean-Michel Pichavant > >> wrote: > >>> I'm no English native, but I already heard women/men referring to a > >>> group as "guys", no matter that group gender configuration. It's even >

Re: Need cleanup advice for multiline string

2009-08-18 Thread Mensanator
On Aug 17, 11:35�pm, Carl Banks wrote: > On Aug 17, 8:49�pm, Mensanator wrote: > > > > > > > On Aug 17, 8:04 pm, Carl Banks wrote: > > > > On Aug 17, 5:40 pm, Mensanator wrote: > > > > > On Aug 17, 4:06 pm, Carl Banks wrote: > > > > > > On Aug 17, 10:03 am, Jean-Michel Pichavant > > > > > wro

Re: Code formatting question: conditional expression

2009-08-18 Thread John Yeung
On Aug 18, 1:25 pm, John Posner wrote: > BTW, from the (admittedly few) responses to my original > post, it seems there's some sentiment that "conditional > expressions" are a non-Pythonic misfeature. Interesting ... Well, it's not like Guido was especially eager to add it in the first place. I

Re: Need cleanup advice for multiline string

2009-08-18 Thread Mensanator
On Aug 18, 7:59�am, Steven D'Aprano wrote: > On Tue, 18 Aug 2009 13:36:49 +0200, Jean-Michel Pichavant wrote: > > MRAB wrote: > >> Carl Banks wrote: > >>> On Aug 17, 10:03 am, Jean-Michel Pichavant > >>> wrote: > I'm no English native, but I already heard women/men referring to a > grou

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:42 PM, Ben Finney wrote: > Simon Forman writes: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from >> a fundamental forgetfulness of our Unity in God (as I would put it) > > It seems odd, for someone who cites religious intolerance as a problem, >

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 8:03 PM, Steven D'Aprano wrote: > On Tue, 18 Aug 2009 17:13:02 -0400, Simon Forman wrote: > >> Sexism, racism, homophobia, religious intolerance, etc., all stem from a >> fundamental forgetfulness of our Unity in God (as I would put it) and > > Of the tens of thousands of Go

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 6:08 PM, Simon Forman wrote: > On Aug 18, 3:44 pm, Pavel Panchekha wrote: >> I want a dictionary that will transparently "inherit" from a parent >> dictionary. So, for example: >> >> """ >> a = InheritDict({1: "one", 2: "two", 4: "four"}) >> b = InheritDict({3: "three", 4:

Re: How do I convert an iterator over bytes into a str?

2009-08-18 Thread Carl Banks
On Aug 18, 3:24 pm, markscottwright wrote: > This does what I expected: >     In [6]: list(iter([1,2,3,4,5])) >     Out[6]: [1, 2, 3, 4, 5] > > But this appears to be doing a __repr__ rather than making me a nice > string: >    In [7]: str(iter("four score and seven years ago")) >    Out[7]: '' U

Re: How do I convert an iterator over bytes into a str?

2009-08-18 Thread John Machin
On Aug 19, 8:24 am, markscottwright wrote: > This does what I expected: >     In [6]: list(iter([1,2,3,4,5])) >     Out[6]: [1, 2, 3, 4, 5] > > But this appears to be doing a __repr__ rather than making me a nice > string: >    In [7]: str(iter("four score and seven years ago")) >    Out[7]: '' >

Re: Editing a wiki

2009-08-18 Thread yaka
On Aug 18, 6:07 pm, Paul Rubin wrote: > KillSwitch writes: > > Is it possible to edit a wiki page with python, including logging in > > to edit the page, and inserting text into the edit box, etc. > > If you are talking about MediaWiki (the software behind Wikipedia)

Re: Scope and classes

2009-08-18 Thread Ben Finney
Ben Finney writes: > Right. So you use ‘Abc.message’ when you specifically want a class > independent of any instance That's “a class attribute independent of any instance”, of course. -- \“Humanity has advanced, when it has advanced, not because it | `\ has been sober, responsi

Re: Scope and classes

2009-08-18 Thread David
On Aug 19, 1:17 am, "Jan Kaliszewski" wrote: > 19-08-2009 o 02:10:58 Jan Kaliszewski wrote: > > > The only ways to reach Abc's attribute 'message' from that method are: > > * 'Abc.message' > > * 'self.__class__.message' > > * 'self.message' (unless there is an instance attribute 'message' which >

Re: Editing a wiki

2009-08-18 Thread Paul Rubin
KillSwitch writes: > Is it possible to edit a wiki page with python, including logging in > to edit the page, and inserting text into the edit box, etc. If you are talking about MediaWiki (the software behind Wikipedia), it already has an API for which there are several Python clients. See: h

Re: Start-up program

2009-08-18 Thread Dave Angel
Virgil Stokes wrote: How difficult is to create a program that will be executed when Windows Vista is started? As Windows Calendar does, for example. I am actually more interested in the Python tools that might be used for this task. I hope that this question is not inappropriate for the lis

Re: Raw Strings with Variables

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 5:51 PM, WilsonOfCanada wrote: > However, when I send the list over as a dictionary for HTML: > > d["places"] = arrPlaces > > return render_to_response('rentSearch.html', d) > > the HTML using Django has: > > {{ places }} but returns ['C:\\moo', 'C:\\supermoo'] As we've exp

Re: Raw Strings with Variables

2009-08-18 Thread WilsonOfCanada
However, when I send the list over as a dictionary for HTML: d["places"] = arrPlaces return render_to_response('rentSearch.html', d) the HTML using Django has: {{ places }} but returns ['C:\\moo', 'C:\\supermoo'] -- http://mail.python.org/mailman/listinfo/python-list

Call for Papers - PyCon Asia Pacific 2010

2009-08-18 Thread mauricel...@acm.org
Dear fellow friends and colleagues, I apologize if you had received multiple copies of this Call for Papers. Maurice == Call for Papers - PyCon Asia Pacific 2010 ---

Re: Need cleanup advice for multiline string

2009-08-18 Thread Ben Finney
Simon Forman writes: > Sexism, racism, homophobia, religious intolerance, etc., all stem from > a fundamental forgetfulness of our Unity in God (as I would put it) It seems odd, for someone who cites religious intolerance as a problem, to then assert an extremely divisive religious idea. We're

Re: Raw Strings with Variables

2009-08-18 Thread Jan Kaliszewski
Dnia 19-08-2009 o 02:09:29 WilsonOfCanada napisał(a): You're right, but the moment I append it onto a list, it would become C:\\moo. No, it would not. Really! C:\moo C:\supermoo ['C:\\moo', 'C:\\supermoo'] It is not the matter of content of the string but only of a way of *presentation

Re: Raw Strings with Variables

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 5:09 PM, WilsonOfCanada wrote: > You're right, but the moment I append it onto a list, it would become > C:\\moo. > > arrPlaces = [] > intPoint =0 > > while (len(testline)): >        testline = fileName.readline() >        print testline >        arrPlaces[intPoint].append(t

Re: Scope and classes

2009-08-18 Thread Jan Kaliszewski
19-08-2009 o 02:10:58 Jan Kaliszewski wrote: The only ways to reach Abc's attribute 'message' from that method are: * 'Abc.message' * 'self.__class__.message' * 'self.message' (unless there is an instance attribute 'message' which overrides the class attribute). And of course getattr(Abc), ge

Re: Scope and classes

2009-08-18 Thread Jan Kaliszewski
19-08-2009 o 00:47:09 David wrote: Hi all, I'm trying to understand how scopes work within a class definition. I'll quickly illustrate with an example. Say I had the following class definition: class Abc: message = 'Hello World' def print_message(self): print message instan

Re: Raw Strings with Variables

2009-08-18 Thread WilsonOfCanada
You're right, but the moment I append it onto a list, it would become C:\\moo. arrPlaces = [] intPoint =0 while (len(testline)): testline = fileName.readline() print testline arrPlaces[intPoint].append(testline) intPoint += 1 print arrPlaces > C:\moo > C:\supermo

Re: sub-list extraction, logical indexation

2009-08-18 Thread Terry Reedy
Pierre wrote: Hello Everyone, I would like to know if it is possible to extract a sub-list from a list ? typically if : L =[[1, 2, 3],[4, 5, 6],[3] ] How to extract easily the elements 0 and 2 of L in order to get : L2 =[[1, 2, 3],[3] ] L2 = [L[0],L[2]] Moreover, I would like to know if

Re: GUI interface builder for python

2009-08-18 Thread Che M
On Aug 18, 10:54 am, sturlamolden wrote: > On 17 Aug, 17:19, Che M wrote: > > > Boa (Boa Constructor) is really nice for wxPython GUI > > work, but it has some bugs when using Linux that might > > be dealbreakers for the user.  At least I have had > > problems on Ubuntu 8.10 64 bit (but none or v

Re: Need cleanup advice for multiline string

2009-08-18 Thread Steven D'Aprano
On Tue, 18 Aug 2009 17:13:02 -0400, Simon Forman wrote: > Sexism, racism, homophobia, religious intolerance, etc., all stem from a > fundamental forgetfulness of our Unity in God (as I would put it) and Of the tens of thousands of Gods that people have invented, which is the one we're supposed t

Re: basic thread question

2009-08-18 Thread birdsong
On Aug 18, 3:18 pm, Derek Martin wrote: > On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote: > > I have some simple threaded code...  If I run this > > with an arg of 1 (start one thread), it pegs one cpu, as I would > > expect.  If I run it with an arg of 2 (start 2 threads), it uses b

Re: How do I convert an iterator over bytes into a str?

2009-08-18 Thread Jan Kaliszewski
19-08-2009 o 00:24:20 markscottwright wrote: What's the correct way to turn an iterator over bytes into a string? This works, but, ewww: In [8]: "".join(iter("four score and seven years ago")) Out[8]: 'four score and seven years ago' But it is the correct way (and even recommended ove

Re: Read C++ enum in python

2009-08-18 Thread MRAB
Ludo wrote: Hello, I work in a very large project where we have C++ packages and pieces of python code. I've been googleing for days but what I find seems really too complicated for what I want to do. My business is, in python, to read enum definitions provided by the header file of an c+

Re: Raw Strings with Variables

2009-08-18 Thread Albert Hopkins
On Tue, 2009-08-18 at 16:16 -0700, WilsonOfCanada wrote: > Hellos, > > I know that if you have: > > happy = r"C:\moo" > print happy > > you get C:\moo instead of C:\\moo > > The thing is that I want to do this a variable instead. > > ex. testline = fileName.readline() > rawtestline = r t

Re: Scope and classes

2009-08-18 Thread Steven D'Aprano
On Tue, 18 Aug 2009 15:47:09 -0700, David wrote: > Hi all, > > I'm trying to understand how scopes work within a class definition. I'll > quickly illustrate with an example. Say I had the following class > definition: > > class Abc: > message = 'Hello World' > > def print_message(self):

Re: Scope and classes

2009-08-18 Thread David
On Aug 19, 12:16 am, Chris Rebert wrote: > On Tue, Aug 18, 2009 at 3:47 PM, David wrote: > > Hi all, > > > I'm trying to understand how scopes work within a class definition. > > I'll quickly illustrate with an example. Say I had the following class > > definition: > > > class Abc: > >    message

recording input from USB port and write to text file

2009-08-18 Thread Allan
Hi! I'm fairly new to Python. I understand the basics basics but I'm been trying to write a simple python code that will let me read input data (such as mouse movement) from my USB port and write it in a text file and I am so lost. Can anyone help or direct me to some resources? Thank you! -- h

Raw Strings with Variables

2009-08-18 Thread WilsonOfCanada
Hellos, I know that if you have: happy = r"C:\moo" print happy you get C:\moo instead of C:\\moo The thing is that I want to do this a variable instead. ex. testline = fileName.readline() rawtestline = r testline Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python on the web, how to?

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 4:06 PM, Atul. wrote: > Hello All, > > Needless to say I am new to python and web programming. I am looking > for a quick Python-101 course / tutorial for "using python to > implement dynamic content on web" under some web server. Any pointers > what should I be reading? Go

Re: Scope and classes

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 3:47 PM, David wrote: > Hi all, > > I'm trying to understand how scopes work within a class definition. > I'll quickly illustrate with an example. Say I had the following class > definition: > > class Abc: >    message = 'Hello World' > >    def print_message(self): >      

Python on the web, how to?

2009-08-18 Thread Atul.
Hello All, Needless to say I am new to python and web programming. I am looking for a quick Python-101 course / tutorial for "using python to implement dynamic content on web" under some web server. Any pointers what should I be reading? Regards, Atul. -- http://mail.python.org/mailman/listinfo/

Read C++ enum in python

2009-08-18 Thread Ludo
Hello, I work in a very large project where we have C++ packages and pieces of python code. I've been googleing for days but what I find seems really too complicated for what I want to do. My business is, in python, to read enum definitions provided by the header file of an c++ package. Of

Re: How do I convert an iterator over bytes into a str?

2009-08-18 Thread Mark Lawrence
markscottwright wrote: This does what I expected: In [6]: list(iter([1,2,3,4,5])) Out[6]: [1, 2, 3, 4, 5] But this appears to be doing a __repr__ rather than making me a nice string: In [7]: str(iter("four score and seven years ago")) Out[7]: '' What's the correct way to turn an i

Scope and classes

2009-08-18 Thread David
Hi all, I'm trying to understand how scopes work within a class definition. I'll quickly illustrate with an example. Say I had the following class definition: class Abc: message = 'Hello World' def print_message(self): print message >>> instance = Abc() >>> instance.print_messag

Re: Need cleanup advice for multiline string

2009-08-18 Thread Emile van Sebille
On 8/18/2009 2:31 PM Unknown said... You mean the single greatest cause of human misery isn't Microsoft Windows? Either that or users... Sick-of-both-today-ly y'rs, Emile -- http://mail.python.org/mailman/listinfo/python-list

How do I convert an iterator over bytes into a str?

2009-08-18 Thread markscottwright
This does what I expected: In [6]: list(iter([1,2,3,4,5])) Out[6]: [1, 2, 3, 4, 5] But this appears to be doing a __repr__ rather than making me a nice string: In [7]: str(iter("four score and seven years ago")) Out[7]: '' What's the correct way to turn an iterator over bytes into a

Re: [Python-Dev] Mercurial migration: help needed

2009-08-18 Thread Dj Gilcrease
On Tue, Aug 18, 2009 at 2:12 AM, "Martin v. Löwis" wrote: > The second item is line conversion hooks. Dj Gilcrease has posted a > solution which he considers a hack himself. Mark Hammond has also > volunteered, but it seems some volunteer needs to be "in charge", > keeping track of a proposed solut

Re: basic thread question

2009-08-18 Thread Derek Martin
On Tue, Aug 18, 2009 at 03:10:15PM -0500, Derek Martin wrote: > I have some simple threaded code... If I run this > with an arg of 1 (start one thread), it pegs one cpu, as I would > expect. If I run it with an arg of 2 (start 2 threads), it uses both > CPUs, but utilization of both is less than

Re: Setuptools - help!

2009-08-18 Thread Robert Kern
On 2009-08-18 15:06 PM, Erik Vandamme wrote: On Aug 7, 9:17 am, Robert Kern wrote: On 2009-08-06 18:04, Peter Chant wrote: Chaps, any ideas, I'm floundering - I don't quite get it. I have the following files, setup.py and main.py in a directory pphoto: # more setup.py from setuptools

Re: Inheriting dictionary

2009-08-18 Thread Simon Forman
On Aug 18, 3:44 pm, Pavel Panchekha wrote: > I want a dictionary that will transparently "inherit" from a parent > dictionary. So, for example: > > """ > a = InheritDict({1: "one", 2: "two", 4: "four"}) > b = InheritDict({3: "three", 4: "foobar"}, inherit_from=a) > > a[1] # "one" > a[4] # "four" >

Re: Setuptools - help!

2009-08-18 Thread Erik Vandamme
On Aug 7, 9:17 am, Robert Kern wrote: > On 2009-08-06 18:04, Peter Chant wrote: > > > > > Chaps, > > > any ideas, I'm floundering - I don't quite get it.  I have the following > > files, setup.py and main.py in a directory pphoto: > > > # more setup.py > > from setuptools import setup, find_packag

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 4:30 pm, "Jan Kaliszewski" wrote: > Lambda in Python is a sintactic sugar for some simple situations. But you > *always* can replace it with def, e.g.: > >   def MyFunction(): > >       localVariable = 20 >       def TaskFunction(): >           SomeOtherFunction(localVariable) > >      

Re: basic thread question

2009-08-18 Thread Jan Kaliszewski
18-08-2009 o 22:10:15 Derek Martin wrote: I have some simple threaded code... If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect. If I run it with an arg of 2 (start 2 threads), it uses both CPUs, but utilization of both is less than 50%. Can anyone explain

Re: Code formatting question: conditional expression

2009-08-18 Thread Ben Finney
John Posner writes: > > excessblk = None > > if total > P.BASE: > > excessblk = ... > > […] > But doesn't it violate the DRY principle? The token "excessblk" > appears twice instead of once. No, the DRY principle http://c2.com/cgi/wiki?DontRepeatYourself> doesn't speak against assigning two

Re: Editing a wiki

2009-08-18 Thread Paul Boddie
On 18 Aug, 23:02, KillSwitch wrote: > Hey guys, > Is it possible to edit a wiki page with python, including logging in > to edit the page, and inserting text into the edit box, etc. I was > thinking maybe python would be the language to do this in, because I > have to iterate through every line in

Re: Need cleanup advice for multiline string

2009-08-18 Thread Grant Edwards
On 2009-08-18, Simon Forman wrote: > Sexism, racism, homophobia, religious intolerance, etc., all > stem from a fundamental forgetfulness of our Unity in God (as > I would put it) and this is perhaps the single greatest cause > of human misery. You mean the single greatest cause of human misery

Re: Editing a wiki

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 2:02 PM, KillSwitch wrote: > Hey guys, > Is it possible to edit a wiki page with python, including logging in > to edit the page, and inserting text into the edit box, etc. Depends on the wiki. For Mediawiki, yes: http://pywikipediabot.sourceforge.net/ Cheers, Chris -- htt

Re: How to create functors?

2009-08-18 Thread Jan Kaliszewski
Dnia 18-08-2009 o 22:51:19 Robert Dailey napisał(a): The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: def MyFunction(): localVariable = 20 Creat

Re: Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
On Aug 18, 5:11 pm, "Jan Kaliszewski" wrote: > 18-08-2009 o 22:27:41 Nat Williams wrote: > > > > > On Tue, Aug 18, 2009 at 2:44 PM, Pavel Panchekha   > > wrote: > > >> I want a dictionary that will transparently "inherit" from a parent > >> dictionary. So, for example: > > >> """ > >> a = Inherit

Re: How to create functors?

2009-08-18 Thread Diez B. Roggisch
The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: funcs = [] for i in xrange(10): def f(i=i): print i funcs.append(f) for f in funcs:

Re: Code formatting question: conditional expression

2009-08-18 Thread Ben Finney
"Diez B. Roggisch" writes: > excessblk = None > if total > P.BASE: > excessblk = ... > > You don't lose any vertical space, I don't see vertical space as such a scarce resource; we don't have an imminent newline shortage, to my knowledge. I value it far lower than, say, local readability. >

Re: Subclass dynamically

2009-08-18 Thread Sergey Simonenko
On Sat, 08 Aug 2009 11:12:30 -0600, Robert Dailey wrote: How can you subclass a class from an object?.. Hey, I have a class that I want to have a different base class depending on a parameter that I pass to its __init__method. For example (pseudocode): class MyDerived( self.base ): def _

Re: Code formatting question: conditional expression

2009-08-18 Thread Ben Finney
John Posner writes: > Is there any consensus on how to format a conditional expression that > is too long for one line? How about this: > > excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True) > if total > P.BASE else > None) > > The above format sep

Re: How to create functors?

2009-08-18 Thread Leonhard Vogt
The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: def MyFunction(): localVariable = 20 CreateTask( lambda: SomeOtherFunction( localVariable ) ) #

Re: Editing a wiki

2009-08-18 Thread Diez B. Roggisch
KillSwitch schrieb: Hey guys, Is it possible to edit a wiki page with python, including logging in to edit the page, and inserting text into the edit box, etc. I was thinking maybe python would be the language to do this in, because I have to iterate through every line in a text file and gather i

Re: basic thread question

2009-08-18 Thread birdsong
On Aug 18, 1:10 pm, Derek Martin wrote: > I have some simple threaded code...  If I run this > with an arg of 1 (start one thread), it pegs one cpu, as I would > expect.  If I run it with an arg of 2 (start 2 threads), it uses both > CPUs, but utilization of both is less than 50%.  Can anyone expl

Re: Need cleanup advice for multiline string

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:05 PM, Jean-Michel Pichavant wrote: > Steve Holden wrote: Robert Dailey: >> >> [...] >> >>> >>> It's a figure of speech. And besides, why would I want programming >>> advice from a woman? lol. Thanks for the help. >>> >> >> Sorry, Robert, simply not acceptab

Re: Inheriting dictionary

2009-08-18 Thread Jan Kaliszewski
18-08-2009 o 22:27:41 Nat Williams wrote: On Tue, Aug 18, 2009 at 2:44 PM, Pavel Panchekha wrote: I want a dictionary that will transparently "inherit" from a parent dictionary. So, for example: """ a = InheritDict({1: "one", 2: "two", 4: "four"}) b = InheritDict({3: "three", 4: "foobar"},

Re: How to create functors?

2009-08-18 Thread Rami Chowdhury
The example I gave earlier is a bit contrived, the real example fundamentally requires a lambda since I am actually passing in local variables into the functions the lambda is wrapping. Example: def MyFunction(): localVariable = 20 CreateTask( lambda: SomeOtherFunction( localVariable ) ) # Cr

[ANN] Pyjamas 0.6 Web Widget Set and python-to-javascript Compiler released

2009-08-18 Thread Luke Kenneth Casson Leighton
Pyjamas 0.6 is finally out: many thanks to everyone who has contributed. Special thanks to Kees Bos; Bernd, Bernd and Jurgen from LovelySystems.com; the people who showed an interest in Pyjamas at EuroPython 2009; and especially to everyone who has helped during the pre-releases, with testing and

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 4:01 pm, "Jan Kaliszewski" wrote: > Dnia 18-08-2009 o 22:42:59 Robert Dailey napisał(a): > > > I see what you're saying now. However, why am I able to use print as a > > function in general-purpose code in my Python 2.6 script, like so: > > > def SomeFunction(): > >    print( "Hello Wo

Editing a wiki

2009-08-18 Thread KillSwitch
Hey guys, Is it possible to edit a wiki page with python, including logging in to edit the page, and inserting text into the edit box, etc. I was thinking maybe python would be the language to do this in, because I have to iterate through every line in a text file and gather info about what to ente

basic thread question

2009-08-18 Thread Derek Martin
I have some simple threaded code... If I run this with an arg of 1 (start one thread), it pegs one cpu, as I would expect. If I run it with an arg of 2 (start 2 threads), it uses both CPUs, but utilization of both is less than 50%. Can anyone explain why? I do not pretend it's impeccable code

Re: How to create functors?

2009-08-18 Thread Jan Kaliszewski
Dnia 18-08-2009 o 22:42:59 Robert Dailey napisał(a): I see what you're saying now. However, why am I able to use print as a function in general-purpose code in my Python 2.6 script, like so: def SomeFunction(): print( "Hello World" ) But, I am not able to do this: SomeFunction = lambda: p

Re: How to create functors?

2009-08-18 Thread Ned Deily
In article <5834f36f-b172-4e76-ad90-7056e7097...@o6g2000yqj.googlegroups.com>, Robert Dailey wrote: > I see what you're saying now. However, why am I able to use print as a > function in general-purpose code in my Python 2.6 script, like so: > > def SomeFunction(): >print( "Hello World" )

Re: How to create functors?

2009-08-18 Thread Grant Edwards
On 2009-08-18, Robert Dailey wrote: > Hello, > > I want to simply wrap a function up into an object so it can be called > with no parameters. The parameters that it would otherwise have taken > are already filled in. Like so: > > > print1 = lambda: print( "Foobar" ) > print1() > > Howe

Re: How to create functors?

2009-08-18 Thread Rami Chowdhury
why am I able to use print as a function in general-purpose code in my Python 2.6 script I believe it's because that is parsed as the print statement followed by a parenthesized expression. On Tue, 18 Aug 2009 13:42:59 -0700, Robert Dailey wrote: On Aug 18, 3:40 pm, Chris Rebert wrote

Re: How to create functors?

2009-08-18 Thread Jerry Hill
On Tue, Aug 18, 2009 at 4:27 PM, Robert Dailey wrote: > Hello, > > I want to simply wrap a function up into an object so it can be called > with no parameters. The parameters that it would otherwise have taken > are already filled in. Like so: > > >      print1 = lambda: print( "Foobar" ) >      pr

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 3:51 pm, "Jan Kaliszewski" wrote: > 18-08-2009 o 22:32:55 Robert Dailey wrote: > > > > > > > On Aug 18, 3:31 pm, Duncan Booth wrote: > >> Robert Dailey wrote: > >> > Hello, > > >> > I want to simply wrap a function up into an object so it can be called > >> > with no parameters. The

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 3:45 pm, "Rami Chowdhury" wrote: > Lambda expressions are, I believe, syntactically limited to a single   > expression -- no statements, like 'print' is in Python 2.x. > > If you are strongly against just defining a function, you might have to   > use a trick to get around it -- this pa

Re: How to create functors?

2009-08-18 Thread Jan Kaliszewski
18-08-2009 o 22:32:55 Robert Dailey wrote: On Aug 18, 3:31 pm, Duncan Booth wrote: Robert Dailey wrote: > Hello, > I want to simply wrap a function up into an object so it can be called > with no parameters. The parameters that it would otherwise have taken > are already filled in. Like so:

Re: Identifying a class type - bad practice?

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 10:09 AM, James Harris wrote: > I am writing some code to form a tree of nodes of different types. The > idea is to define one class per node type such as > > class node_type_1(node): >   > class node_type_2(node): >   > etc > > (Class "node" would hold any common properties

Re: Parallelization in Python 2.6

2009-08-18 Thread Robert Dailey
On Aug 18, 3:41 pm, Jonathan Gardner wrote: > On Aug 18, 11:19 am, Robert Dailey wrote: > > > > > > > I'm looking for a way to parallelize my python script without using > > typical threading primitives. For example, C++ has pthreads and TBB to > > break things into "tasks". I would like to see s

Re: How to create functors?

2009-08-18 Thread Ned Deily
In article , Robert Dailey wrote: > On Aug 18, 3:31 pm, Duncan Booth wrote: > > Robert Dailey wrote: > > > Hello, > > > > > I want to simply wrap a function up into an object so it can be called > > > with no parameters. The parameters that it would otherwise have taken > > > are already fille

Re: How to create functors?

2009-08-18 Thread Rami Chowdhury
Lambda expressions are, I believe, syntactically limited to a single expression -- no statements, like 'print' is in Python 2.x. If you are strongly against just defining a function, you might have to use a trick to get around it -- this page (http://p-nand-q.com/python/stupid_lambda_tricks

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 3:40 pm, Chris Rebert wrote: > On Tue, Aug 18, 2009 at 1:32 PM, Robert Dailey wrote: > > On Aug 18, 3:31 pm, Duncan Booth wrote: > >> Robert Dailey wrote: > >> > Hello, > > >> > I want to simply wrap a function up into an object so it can be called > >> > with no parameters. The param

Re: Parallelization in Python 2.6

2009-08-18 Thread Jonathan Gardner
On Aug 18, 11:19 am, Robert Dailey wrote: > I'm looking for a way to parallelize my python script without using > typical threading primitives. For example, C++ has pthreads and TBB to > break things into "tasks". I would like to see something like this for > python. So, if I have a very linear sc

Re: define class over 2 files

2009-08-18 Thread Jan Kaliszewski
18-08-2009 o 06:58:58 Xavier Ho wrote: On Tue, Aug 18, 2009 at 2:45 PM, naveen wrote: Is it possible to split up a class definition over multiple files? - Answer in short, I don't think so. Why not? - File a.py: class MyClass: def foo(self, x): return x * 6 -

Re: How to create functors?

2009-08-18 Thread Chris Rebert
On Tue, Aug 18, 2009 at 1:32 PM, Robert Dailey wrote: > On Aug 18, 3:31 pm, Duncan Booth wrote: >> Robert Dailey wrote: >> > Hello, >> >> > I want to simply wrap a function up into an object so it can be called >> > with no parameters. The parameters that it would otherwise have taken >> > are al

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 3:31 pm, Duncan Booth wrote: > Robert Dailey wrote: > > Hello, > > > I want to simply wrap a function up into an object so it can be called > > with no parameters. The parameters that it would otherwise have taken > > are already filled in. Like so: > > >       print1 = lambda: print(

Re: define class over 2 files

2009-08-18 Thread Simon Forman
On Tue, Aug 18, 2009 at 1:57 AM, Steven D'Aprano wrote: > On Mon, 17 Aug 2009 21:45:57 -0700, naveen wrote: > >> Is it possible to split up a class definition over multiple files? > > Not exactly, but you can do variations of this: > > > In file A.py, create: > > class Parent: >    def method(self)

Re: Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
On Aug 18, 4:23 pm, "Jan Kaliszewski" wrote: > 18-08-2009 o 21:44:55 Pavel Panchekha wrote: > > > > > I want a dictionary that will transparently "inherit" from a parent > > dictionary. So, for example: > > > """ > > a = InheritDict({1: "one", 2: "two", 4: "four"}) > > b = InheritDict({3: "three"

Re: How to create functors?

2009-08-18 Thread Robert Dailey
On Aug 18, 3:31 pm, Duncan Booth wrote: > Robert Dailey wrote: > > Hello, > > > I want to simply wrap a function up into an object so it can be called > > with no parameters. The parameters that it would otherwise have taken > > are already filled in. Like so: > > >       print1 = lambda: print(

Re: How to create functors?

2009-08-18 Thread Duncan Booth
Robert Dailey wrote: > Hello, > > I want to simply wrap a function up into an object so it can be called > with no parameters. The parameters that it would otherwise have taken > are already filled in. Like so: > > > print1 = lambda: print( "Foobar" ) > print1() > > However, the a

How to create functors?

2009-08-18 Thread Robert Dailey
Hello, I want to simply wrap a function up into an object so it can be called with no parameters. The parameters that it would otherwise have taken are already filled in. Like so: print1 = lambda: print( "Foobar" ) print1() However, the above code fails with: File "C:\IT\work\dis

Re: Inheriting dictionary

2009-08-18 Thread Nat Williams
On Tue, Aug 18, 2009 at 2:44 PM, Pavel Panchekha wrote: > I want a dictionary that will transparently "inherit" from a parent > dictionary. So, for example: > > """ > a = InheritDict({1: "one", 2: "two", 4: "four"}) > b = InheritDict({3: "three", 4: "foobar"}, inherit_from=a) > > a[1] # "one" > a[

Re: Inheriting dictionary

2009-08-18 Thread Jan Kaliszewski
18-08-2009 o 21:44:55 Pavel Panchekha wrote: I want a dictionary that will transparently "inherit" from a parent dictionary. So, for example: """ a = InheritDict({1: "one", 2: "two", 4: "four"}) b = InheritDict({3: "three", 4: "foobar"}, inherit_from=a) a[1] # "one" a[4] # "four" b[1] # "one"

Re: Code formatting question: conditional expression

2009-08-18 Thread Jan Kaliszewski
18-08-2009 Steven D'Aprano wrote: On Tue, 18 Aug 2009 10:04:36 -0400, John Posner wrote: [snip] How about this: excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True) if total > P.BASE else None) If you insist on using the conditional expres

Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
I want a dictionary that will transparently "inherit" from a parent dictionary. So, for example: """ a = InheritDict({1: "one", 2: "two", 4: "four"}) b = InheritDict({3: "three", 4: "foobar"}, inherit_from=a) a[1] # "one" a[4] # "four" b[1] # "one" b[3] # "three" b[4] # "foobar" """ I've written

Re: comparing XML files to eachother

2009-08-18 Thread Simon Forman
On Mon, Aug 17, 2009 at 3:51 PM, David Brochu wrote: > I need to compare one xml document to another to see if the content matches. > Unfortunately, the formatting (spacing) and order of elements may change > between files from run to run. I have looked into xml dom minidom but can't > seem to find

  1   2   >