Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-08 Thread Kay Schluehr
O.K. Mark. Since you seem to accept the basic requirement to build an *external* DSL I can provide some help. I'm the author of EasyExtend ( EE ) which is a system to build external DSLs for Python. http://www.fiber-space.de/EasyExtend/doc/EE.html EE is very much work in progress and in the last

Python Imaging Library and textmate

2009-01-08 Thread bilgin arslan
Hello, I am a beginner in python and I am trying to create image files that contain lines from a text file. I am trying to do this with PIL, which seems like a suitable tool. I have a copy of TextMate(1.5.8) and I run Macosx 10.5.6 The problem is, even though I installed PIL correctly (I get no er

Re: threading in PyQt vs threading in standard library

2009-01-08 Thread Steven Woody
On Fri, Jan 9, 2009 at 3:32 PM, Phil Thompson wrote: > On Fri, 9 Jan 2009 15:15:28 +0800, "Steven Woody" > wrote: >> Hi, >> >> I am considering using PyQt for GUI programs, and I notices that both >> of them include threading supports, so which one should I pick up? >> Similar also applies 'socke

threading in PyQt vs threading in standard library

2009-01-08 Thread Steven Woody
Hi, I am considering using PyQt for GUI programs, and I notices that both of them include threading supports, so which one should I pick up? Similar also applies 'socket'. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Best practice in organize classes into modules

2009-01-08 Thread Steven Woody
On Fri, Jan 9, 2009 at 2:52 PM, Steve Holden wrote: > Chris Rebert wrote: >> On Thu, Jan 8, 2009 at 9:09 PM, Steven Woody wrote: >>> On Fri, Jan 9, 2009 at 1:02 PM, James Mills >>> wrote: On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody wrote: > In C++/Java, people usually put one class in

Re: Best practice in organize classes into modules

2009-01-08 Thread Steve Holden
Chris Rebert wrote: > On Thu, Jan 8, 2009 at 9:09 PM, Steven Woody wrote: >> On Fri, Jan 9, 2009 at 1:02 PM, James Mills >> wrote: >>> On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody wrote: In C++/Java, people usually put one class into one file. What's the suggestion on this topic in Py

Re: Implementing file reading in C/Python

2009-01-08 Thread Steve Holden
MRAB wrote: > Johannes Bauer wrote: >> Hello group, [and about 200 other lines there was no need to quote] [...] > Have a look at psyco: http://psyco.sourceforge.net/ Have a little consideration for others when making a short reply to a long post, please. Trim what isn't necessary. Thanks. regard

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 2:29 PM, James Mills wrote: > I shall attempt to optimize this :) > I have a funny feeling you might be caught up with > some features of Python - one notable one being that > some things in Python are immutable. > > psyco might help here though ... What does this little t

Re: why cannot assign to function call

