Re: revive a generator

2011-10-21 Thread Yingjie Lan
> Here's an example of an explicit request to revive the generator: > g = (x*x for x in range(3)) for x in g: print x > 0 > 1 > 4 g = (x*x for x in range(3)) # revive the generator for x in g: print x #now this will work > 0 > 1 > 4 > > ChrisA What if the generator is p

Re: revive a generator

2011-10-21 Thread Paul Rudin
Yingjie Lan writes: > - Original Message - >> From: Paul Rudin >> Generators are like that - you consume them until they run out of >> values. You could have done [x*x for x in range(3)] and then iterated >> over that list as many times as you wanted. >> >> A generator doesn't have to

Re: revive a generator

2011-10-21 Thread Yingjie Lan
- Original Message - > From: Paul Rudin > The language has no explicit notion of a request to "revive" a > generator. You could use the same syntax to make a new generator that > yeilds the same values as the one you started with if that's what you > want. > > As we've already discussed

Re: revive a generator

2011-10-21 Thread Yingjie Lan
- Original Message - > From: Paul Rudin > To: python-list@python.org > Cc: > Sent: Friday, October 21, 2011 3:27 PM > Subject: Re: revive a generator > > > The language has no explicit notion of a request to "revive" a > generator. You could use the same syntax to make a new generator

Problem with inheritance

2011-10-21 Thread Sverre
I have to classes a and b class a(object): def __init__(self,x): self.x = x self.build() def build(self): return class b(a): def __init__(self,x): a.__init__(self,x) self.y = 0 # ??? def build(self): # do something self.

Re: revive a generator

2011-10-21 Thread Paul Rudin
Yingjie Lan writes: > > > What if the generator involves a variable from another scope, > and before re-generating, the variable changed its value. > Also, the generator could be passed in as an argument, > so that we don't know its exact expression. > vo = 34  g = (vo*x for x in range(3

Re: revive a generator

2011-10-21 Thread Chris Angelico
On Fri, Oct 21, 2011 at 7:02 PM, Yingjie Lan wrote: > What if the generator involves a variable from another scope, > and before re-generating, the variable changed its value. > Also, the generator could be passed in as an argument, > so that we don't know its exact expression. > There's actually

Re: Problem with inheritance

2011-10-21 Thread Chris Angelico
On Fri, Oct 21, 2011 at 7:07 PM, Sverre wrote: > The line marked with "???" will no be executed and I don't know the > reason. This example is working as intended, but not not the code I'm > working on. I'm using Eclipse. I don't know how to debug this > problem. > Did you notice the error you go

Re: Problem with inheritance

2011-10-21 Thread Sverre
On Oct 21, 10:07 am, Sverre wrote: > I have to classes a  and b > > class a(object): >     def __init__(self,x): >         self.x = x >         self.build() > >     def build(self): >         return > > class b(a): >     def __init__(self,x): >         a.__init__(self,x) >         self.y = 0  # ??

Re: revive a generator

2011-10-21 Thread Yingjie Lan
- Original Message - > From: Paul Rudin > > I'm not really sure whether you intend g to yield the original values > after your "revive" or new values based on the new value of vo.  But > still you can make a class that supports the iterator protocol and does > whatever you want (but you

Re: SMS api for python

2011-10-21 Thread Chris Rebert
On Fri, Oct 21, 2011 at 12:10 AM, Pankaj wrote: > I want to make an api that would recieve the SMS text from the user > and process it then send the result back to the use. Is there any api > that I can use to do this?? There would seem to be several options: http://pypi.python.org/pypi?%3Aaction

Re: revive a generator

2011-10-21 Thread Yingjie Lan
- Original Message - > From: Chris Angelico > To: python-list@python.org > Cc: > Sent: Friday, October 21, 2011 4:27 PM > Subject: Re: revive a generator > > On Fri, Oct 21, 2011 at 7:02 PM, Yingjie Lan wrote: >> What if the generator involves a variable from another scope, >> and

No module named Pwd - under Apache 2.2

2011-10-21 Thread durumdara
Hi! Win7/x64, Python 3.2, PyPGSQL f 3.2 and Apahce 2.2. I created a script that working in CGI mode, it is read some table, and returns with an XML. It was working with normal mode, under Pyscripter, and under command line. But! When I trying to use it from Apache 2.2 as cgi, I got the subject

Re: No module named Pwd - under Apache 2.2

2011-10-21 Thread Peter Otten
durumdara wrote: > Hi! > > Win7/x64, Python 3.2, PyPGSQL f 3.2 and Apahce 2.2. > > I created a script that working in CGI mode, it is read some table, > and returns with an XML. > > It was working with normal mode, under Pyscripter, and under command > line. > > But! > > When I trying to use

