474,030 Members | 2,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I dynamically create functions without lambda?

I want my code to be Python 3000 compliant, and hear
that lambda is being eliminated. The problem is that I
want to partially bind an existing function with a value
"foo" that isn't known until run-time:

someobject.newf unc = lambda x: f(foo, x)

The reason a nested function doesn't work for this is
that it is, well, dynamic. I don't know how many times
or with what foo's this will be done.

Now, I am sure there are a half-dozen ways to do this.
I just want the one, new and shiny, Pythonic way. ;-)

Jan 27 '06
25 2609
Alan Morgan <am*****@xenon. Stanford.EDU> wrote:
...
Since there are a lot more stupid people than clever people out there I
think the more likely scenario is having to maintain unmaintainable code
written by a complete idiot whose programming knowledge comes solely from
books whose titles end with "In 7 Days".


Disagree -- far more people THINK they're clever, than really ARE
clever.


No doubt about it, but I don't see how it contradicts my statement.


The problem comes with the ones who aren't clever, think they are, and
attempt cleverness.

According to a recent article in the Financial Times, over 40%
of a typical financial firm's employees firmly believe they are among
the 5% best employees of the firm -- and the situation, believe me, is
no different in programming.


I wonder if python, which has a low barrier to entry due to its simple
syntax and general readability, might not have a worse time of this than
other languages.