2009-01-08 Thread rurpy
Joe Strout wrote: > ru...@yahoo.com wrote: > >> "the same as anyone else's" only if [Python's] "idea >> of assignment" does not include producing the same >> results. >> >> a = array (1,2,3) >> b = a >> a[1] = 4 >> print b >> >> C, C++, VBA, Fortran, Perl: 1, 2, 3 >> Python: 1, 4, 3 > > Y

Re: drive a desktop app from python?

2009-01-08 Thread Srinivasa NL
You can use subprocess module to start an application and also read it's output. You can kill it yourself (when you know when to do it) Srinivas. On Fri, Jan 9, 2009 at 2:36 AM, Tim Arnold wrote: > Hi, I don't even know what to google for on this one. I need to drive a > commercial desktop app

Re: "python -3" not working as expected

2009-01-08 Thread John Machin
On Jan 9, 1:56 pm, Benjamin wrote: > On Jan 8, 4:21 pm, Thorsten Kampe wrote: > > > * Terry Reedy (Thu, 08 Jan 2009 17:04:04 -0500) > > > Since you are, I believe, at least the second person to report being bit > > > by this confusion, please open an issue at bugs.python.org and suggest a > > > c

Re: Best practice in organize classes into modules

2009-01-08 Thread Chris Rebert
On Thu, Jan 8, 2009 at 9:09 PM, Steven Woody wrote: > On Fri, Jan 9, 2009 at 1:02 PM, James Mills > wrote: >> On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody wrote: >>> In C++/Java, people usually put one class into one file. What's the >>> suggestion on this topic in Python? I so much interestin

drive a desktop app from python?

2009-01-08 Thread Tim Arnold
Hi, I don't even know what to google for on this one. I need to drive a commercial desktop app (on windows xp) since the app doesn't have a batch interface. It's intended to analyze one file at a time and display a report. I can get the thing to write out the report an html browser, but I have

Re: Printed Documentation

2009-01-08 Thread Tim Arnold
"floob" wrote in message news:0af87074-6d9c-41a8-98ec-501f6f37b...@s1g2000prg.googlegroups.com... >I have been searching for a way to print the official Python > documentation into some kind of book (for my own uses). I don't > really care if it's printed on newspaper and bound with elmer's > gl

Re: Best practice in organize classes into modules

2009-01-08 Thread Steven Woody
On Fri, Jan 9, 2009 at 1:02 PM, James Mills wrote: > On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody wrote: >> In C++/Java, people usually put one class into one file. What's the >> suggestion on this topic in Python? I so much interesting this >> especially when exception classes also involved. >

Re: multiprocessing and SIGINT

2009-01-08 Thread akineko
It is a bit awkward to respond to my posting but I have some updates. I created two simple test programs, one uses threading and another uses multiprocessing. What I found was: (1) test program with threading Only main thread receives SIGINT (generated thread won't receive SIGINT) (2) test progra

Re: Best practice in organize classes into modules

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 2:57 PM, Steven Woody wrote: > In C++/Java, people usually put one class into one file. What's the > suggestion on this topic in Python? I so much interesting this > especially when exception classes also involved. Normally i group related functionality into the one modul

Best practice in organize classes into modules

2009-01-08 Thread Steven Woody
Hi, In C++/Java, people usually put one class into one file. What's the suggestion on this topic in Python? I so much interesting this especially when exception classes also involved. Thanks. - narke -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a decorator a staticmethod

2009-01-08 Thread Carl Banks
On Jan 8, 1:57 pm, Jonathan Gardner wrote: > (Aside: I really can't think of any reason to use staticmethods in > Python other than to organize functions into namespaces, and even > then, that's what modules are for, right?) In a certain widget toolkit (which I won't mention by name but it begins

Re: figuring week of the day....

2009-01-08 Thread Tim Chase
tekion wrote: Is there a module where you could figure week of the day, like where it starts and end. I need to do this for a whole year. Thanks. sounds like you want the standard library's "calendar" module, particularly the monthcalendar() which gets you pretty close. For a lazy version ju

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 3:13 PM, Johannes Bauer wrote: > Uhh, yes, you're right there... I must admit that I was too lazy to > include all the stat headers and to a proper st_size check in the C > version (just a quick hack), so it's practically hardcoded. > > With files of exactly 2GB in size the

Re: why cannot assign to function call

2009-01-08 Thread Joe Strout
ru...@yahoo.com wrote: "the same as anyone else's" only if [Python's] "idea of assignment" does not include producing the same results. a = array (1,2,3) b = a a[1] = 4 print b C, C++, VBA, Fortran, Perl: 1, 2, 3 Python: 1, 4, 3 You are mistaken (except perhaps in the Fortran case,

Re: Implementing file reading in C/Python

2009-01-08 Thread Johannes Bauer
James Mills schrieb: > I have tested this against a randomly generated > file from /dev/urandom (10M). Yes the Python > one is much slower, but I believe it's bebcause > the Python implementation is _correct_ where > teh C one is _wrong_ :) > > The resulting test.bin.pgm from python is exactly >

Re: Implementing file reading in C/Python

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 1:04 PM, Johannes Bauer wrote: > Hello group, Hello. (...) > Which takes about 40 seconds. I want the niceness of Python but a little > more speed than I'm getting (I'd settle for factor 2 or 3 slower, but > factor 30 is just too much). > > Can anyone point out how to sol

Re: Implementing file reading in C/Python

2009-01-08 Thread MRAB
Johannes Bauer wrote: Hello group, I've come from C/C++ and am now trying to code some Python because I absolutely love the language. However I still have trouble getting Python code to run efficiently. Right now I have a easy task: Get a file, split it up into a million chunks, count the most p

Re: "python -3" not working as expected

2009-01-08 Thread Benjamin
On Jan 8, 4:21 pm, Thorsten Kampe wrote: > * Terry Reedy (Thu, 08 Jan 2009 17:04:04 -0500) > > Since you are, I believe, at least the second person to report being bit > > by this confusion, please open an issue at bugs.python.org and suggest a > > couple of revised sentences that you think are mo

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread webcomm
On Jan 8, 8:54 pm, MRAB wrote: > Have you tried gzip instead? There's no option to download the data in a gzipped format. The files are .zip archives. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tree views - Best design practices

2009-01-08 Thread Diez B. Roggisch
Filip Gruszczyński wrote: > class Element(object): >>operations = "Element operations" >> >> > class Group(object): >>operations = "Group operations" >> >> > e = Element() > g = Group() > > e.operations >> 'Element operations' > g.operations >> 'Group op

Re: How to Delete a Cookie?

2009-01-08 Thread Jose C
> To kill the cookie, simply set a cookie with the same name (and path) Actually you may not even need to specify the path. Just the name and expires param should do the trick. Haven't played with cookies in a while so try with and without the path. -- http://mail.python.org/mailman/listinfo/pyt

Implementing file reading in C/Python

2009-01-08 Thread Johannes Bauer
Hello group, I've come from C/C++ and am now trying to code some Python because I absolutely love the language. However I still have trouble getting Python code to run efficiently. Right now I have a easy task: Get a file, split it up into a million chunks, count the most prominent character in ea

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread MRAB
webcomm wrote: On Jan 8, 8:02 pm, MRAB wrote: You're just creating a file called "data.zip". That doesn't make it a zip file. A zip file has a specific format. If the file doesn't have that format then the zipfile module will complain. Hmm. When I open it in Windows or with 7-Zip, it contain

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread webcomm
On Jan 8, 8:39 pm, "James Mills" wrote: > Send us a sample of this file in question... It contains data that I can't share publicly. I could ask the providers of the service if they have a dummy file I could use that doesn't contain any real data, but I don't know how responsive they'll be. It'

Re: Python 2.6 fails on compiling > Bug report

2009-01-08 Thread googler . 1 . webmaster
Hi searched for "Library/Frameworks/" in the config file and edited it to "@executable_path". Well my configure and make command worked very fine. Just 'make install' aborted after this error message. test -d "/Applications/Python 2.6" || mkdir -p "/Applications/Python 2.6" test -d "/Application

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread James Mills
On Fri, Jan 9, 2009 at 11:28 AM, webcomm wrote: > Hmm. When I open it in Windows or with 7-Zip, it contains a text file > that has the data I would expect it to have. I guess that alone > doesn't necessarily prove it's a zip file? > > datum is something I'm downloading via a web service. The pr

Python 2.6 fails on compiling > Bug report

2009-01-08 Thread googler . 1 . webmaster
Hi! I compiled Python 2.6.1 on a Mac OSX 10.5.5 Intel machine with this configure command and got this message FAILS: ./configure --with-framework-name=Python --with- universal-archs=all --enable-framework --enable- universals...@executable_path/my/path/to/app WORKS: ./configur

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread webcomm
On Jan 8, 8:02 pm, MRAB wrote: > You're just creating a file called "data.zip". That doesn't make it a > zip file. A zip file has a specific format. If the file doesn't have > that format then the zipfile module will complain. Hmm. When I open it in Windows or with 7-Zip, it contains a text file

Re: why cannot assign to function call

2009-01-08 Thread rurpy
Mark Wooding wrote: ... > I agree with the comment about Pascal, but C is actually pretty similar > to Python here. C only does pass-by-value. As a side comment (because it always bugs me when I read this, even though I read it in very authoritative sources), ISTM that C passes everything by valu

OSCON 2009: Call For Participation

2009-01-08 Thread Aahz
The O'Reilly Open Source Convention has opened up the Call For Participation -- deadline for proposals is Tuesday Feb 3. OSCON will be held July 20-24 in San Jose, California. For more information, see http://conferences.oreilly.com/oscon http://en.oreilly.com/oscon2009/public/cfp/57 -- Aahz (a.

Re: why cannot assign to function call

2009-01-08 Thread rurpy
Mark Wooding wrote: ... > Python doesn't need another name for assignment, OK. > because actually its > idea of assignment is the same as anyone else's. The difference is in > the way it deals with objects. See argument elsewhere. "the same as anyone else's" only if [Python's] "idea of assignm

Re: BadZipfile "file is not a zip file"

2009-01-08 Thread MRAB
webcomm wrote: The error... file = zipfile.ZipFile('data.zip', "r") Traceback (most recent call last): File "", line 1, in file = zipfile.ZipFile('data.zip', "r") File "C:\Python25\lib\zipfile.py", line 346, in __init__ self._GetContents() File "C:\Python25\lib\zipfile.py", line

BadZipfile "file is not a zip file"

2009-01-08 Thread webcomm
The error... >>> file = zipfile.ZipFile('data.zip', "r") Traceback (most recent call last): File "", line 1, in file = zipfile.ZipFile('data.zip', "r") File "C:\Python25\lib\zipfile.py", line 346, in __init__ self._GetContents() File "C:\Python25\lib\zipfile.py", line 366, in _GetCo

Re: ulimit stack size and python threads

2009-01-08 Thread Greg Lindahl
I see. I should be blaming the default behavior of pthreads. I did work on a OpenMP library once, and we worked around this problem, plus we gave good error messages. Given the number of HPC sites which use Python, I'd think that Python would have grown similar features. (HPC sites are more likely

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Sergey Kishchenko
On 8 янв, 22:03, "Chris Rebert" wrote: > On Thu, Jan 8, 2009 at 5:53 AM, Sergey Kishchenko wrote: > > In Python empty container equals False in 'if' statements: > > > # prints "It's ok" > > if not []: > >    print "It's ok" > > > Let's create a simple Foo class: > > > class Foo: > >    pass > > >

Re: ulimit stack size and python threads

2009-01-08 Thread Andrew MacIntyre
Greg Lindahl wrote: I figure this is a FAQ, but I can't find it in any FAQs. I want to limit the stacksize on my server. If I set it to 8 megs, or unlimited, python is happy. If I set it to 4 gigabytes, things like yum (which is a python program) crash creating a thread. This is on an x86_64 l

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-08 Thread J Kenneth King
Kay Schluehr writes: > On 8 Jan., 16:25, J Kenneth King wrote: > >> As another poster mentioned, eventually PyPy will be done and then >> you'll get more of an "in-Python" DSL. > > May I ask why you consider it as important that the interpreter is > written in Python? I don't think it's importa

Re: ulimit stack size and python threads

2009-01-08 Thread Greg Lindahl
> Why do you think Python is overloading the meaning of that? I ensure > you it isn't - it doesn't actively care what the limits are. Always crashing because I asked the OS to please not allow a process to grow too big is what I call overloading the meaning of ulimit -s. It's quite surprising. Not

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : To Bruno's first e-mail: Everything you said was correct but largely off topic. for a definition of "off topic" equals to "didn't fit your expectations". I did already understand these things as well. Sorry - but it was not necessarily obvious from your post, and it's ne

Re: ulimit stack size and python threads

2009-01-08 Thread Martin v. Löwis
> But even if that worked, I'd be worried that python is doing something > bad with the ulimit -s value under the covers. Again: it definitely isn't. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:50 pm, "Filip Gruszczyński" wrote: > > But I am looking for a different type of flexibility. I would like to > be able to add more classes to my hierarchy and not have to change my > code in many places when I add new class to the hierarchy. If I have > to change every class in the hie

Re: ulimit stack size and python threads

2009-01-08 Thread Greg Lindahl
> How much higher? You could try just under 4GB (unsigned 32-bit) and just > under 2GB (signed 32-bit). I'd like to set it to be about 1/2 the memory size of my server, which happens to end up being 4 gbytes. And no, slightly less than 4 gb doesn't work. But even if that worked, I'd be worried th

Re: "python -3" not working as expected

2009-01-08 Thread Thorsten Kampe
* Terry Reedy (Thu, 08 Jan 2009 17:04:04 -0500) > Thorsten Kampe wrote: > > * Marc 'BlackJack' Rintsch (8 Jan 2009 16:26:55 GMT) > >> On Thu, 08 Jan 2009 16:38:53 +0100, Thorsten Kampe wrote: > >>> [Python 2.6.1] > >>> > >>> to test existing Python code, I ran "python -3" ("warn about Python 3.x >

Re: linked list with cycle structure

2009-01-08 Thread David Hláčik
Hi, well i am able to find a loop in a list using two iterators.One iterator runs "two times faster than the other", and if he encounters the first, it means that there is a loop. Example : 1,2,3,4,5,6,7,8,9,5 the algorithm would generate: start - 1,2 iteration 1- 2, 4 iteration 2- 3, 6 iteratio

Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Grant Edwards
On 2009-01-08, Bruno Desthuilliers wrote: > Grant Edwards a ?crit : >> On 2009-01-08, Alex van der Spek wrote: >> >>> Thanks much, that makes sense! >> >> Well, that's the correct explanation. >> >> Whether that feature makes sense or not is debatable. Even I'm >> not old-school enough that

Re: ulimit stack size and python threads

2009-01-08 Thread Martin v. Löwis
> Why is Python overloading the meaning of the ulimit -s like this? Why do you think Python is overloading the meaning of that? I ensure you it isn't - it doesn't actively care what the limits are. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
To Bruno's first e-mail: Everything you said was correct but largely off topic. I did already understand these things as well. To Bruno's second email quote: """ Nope. He's relying on (part of) the interface(s) implemented by the first argument. The class object itself has nothing to do with is (we

Re: "python -3" not working as expected

2009-01-08 Thread Terry Reedy
Thorsten Kampe wrote: * Marc 'BlackJack' Rintsch (8 Jan 2009 16:26:55 GMT) On Thu, 08 Jan 2009 16:38:53 +0100, Thorsten Kampe wrote: [Python 2.6.1] to test existing Python code, I ran "python -3" ("warn about Python 3.x incompatibilities") against a test file that only contains "print 'test'".

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Bruno Desthuilliers
Sergey Kishchenko a écrit : In Python empty container equals False in 'if' statements: Yes. # prints "It's ok" if not []: print "It's ok" Let's create a simple Foo class: class Foo: pass Now I can use Foo objects in 'if' statements: Yes. #prints "Ouch!" f=Foo() if f: print

Re: ulimit stack size and python threads

2009-01-08 Thread MRAB
Greg Lindahl wrote: I'm only guessing, but could it be a 32-bit limit somewhere? Have you tried, say, 1GB, which would be within a 32-bit limit? Indeed, ulimit -s 100 (a bit smaller than 1 GB) does work, but it doesn't solve my problem, since I want to set the limit higher than 1 GB. How m

Re: Work with Open Office

2009-01-08 Thread Michael Torrie
Dan Esch wrote: > Have been browsing through this list and reading documentation and tutorials > for python self-study. I have, apparently, teh stupid. Google is my > friend. Off I go. Thanks. Let us know how it goes. Last time I tried to script OO, I found it to be much more difficult than V

Re: Tree views - Best design practices

2009-01-08 Thread Filip Gruszczyński
> Yes. There is a difference between the interface of an object (namely, > what methods and attributes it has and what their semantic meaning is) > and the class of an object (what methods and attributes it has and how > they are implemented.) > > In general, you shouldn't be asking about an object

Re: "python -3" not working as expected

2009-01-08 Thread Thorsten Kampe
* Marc 'BlackJack' Rintsch (8 Jan 2009 16:26:55 GMT) > On Thu, 08 Jan 2009 16:38:53 +0100, Thorsten Kampe wrote: > > [Python 2.6.1] > > > > to test existing Python code, I ran "python -3" ("warn about Python 3.x > > incompatibilities") against a test file that only contains "print > > 'test'". > >

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:00 pm, "Filip Gruszczyński" wrote: > > Is it really any better than asking for class? I mean, if I need to > add another class to a hierarchy which behaves differently, will it be > more flexible (actually you have to add another method to every class > and check for in the gui). I bel

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 1:00 pm, "Filip Gruszczyński" wrote: > > Is it really any better than asking for class? I mean, if I need to > add another class to a hierarchy which behaves differently, will it be > more flexible (actually you have to add another method to every class > and check for in the gui). I bel

Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2009-01-08, Alex van der Spek wrote: Thanks much, that makes sense! Well, that's the correct explanation. Whether that feature makes sense or not is debatable. Even I'm not old-school enough that I ever use octal literals -- and I used Unix on a PDP-11 for years

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Jonathan Gardner a écrit : On Jan 8, 11:18 am, "Zac Burns" wrote: In my use case (not the example below) the decorator returns a function of the form def f(self, *args, **kwargs) which makes use of attributes on the instance self. So, it only makes sense to use the staticmethod in the class and

Re: ulimit stack size and python threads

2009-01-08 Thread Greg Lindahl
> I'm only guessing, but could it be a 32-bit limit somewhere? Have you > tried, say, 1GB, which would be within a 32-bit limit? Indeed, ulimit -s 100 (a bit smaller than 1 GB) does work, but it doesn't solve my problem, since I want to set the limit higher than 1 GB. -- greg -- http://mail.p

Re: [Python-Dev] compiling python2.5 on linux under wine

2009-01-08 Thread Martin v. Löwis
> i'd just ... much rather be completely independent of proprietary > software when it comes to building free software. I guess my question is then: why do you want to use Windows in the first place? Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : I've read the "Making staticmethod objects callable?" thread now, and would have to disagree that all the use cases are strange as stated at http://www.python.org/dev/summary/2006-03-01_2006-03-15/#making-staticmethod-objects-callable In my use case (not the example below)

Re: ulimit stack size and python threads

2009-01-08 Thread MRAB
Greg Lindahl wrote: I figure this is a FAQ, but I can't find it in any FAQs. I want to limit the stacksize on my server. If I set it to 8 megs, or unlimited, python is happy. If I set it to 4 gigabytes, things like yum (which is a python program) crash creating a thread. This is on an x86_64 l

Re: Tree views - Best design practices

2009-01-08 Thread Filip Gruszczyński
>class Element(object): >@staticmethod >def is_leaf(): return True >@staticmethod >def is_branch(): return False > >class Group(object): >@staticmethod >def is_leaf(): return False >@staticmethod >def is_branch(): return True >

ulimit stack size and python threads

2009-01-08 Thread Greg Lindahl
I figure this is a FAQ, but I can't find it in any FAQs. I want to limit the stacksize on my server. If I set it to 8 megs, or unlimited, python is happy. If I set it to 4 gigabytes, things like yum (which is a python program) crash creating a thread. This is on an x86_64 linux kernel, RHEL5, et

Re: mmap only supports string

2009-01-08 Thread Robert Kern
Neal Becker wrote: Problem is, AFAIK a string can only be created as a copy of some other data. Say I'd like to take some large object and read/write to/from mmap object. A good way to do this would be the buffer protocol. Unfortunately, mmap only supports string. A string could only be cr

Re: Replying to list messages

2009-01-08 Thread Terry Reedy
Ben Finney wrote: For Thunderbird (which I see you're using, Paul), the open bug report is https://bugzilla.mozilla.org/show_bug.cgi?id=45715>. Meanwhile, you can install an add-on to provide the function http://www.juergen-ernst.de/addons/replytolist.html>. When I read the list as a newsgroup

Re: Tree views - Best design practices

2009-01-08 Thread Jonathan Gardner
On Jan 8, 8:16 am, MRAB wrote: > Filip Gruszczyński wrote: > > Hi! > > > I have certain design problem, which I cannot solve elegantly. Maybe > > you know some good design patterns for this kind of tasks. > > > Task: > > > We have a model which has two kinds of objects: groups and elements. > > Gr

Re: How to deepcopy a list of user defined lists?

2009-01-08 Thread Terry Reedy
srinivasan srinivas wrote: Hi, I have a class which is a subclass of builtin-type list. #-- class clist(list): def __new__(cls, values, ctor): val = [] for item in values: item = ctor(item

Re: Tree views - Best design practices

2009-01-08 Thread Filip Gruszczyński
I'd love to have operations methods, which would return names of operations and references to proper methods. The problem is that certain operations require more, than just running some operation on the Group or Element. Let's say, you want to add new group to an existing one - you can't do that to

Re: figuring week of the day....

2009-01-08 Thread Chris Rebert
On Tue, Jan 6, 2009 at 7:56 AM, tekion wrote: > Is there a module where you could figure week of the day, like where > it starts and end. I need to do this for a whole year. Thanks. The "%U" time format specifier (Week number of the year) to strftime() [http://docs.python.org/library/datetime.htm

Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Terry Reedy
Alex van der Spek wrote: I can't think of anything that could cause this. Similarly, eval('09') fails, but for string 0x with x<8 it works. I am teaching myself Python in order to climb the ladder from Algol(1980s)-->Pascal(1990s)-- VisualBasic(2000)-->Python. I am a physicist, have programmed

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Chris Rebert
On Thu, Jan 8, 2009 at 5:53 AM, Sergey Kishchenko wrote: > In Python empty container equals False in 'if' statements: > > # prints "It's ok" > if not []: >print "It's ok" > > Let's create a simple Foo class: > > class Foo: >pass > > Now I can use Foo objects in 'if' statements: > > #prints

Re: why cannot assign to function call

2009-01-08 Thread Joe Strout
Mark Wooding wrote: The `they're just objects' model is very simple, but gets tied up in knots explaining things. The `it's all references' model is only a little more complicated, but explains everything. But it *over* explains, because it implies things that "everybody knows" about reference

Re: Making a decorator a staticmethod

2009-01-08 Thread Jonathan Gardner
On Jan 8, 11:18 am, "Zac Burns" wrote: > > In my use case (not the example below) the decorator returns a > function of the form def f(self, *args, **kwargs) which makes use of > attributes on the instance self. So, it only makes sense to use the > staticmethod in the class and in the baseclass. M

Re: Default __nonzero__ impl doesn't throw a TypeError exception

2009-01-08 Thread Terry Reedy
Sergey Kishchenko wrote: In Python empty container equals False in 'if' statements: # prints "It's ok" if not []: print "It's ok" Let's create a simple Foo class: class Foo: pass Now I can use Foo objects in 'if' statements: #prints "Ouch!" f=Foo() if f: print "Ouch!" So, defaul

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Zac Burns
Correct, 2.6.1 does not complain. If only I could upgrade! The workaround is obvious and I'll do that. Thanks for your help. -- Zachary Burns (407)590-4814 Aim - Zac256FL Production Engineer (Digital Overlord) Zindagi Games On Thu, Jan 8, 2009 at 11:34 AM, Carl Banks wrote: > On Jan 8, 12:27

Re: looking for tips on how to implement "ruby-style" Domain Specific Language in Python

2009-01-08 Thread mark
> So you can't make an internal DSL like this that uses Python's built- > in grammar.  You'd have to hack the parser or settle for an external > preprocessor. This time it is really hard for me but I begin accepting the fact that I will have to build an external DSL. I experimented some weeks ago

Re: Tree views - Best design practices

2009-01-08 Thread Terry Reedy
Filip Gruszczyński wrote: class Element(object): operations = "Element operations" class Group(object): operations = "Group operations" e = Element() g = Group() e.operations 'Element operations' g.operations 'Group operations' But this is the same as asking for a clas

Re: cPickle vs pickle discrepancy

2009-01-08 Thread Carl Banks
On Jan 8, 12:27 pm, "Zac Burns" wrote: > Thanks for your patience waiting for me to isolate the problem. > > | Package > --__init__.py ->empty > --Package.py ->empty > --Module.py >      import cPickle >      class C(object): >         pass >      def fail(): >         return cPickle.dumps(C(), -1

Re: Work with Open Office

2009-01-08 Thread Terry Reedy
Benjamin Kaplan wrote: On Thu, Jan 8, 2009 at 10:07 AM, Dan Esch > wrote: Okay, I'm currently stuck with VBA / Excel in work and the following paradigm: VB (6? .NET? not sure) ==> VBA ==> Excel 2003 and Access Where I'd like to be is

Re: why cannot assign to function call

2009-01-08 Thread Mark Wooding
Erik Max Francis wrote: > Terry Reedy wrote: > > > >>> a='par'+'rot' > > >>> b='parrot' > > >>> a is b > > True > > One exactly doesn't really say much. It's implementation dependent, and > depends on the length of the string: > > >>> a = 'this is a much longer ' + 'parrot' > >>> b = 'thi

Re: Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
I've read the "Making staticmethod objects callable?" thread now, and would have to disagree that all the use cases are strange as stated at http://www.python.org/dev/summary/2006-03-01_2006-03-15/#making-staticmethod-objects-callable In my use case (not the example below) the decorator returns a

Re: How do you write to the printer ?

2009-01-08 Thread Albert Hopkins
On Wed, 2009-01-07 at 16:46 -0600, da...@bag.python.org wrote: > Can find nothing in the on-line docs or a book. > Groping in the dark I attempted : > > script24 > import io > io.open('stdprn','w') # accepted > stdprn.write('hello printer') # fails < stdprn is not defined >

Re: Making a decorator a staticmethod

2009-01-08 Thread Bruno Desthuilliers
Zac Burns a écrit : I have a decorator in a class Why ? (snip) The exception that I get when using it as a staticmethod and try to use it in the baseclass is "TypeError: 'staticmethod' object is not callable". When it is not staticmethod the exception I get in the extension class is is "TypeE

Re: How to Delete a Cookie?

2009-01-08 Thread Jose C
On Jan 8, 10:33 am, tryg.ol...@gmail.com wrote: > On Jan 8, 1:16 pm, Jose C wrote: > > > > > > c["mycook"]["expires"] = 0 > > > Set ["expires"] using the following format to any time less than > > current (which causes the browser to delete the cookie). > > Here's a function I use to return a cook

Re: compiling python2.5 on linux under wine

2009-01-08 Thread lkcl
> ... nd, that means disabling setup.py or hacking it significantly > to support a win32 build, e.g. to build pyexpat, detect which modules > are left, etc. by examining the remaining vcproj files in PCbuild. ok - i started the hacking. the first bit of hacking is this, in distutils/sysconfi

Making a decorator a staticmethod

2009-01-08 Thread Zac Burns
I have a decorator in a class to be used by that class and by inheriting classes ## class C(object): @staticmethod # With this line enabled or disabled usage in either C or D will be broken. To see that D works remember to remove usage in C def decorateTest(func):

Re: sftp with no password from python

2009-01-08 Thread Mike Hjorleifsson
On Jan 8, 10:39 am, loial wrote: > Is it possible to use sftp without a password from python? Yes you can use keys you preestablish between the server and client so you dont need passwords, i do this on all my servers then lock off the ability to accept passwords at all, this way no one can dicti

Re: Is it ok to type check a boolean argument?

2009-01-08 Thread Carl Banks
On Jan 7, 6:21 pm, Scott David Daniels wrote: > Adal Chiriliuc wrote: > > On Jan 7, 10:15 pm, Bruno Desthuilliers > > wrote: > >> ... I'd either keep the argument as a boolean but rename it "ascending" ... > > > Well, I lied a bit :-p   > > But what if we can't solve it as elegantly, and we n

Re: why cannot assign to function call

2009-01-08 Thread Mark Wooding
[Steven's message hasn't reached my server, so I'll reply to it here. Sorry if this is confusing.] Aaron Brady wrote: > On Jan 8, 1:45 am, Steven D'Aprano > wrote: > > On Wed, 07 Jan 2009 10:17:55 +, Mark Wooding wrote: > > > > > The `they're just objects' model is very simple, but gets tied

Re: "python -3" not working as expected

2009-01-08 Thread Benjamin Peterson
Steve Holden holdenweb.com> writes: > Thorsten Kampe wrote: > > Unfortunately I saw no warnings about print becoming a function in > > Python 3 ("print()"). Where is the problem? > > > I *believe* that's not flagged because 2to3 will fix it automatically. This is correct; there's not much point

Re: Replying to list messages

2009-01-08 Thread Paul McNett
Ben Finney wrote: Paul McNett writes: But arguing about this here isn't going to change anything: opinions differ just like tabs/spaces and bottom-post/top-post. In cases like this, one side can simply be wrong :-) Best of luck getting your programs behaving as you want them to! BTW, I agr

Re: How to Delete a Cookie?

2009-01-08 Thread tryg . olson
On Jan 8, 1:16 pm, Jose C wrote: > > c["mycook"]["expires"] = 0 > > Set ["expires"] using the following format to any time less than > current (which causes the browser to delete the cookie). > Here's a function I use to return a cookie expiry timestamp, negative > values passed in result in cooki

  1   2   >