Re: Problem with inheritance

2011-10-21 Thread Jean-Michel Pichavant
Sverre wrote: I have to classes a and b class a(object): def __init__(self,x): self.x = x self.build() def build(self): return class b(a): def __init__(self,x): a.__init__(self,x) self.y = 0 # ??? def build(self): # do somethi

Re: Benefit and belief

2011-10-21 Thread rusi
On Oct 21, 11:36 am, Ben Finney wrote: > rusi writes: > > The American programmer would profit more from learning Latin than > > from learning yet another programming language. > > > Edsger Dijkstra in "On the fact that the Atlantic Ocean has two > > sides" > > >http://www.cs.utexas.edu/users/EWD

Re: revive a generator

2011-10-21 Thread Dave Angel
On 10/20/2011 10:09 PM, Yingjie Lan wrote: What if the generator is passed in as an argument when you are writing a function? That is, the expression is not available? Secondly, it would be nice to automatically revive it. For example, when another for-statement or other equivalent is appli

Re: Py3K: file inheritance

2011-10-21 Thread Yosifov Pavel
On 21 окт, 13:50, Ian Kelly wrote: > On Thu, Oct 20, 2011 at 10:17 PM, Yosifov Pavel wrote: > > Little silly example: > > > class MyFile(file): > > šdef __init__(self, *a, **ka): > > š šsuper(MyFile, self).__init__(*a, **ka) > > š šself.commented = 0 > > šdef write(self, s): > > š šif s.startswit

Automated form submissions

2011-10-21 Thread Matty Sarro
Hey everyone. First, I apologize because I know this question has probably gotten asked a lot. I am looking to automate filling out web forms, and no, its not for spamming purposes. I have looked at mechanize so far, but I'm not sure it quite fits what I'm looking for. I know it can act as a brows

Re: revive a generator

2011-10-21 Thread Steven D'Aprano
On Thu, 20 Oct 2011 19:09:42 -0700, Yingjie Lan wrote: >> Here's an example of an explicit request to revive the generator: > > > g = (x*x for x in range(3)) > for x in g: print x >> 0 >> 1 >> 4 > g = (x*x for x in range(3)) # revive the generator for x in g: > print x #now t

Re: revive a generator

2011-10-21 Thread Ian Kelly
On Fri, Oct 21, 2011 at 2:02 AM, Yingjie Lan wrote: > Oops, my former reply has the code indentation messed up > by the mail system. Here is a reformatted one: > > > What if the generator involves a variable from another scope, > and before re-generating, the variable changed its value. > Also, th

Re: IDLE lost from Windows menu !

2011-10-21 Thread c . fangeux
Thanks Alec. For me it works with the following Default key : "C:\Python32\pythonw.exe" "C:\Python32\Lib\idlelib\idle.pyw" -e "%1" Otherwise IDLE does not open, only python was executed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Automated form submissions

2011-10-21 Thread Grant Edwards
On 2011-10-21, Matty Sarro wrote: > First, I apologize because I know this question has probably gotten > asked a lot. I am looking to automate filling out web forms, and no, > its not for spamming purposes. I use ClientForm for that, and I'm happy with it. -- Grant Edwards grant

non-standard module location (again)

2011-10-21 Thread Shane
Need to refine a question I asked earlier. If I have a module, |-- foo |---| |---|---bar |---|---| |---|---|---__init__.py then I can say import foo.bar But suppose I want to import foo.bar.stuff and stuff isn't located on under `bar' because it's user supplied code: |-

Re: non-standard module location (again)

2011-10-21 Thread 88888 Dihedral
1. Define a new class with an instance of the foo class included so that one can use all foo's properties and add new attributes. 2. Derive a new class from foo that extends its properties with the properties in foo accessible. -- http://mail.python.org/mailman/listinfo/python-list

Re: non-standard module location (again)

2011-10-21 Thread Ian Kelly
On Fri, Oct 21, 2011 at 8:05 AM, Shane wrote: > Need to refine a question I asked earlier. If I have a module, > > |--  foo > |---| > |---|---bar > |---|---| > |---|---|---__init__.py > > then I can say import foo.bar > > But suppose I want to import foo.bar.stuff and stuff

Re: fromutc: dt.tzinfo is not self: pytz.timezone('UTC').fromutc(datetime.utcnow())

