Re: compare range objects

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 8:16 PM, Chris Angelico wrote: > Hmm. I wonder would slice objects be appropriate? They're comparable: > a=slice(1,10) b=slice(1,10) a==b > True > > They're not iterable though - not directly (but you could slice > range(maxint) down to size). You could possi

Re: Py3K: file inheritance

2011-10-20 Thread Ian Kelly
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.startswith("#"): >      self.commented += 1 >      super(MyFi

Re: Benefit and belief

2011-10-20 Thread Ben Finney
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/transcriptions/EWD06xx/EWD611.html It's ambiguou

Re: Benefit and belief

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 1:34 PM, rusi wrote: > 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" > Expanding that quote: --- A thorough study of one or

Re: Py3K: file inheritance

2011-10-20 Thread Yosifov Pavel
On 21 окт, 00:42, Ian Kelly wrote: > On Thu, Oct 20, 2011 at 11:28 AM, Yosifov Pavel wrote: > > In the Python 2.x was simple to create own file object: > > > class MyFile(file): > > špass > > > for example to reimplement write() or something else. How to do it in > > Python 3.x? > > See the docs

Re: compare range objects

2011-10-20 Thread alex23
On Oct 21, 12:16 pm, Chris Angelico wrote: > Hmm. I wonder would slice objects be appropriate? > They're not iterable though They're not hashable either, which kind of surprised me. -- http://mail.python.org/mailman/listinfo/python-list

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

2011-10-20 Thread install...@189.cn
On 10月21日, 上午9时26分, Chris Rebert wrote: > On Thu, Oct 20, 2011 at 6:08 PM, install...@189.cn wrote: > > what i want to do is,when i press a button, i change the order of > > selected components,how to do this? > > Which GUI toolkit are you using? > > Cheers, > Chris wxpython. thx so much. -- ht

Re: Benefit and belief

2011-10-20 Thread rusi
On Oct 21, 5:31 am, Chris Angelico wrote: > On Fri, Oct 21, 2011 at 9:14 AM, Redcat wrote: > > On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote: > > >> I think you need to speak German fluently to be a good programmer. > > > No, just Dutch :) > > Whatever language it be, you do need to

Re: compare range objects

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:55 PM, 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. > Hmm. I wonder would slice objects be approp

Re: compare range objects

2011-10-20 Thread Yingjie Lan
- Original Message - > From: Westley Martínez > To: python-list@python.org > Cc: > Sent: Friday, October 21, 2011 12:22 AM > Subject: Re: compare range objects > > There's already a discussion about this on python-ideas.  But somebody > please tell me, why would you ever need to comp

Re: revive a generator

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:46 PM, Yingjie Lan wrote: > > Thanks a lot to all who answered my question. > I am still not sure why should we enforce that > a generator can not be reused after an explicit > request to revive it? Here's an example of an explicit request to revive the generator: >>>

Re: revive a generator

2011-10-20 Thread Yingjie Lan
- Original Message - > From: Paul Rudin > To: python-list@python.org > Cc: > Sent: Thursday, October 20, 2011 10:28 PM > Subject: Re: revive a generator > > Yingjie Lan writes: > >> Hi, >> >> it seems a generator expression can be used only once: >> > g = (x*x for x in ran

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

2011-10-20 Thread Chris Rebert
On Thu, Oct 20, 2011 at 6:08 PM, install...@189.cn wrote: > what i want to do is,when i press a button, i change the order of > selected components,how to do this? Which GUI toolkit are you using? Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Re: Benefit and belief

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 9:14 AM, Redcat wrote: > On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote: >> >> I think you need to speak German fluently to be a good programmer. > > No, just Dutch :) Whatever language it be, you do need to be competent in a human language to be a good program

Re: [OT] Re: Benefit and belief

2011-10-20 Thread Westley Martínez
On Thu, Oct 20, 2011 at 06:05:00PM -0400, Prasad, Ramit wrote: > >I think you need to speak German fluently to be a good programmer. > Why? > I won't reveal my secrets to JP Morgan Chase! I am loyal to the mighty Bank of America. -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Re: Benefit and belief

2011-10-20 Thread Redcat
On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote: >> I am a poly-illiterate. I can't read or write hundreds of languages. > > I think you need to speak German fluently to be a good programmer. No, just Dutch :) -- http://mail.python.org/mailman/listinfo/python-list

