In article ,
Daniel Fetchinson wrote:
> > 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?
In Pyt
On 12 jul, 02:59, Vincent Vande Vyvre
wrote:
> On 11/07/12 17:37, Jean Dubois wrote:
>
>
>
>
>
>
>
> > I'm trying to combine python-code made with QT4 designer with plain
> > python statements like
> > file = open("test","w")
> > Can anyone tell me what I have to add to the following code just to
On Wed, 11 Jul 2012 22:04:51 -0700, 8 Dihedral wrote:
> I have to make sure my functor to keep the state variable values for
> different objects that call the same functor to behave correctly in
> order to avoid passing extra parameters in various objects using the
> same functor.
Yo dawg,
On Thu, 12 Jul 2012 10:41:52 +1000
Simon Cropper wrote:
> That said... with more than a passing interest in software and
> content licensing I looked at how the work was licensed. A
> none-standard license like this makes most people stop and think
> "will this be a problem if I use this in my w
On Wed, 11 Jul 2012 13:21:34 -0700 (PDT)
John Ladasky wrote:
> Exactly. It's threads like these which remind me why I never use lambda. I
> would rather give a function an explicit name and adhere to the familiar
> Python syntax, despite the two extra lines of code. I don't even like the
> nam
On Thursday, July 12, 2012 11:51:04 AM UTC+8, Steven D'Aprano wrote:
> On Wed, 11 Jul 2012 20:39:45 -0700, 8 Dihedral wrote:
>
> > I'll contribute my way of python programming:
> >
> > def powerb(x, b): #
> > return x**b
>
> Here's a shorter version:
>
> py> pow
>
On 7/11/2012 11:53 PM, Steven D'Aprano wrote:
On Wed, 11 Jul 2012 21:05:30 -0400, Dennis Lee Bieber wrote:
{non sequitur: I still recall my archaic C++ class with the OOAD
assignment of designing said calculator -- we never had to implement
one, just design the basic classes/methods/attributes
On Wed, 11 Jul 2012 08:41:57 +0200, Daniel Fetchinson wrote:
> funcs = [ lambda x: x**i for i in range( 5 ) ]
Here's another solution:
from functools import partial
funcs = [partial(lambda i, x: x**i, i) for i in range(5)]
Notice that the arguments i and x are defined in the opposite order.
T
On Wed, 11 Jul 2012 20:39:45 -0700, 8 Dihedral wrote:
> I'll contribute my way of python programming:
>
> def powerb(x, b): #
> return x**b
Here's a shorter version:
py> pow
> One functor is enough!
Nothing we have been discussing in this thread has been a functor, either
in the
On Wed, 11 Jul 2012 21:05:30 -0400, Dennis Lee Bieber wrote:
> {non sequitur: I still recall my archaic C++ class with the OOAD
> assignment of designing said calculator -- we never had to implement
> one, just design the basic classes/methods/attributes [on 3x5 cards] for
> a four-banger. I manag
On Thursday, July 12, 2012 12:34:33 AM UTC+8, Ian wrote:
> On Wed, Jul 11, 2012 at 4:28 AM, Colin J. Williams wrote:
> > I don't understand why you would expect 1, 2, 4.
>
> Because:
>
> funcs[0](2) == 2 ** 0 == 1
> funcs[1](2) == 2 ** 1 == 2
> funcs[2](2) == 2 ** 2 == 4
>
> > Perh
The latest Zeus IDE Version 3.97o is now available:
http://www.zeusedit.com/python.html
This latest Zeus release adds improved Python debugger support.
Other Pyhon language features include syntax highlighting, code
completion, smart indenting, class browsing and code folding.
Zeus is also
>> You should not be using lambda in this case
>> .for x in [2, 3]:
>> .funcs = [x**ctr for ctr in range( 5 )]
>> .for p in range(5):
>> .print x, funcs[p]
>> .print
>
> If you change the requirements, it's always easy to solve problems. But
> it is the wrong problem that you ha
Hi,
I'm working on a meta path hook that performs compilation of C extension
modules on import ( github.com/jwp/py-c ; pip install c ). It mostly works, but
I'm having a hard time finding a standard way to automatically install the hook
upon interpreter startup.
I've thought about just having
On 11/07/12 17:37, Jean Dubois wrote:
> I'm trying to combine python-code made with QT4 designer with plain
> python statements like
> file = open("test","w")
> Can anyone tell me what I have to add to the following code just to
> open a file when clicking on the load-button and closing it by
> cl
On Wed, 11 Jul 2012 13:21:34 -0700, John Ladasky wrote:
> Exactly. It's threads like these which remind me why I never use
> lambda. I would rather give a function an explicit name and adhere to
> the familiar Python syntax, despite the two extra lines of code.
lambda is familiar Python syntax,
On 12/07/12 00:06, Chris Gonnerman wrote:
I've held off announcing this until I was sure it was really stable;
it's been 19 days since I made the last change to it, so here goes.
PollyReports is my Python module for report generation. It is designed
to be, quite literally, the "simplest thing tha
On Wed, 11 Jul 2012 11:38:18 -0700, woooee wrote:
> You should not be using lambda in this case
> .for x in [2, 3]:
> .funcs = [x**ctr for ctr in range( 5 )]
> .for p in range(5):
> .print x, funcs[p]
> .print
If you change the requirements, it's always easy to solve problem
On Wed, 11 Jul 2012 11:15:02 -0700, subhabangalore wrote:
> On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, 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/g
On 11/07/12 20:38:18, woooee wrote:
> You should not be using lambda in this case
> .for x in [2, 3]:
> .funcs = [x**ctr for ctr in range( 5 )]
> .for p in range(5):
> .print x, funcs[p]
> .print
The list is called "funcs" because it is meant to contain functions.
Your code doe
On 11 July 2012 19:15, wrote:
> On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, 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 f
Exactly. It's threads like these which remind me why I never use lambda. I
would rather give a function an explicit name and adhere to the familiar Python
syntax, despite the two extra lines of code. I don't even like the name
"lambda". It doesn't tell you what it is (unless you're John McCa
On Tuesday, July 10, 2012 11:16:08 PM UTC+5:30, 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
> proc
On Wed, Jul 11, 2012 at 4:28 AM, Colin J. Williams wrote:
> I don't understand why you would expect 1, 2, 4.
Because:
funcs[0](2) == 2 ** 0 == 1
funcs[1](2) == 2 ** 1 == 2
funcs[2](2) == 2 ** 2 == 4
> Perhaps parentheses will help the order of evaluation:
>
> funcs = [(lambda x: x**i) for i in
I'm trying to combine python-code made with QT4 designer with plain
python statements like
file = open("test","w")
Can anyone tell me what I have to add to the following code just to
open a file when clicking on the load-button and closing it by
clicking on the save button.
#!/usr/bin/env python
I've held off announcing this until I was sure it was really stable;
it's been 19 days since I made the last change to it, so here goes.
PollyReports is my Python module for report generation. It is designed
to be, quite literally, the "simplest thing that can possibly work" in
the field of PDF
In article ,
Vojt®Ãch Pol®¢â°ek wrote:
> Then the menu module kicks in and should launch its
> own loop checking for pygame keyboard events, but right after doing it
> it prints:
> [xcb] Unknown sequence number while processing queue
> [xcb] Most likely this is a multi-threaded client and X
On 11/07/2012 2:41 AM, Daniel Fetchinson wrote:
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
I don't understand why you would expect 1, 2,
Greetings,
My name is Vojta and I am blind student. I am slowly learning Python for
about 4 years and I like it alot, mostly its ability to run on various
platforms.
My primary system is Ubuntu 12.04, but I have Windows XP at hand. I am
using python 2.7. I have learned basics from the book A byte o
On Tue, 2012-07-10 at 18:06 -0700, Rick Johnson wrote:
> 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]?
>
I find custom-named widge
>>> funcs = [ lambda x: x**i for i in range( 5 ) ]
>>> print funcs[0]( 2 )
>>>
>>> This gives me
>>> 16
>>>
>>> When I was excepting
>>> 1
>>>
>>> Does anyone know why?
>
>Just the way Python lambda expressions bind their variable
> references. Inner 'i' references the outer scope's 'i' variabl
Hi.
funcs = [ lambda x: x**i for i in range( 5 ) ]
print funcs[0]( 2 )
This gives me
16
When I was excepting
1
Does anyone know why?
Just the way Python lambda expressions bind their variable
references. Inner 'i' references the outer scope's 'i' variable and not
its value 'at the tim
32 matches
Mail list logo