So far, no, according to all the people I often exchange chat on such
experiences with. E.g., I was a panelist at SDForum the other day, the
moderator was Alexandra Weber Morales (until recently head editor of SD
Magazine, she's a freelance now), and she confirmed that Python
programmers still have the highest median and average salaries
(VisualBasic ones, the lowest), a strong indicator that they ARE good.

[[ Surprisingly, from all anecdotal experiences I hear about, the new
"digital peons" after VB programmers appear to be J2EE coders (I use the
word deliberately: people who _architect_, or even just _design_, J2EE
apps, are on a different plane -- people who _code_ J2EE apps are the
ones laboring long hours for low salaries, it seems). And, from
somebody who desperately needs to hire a small number of stellar-quality
Java experts, I've heard strong anecdotal confirmation: candidates who
tout their "J2EE" are much more likely to be "mindless code drones" than
ones who just focus in their resume on "Java". I don't understand J2EE
well enough to even guess at an explanation of why that might be so. ]]

Paul Graham makes the same point: if you're an entrepreneur with a
startup just ramping up, you'll get much abler people if you're looking
for Lisp or (failing that) Python programmers, than if you look for Java
programmers (he fails to distinguish between "Java" and "J2EE").

Now Lisp (or Haskell, etc) I could easily see. But why should Python
tend to correlate with "high skill", when, as you point out, it's in
fact _simpler_?! My current working hypothesis: Python has never been
marketed and hyped the way Java and C# &c have; somebody who CHOOSES
Python shows some ability to think for themselves, rather than following
the herd, and such ability correlated with programming skill. Note that
this hypothesis is reasonably independent of whether Python is a great
language or not: it would apply equally well to any language that has
never been substantially hyped/marketed. But there are probably too few
programmers who identify as, say, "D programmers", "Eiffel programmers",
etc, to show up in SD's statistics, while Python's starting (gradually,
and mostly "by word of mouth") to register on their radar...
Alex
Feb 3 '06 #21
al*****@yahoo.c om (Alex Martelli) writes:
Now Lisp (or Haskell, etc) I could easily see. But why should Python
tend to correlate with "high skill", when, as you point out, it's in
fact _simpler_?! My current working hypothesis: Python has never been
marketed and hyped the way Java and C# &c have; somebody who CHOOSES
Python shows some ability to think for themselves, rather than following
the herd, and such ability correlated with programming skill.


Python also has a type of beauty to it (despite warts here and there),
so someone who chooses it probably has better attunement to
well-designed software than someone who chooses an uglier but equally
obscure language. That attunement would correlate with skill.
Feb 3 '06 #22
On Thu, 2 Feb 2006 20:05:14 -0800
al*****@yahoo.c om (Alex Martelli) wrote:
Benji York <be***@benjiyor k.com> wrote:
Alex Martelli wrote:
Disagree -- far more people THINK they're clever, than
really ARE clever. According to a recent article in
the Financial Times, over 40% of a typical financial
firm's employees firmly believe they are among the 5%
best employees of the firm -- and the situation,
believe me, is no different in programming.


It's apparently no different anywhere:
http://www.phule.net/mirrors/unskilled-and-unaware.html


I have to say, I've read this paper, and it's pretty bad
science. I think they seriously over-interpreted their
data. There are a lot of different ways to interpret the
data they present, and it takes a fair amount of sophistry
for them to come up with it "supporting " their hypothesis.

Which doesn't *disprove* the idea, but I remain unconvinced
by their reasoning. No doubt the effect they describe is
not non-existant, but I question whether it has as much
impact as proposed.

Note also in the datasets that *overperformers * *underrated*
their performance.

Also, the research was done on *particularly* subjective
subject matter! Take the "humor" category for example.

I also think this is precisely the kind of experiment that
has to be made *very* objective to be at all useful. It's so
easy to sensationalize: it plays on your self-worth fears,
your cynicism, and your arrogance *at the same time*. It's
hard to imagine that anyone accepting the results is doing
so for scientific reasons.

Frankly this paper sounds like a bid for the "Journal of
Irreproducible Results" that somehow got accidentally
submitted to a serious journal (of course, I don't know
enough about psychology journals to know if that is really
a "serious journal", but I'm taking it at face value).

Of course, you *could* conclude that I'm just "unskilled and
unaware of it" for believing this -- but that's the beauty
of all self-reinforcing delusions, isn't it. ;-)

Cheers,
Terry
--
Terry Hancock (ha*****@Anansi Spaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Feb 3 '06 #23
Terry Hancock wrote:
Frankly this paper sounds like a bid for the "Journal of
Irreproducible Results" that somehow got accidentally
submitted to a serious journal


http://www.improbable.com/ig/ig-pastwinners.html#ig2000

</F>

Feb 3 '06 #24
Terry Hancock wrote:
Note also in the datasets that *overperformers * *underrated*
their performance.


Well, if you're the best in the group and aren't perfectly exact
in your evaluation of your position relative to others, you can't
overrate yourself. It's quite natural that the self evaluation curve
would be flatter than the actual curve, since "noise" will drive
the curve towards the middle, and it's also natural that the bad
performers are also less good at evaluating their own work, but
the strange thing is that the lowest quartile has higher self-
evaluation than the second lowest. I can't say my general picture
of coworkers generally support *this*, but I supect we've all run
across people who were incompetent and unaware of it now and then...
Feb 3 '06 #25
On Fri, 3 Feb 2006 09:39:39 +0100
"Fredrik Lundh" <fr*****@python ware.com> wrote:
Terry Hancock wrote:
Frankly this paper sounds like a bid for the "Journal of
Irreproducible Results" that somehow got accidentally
submitted to a serious journal

http://www.improbable.com/ig/ig-pastwinners.html#ig2000
</F>


Wow. It's a relief to know I'm not the only one who regards
this paper as a joke. :-)

Cheers,
Terry

--
Terry Hancock (ha*****@Anansi Spaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com

Feb 3 '06 #26

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
6059
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
53
3750
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions are constructed on the fly. Now my problem is lazy evaluation. Or at least I think it is. :-)
76
3885
by: Nick Coghlan | last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0. Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped in favour of a different syntax, rather than completely losing the ability to have anonymous functions. Anyway, I'm looking for feedback on a def-based syntax that came up in a recent c.l.p discussion:...
37
2236
by: Kay Schluehr | last post by:
Since George Sakkis proposed a new way of doing list comprehensions http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/ac5023ad18b2835f/d3ff1b81fa70c8a7#d3ff1b81fa70c8a7 letting tuples-like objects (x,y,z=0) acting as functions on other tuples I wonder why this would not be a good starting point of rethinking anonymus functions? In Georges proposition the action is
4
2383
by: Max Derkachev | last post by:
Good day to all. Some time ago I'd been playing with a framework which uses dynamic class creation havily. Say, I could do: class A: pass # I method name is dynamic meth_name = 'foo'
8
4845
by: Falc2199 | last post by:
Hi, Does anyone know how to make this work? var sectionId = 5; repeat_section_sectionId(); function repeat_section_5(){ alert("firing"); }
13
4409
by: invincible | last post by:
hi friends , how can I declare / create function during runtime similiar to lambda in lisp. thanks Mohan
11
3948
by: Josiah Manson | last post by:
In the following program I am trying to learn how to use functional programming aspects of python, but the following program will crash, claiming that the recursion depth is too great. I am attempting to make a list of polynomial functions such that poly(3) = 1, poly(3) = 3, poly(3) = 9, etc. Could someone point me in the right direction? Thanks. def make_polys(n): """Make a list of polynomial functions up to order n. """
5
1960
by: Maxim Veksler | last post by:
Hello, I'm new on this list and in python. It seems python has some interesting concept of "ad hoc" function which I'm trying to understand without much success. Take the following code for example: """ .... return lambda x: x + n
0
10512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12094
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10274
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6619
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.