RE: [OT] Re: Benefit and belief

2011-10-20 Thread Prasad, Ramit
>I think you need to speak German fluently to be a good programmer. Why? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions i

RE: Problem with a wx notebook

2011-10-20 Thread Mel
Prasad, Ramit wrote: > I've created a wx NoteBook in wich I set multiples panels in wich I > set one or more sizers. But nothing displays in the notebook, > everything is outside. I've been searching an answer for 2 days ><. > Can you help me plz ? Here is my code(with only one panel, to sum up >

RE: Problem with a wx notebook

2011-10-20 Thread Prasad, Ramit
-Original Message- From: python-list-bounces+ramit.prasad=jpmorgan@python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of faucheuse Sent: Monday, October 17, 2011 5:33 AM To: python-list@python.org Subject: Problem with a wx notebook Hi there, I've

Re: COM / .NET

2011-10-20 Thread Gregory Ewing
Tim Golden wrote: You have a few choices in this regard: Also it's reportedly possible to register a .NET assembly as a COM library and use it that way. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: sysconfig on OS X 10.7 (Lion) and XCode 4.2

2011-10-20 Thread Ned Deily
In article <5ed3f418-a03d-4be6-91a5-51c0df899...@mantaro.com>, David Riley wrote: > I've struggled mightily to get Numpy and pyopencl installed on my brand-new > Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for > punishment). I did finally succeed, anyway. > > I f

Re: revive a generator

2011-10-20 Thread Terry Reedy
On 10/20/2011 9:23 AM, Yingjie Lan wrote: it seems a generator expression can be used only once: Generators are iterators. Once iterators raise StopIteration, they are supposed to continue doing so. A generator expression defines a temporary anonymous generator function that is called once t

Re: google maps api help

2011-10-20 Thread Christopher Saunders
On Oct 20, 1:02 pm, MRAB wrote: > On 20/10/2011 19:39, Christopher Saunders wrote: > > > > > > > > > > > I have an excel sheet with a bunch of info regarding the stops a > > delivery truck makes throughout the day.  I can successfully extract > > the information I need with xlrd.  This is the code

sysconfig on OS X 10.7 (Lion) and XCode 4.2

2011-10-20 Thread David Riley
Hello all, I've struggled mightily to get Numpy and pyopencl installed on my brand-new Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for punishment). I did finally succeed, anyway. I found that the greatest problem I had (after installing gfortran from a precompile

Re: compare range objects

2011-10-20 Thread 88888 Dihedral
The range() in python is an iterable generator that returns an object ref/id. The xrange() is different. -- http://mail.python.org/mailman/listinfo/python-list

Re: google maps api help

2011-10-20 Thread MRAB
On 20/10/2011 19:39, Christopher Saunders wrote: I have an excel sheet with a bunch of info regarding the stops a delivery truck makes throughout the day. I can successfully extract the information I need with xlrd. This is the code I am using: book = xlrd.open_workbook(r'c:\xytest.xls') sheet

Re: Benefits of xml.dom.minidom?

2011-10-20 Thread Stefan Behnel
John Gordon, 20.10.2011 19:46: I recently inherited some code that uses xml.dom.minidom to build a large XML document, and I noticed that it is quite slow and uses a ton of memory. I converted the same code to use lxml.etree and it is much faster and uses not nearly so much memory. Why is minid

Re: Benefits of xml.dom.minidom?

2011-10-20 Thread Hidura
I use minidom all the time and i don' t have that problem could you describe more of the process ? El oct 20, 2011 5:53 p.m., "John Gordon" escribió: > > I recently inherited some code that uses xml.dom.minidom to build a large > XML document, and I noticed that it is quite slow and uses a ton of

google maps api help

2011-10-20 Thread Christopher Saunders
I have an excel sheet with a bunch of info regarding the stops a delivery truck makes throughout the day. I can successfully extract the information I need with xlrd. This is the code I am using: book = xlrd.open_workbook(r'c:\xytest.xls') sheet= book.sheet_by_index(0) odList = [] for i in rang

Re: compare range objects

2011-10-20 Thread Ethan Furman
Ian Kelly wrote: On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder wrote: There's already a discussion about this on python-ideas. But somebody please tell me, why would you ever need to compare ranges? It could be useful if you're unit-testing a function that returns a range. Easy: list(range

Re: compare range objects

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder wrote: >> There's already a discussion about this on python-ideas.  But somebody >> please tell me, why would you ever need to compare ranges? > > It could be useful if you're unit-testing a function that returns a range. Easy: list(range1) == list(r

Re: compare range objects

2011-10-20 Thread Hans Mulder
On 20/10/11 18:22:04, Westley Martínez wrote: On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote: Hi, Is it possible to test if two range objects contain the same sequence of integers by the following algorithm in Python 3.2? 1. standardize the ending bound by letting it be the first

Benefits of xml.dom.minidom?

2011-10-20 Thread John Gordon
I recently inherited some code that uses xml.dom.minidom to build a large XML document, and I noticed that it is quite slow and uses a ton of memory. I converted the same code to use lxml.etree and it is much faster and uses not nearly so much memory. Why is minidom so hungry for resources? What

Re: Py3K: file inheritance

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 11:28 AM, Yosifov Pavel wrote: > In the Python 2.x was simple to create own file object: > > class MyFile(file): >  pass > > for example to reimplement write() or something else. How to do it in > Python 3.x? See the docs for the io module. Depending on what you want to d

Py3K: file inheritance

2011-10-20 Thread Yosifov Pavel
In the Python 2.x was simple to create own file object: class MyFile(file): pass for example to reimplement write() or something else. How to do it in Python 3.x? -- http://mail.python.org/mailman/listinfo/python-list

Re: compare range objects

2011-10-20 Thread Westley Martínez
On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote: > Hi,  > > Is it possible to test if two range objects contain the same sequence of > integers by the following algorithm in Python 3.2? > > 1. standardize the ending bound by letting it be the first excluded integer > for the given s

Re: Are range iterators thread safe?

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 3:22 AM, Stefan Behnel wrote: > Steven D'Aprano, 20.10.2011 10:04: >> >> Using Python 3, are range_iterator objects thread-safe? >> >> I have tried this, and it seems to be safe: >> >> >>> from threading import Thread >> >>> x = iter(range(4)) >> >>> def doit(x): >> ...    

Re: revive a generator

2011-10-20 Thread Paul Rudin
Yingjie Lan writes: > Hi, > > it seems a generator expression can be used only once: > g = (x*x for x in range(3)) for x in g: print x > 0 > 1 > 4 for x in g: print x #nothing printed > > Is there any way to revive g here? > Generators are like that - you consume them until t

Re: revive a generator

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:23 AM, Yingjie Lan wrote: > Hi, > > it seems a generator expression can be used only once: > g = (x*x for x in range(3)) for x in g: print x > 0 > 1 > 4 for x in g: print x #nothing printed > > Is there any way to revive g here? If you're not generat

compare range objects

2011-10-20 Thread Yingjie Lan
Hi,  Is it possible to test if two range objects contain the same sequence of integers by the following algorithm in Python 3.2? 1. standardize the ending bound by letting it be the first excluded integer for the given step size. 2. compare the standardized starting bound, ending bound and step

revive a generator

2011-10-20 Thread Yingjie Lan
Hi, it seems a generator expression can be used only once: >>> g = (x*x for x in range(3)) >>> for x in g: print x 0 1 4 >>> for x in g: print x #nothing printed >>> Is there any way to revive g here? Yingjie -- http://mail.python.org/mailman/listinfo/python-list

Re: Insert Data with pymongo

2011-10-20 Thread Roy Smith
In article , 4k3nd0 <4k3...@googlemail.com> wrote: > Hi guys, > > i want to insert a JSON formated String into a mongoDB. But get some > problem with the insert to the database. > > Traceback (most recent call last): > File "obp_import_pb.py", line 102, in > do_import() > File "obp_im

Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel
Ben Finney, 20.10.2011 13:23: Stefan Behnel writes: Steven D'Aprano, 20.10.2011 10:04: Using Python 3, are range_iterator objects thread-safe? The GIL ensures it's thread safe. The GIL applies only to CPython. and PyPy. What is the answer for other Python implementations which don't ha

Insert Data with pymongo

2011-10-20 Thread 4k3nd0
Hi guys, i want to insert a JSON formated String into a mongoDB. But get some problem with the insert to the database. Traceback (most recent call last): File "obp_import_pb.py", line 102, in do_import() File "obp_import_pb.py", line 97, in do_import collection = db.pb_mp.insert(obp

Re: Threading: Method trigger after thred finished

2011-10-20 Thread Christian Heimes
Am 20.10.2011 05:55, schrieb Steven D'Aprano: > # Make consumer threads. > class ThreadSql(threading.Thread): > def __init__(self, queue): > threading.Thread.__init__(self) > self.queue = queue > # Open database connection instance > self.session = "+++connectio

Re: Are range iterators thread safe?

2011-10-20 Thread Ben Finney
Stefan Behnel writes: > Steven D'Aprano, 20.10.2011 10:04: > > Using Python 3, are range_iterator objects thread-safe? > The GIL ensures it's thread safe. The GIL applies only to CPython. What is the answer for other Python implementations which don't have a GIL? -- \ Eccles: “I just sa

Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi
On 20/10/2011 12:12 م, Tim Golden wrote: If you can get the source (specifically including the setup.py which I don't think is included in the wininst .zip) then you can use that to build an msi: python setup.py bdist_msi which you can then manage via the usual msiexec switches. It's often a

Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel
Steven D'Aprano, 20.10.2011 10:04: Using Python 3, are range_iterator objects thread-safe? I have tried this, and it seems to be safe: >>> from threading import Thread >>> x = iter(range(4)) >>> def doit(x): ... print("result =", next(x)) ... >>> threads = [Thread(target=doit, args=(x,)) fo

Re: COM / .NET

2011-10-20 Thread Uffe Kousgaard
"Tim Golden" wrote in message news:mailman.2075.1319100141.27778.python-l...@python.org... > > You have a few choices in this regard: Thanks for a detailed reply. We'll start looking at [1] and [3]. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python based silent installer, how to?

2011-10-20 Thread Tim Golden
On 20/10/2011 09:45, Muhammad Bashir Al-Noimi wrote: On 20/10/2011 01:35 ص, Alec Taylor wrote: Just download the msi (script is available to regenerate yourself) and run it with the silent swtich, something like: msiexec /x nameofmsi.msi Sorry I didn't explain what I'm looking for exactly. I'

Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi
On 20/10/2011 12:00 ص, Steven D'Aprano wrote: Please don't send raw HTML (so-called "rich text") to mailing lists. It makes it very difficult for some people to read. If you must use HTML, please ensure your email client or news reader also sends a plain text version of the message as well. Sorr

Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi
On 20/10/2011 01:35 ص, Alec Taylor wrote: Just download the msi (script is available to regenerate yourself) and run it with the silent swtich, something like: msiexec /x nameofmsi.msi Sorry I didn't explain what I'm looking for exactly. I've packages built by bdist_wininst, Is there any way f

Re: COM / .NET

2011-10-20 Thread Tim Golden
On 20/10/2011 09:06, Uffe Kousgaard wrote: Is python able to access COM libraries or .NET assemblies? If both, which is the easist or most popular? You have a few choices in this regard: * CPython can access COM objects either via the pywin32 extensions[1] or via comtypes[2]. The former is mai

COM / .NET

2011-10-20 Thread Uffe Kousgaard
Is python able to access COM libraries or .NET assemblies? If both, which is the easist or most popular? -- http://mail.python.org/mailman/listinfo/python-list

Are range iterators thread safe?

2011-10-20 Thread Steven D'Aprano
Using Python 3, are range_iterator objects thread-safe? I have tried this, and it seems to be safe: >>> from threading import Thread >>> x = iter(range(4)) >>> def doit(x): ... print("result =", next(x)) ... >>> threads = [Thread(target=doit, args=(x,)) for i in range(4)] >>> for t in thread

Re: Threading: Method trigger after thred finished

2011-10-20 Thread Markus
On Oct 20, 5:55 am, Steven D'Aprano wrote: > On Wed, 19 Oct 2011 13:14:21 -0700, markus.mj wrote: > > Hi, > > > I am looking for help with following problem. I scripted threaded > > database query, with session open per thread, and queries delivered > > through queue. Every open DB session must be