Re: lambda in list comprehension acting funny

2012-07-10 Thread Daniel Fetchinson
> funcs = [ lambda x: x**i for i in range( 5 ) ] > print funcs[0]( 2 ) > print funcs[1]( 2 ) > print funcs[2]( 2 ) > > This gives me > > 16 > 16 > 16 > > When I was excepting > > 1 > 2 > 4 > > Does anyone know why? And more importantly, what's the simplest way to achieve the latter? :) -- Psss,

lambda in list comprehension acting funny

2012-07-10 Thread Daniel Fetchinson
funcs = [ lambda x: x**i for i in range( 5 ) ] print funcs[0]( 2 ) print funcs[1]( 2 ) print funcs[2]( 2 ) This gives me 16 16 16 When I was excepting 1 2 4 Does anyone know why? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mail

Re: Opening multiple Files in Different Encoding

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 10:46:08 -0700, Subhabrata wrote: > Dear Group, > > I kept a good number of files in a folder. Now I want to read all of > them. They are in different formats and different encoding. Using > listdir/glob.glob I am able to find the list but how to open/read or > process them fo

Re: Python Interview Questions

2012-07-10 Thread Stefan Behnel
Mark Lawrence, 10.07.2012 11:42: > I recall reading in a book in the local library > of a manager that wouldn't employ people unless they were wearing a new > pair of shoes. Guess they didn't take many people on. Managers tend to like wasting resources. Buying a new pair of shoes for each job int

Re: Python Interview Questions

2012-07-10 Thread Rick Johnson
On Jul 10, 4:29 am, Jean-Michel Pichavant wrote: > Why would you want to hire someone that knows something pointless as the > version where feature X has been introduced ? Just tell him that feature > X has been introducted in version Y, costless 2.5sec training. Don't you > want to hire someone t

Re: Python Interview Questions

2012-07-10 Thread David Robinow
On Tue, Jul 10, 2012 at 1:02 PM, Ethan Furman wrote: ... > > Reminds me of a job posting a few years ago where the prospective employer > wanted three plus years experience in some language, and that language had > only been created a year and a half before. I saw several of those when Java was n

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-10 Thread Rick Johnson
Also: Q3: Why are you explicitly setting the name of your "subFrame" widgets instead of allowing Tkinter to assign a unique name?...AND are you aware of the conflicts that can arise from such changes[1]? Q4: Are you aware of the built-in function "enumerate"[2]? I see you are passing around inde

Re: Python Interview Questions

2012-07-10 Thread Ian Kelly
On Tue, Jul 10, 2012 at 4:26 PM, Dennis Lee Bieber wrote: > On Tue, 10 Jul 2012 09:05:50 -0700, Ethan Furman > declaimed the following in gmane.comp.python.general: > >> As an example from today, if someone claimed to have 5+ years of Python >> experience, but didn't know that 'with' was standard

RE: how to interact with Windows cmd?

2012-07-10 Thread Prasad, Ramit
> what I want to do is > 1.open cmd > 2.waiting for user's typing > 3.when I type "dir" > 4.print the result of "dir" > 5.then I type some other commands, printing the result until I type > 'exit' > > I used > p=subprocess.Popen('cmd',stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=s > ubproce

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-10 Thread Rick Johnson
I've tried to condense your code using the very limited info you have provided. I have removed unnecessarily configuring of widgets and exaggerated the widget borders to make debugging easier. Read below for Q&A. ## START CONDENSED CODE ## records = range(4) CNF_SUBFRAME = { 'bd':5, # rowFram

Re: Adding to a List and displaying quantity in the list

2012-07-10 Thread Shamefaced
else: > print("%8.3f %s: Waited too long %6.3f" % (now()/60, self.name, > wait) + " time units have passed - Customer has left") > leavelist.append(self.acquired) Yeah, I should have changed that back to : leavelist.append(self.name) -- my thinking was that it would app

Re: Adding to a List and displaying quantity in the list

2012-07-10 Thread John Gordon
In Shamefaced writes: > else: > print("%8.3f %s: Waited too long %6.3f" % (now()/60, self.name, > wait) + " time units have passed - Customer has left") > leavelist.append(self.acquired) What is self.acquired? Judging from earlier code it appears to be a funct

Re: Opening multiple Files in Different Encoding

2012-07-10 Thread MRAB
On 10/07/2012 18:46, Subhabrata wrote: Dear Group, I kept a good number of files in a folder. Now I want to read all of them. They are in different formats and different encoding. Using listdir/glob.glob I am able to find the list but how to open/read or process them for different encodings? If

Adding to a List and displaying quantity in the list