2011-10-21 Thread aspineux
On Oct 19, 11:03 pm, Steven D'Aprano wrote: > On Wed, 19 Oct 2011 01:06:53 -0700, aspineux wrote: > > hi > > import pytz > from datetime import datetime > pytz.timezone('GMT0').fromutc(datetime.utcnow()) > > datetime.datetime(2011, 10, 19, 7, 54, 45, 579125, tzinfo= > 'GMT0'>) > >>>

Re: non-standard module location (again)

2011-10-21 Thread Calvin Spealman
I am biased, but you could use a plugin loader like straight.plugin at https://github.com/ironfroggy/straight.plugin On Fri, Oct 21, 2011 at 10:05 AM, Shane wrote: > Need to refine a question I asked earlier. If I have a module, > > |--  foo > |---| > |---|---bar > |---|---| > |--

Re: non-standard module location (again)

2011-10-21 Thread Steven D'Aprano
On Fri, 21 Oct 2011 07:05:32 -0700, Shane wrote: > Need to refine a question I asked earlier. If I have a module, > > |-- foo > |---| > |---|---bar > |---|---| > |---|---|---__init__.py > > then I can say import foo.bar No you can't, not the way you have listed it. As s

Re: how to change the order of a button, static text or other components

2011-10-21 Thread Ian Kelly
I assume you're arranging the components with a sizer. Remove them from the sizer, reinsert them in the order you want, and then call sizer.Layout(). Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list

Re: revive a generator

2011-10-21 Thread Terry Reedy
Here is a class that creates a re-iterable from any callable, such as a generator function, that returns an iterator when called, + captured arguments to be given to the function. class reiterable(): def __init__(self, itercall, *args, **kwds): self.f = itercall # callable that returns a

RE: how to change the order of a button, static text or other components

2011-10-21 Thread Prasad, Ramit
>what i want to do is,when i press a button, i change the order of >selected components,how to do this? This is so vague, I am tempted to think it is spambut on the chance it is not, I need a lot more information than you are providing to even attempt to give you any guidance. 1. By "button

need python+windows edit control help

2011-10-21 Thread Eric S. Johansson
I'm back with yet another attempt at adding accessibility features using Python and NaturallySpeaking. I've simplified the concepts again and I really need some help from someone who knows Microsoft Windows and Python. My goal is developing a template for what I'm trying to do, then I can take o

Re: compare range objects

2011-10-21 Thread SigmundV
On Oct 21, 2:55 am, Yingjie Lan wrote: > > In simulation, one can use range objects to denote a discrete domain, > and domain comparison could be very useful. Not just equality, but also > things like if one domain is contained in another. Can't sets [help(set)] be used for this? -- http://mail

Re: need python+windows edit control help

2011-10-21 Thread Mark Hammond
On 22/10/2011 10:30 AM, Eric S. Johansson wrote: I'm back with yet another attempt at adding accessibility features using Python and NaturallySpeaking. I've simplified the concepts again and I really need some help from someone who knows Microsoft Windows and Python. My goal is developing a templ

Python on BlackBerry PlayBook

2011-10-21 Thread Peter Hansen
I'm slightly surprised to search and not see any recent mention of Python running on the BlackBerry PlayBook. Since the PlayBook simulators (for developers) were first available late last year, they've contained Python 2.7. Some time before release, the permissions were changed so the binaries wer

shutil _isindir

2011-10-21 Thread David Hoese
Hi, I wasn't really sure where to post this since the python-dev list seems way too official. I'm wondering/questioning the behavior of shutil.move. It currently does a check for if the dst is inside the src directory with a _destinsrc function. This function uses os.path.abspath to conver

Re: need python+windows edit control help

2011-10-21 Thread Eric S. Johansson
On 10/21/2011 10:03 PM, Mark Hammond wrote: On 22/10/2011 10:30 AM, Eric S. Johansson wrote: I'm back with yet another attempt at adding accessibility features using Python and NaturallySpeaking. I've simplified the concepts again and I really need some help from someone who knows Microsoft Wind

Re: compare range objects

2011-10-21 Thread Steven D'Aprano
On Fri, 21 Oct 2011 16:42:16 -0700, SigmundV wrote: > On Oct 21, 2:55 am, Yingjie Lan wrote: >> >> In simulation, one can use range objects to denote a discrete domain, >> and domain comparison could be very useful. Not just equality, but also >> things like if one domain is contained in another.

Re: revive a generator

2011-10-21 Thread Steven D'Aprano
On Fri, 21 Oct 2011 16:25:47 -0400, Terry Reedy wrote: > Here is a class that creates a re-iterable from any callable, such as a > generator function, that returns an iterator when called, + captured > arguments to be given to the function. > > class reiterable(): >def __init__(self, itercall