with statement and standard library

2010-02-18 Thread nobrowser
Hi. The with statement is certainly nifty. The trouble is, the *only* two documented examples how it can be used with the library classes are file objects (which I use all the time) and thread locks which I almost never use. Yet there are many, many classes in the library whose use would be more

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:52 pm, Gregory Ewing wrote: > Steve Howell wrote: > > Python may not support the broadest notion of anonymous functions, but > > it definitely has anonymous blocks.  You can write this in Python: > > >     for i in range(10): > >         print i > >         print i * i > >         pri

ANN: PiCloud cloud library 1.8 release

2010-02-18 Thread Ken Elkabany
PiCloud, a cloud-computing platform for the Python Programming Language, has released version 1.8 of its client library, cloud. PiCloud enables Python users to leverage the power of an on-demand, high performance, and auto scaling compute cluster with as few as three lines of code! No server manage

Re: How to make an empty generator?

2010-02-18 Thread Ben Finney
Robert Kern writes: > On 2010-02-18 18:33 PM, Ben Finney wrote: > > Robert Kern writes: > > > >> He doesn't want *any* empty generator. He wants an iterator that > >> executes some given side-effect-producing code then immediately > >> raises the StopIteration. > > > > Ah, hm. That's a rather pe

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:37 pm, Kurt Smith wrote: > On Thu, Feb 18, 2010 at 10:46 PM, Steve Howell wrote: > > On Feb 18, 2:49 pm, Jonathan Gardner > > wrote: > >> On Feb 18, 8:15 am, Steve Howell wrote: > > >> >     def print_numbers() > >> >         [1, 2, 3, 4, 5, 6].map { |n| > >> >             [n * n,

Re: How to make an empty generator?

2010-02-18 Thread Steven D'Aprano
On Fri, 19 Feb 2010 00:15:20 -0600, Robert Kern wrote: >>> What's the point of the wheel spinning? Did I miss something? >> >> I wonder whether it's for some kind of framework with a main loop like >> >> for it in list_of_iterables: >> for x in it: >> do_this_or_that (x) >> >> where,

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On 2010-02-18 18:33 PM, Ben Finney wrote: Robert Kern writes: He doesn't want *any* empty generator. He wants an iterator that executes some given side-effect-producing code then immediately raises the StopIteration. Ah, hm. That's a rather perverse use case, but I'm sure the OP has their re

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On 2010-02-18 19:28 PM, Mel wrote: Steven D'Aprano wrote: On Thu, 18 Feb 2010 17:30:54 -0600, Robert Kern wrote: > If all you want is a generator that doesn't yield anything, then > surely there isn't any one-time processing and you don't need the > comment? Sure there is. Python do

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:46 pm, Steven D'Aprano wrote: > On Thu, 18 Feb 2010 19:57:35 -0800, Steve Howell wrote: > > The names you give to the intermediate results here are terse--"tuples" > > and "filtered"--so your code reads nicely. > > > In a more real world example, the intermediate results would be > >

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Fri, 19 Feb 2010 18:52:20 +1300, Gregory Ewing wrote: > The Ruby approach has the advantage of making it possible to implement > user-defined control structures without requiring a macro facility. You > can't do that in Python. [...] > Also, most people who advocate adding some form of block-p

Re: How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 21:34:58 -0800, Dennis Lee Bieber wrote: > On Thu, 18 Feb 2010 15:09:28 -0500, pyt...@bdurham.com declaimed the > following in gmane.comp.python.general: > >> 2. As soon as my process terminates (voluntarily or involuntarily), the >> temp file gets deleted. >> > Which o

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:41 pm, Steven D'Aprano wrote: > On Thu, 18 Feb 2010 22:48:21 -0500, Steve Holden wrote: > > Next week: Lesson 2 - Ad Hominem Attacks > > I wouldn't pay any attention to Steve, all Stevens are notorious liars. > > -- > Steven Especially when their last name starts with H. Cheers, St

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 19:57:35 -0800, Steve Howell wrote: > The names you give to the intermediate results here are terse--"tuples" > and "filtered"--so your code reads nicely. > > In a more real world example, the intermediate results would be > something like this: > >departments >depart

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Gregory Ewing
Steve Howell wrote: Python may not support the broadest notion of anonymous functions, but it definitely has anonymous blocks. You can write this in Python: for i in range(10): print i print i * i print i * i * i There's a clear difference between this and a Ruby

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 22:48:21 -0500, Steve Holden wrote: > Next week: Lesson 2 - Ad Hominem Attacks I wouldn't pay any attention to Steve, all Stevens are notorious liars. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Paul Rubin
Steve Howell writes: >> http://haskell.org/ghc/docs/6.10.4/html/users_guide/syntax-extns.html... >> might be of interest.  Maybe Ruby and/or Python could grow something similar. > Can you elaborate? List comprehensions are a Python feature you're probably familiar with, and I think Ruby has somet

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 7:58 pm, Paul Rubin wrote: > Steve Howell writes: > >> But frankly, although there's no reason that you _have_ to name the > >> content at each step, I find it a lot more readable if you do: > > >> def print_numbers(): > >>     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)] > >>     fi

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Kurt Smith
On Thu, Feb 18, 2010 at 10:46 PM, Steve Howell wrote: > On Feb 18, 2:49 pm, Jonathan Gardner > wrote: >> On Feb 18, 8:15 am, Steve Howell wrote: >> >> >> >> >     def print_numbers() >> >         [1, 2, 3, 4, 5, 6].map { |n| >> >             [n * n, n * n * n] >> >         }.reject { |square, cu

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Gregory Ewing
John Nagle wrote: One way to implement locking is something like this: Mutable objects have a reference count field, a lock field, and an "owner" field. Initially, the owner of an object is its thread. If an object's only reference is a field of a synchronized object, the owner is the sy

best way to create a dict from string

2010-02-18 Thread Tim Arnold
Hi, I've got some text to parse that looks like this text = ''' blah blah blah \Template[Name=RAD,LMRB=False,LMRG=True]{tables} ho dee ho ''' I want to extract the bit between the brackets and create a dictionary. Here's what I'm doing now: def options(text): d = dict() options = text[te

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 8:27 pm, "sjdevn...@yahoo.com" wrote: > On Feb 18, 10:58 pm, Paul Rubin wrote: > > Steve Howell writes: > > >> But frankly, although there's no reason that you _have_ to name the > > >> content at each step, I find it a lot more readable if you do: > > > >> def print_numbers(): > > >

Using compileall to create -OO type .pyo files

2010-02-18 Thread python
I've read the documentation on compileall and tried using this module directly. Nowhere can I find how to specify to compileall that it should create .pyo vs. .pyc files. Goal: I would like to use the compileall.compile_dir() method to generate -OO type .pyo files as part of a larger Python build

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 7:58 pm, Paul Rubin wrote: > Steve Howell writes: > >> But frankly, although there's no reason that you _have_ to name the > >> content at each step, I find it a lot more readable if you do: > > >> def print_numbers(): > >>     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)] > >>     fi

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 2:49 pm, Jonathan Gardner wrote: > On Feb 18, 8:15 am, Steve Howell wrote: > > > > >     def print_numbers() > >         [1, 2, 3, 4, 5, 6].map { |n| > >             [n * n, n * n * n] > >         }.reject { |square, cube| > >             square == 25 || cube == 64 > >         }.map {

Re: Upgrading Py2exe App

2010-02-18 Thread CM
On Feb 18, 7:19 pm, Ryan Kelly wrote: > On Thu, 2010-02-18 at 07:46 -0800, T wrote: > > I have a Python app which I converted to an EXE (all files separate; > > single EXE didn't work properly) via py2exe - I plan on distributing > > this and would like the ability to remotely upgrade the program

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread sjdevn...@yahoo.com
On Feb 18, 10:58 pm, Paul Rubin wrote: > Steve Howell writes: > >> But frankly, although there's no reason that you _have_ to name the > >> content at each step, I find it a lot more readable if you do: > > >> def print_numbers(): > >>     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)] > >>     f

Re: How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread python
Steven, Thank you very much for your wonderful reply!! I had read the Fine Manual, but as you pointed out the documentation only mentions visibility of file names. > Exclusive locks are advisory, not mandatory, on some operating systems, so > you can't rely on it. That comment and your list

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Paul Rubin
Steve Howell writes: >> But frankly, although there's no reason that you _have_ to name the >> content at each step, I find it a lot more readable if you do: >> >> def print_numbers(): >>     tuples = [(n*n, n*n*n) for n in (1,2,3,4,5,6)] >>     filtered = [ cube for (square, cube) in tuples if s

Re: How to make an empty generator?

2010-02-18 Thread Steve Holden
Stephen Hansen wrote: > On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern > wrote: > > class once(object): >def __init__(self, func, *args, **kwds): >self.func = func >self.args = args >self.kwds = kwds > >def __ite

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 3:04 pm, "sjdevn...@yahoo.com" wrote: > On Feb 18, 11:15 am, Steve Howell wrote: > > >     def print_numbers() > >         [1, 2, 3, 4, 5, 6].map { |n| > >             [n * n, n * n * n] > >         }.reject { |square, cube| > >             square == 25 || cube == 64 > >         }.map

Re: "Sounding" Off, IDLE (Win7)

2010-02-18 Thread MRAB
rantingrick wrote: On Feb 18, 6:10 pm, "W. eWatson" wrote: In Win7 IDLE, when I type in something with a syntax problem, a bell rings. How do I stop that? I've looked at Control Panel Sounds, but don't see anything of apparent use. Monkey Patch Said: """ Turn off your speakers""" But what i

Re: Few questions on SOAP

2010-02-18 Thread Steve Holden
Brendon Wickham wrote: > On 19 February 2010 08:07, Mark Lawrence wrote: >> Muhammad Alkarouri wrote: >>> Your question is borderline if not out of topic in this group. I will >>> make a few comments though. >> This might be a Python group, but threads often drift way off topic, which >> added to

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Holden
Steven D'Aprano wrote: > On Thu, 18 Feb 2010 06:15:20 -0800, Steve Howell wrote: [...] > There really ought to be a special level of Hell for people who misuse > "strawman" to mean "a weak or invalid argument" instead of what it > actually means, which is a weak or invalid argument NOT HELD by yo

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 3:00 pm, Steven D'Aprano wrote: > [...] > You wouldn't name your functions: > > f01, f02, f03, f04, ... f99 > Exactly. > (say), unless you were trying to deliberately obfuscate your code. > Anonymous functions are even more obfuscated than that. You can get away > with it so long as y

Re: "Sounding" Off, IDLE (Win7)

2010-02-18 Thread rantingrick
On Feb 18, 6:10 pm, "W. eWatson" wrote: > In Win7 IDLE, when I type in something with a syntax problem, a bell > rings. How do I stop that? I've looked at Control Panel Sounds, but > don't see anything of apparent use. Monkey Patch Said: """ Turn off your speakers""" -- http://mail.python.org/ma

Re: How to make an empty generator?

2010-02-18 Thread Mel
Steven D'Aprano wrote: > On Thu, 18 Feb 2010 17:30:54 -0600, Robert Kern wrote: > >> > If all you want is a generator that doesn't yield anything, then >> > surely there isn't any one-time processing and you don't need the >> > comment? >> >> Sure there is. Python doesn't know that nothing ge

Re: Creating Import Hooks

2010-02-18 Thread Jonathan Gardner
On Feb 18, 1:28 am, Sreejith K wrote: > On Feb 18, 1:57 pm, Steven D'Aprano > > > > wrote: > > On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: > > > On Feb 17, 10:48 pm, Sreejith K wrote: > > >> Hi everyone, > > > >> I need to implement custom import hooks for an application > > >> (

Re: MODULE FOR I, P FRAME

2010-02-18 Thread Rhodri James
On Thu, 18 Feb 2010 09:50:14 -, DANNY wrote: If I want to have a MPEG-4/10 coded video and stream it through the network and than have the same video on the client side, what should I use and of course I don't want to have raw MPEG data, because than I couldn't extract the frames to manipul

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 3:04 pm, "sjdevn...@yahoo.com" wrote: > > You could do it without intermediate names or lambdas in Python as: > def print_numbers(): >     for i in [ cube for (square, cube) in >                          [(n*n, n*n*n) for n in [1,2,3,4,5,6]] >                if square!=25 and cube!=64 ]

Re: How to make an empty generator?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 18:12:10 -0600, Robert Kern wrote: > He wants an iterator that executes some given side-effect-producing code > then immediately raises the StopIteration. Ah, that's the bit I missed! Yewww. Programming by side-effect... I hope the original poster has a good reason for such

Re: How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 15:09:28 -0500, python wrote: > That's my concern - can other applications really read my temp files > created with tempfile.TemporaryFile( delete=True )? >>> import tempfile >>> x = tempfile.TemporaryFile(delete=True) Traceback (most recent call last): File "", line 1, in

Re: How to make an empty generator?

2010-02-18 Thread Ben Finney
Arnaud Delobelle writes: > What about > foo = iter('') That doesn't return a generator. >>> foo = iter('') >>> foo Whether the OP needs to create a generator, or just any iterable type, isn't clear. Robert Kern writes: > He doesn't want *any* empty generator. He wants an i

Re: How to make an empty generator?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 17:30:54 -0600, Robert Kern wrote: > > If all you want is a generator that doesn't yield anything, then > > surely there isn't any one-time processing and you don't need the > > comment? > > Sure there is. Python doesn't know that nothing gets yielded until it > hits the re

Bypassing properties on an object (also with __slots__?)

2010-02-18 Thread Andrey Fedorov
Two questions: 1 - is it documented that o.__dict__[attr] is a reliable way to bypass property methods? 2 - can one bypass a property method if the class has __slots__? Reason: I have a couple of different flavors of request objects which I need to make lazily conform to a standard interface. As

Re: string to list when the contents is a list

2010-02-18 Thread Rhodri James
On Thu, 18 Feb 2010 14:52:29 -, nn wrote: Wes James wrote: I have been trying to create a list form a string. The string will be a list (this is the contents will look like a list). i.e. "[]" or "['a','b']" The "[]" is simple since I can just check if value == "[]" then return [] Bu

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On 2010-02-18 17:36 PM, Stephen Hansen wrote: On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern mailto:robert.k...@gmail.com>> wrote: class once(object): def __init__(self, func, *args, **kwds): self.func = func self.args = args self.kwds = kwds

Re: Upgrading Py2exe App

2010-02-18 Thread Ryan Kelly
On Thu, 2010-02-18 at 07:46 -0800, T wrote: > I have a Python app which I converted to an EXE (all files separate; > single EXE didn't work properly) via py2exe - I plan on distributing > this and would like the ability to remotely upgrade the program (for > example, via HTTP/HTTPS). Looks like i

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Rhodri James
On Thu, 18 Feb 2010 22:11:24 -, Chris Rebert wrote: On Thu, Feb 18, 2010 at 11:58 AM, John Nagle wrote: On that note, I went to a talk at Stanford yesterday by one of the designers of Intel's Nelahem core. The four-core, eight thread version is out now. The six-core, twelve thread ve

[Tutor] "Sounding" Off, IDLE (Win7)

2010-02-18 Thread W. eWatson
In Win7 IDLE, when I type in something with a syntax problem, a bell rings. How do I stop that? I've looked at Control Panel Sounds, but don't see anything of apparent use. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On 2010-02-18 17:33 PM, Ben Finney wrote: Robert Kern writes: On 2010-02-18 16:25 PM, Stephen Hansen wrote: The only way I can figure out how to make an empty generator is: def gen(): # do my one-time processing here return yield Is there a better way? T

Re: How to make an empty generator?

2010-02-18 Thread Terry Reedy
On 2/18/2010 5:25 PM, Stephen Hansen wrote: This has to be a stupid question, but :) I have some generators that do stuff, then start yielding results. On occasion, I don't want them to yield anything ever-- they're only really "generators" because I want to call them /as/ a generator as part of

Re: Why this doesn't work?

2010-02-18 Thread John Posner
On 2/18/2010 12:28 PM, mk wrote: Sorry to bother everyone again, but I have this problem bugging me: #!/usr/bin/python -i class Foo(object): def nostat(self,val): print val nostat.__orig_get__ = nostat.__get__ @staticmethod def nostatget(*args, **kwargs): print 'args:', args, 'kwargs:', kwa

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread John Bokma
John Bokma writes: > Jonathan Gardner writes: > >> On Feb 18, 8:15 am, Steve Howell wrote: >>> >>>     def print_numbers() >>>         [1, 2, 3, 4, 5, 6].map { |n| >>>             [n * n, n * n * n] >>>         }.reject { |square, cube| >>>             square == 25 || cube == 64 >>>         }.m

Re: How to make an empty generator?

2010-02-18 Thread Arnaud Delobelle
On 18 Feb, 23:33, Ben Finney wrote: [...] > No need to define functions or classes; let a generator expression take > care of it for you:: > >     >>> foo = (x for x in list()) >     >>> foo.next() >     Traceback (most recent call last): >       File "", line 1, in >     StopIteration What abou

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread John Bokma
Jonathan Gardner writes: > On Feb 18, 8:15 am, Steve Howell wrote: >> >>     def print_numbers() >>         [1, 2, 3, 4, 5, 6].map { |n| >>             [n * n, n * n * n] >>         }.reject { |square, cube| >>             square == 25 || cube == 64 >>         }.map { |square, cube| >>          

Re: How to make an empty generator?

2010-02-18 Thread Stephen Hansen
On Thu, Feb 18, 2010 at 3:36 PM, Stephen Hansen wrote: > My motivation is clarity, I can just see a colleague a year from now asking > me, "... what the hell is return / yield?" and although this is more > expensive, its less clear to me. > MORE clear to me. A class / decorator / whatever may be

Re: How to make an empty generator?

2010-02-18 Thread Stephen Hansen
On Thu, Feb 18, 2010 at 3:08 PM, Steven D'Aprano < st...@remove-this-cybersource.com.au> wrote: > On 2010-02-18 16:25 PM, Stephen Hansen wrote: > > The only way I can figure out how to make an empty generator is: > > > > def gen(): > > # do my one-time processing here > > > >

Re: How to make an empty generator?

2010-02-18 Thread Stephen Hansen
On Thu, Feb 18, 2010 at 2:56 PM, Robert Kern wrote: > class once(object): >def __init__(self, func, *args, **kwds): >self.func = func >self.args = args >self.kwds = kwds > >def __iter__(self): >return self > >def next(self): >self.func(*self.arg

Re: How to make an empty generator?

2010-02-18 Thread Xavier Ho
I don't think it's a stupid question at all. =]. But wouldn't it solve the problem if you call the generator the first time you need it to yield? Cheers, Xav On Fri, Feb 19, 2010 at 9:30 AM, Robert Kern wrote: > On Feb 18, 5:08 pm, Steven D'Aprano > wrote: > > On 2010-02-18 16:25 PM, Stephen

Re: How to make an empty generator?

2010-02-18 Thread Ben Finney
Robert Kern writes: > On 2010-02-18 16:25 PM, Stephen Hansen wrote: > > The only way I can figure out how to make an empty generator is: > > > > def gen(): > > # do my one-time processing here > > > > return > > yield > > > > Is there a better way? The return/yield

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On Feb 18, 5:08 pm, Steven D'Aprano wrote: > On 2010-02-18 16:25 PM, Stephen Hansen wrote: > > > This has to be a stupid question, but :) > > > I have some generators that do stuff, then start yielding results. On > > occasion, I don't want them to yield anything ever-- they're only > > really "

Re: How to make an empty generator?

2010-02-18 Thread Steven D'Aprano
Sorry for breaking the threading, but Stephen's original post hasn't come through to my provider. On 2010-02-18 16:25 PM, Stephen Hansen wrote: > This has to be a stupid question, but :) > > I have some generators that do stuff, then start yielding results. On > occasion, I don't want them to yi

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread sjdevn...@yahoo.com
On Feb 18, 11:15 am, Steve Howell wrote: >     def print_numbers() >         [1, 2, 3, 4, 5, 6].map { |n| >             [n * n, n * n * n] >         }.reject { |square, cube| >             square == 25 || cube == 64 >         }.map { |square, cube| >             cube >         }.each { |n| >      

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 08:15:46 -0800, Steve Howell wrote: > Just to be clear, I'm not saying it's unforgivable to occasionally ship > software with bugs. It happens. "Occasionally"? Oh, if only. I would say that there probably isn't a non-trivial application in the world that is entirely bug-fre

Re: How to make an empty generator?

2010-02-18 Thread Robert Kern
On 2010-02-18 16:25 PM, Stephen Hansen wrote: This has to be a stupid question, but :) I have some generators that do stuff, then start yielding results. On occasion, I don't want them to yield anything ever-- they're only really "generators" because I want to call them /as/ a generator as part

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Jonathan Gardner
On Feb 18, 8:15 am, Steve Howell wrote: > >     def print_numbers() >         [1, 2, 3, 4, 5, 6].map { |n| >             [n * n, n * n * n] >         }.reject { |square, cube| >             square == 25 || cube == 64 >         }.map { |square, cube| >             cube >         }.each { |n| >    

Re: Few questions on SOAP

2010-02-18 Thread Brendon Wickham
On 19 February 2010 08:07, Mark Lawrence wrote: > Muhammad Alkarouri wrote: >> >> Your question is borderline if not out of topic in this group. I will >> make a few comments though. > > This might be a Python group, but threads often drift way off topic, which > added to the language itself make

Re: Help with lambda

2010-02-18 Thread Jonathan Gardner
On Feb 18, 4:28 am, lallous wrote: > > f = [lambda x: x ** n for n in xrange(2, 5)] This is (pretty much) what the above code does. >>> f = [] >>> n = 2 >>> f.append(lambda x: x**n) >>> n = 3 >>> f.append(lambda x: x**n) >>> n = 4 >>> f.append(lambda x: x**n) >>> n = 5 >>> f.append(lambda x: x**

How to make an empty generator?

2010-02-18 Thread Stephen Hansen
This has to be a stupid question, but :) I have some generators that do stuff, then start yielding results. On occasion, I don't want them to yield anything ever-- they're only really "generators" because I want to call them /as/ a generator as part of a generalized system. The only way I can fig

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 06:15:20 -0800, Steve Howell wrote: > On Feb 18, 1:23 am, Duncan Booth wrote: >> Jonathan Gardner wrote: >> > On Feb 17, 12:02 am, Lawrence D'Oliveiro > > central.gen.new_zealand> wrote: >> >> In message >> >> <8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 11:58:32 -0800, John Nagle wrote: > John Nagle wrote: > >>I look at this as Python's answer to multicore CPUs and "Go". > > On that note, I went to a talk at Stanford yesterday by one of the > designers of Intel's Nelahem core. The four-core, eight thread version > i

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Chris Rebert
On Thu, Feb 18, 2010 at 11:58 AM, John Nagle wrote: >   On that note, I went to a talk at Stanford yesterday by one of the > designers of Intel's Nelahem core.  The four-core, eight thread > version is out now.  The six-core, twelve thread version is working; > the speaker has one in his lab.  Th

Re: Why this doesn't work?

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 18:28:44 +0100, mk wrote: > nostat.__orig_get__ = nostat.__get__ I should point out that leading-and-trailing-double-underscore names are reserved for use by the language. It's unlikely that Python will introduce a special method named __orig_get__, and in truth the pr

Re: Executing a command from within python using the subprocess module

2010-02-18 Thread Aahz
In article <5yudnafyso8houtwnz2dnuvz_tidn...@westnet.com.au>, R (Chandra) Chandrasekhar wrote: > >--- >import subprocess > >width = 5 >height = 30 >colors = ['#abcdef]', '#456789'] >filename = "/tmp/image.png" > ># I want to get the equivalent of variable interpolation in Perl ># so that the comma

LISA 2010 CFP

2010-02-18 Thread ntwrkd
Hello All, The USENIX Large Installation System Administration Conference is now accepting paper proposals. If you are interested in submitting a paper, please check out this blog post about submitting a paper (http://www.usenix.org/events/lisa10/cfp/), or feel free to contact me directly if you th

Re: string to list when the contents is a list

2010-02-18 Thread Aahz
In article , Wes James wrote: > >try: >if value=3D=3D'[]' or value=3D=3D'': > value=3D[] >else: > no_brackets =3D value[1:-1] # s.strip(' \t[]') > c =3D csv.reader([no_brackets], quotechar=3D"'") > value=3Dc.n

Python won't run

2010-02-18 Thread Nardin, Cory L.
Quickly, I have a Mac Intel with Windows XP installed. Tried installing Python 2.6.4 from the binary and also ActivePython 2.6.4.10. Both installations acted the same. There seemed to be no problems during installation (used default options), but when I try to run Python I get an error message:

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Ethan Furman
John Nagle wrote: John Nagle wrote: I look at this as Python's answer to multicore CPUs and "Go". On that note, I went to a talk at Stanford yesterday by one of the designers of Intel's Nelahem core. The four-core, eight thread version is out now. The six-core, twelve thread version i

Re: Few questions on SOAP

2010-02-18 Thread Mark Lawrence
Muhammad Alkarouri wrote: Your question is borderline if not out of topic in this group. I will make a few comments though. This might be a Python group, but threads often drift way off topic, which added to the language itself make this a great group to read. If you don't like the way a threa

Re: string to list when the contents is a list

2010-02-18 Thread Benjamin Kaplan
On Thu, Feb 18, 2010 at 2:56 PM, Wes James wrote: > > I get an error (when I take the "try" out): > > AttributeError: 'function' object has no attribute 'reader' > You have a function called "csv" that's defined after the import csv statement is executed. That function has no attribute 'reader",

Why do full path names to module show up multiple times in .PYC files?

2010-02-18 Thread python
I just happened to look at a compiled Python 2.6.4 .PYC file in an editor and noticed that the full path and file name of the compiled module showed up in my .PYC file at least 10 different times. Is there a reason for full vs. relative path names and why does the module name need to be duplicated

Re: What happened to pyjamas?

2010-02-18 Thread Chris Colbert
ah, yep, i was viewing the page chrome had cached. It's down for me too. I lose the trace in Washington: 3 G3-0-873.TAMPFL-LCR-08.verizon-gni.net (130.81.110.222) 14.399 ms 17.917 ms 18.040 ms 4 so-6-1-0-0.TPA01-BB-RTR2.verizon-gni.net (130.81.29.242) 18.666 ms 18.890 ms 19.232 ms 5 ge

Re: unit testing a routine that sends mail

2010-02-18 Thread Phlip
commander_coder wrote: > I have a routine that sends an email (this is how a Django view > notifies me that an event has happened).  I want to unit test that > routine. Are you opening SMTP and POP3 sockets?? If you are not developing that layer itself, just use Django's built- in mock system. H

Re: string to list when the contents is a list

2010-02-18 Thread Tim Chase
import csv class IS_LIST(): def __init__(self, format='', error_message='must be a list!'): self.format = format self.error_message = error_message def __call__(self, value): try: if value=='[]' or value=='': value=[] else:

Re: How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread python
MRAB, > Well, the contents of temp files aren't encrypted, if that's what you're > asking I understand the contents of temp files aren't encrypted. > if you're writing unencrypted data to a temp file then other applications > could read it. That's my concern - can other applications really re

Re: Few questions on SOAP

2010-02-18 Thread Muhammad Alkarouri
Your question is borderline if not out of topic in this group. I will make a few comments though. On Feb 18, 3:36 pm, joy99 wrote: > Dear Group, > > I was reading on SOA or Service Oriented Architecture for last few > days and got some questions. As this is a room for the expert computer > scient

Re: string to list when the contents is a list

2010-02-18 Thread Wes James
On Thu, Feb 18, 2010 at 12:32 PM, Wes James wrote: > On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase > wrote: >> Wes James wrote: > > >> >> Just to add to the list of solutions I've seen, letting the built-in csv >> module do the heavy lifting: >> >>  >>> s = "['a','b']" >>  >>> import csv >>  >>> no

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread John Nagle
John Nagle wrote: I look at this as Python's answer to multicore CPUs and "Go". On that note, I went to a talk at Stanford yesterday by one of the designers of Intel's Nelahem core. The four-core, eight thread version is out now. The six-core, twelve thread version is working; the spea

Re: How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread MRAB
pyt...@bdurham.com wrote: I'm doing a code review of an application that occassionally writes blocks of secure data to temp files created with tempfile.TemporaryFile( delete=True ). How secure are temp files created via tempfile.TemporaryFile( delete=True )? Are there OS specific nuances I s

Re: string to list when the contents is a list

2010-02-18 Thread Wes James
On Thu, Feb 18, 2010 at 8:18 AM, Tim Chase wrote: > Wes James wrote: > > Just to add to the list of solutions I've seen, letting the built-in csv > module do the heavy lifting: > >  >>> s = "['a','b']" >  >>> import csv >  >>> no_brackets = s[1:-1] # s.strip(' \t[]') >  >>> c = csv.reader([no_br

Re: What happened to pyjamas?

2010-02-18 Thread sstein...@gmail.com
Down from here (NH, US). S On Feb 18, 2010, at 1:44 PM, Chris Colbert wrote: > -- http://mail.python.org/mailman/listinfo/python-list

How secure are temp files created via tempfile.TemporaryFile()?

2010-02-18 Thread python
I'm doing a code review of an application that occassionally writes blocks of secure data to temp files created with tempfile.TemporaryFile( delete=True ). How secure are temp files created via tempfile.TemporaryFile( delete=True )? Are there OS specific nuances I should be concerned about regard

Re: What happened to pyjamas?

2010-02-18 Thread Daniel Fetchinson
>> Does anyone know what happened to pyjs.org ? > > it's working for me. That's odd, it's unpingable for me from both Europe and the US, ping says unknown host. Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list

Re: What happened to pyjamas?

2010-02-18 Thread Chris Colbert
it's working for me. On Thu, Feb 18, 2010 at 1:16 PM, Daniel Fetchinson < fetchin...@googlemail.com> wrote: > Does anyone know what happened to pyjs.org ? > > Cheers, > Daniel > > > -- > Psss, psss, put it down! - http://www.cafepress.com/putitdown > -- > http://mail.python.org/mailman/listinfo/p

Re: What happened to pyjamas?

2010-02-18 Thread Mark Lawrence
Daniel Fetchinson wrote: Does anyone know what happened to pyjs.org ? Cheers, Daniel According to google cache it was fine 13/02/2010 and it's down according to this. http://downforeveryoneorjustme.com/pyjs.org HTH. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list

What happened to pyjamas?

2010-02-18 Thread Daniel Fetchinson
Does anyone know what happened to pyjs.org ? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list

Re: Few questions on SOAP

2010-02-18 Thread Simon Brunning
On 18 February 2010 15:36, joy99 wrote: > (iv)    Is SOAPpy fine? AFAIK, SOAPpy is unsupported, and a bit on the stale side. Those poor souls forced to make SOAP calls with Python seem to be using Suds mostly these days,. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-li

Why this doesn't work?

2010-02-18 Thread mk
Sorry to bother everyone again, but I have this problem bugging me: #!/usr/bin/python -i class Foo(object): def nostat(self,val): print val nostat.__orig_get__ = nostat.__get__ @staticmethod def nostatget(*args, **kwargs): print 'args:', args, 'kwargs:', kwarg

Re: Constraints on __sub__, __eq__, etc.

2010-02-18 Thread Jean-Michel Pichavant
Andrey Fedorov wrote: It may be intuitive to you, but its not true, written down anywhere, nor assumed by the language, and the mathematical meaning of the operators doesn't matter to Python. Python purposefully does not enforce anything for these methods. Right, so neither is

Re: Is automatic reload of a module available in Python?

2010-02-18 Thread Simon Brunning
2010/2/17 Arnaud Delobelle : > I know some people will point at more 'pro' ways of testing but this has > the merit of being very straightforward.  Then when you move on to more > sophisticated techniques, I think you will understand better the > motivations behind them. Oh, I don't know. I like t

  1   2   >