2012-07-10 Thread Shamefaced
Hi I have coded a program whihc outputs what I like, but I am trying to modify it to add specific result info to a list and then display the number of items in the list. This is easy for me with basic code, but seems difficult when trying to adapt my program. My code and explanation is as follow

Re: ANN: Intro+Intermediate Python, San Francisco, Aug 1-3

2012-07-10 Thread wesley chun
hello everyone, hope some of you enjoyed #EuroPython this past week/end, and perhaps i'll see some of you at OSCON next week! as promised, here's the one and only FINAL REMINDER of the hardcore intro+intermediate Python course i'm offering 2012 Aug 1-3 near the San Francisco airport. reach out to

Re: Python Interview Questions

2012-07-10 Thread Demian Brecht
I also judge candidates on their beards (http://www.wired.com/wiredenterprise/2012/06/beard-gallery/). If the beard's awesome enough, no questions needed. They're pro. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Mark Lawrence
On 10/07/2012 18:12, Dennis Lee Bieber wrote: On 10 Jul 2012 07:33:59 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: may not be capable of telling the difference between a cheese sandwich and a box of hair -- and even the *good* interviewers are probably making

Opening multiple Files in Different Encoding

2012-07-10 Thread Subhabrata
Dear Group, I kept a good number of files in a folder. Now I want to read all of them. They are in different formats and different encoding. Using listdir/glob.glob I am able to find the list but how to open/read or process them for different encodings? If any one can help me out.I am using Pytho

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Wed, 11 Jul 2012 02:59:15 +1000, Chris Angelico wrote: > On Wed, Jul 11, 2012 at 2:51 AM, Steven D'Aprano > wrote: >> If only that were true. I know quite a few people who looked the >> interviewer straight in the eye and told the most bare-faced lies >> without a trace of shame, and got the j

Re: Python Interview Questions

2012-07-10 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Tue, 10 Jul 2012 11:29:24 +0200, Jean-Michel Pichavant wrote: Why would you want to hire someone that knows something pointless as the version where feature X has been introduced ? Just tell him that feature X has been introducted in version Y, costless 2.5sec train

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 2:51 AM, Steven D'Aprano wrote: > If only that were true. I know quite a few people who looked the > interviewer straight in the eye and told the most bare-faced lies without > a trace of shame, and got the job. Ten years on, at least one of them is > making something aroun

Re: Python Interview Questions

2012-07-10 Thread Ethan Furman
Chris Angelico wrote: On Wed, Jul 11, 2012 at 2:34 AM, Steven D'Aprano wrote: Of course, if they try to sell themselves as having five years experience with Python 3.2... ... then they've been borrowing Guido's time machine for personal purposes. Reminds me of a job posting a few years ago

Wing IDE 4.1.7 released

2012-07-10 Thread Wingware
Hi, Wingware has released version 4.1.7 of Wing IDE, our integrated development environment designed specifically for the Python programming language. Wing IDE provides a professional quality code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aw

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 10:11:22 +0200, Christian Heimes wrote: > Am 10.07.2012 09:33, schrieb Steven D'Aprano: >> This is why I hate job interviews. You have like 30 minutes, or even as >> little as 30 seconds, to make a good impression on somebody who may or >> may not be capable of telling the diff

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 11:29:24 +0200, Jean-Michel Pichavant wrote: > Why would you want to hire someone that knows something pointless as the > version where feature X has been introduced ? Just tell him that feature > X has been introducted in version Y, costless 2.5sec training. Don't you > want t

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 2:34 AM, Steven D'Aprano wrote: > Of course, if they try to sell themselves as having > five years experience with Python 3.2... ... then they've been borrowing Guido's time machine for personal purposes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2012 09:05:50 -0700, Ethan Furman wrote: > Jean-Michel Pichavant wrote: >> Why would you want to hire someone that knows something pointless as >> the version where feature X has been introduced ? > > As an example from today, if someone claimed to have 5+ years of Python > experie

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Wed, Jul 11, 2012 at 1:55 AM, BartC wrote: > There's also the risk of mixing up software created at home, with that done > at work, with all the intellectual property issues that might arise. You just make the matter clear from the beginning, for instance: what's done at work stays at work, an

Re: Python Interview Questions

2012-07-10 Thread BartC
"Peter" wrote in message news:35e7a860-fd41-4018-82f6-aabc32610...@googlegroups.com... One of my favourite questions when interviewing - and it was 100% reliable :-) - "what are your hobbies?" If the answer included programming then they were hired, if not, then they went to the "B" list.

Re: Python Interview Questions

2012-07-10 Thread Ethan Furman
Jean-Michel Pichavant wrote: Why would you want to hire someone that knows something pointless as the version where feature X has been introduced ? As an example from today, if someone claimed to have 5+ years of Python experience, but didn't know that 'with' was standard in 2.6 (or at least

Re: what's the effect of cmp here?

2012-07-10 Thread Mark Lawrence
On 10/07/2012 16:01, levi nie wrote: aList=[3,2,5,4] bList=aList[:] bList.sort() print "bList is",bList cList=aList[:] cList.sort(cmp) print "cList is",cList Why don't you tell us, you have the same documentatation avaialable as everybody else. -- Cheers. Mark Lawrence. -- http://mail

Re: what's the effect of cmp here?

2012-07-10 Thread Dave Angel
On 07/10/2012 11:01 AM, levi nie wrote: > what's the effect of cmp here? The bList and cList is the same at last. > > code: > aList=[3,2,5,4] > > bList=aList[:] > bList.sort() > print "bList is",bList > > cList=aList[:] > cList.sort(cmp) > print "cList is",cList > > The main effect is for the read

Re: Issues with `codecs.register` and `codecs.CodecInfo` objects

2012-07-10 Thread Walter Dörwald
On 07.07.12 04:56, Steven D'Aprano wrote: On Fri, 06 Jul 2012 12:55:31 -0400, Karl Knechtel wrote: Hello all, While attempting to make a wrapper for opening multiple types of UTF-encoded files (more on that later, in a separate post, I guess), I ran into some oddities with the `codecs` module

Re: Python Interview Questions

2012-07-10 Thread rusi
On Jul 10, 12:33 pm, Steven D'Aprano wrote: > This is why I hate job interviews. You have like 30 minutes, or even as > little as 30 seconds, to make a good impression on somebody who may or > may not be capable of telling the difference between a cheese sandwich > and a box of hair -- and even th

what's the effect of cmp here?

2012-07-10 Thread levi nie
what's the effect of cmp here? The bList and cList is the same at last. code: aList=[3,2,5,4] bList=aList[:] bList.sort() print "bList is",bList cList=aList[:] cList.sort(cmp) print "cList is",cList -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter.event.widget: handler gets name instead of widget.

2012-07-10 Thread Frederic Rentsch
On Mon, 2012-07-09 at 10:49 -0700, Rick Johnson wrote: > On Jul 9, 12:58 am, Terry Reedy wrote: > > When posting problem code, you should post a minimal, self-contained > > example that people can try on other systems and versions. Can you > > create the problem with one record, which you could gi

Re: Python Interview Questions

2012-07-10 Thread Mark Lawrence
On 10/07/2012 09:11, Christian Heimes wrote: Almost everybody can garden under ideal conditions. I grow about 15 herbs, strawberries, tomatoes, chillies and flowers on a small balcony in the middle of the city. This year I'm going to harvest at least 200 tomatoes from two plants in a 1m * 40cm *

Re: Python Interview Questions

2012-07-10 Thread Mark Lawrence
On 10/07/2012 09:03, Chris Angelico wrote: On Tue, Jul 10, 2012 at 3:08 PM, Shambhu Rajak wrote: I agree with Christian, a developer should have hobbies other than computer stuffs. Versatile environment give more Ability to think differently. I like playing guitar :-) Music and programming d

Re: Python Interview Questions

2012-07-10 Thread Jean-Michel Pichavant
Tim Chase wrote: On 07/09/12 19:27, Roy Smith wrote: prefer folks that know which features to check availability for deployment. Heh. Tell me, when did strings get methods? :-) IIRC, ~2.0? I'm cognizant of the shift happening from the string module to string methods, but I wo

Re: Python Interview Questions

2012-07-10 Thread Christian Heimes
Am 10.07.2012 09:33, schrieb Steven D'Aprano: > This is why I hate job interviews. You have like 30 minutes, or even as > little as 30 seconds, to make a good impression on somebody who may or > may not be capable of telling the difference between a cheese sandwich > and a box of hair -- and eve

Re: Python Interview Questions

2012-07-10 Thread Chris Angelico
On Tue, Jul 10, 2012 at 3:08 PM, Shambhu Rajak wrote: > I agree with Christian, a developer should have hobbies other than computer > stuffs. Versatile environment give more > Ability to think differently. > I like playing guitar :-) Music and programming do go VERY well together. My hobbies inc

Re: tiffany 0.6.1 released

2012-07-10 Thread Christian Heimes
Am 09.07.2012 17:51, schrieb Christian Tismer: > It turns out to be a problem with multiple strips in a tiff file. > PIL does not support that. Maybe I can find an easy solution, > maybe I'm better off using > > smc.freeimage > > as suggested by Christian Heimes, > > we will see. Right now I'm p