Re: Functions help

2014-03-01 Thread Grant Edwards
On 2014-02-24, Benjamin Kaplan wrote: > On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: >> On 24/02/2014 11:09 AM, Mark Lawrence wrote: >>> >>> On 24/02/2014 00:55, alex23 wrote: for _ in range(5): func() >>> >>> >>> the obvious indentation error above >> >> >> Stupid

Re: Functions help

2014-03-01 Thread Roy Smith
In article , Mark Lawrence wrote: > On 24/02/2014 00:55, alex23 wrote: > > On 23/02/2014 3:43 PM, Scott W Dunning wrote: > >> I had a question regarding functions. Is there a way to call a > >> function multiple times without recalling it over and over. Meaning > >> is there a way I can call a

Re: Functions help

2014-02-27 Thread Rhodri James
On Tue, 25 Feb 2014 02:18:43 -, Dennis Lee Bieber wrote: On Mon, 24 Feb 2014 01:01:15 -, "Rhodri James" declaimed the following: The function "range" returns the sequence of numbers 1, 2, 3, 4 and 5 [*], so this has the same effect as if you had typed: Wrong -- it

Re: Functions help

2014-02-26 Thread rurpy
On 02/25/2014 07:52 PM, Ethan Furman wrote: > On 02/23/2014 08:01 PM, ru...@yahoo.com wrote: >> On 02/23/2014 08:21 PM, Mark Lawrence wrote: >>> On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: > On 24/02/2014 11:09 AM, Mark Lawrence wrote: >>

Re: Functions help

2014-02-26 Thread Mark Lawrence
On 26/02/2014 02:06, Cameron Simpson wrote: On 24Feb2014 13:59, Mark Lawrence wrote: On 24/02/2014 04:01, ru...@yahoo.com wrote: On 02/23/2014 08:21 PM, Mark Lawrence wrote: On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: On 24/02/2014 11:09 AM, M

Re: Functions help

2014-02-25 Thread Ethan Furman
On 02/23/2014 08:01 PM, ru...@yahoo.com wrote: On 02/23/2014 08:21 PM, Mark Lawrence wrote: On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5):

Re: Functions help

2014-02-25 Thread Cameron Simpson
On 23Feb2014 18:55, Benjamin Kaplan wrote: > On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: > > On 24/02/2014 11:09 AM, Mark Lawrence wrote: > >> On 24/02/2014 00:55, alex23 wrote: > >>> for _ in range(5): > >>> func() > >> > >> the obvious indentation error above > > > > Stupid cut&pas

Re: Functions help

2014-02-25 Thread Cameron Simpson
On 24Feb2014 13:59, Mark Lawrence wrote: > On 24/02/2014 04:01, ru...@yahoo.com wrote: > >On 02/23/2014 08:21 PM, Mark Lawrence wrote: > >>On 24/02/2014 02:55, Benjamin Kaplan wrote: > >>>On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: > On 24/02/2014 11:09 AM, Mark Lawrence wrote: > >On 2

Re: Functions help

2014-02-24 Thread Jean-Michel Pichavant
- Original Message - > On Feb 23, 2014, at 1:44 AM, Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info > wrote: > > Sorry, I don't really understand your question. Could you show an > > example > > > of what you are doing? > > > Do you mean "add 5" or "*5"? "Add *5 doesn't really

Re: Functions help

2014-02-24 Thread Mark Lawrence
On 24/02/2014 04:01, ru...@yahoo.com wrote: On 02/23/2014 08:21 PM, Mark Lawrence wrote: On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5):

Re: Functions help

2014-02-24 Thread sffjunkie
On Sunday, 23 February 2014 05:43:17 UTC, Scott W Dunning wrote: > I had a question regarding functions. Is there a way to call a function > multiple times without recalling it over and over. Meaning is there a way I > can call a function and then add *5 or something like that? The followin

Re: Functions help

2014-02-24 Thread sffjunkie
On Sunday, 23 February 2014 05:43:17 UTC, Scott W Dunning wrote: > I had a question regarding functions. Is there a way to call a function > multiple times without recalling it over and over. Meaning is there a way I > can call a function and then add *5 or something like that? > The followi

Re: Functions help

2014-02-23 Thread rurpy
On 02/23/2014 08:21 PM, Mark Lawrence wrote: > On 24/02/2014 02:55, Benjamin Kaplan wrote: >> On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: >>> On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: > for _ in range(5): > func() the obvious i

Re: Functions help

2014-02-23 Thread MRAB
On 2014-02-24 03:21, Mark Lawrence wrote: On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5): func() the obvious indentation error above

Re: Functions help

2014-02-23 Thread Mark Lawrence
On 24/02/2014 02:55, Benjamin Kaplan wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5): func() the obvious indentation error above Stupid cut&paste :( -- Your message c

Re: Functions help

2014-02-23 Thread Benjamin Kaplan
On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote: > On 24/02/2014 11:09 AM, Mark Lawrence wrote: >> >> On 24/02/2014 00:55, alex23 wrote: >>> >>> >>> for _ in range(5): >>> func() >> >> >> the obvious indentation error above > > > Stupid cut&paste :( > -- Your message came through fine for

Re: Functions help

2014-02-23 Thread Scott W Dunning
I understood what you meant because I looked up loops in the python documentation since we haven’t got there yet in school. On Feb 23, 2014, at 6:39 PM, alex23 wrote: > On 24/02/2014 11:09 AM, Mark Lawrence wrote: >> On 24/02/2014 00:55, alex23 wrote: >>> >>> for _ in range(5): >>> f

Re: Functions help

2014-02-23 Thread Scott W Dunning
On Feb 23, 2014, at 12:59 AM, Ben Finney wrote: > > You should ask question like this on the “python-tutor” forum. Thanks Ben, I wasn’t aware of PythonTutor. -- https://mail.python.org/mailman/listinfo/python-list

Re: Functions help

2014-02-23 Thread alex23
On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5): func() the obvious indentation error above Stupid cut&paste :( -- https://mail.python.org/mailman/listinfo/python-list

Re: Functions help

2014-02-23 Thread Travis Griggs
> On Feb 23, 2014, at 17:09, Mark Lawrence wrote: > > For the benefit of newbies, besides the obvious indentation error above, the > underscore basically acts as a dummy variable. I'll let the language lawyers > give a very detailed, precise description :) You mean a dummy name binding, rig

Re: Functions help

2014-02-23 Thread Scott W Dunning
On Feb 23, 2014, at 1:44 AM, Steven D'Aprano wrote: > > Sorry, I don't really understand your question. Could you show an example > of what you are doing? > > Do you mean "add 5" or "*5"? "Add *5 doesn't really mean anything to me. Sorry I forgot to add the code that I had to give an example

Re: Functions help

2014-02-23 Thread Mark Lawrence
On 24/02/2014 00:55, alex23 wrote: On 23/02/2014 3:43 PM, Scott W Dunning wrote: I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that? The

Re: Functions help

2014-02-23 Thread Rhodri James
On Sun, 23 Feb 2014 05:43:17 -, Scott W Dunning wrote: I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that? The usual way to ca

Re: Functions help

2014-02-23 Thread alex23
On 23/02/2014 3:43 PM, Scott W Dunning wrote: I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that? The same way you repeat anything in P

Re: Functions help

2014-02-23 Thread Steven D'Aprano
On Sat, 22 Feb 2014 22:43:17 -0700, Scott W Dunning wrote: > Hello, > > I had a question regarding functions. Is there a way to call a function > multiple times without recalling it over and over. Meaning is there a > way I can call a function and then add *5 or something like that? Sorry, I

Re: Functions help

2014-02-23 Thread Ben Finney
Scott W Dunning writes: > I had a question regarding functions. Is there a way to call a > function multiple times without recalling it over and over. You should ask question like this on the “python-tutor” forum. I say that because this question suggests you have yet to learn about basic Pytho

Functions help

2014-02-22 Thread Scott W Dunning
Hello, I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that? Thanks for any help! Scott -- https://mail.python.org/mailman/listinfo/pytho

Re: Profiling very small/quick functions, help!?

2008-04-16 Thread Aaron Watters
On Apr 16, 12:35 pm, [EMAIL PROTECTED] wrote: > if __name__=="__main__": > try: > from cProfile import run > except: > from profile import run > for x in range(1, 1): > run("power(10,10)") def test1(): for x in xrange(1,1): test = power(10,10

Profiling very small/quick functions, help!?

2008-04-16 Thread skanemupp
i use this code to profile. however for small standard functions it just says 0 seconds. so one solution is to run the function a very big number of times(how big?). but the bottom code doesnt work, it just runs the same profiling 1 times insetad of running the fucntion 10K times and evaluate t

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
NickC a écrit : > On Sep 24, 9:16 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Matthew Woodcraft a écrit : >>> One reason for the different syntax is that functions, unlike most >>> other objects, know their own names (which can be shown in tracebacks >>> and the like). >> Nope. They know

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread NickC
On Sep 24, 9:16 pm, Bruno Desthuilliers wrote: > Matthew Woodcraft a écrit : > > One reason for the different syntax is that functions, unlike most > > other objects, know their own names (which can be shown in tracebacks > > and the like). > > Nope. They know *one* of their names - the one they'v

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Matthew Woodcraft a écrit : > Cristian <[EMAIL PROTECTED]> wrote: >> To me, the biggest setback for new programmers is the different >> syntax Python has for creating functions. Instead of the common (and >> easy to grasp) syntax of foo = bar Python has the def foo(): syntax. > > [...] > >> in a

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Fri, 21 Sep 2007 22:07:55 +, Cristian wrote: > >> True, there is lambda, but that is very limited. It might be useful for >> key arguments, but not much else. > > No, lambda is useful for anything that any other function is useful for, > provided that you can w

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Duncan Booth
Carsten Haese <[EMAIL PROTECTED]> wrote: > It comes from the 'new' module: > import new help(new.function) > Help on class function in module __builtin__: > ... > > Oddly enough, the help misrepresents which module the function is coming > from. No, I don't think it is misrepresenting

RE: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Delaney, Timothy (Tim)
Carsten Haese wrote: >> Where the heck does *this* come from? Neither Python 2.5.1 nor the >> 3.0alpha has this in `__builtin__`. > > It comes from the 'new' module: > import new help(new.function) > Help on class function in module __builtin__: > ... > > Oddly enough, the help misre

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Kay Schluehr
On Sep 24, 9:09 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > Python: > > class B(object): > def __init__(self): > self.things = list() > > def add(self, thing): > self.things.append(thing) > > And Io: > > B := Object clone do( > init := method( > se

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Carsten Haese
On Mon, 2007-09-24 at 10:05 +, Marc 'BlackJack' Rintsch wrote: > On Mon, 24 Sep 2007 11:43:59 +0200, Bruno Desthuilliers wrote: > > > You already can create functions without using the def statement: > > > > Help on class function in module __builtin__: > > > > class function(object) > > |

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Marc 'BlackJack' Rintsch
On Mon, 24 Sep 2007 11:43:59 +0200, Bruno Desthuilliers wrote: > You already can create functions without using the def statement: > > Help on class function in module __builtin__: > > class function(object) > | function(code, globals[, name[, argdefs[, closure]]]) > | > | Create a funct

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Bruno Desthuilliers
Cristian a écrit : > On Sep 21, 5:21 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: > >> Ok, then what about classes ? They also are objects-like-any-other, >> after all. So should we have this syntax too ? >> >> MyClass = class(ParentClass): >>__init__ = function (self, name): >> s

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Paul Rubin
Lawrence D'Oliveiro <[EMAIL PROTECTED]> writes: > The fact that Python has difficulties is purely a demonstration of the > limitations of indentation-controlled syntax, not a criticism of the > concept itself. Not even. Haskell has indentation syntax (they call it "layout") but can have multi-lin

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > A question: if you WERE to implement function definitions as normal > expressions, how would you go about embedding it within an expression? > > x = map(def a: > > > > , [1, 2, 3]) Perl can

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Cristian wrote: > I think it would make more sense to have beginners _know_ that functions > are like all other variables ... Functions are not variables. Though they are values, and can be held in variables. In Python, every name is a variable, and can be assigne

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Bryan Olson wrote: > The keyword "lambda" sucks. ... > > Alonzo Church's calculus used the *symbol*. The keyword was popularized by LISP, and hence adopted by most other languages to copy the concept. In my view, it's no worse than using "=" for assignment instea

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Marc 'BlackJack' Rintsch
On Sun, 23 Sep 2007 18:32:28 -0700, Kay Schluehr wrote: > On 22 Sep., 02:14, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Kay Schluehr a crit : >> (snip) >> >> > I checked out Io once and I disliked it. I expected Io's prototype OO >> > being just a more flexible variant of class based OO b

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Cristian
On Sep 21, 5:21 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Ok, then what about classes ? They also are objects-like-any-other, > after all. So should we have this syntax too ? > > MyClass = class(ParentClass): >__init__ = function (self, name): > self.name = name > > ?-) For co

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Kay Schluehr
On 22 Sep., 02:14, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Kay Schluehr a écrit : > (snip) > > > > > I checked out Io once and I disliked it. I expected Io's prototype OO > > being just a more flexible variant of class based OO but Io couples a > > prototype very closely to its offspring.

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> Scott David Daniels wrote: >>> Ron Adam wrote: How about this? def integrate(fn, x1, x2, n=100):... >>> The point was a pedagogic suggestion, ... >> I understood your point. I just found it interesting since I've been >> trying to

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Cristian a écrit : > On Sep 21, 4:47 pm, "Sean Tierney" <[EMAIL PROTECTED]> wrote: > >>Just tell him that "functions are like all other variables and can >>therefore be passed by other functions or returned by other functions. >>" >> > > > > > I could """Just tell him that "functions are like

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Kay Schluehr a écrit : > On 22 Sep., 23:17, Erik Max Francis <[EMAIL PROTECTED]> wrote: > > >>The attribute and method (not made distinct in Io; they're called >>"slots") is much the same as with Python; the current instance is >>checked for the object, then its parents, then _its_ parents, and s

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Kay Schluehr a écrit : (snip) > > I checked out Io once and I disliked it. I expected Io's prototype OO > being just a more flexible variant of class based OO but Io couples a > prototype very closely to its offspring. When A produces B and A.f is > modified after production of B also B.f is modif

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Bruno Desthuilliers
Cristian a écrit : (snip) > To me, the biggest setback for new programmers is the different syntax > Python has for creating functions. Instead of the common (and easy to > grasp) syntax of foo = bar It's actually a mostly *un*common syntax when it comes to functions. The only "mainstream" langua

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Scott David Daniels
Ron Adam wrote: > Scott David Daniels wrote: >> Ron Adam wrote: >>> How about this? >>> def integrate(fn, x1, x2, n=100):... >> The point was a pedagogic suggestion, ... > I understood your point. I just found it interesting since I've been > trying to extend my math (for use with python) s

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-23 Thread Ron Adam
Scott David Daniels wrote: > Ron Adam wrote: >> >> Scott David Daniels wrote: >>> Cristian wrote: On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > I think key may be to discuss names and name binding with your friend. >>> Here's an idea: >>> >>> import math >>> >>> def sin_

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Kay Schluehr
On 22 Sep., 23:17, Erik Max Francis <[EMAIL PROTECTED]> wrote: > The attribute and method (not made distinct in Io; they're called > "slots") is much the same as with Python; the current instance is > checked for the object, then its parents, then _its_ parents, and so on. Repeating the same poin

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Steven D'Aprano
On Sat, 22 Sep 2007 14:09:13 -0700, Paul Rubin wrote: >> Nevertheless, def is never a real anonymous function constructor. > > Well, def constructs a function with a name, but the function can stay > around after the name goes away, after which I'd say the function is > nameless. One could other

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Erik Max Francis
Kay Schluehr wrote: > I checked out Io once and I disliked it. I expected Io's prototype OO > being just a more flexible variant of class based OO but Io couples a > prototype very closely to its offspring. When A produces B and A.f is > modified after production of B also B.f is modified. A contr

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Paul Rubin
Bryan Olson <[EMAIL PROTECTED]> writes: > How anonymous is that function when we can see that its name is 'h'? h is out of scope after compose returns, so the function is anonymous in the sense that there is no symbol bound to the function, through which you can refer to it. > import math >

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Bryan Olson
Paul Rubin wrote: > Bryan Olson <[EMAIL PROTECTED]> writes: >> [EMAIL PROTECTED] wrote: >>> There are already anonymous functions in Python. >>> lambda x, y, z: x + y + z >>> is the same as: >>> def _(x, y, z): return x + y + z >> They are the same only in special cases: >> The special identif

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Bryan Olson
Cristian wrote: > [...] Specifically, he's having trouble > thinking of functions as first order data (don't worry, I haven't > confused him with such terminology yet). [...] > And, after we finally > get a hold of first order functions, we appreciate its incorporation > into languages. It would b

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Paul Rubin
Bryan Olson <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: > > There are already anonymous functions in Python. > > lambda x, y, z: x + y + z > > is the same as: > > def _(x, y, z): return x + y + z > > They are the same only in special cases: > The special identifier "_" is used in t

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Matthew Woodcraft
Cristian <[EMAIL PROTECTED]> wrote: > To me, the biggest setback for new programmers is the different > syntax Python has for creating functions. Instead of the common (and > easy to grasp) syntax of foo = bar Python has the def foo(): syntax. [...] > in a program like Python there doesn't seem

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > There are already anonymous functions in Python. > > lambda x, y, z: x + y + z > > is the same as: > > def _(x, y, z): return x + y + z They are the same only in special cases: The special identifier "_" is used in the interactive interpreter to store the r

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 06:58:57 -0700, Kay Schluehr wrote: > On Sep 22, 1:15 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Sat, 22 Sep 2007 02:44:35 -0700, Kay Schluehr wrote: >> > I checked out Io once and I disliked it. I expected Io's prototype OO >> > being just a more flexible va

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Scott David Daniels
Ron Adam wrote: > > > Scott David Daniels wrote: >> Cristian wrote: >>> On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >>> I think key may be to discuss names and name binding with your friend. >> >> Here's an idea: >> >> import math >> >> def sin_integral(start, finish, dx): ... >>

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Kay Schluehr
On Sep 22, 1:15 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 22 Sep 2007 02:44:35 -0700, Kay Schluehr wrote: > > I checked out Io once and I disliked it. I expected Io's prototype OO > > being just a more flexible variant of class based OO but Io couples a > > prototype very cl

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Carl Banks
On Sat, 22 Sep 2007 02:32:30 -0700, Paul Rubin wrote: > Carl Banks <[EMAIL PROTECTED]> writes: >> That's it, lost me already. You ever see the kinds of programs >> mechanical engineers write? It isn't software. > > They do a lot of number crunching. Certainly they can appreciate higher > order

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 02:44:35 -0700, Kay Schluehr wrote: > I checked out Io once and I disliked it. I expected Io's prototype OO > being just a more flexible variant of class based OO but Io couples a > prototype very closely to its offspring. When A produces B and A.f is > modified after productio

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Kay Schluehr
On Sep 22, 10:40 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sat, 22 Sep 2007 00:47:37 -0700, Kay Schluehr wrote: > > On 22 Sep., 08:56, Paul Rubin wrote: > >> Kay Schluehr <[EMAIL PROTECTED]> writes: > >> > If you feel you can transform it into another u

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Paul Rubin
Carl Banks <[EMAIL PROTECTED]> writes: > That's it, lost me already. You ever see the kinds of programs > mechanical engineers write? It isn't software. They do a lot of number crunching. Certainly they can appreciate higher order functions like integrate(f, x0, x1) to integrate the function f

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Carl Banks
On Fri, 21 Sep 2007 23:38:38 -0700, Paul Rubin wrote: > Carl Banks <[EMAIL PROTECTED]> writes: >> Especially someone like an >> engineer (in the classical sense), who isn't building versatile >> software packages, won't need to resort to functional programming much. > > http://www.math.chalmers.s

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 00:47:37 -0700, Kay Schluehr wrote: > On 22 Sep., 08:56, Paul Rubin wrote: >> Kay Schluehr <[EMAIL PROTECTED]> writes: >> > If you feel you can transform it into another unambigous grammar >> > mixing statements and expressions it's up to you. >> >> W

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Kay Schluehr
On 22 Sep., 08:56, Paul Rubin wrote: > Kay Schluehr <[EMAIL PROTECTED]> writes: > > If you feel you can transform it into another unambigous grammar > > mixing statements and expressions it's up to you. > > We got rid of the print statement for python 3.0. Why not get ri

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Ron Adam
Scott David Daniels wrote: > Cristian wrote: >> On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: >> >>> I think key may be to discuss names and name binding with your friend. > > Here's an idea: > > import math > > def sin_integral(start, finish, dx): > total = 0.0 > y0 = math

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Paul Rubin
Kay Schluehr <[EMAIL PROTECTED]> writes: > If you feel you can transform it into another unambigous grammar > mixing statements and expressions it's up to you. We got rid of the print statement for python 3.0. Why not get rid of the rest of them too? Just use expressions for everything, as works

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Kay Schluehr
On 22 Sep., 00:36, Cristian <[EMAIL PROTECTED]> wrote: > Yeah, I agree, that does look pretty ugly. Correct me if I'm wrong, > but I thought the way Python determines a block is by the whitespace > of the first line. So, as long as the spacing (or !tabbing!) is > consistent from line to line the p

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Paul Rubin
Carl Banks <[EMAIL PROTECTED]> writes: > Especially someone like an > engineer (in the classical sense), who isn't building versatile software > packages, won't need to resort to functional programming much. http://www.math.chalmers.se/~rjmh/Papers/whyfp.html -- http://mail.python.org/mailman/

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Marc 'BlackJack' Rintsch
On Fri, 21 Sep 2007 19:52:41 -0400, Carl Banks wrote: > First of all, let me say that I think "functions as first class data" is > helpful, but not crucial, to programming in Python, and there are many > people who simply don't need the lesson. Especially someone like an > engineer (in the cla

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Scott David Daniels
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > >> I think key may be to discuss names and name binding with your friend. Here's an idea: import math def sin_integral(start, finish, dx): total = 0.0 y0 = math.sin(start) for n in range(1, 1 + int((finis

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Steven D'Aprano
On Fri, 21 Sep 2007 22:07:55 +, Cristian wrote: > True, there is lambda, but that is very limited. It might be useful for > key arguments, but not much else. No, lambda is useful for anything that any other function is useful for, provided that you can write it as a single expression and not

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Ron Adam
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > >> I think key may be to discuss names and name binding with your friend. How >> a name is not the object it self, like a variable is in other languages. >> For example show him how an object can have more than one name

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Carl Banks
On Fri, 21 Sep 2007 21:37:18 +, Cristian wrote: > Although his learning experience has gone mostly smoothly, he's hit a > lot of speed bumps with functions. Specifically, he's having trouble > thinking of functions as first order data (don't worry, I haven't > confused him with such terminology

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
On Sep 21, 4:47 pm, "Sean Tierney" <[EMAIL PROTECTED]> wrote: > Just tell him that "functions are like all other variables and can > therefore be passed by other functions or returned by other functions. > " > I could """Just tell him that "functions are like all other variables and can theref

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
On Sep 21, 4:27 pm, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > Cristian wrote: > > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > > >> I think key may be to discuss names and name binding with your friend. How > >> a name is not the object it self, like a variable is in other language

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Sean Tierney
On 9/21/07, Sean Tierney <[EMAIL PROTECTED]> wrote: > Just tell him that "functions are like all other variables and can > therefore be passed by other functions or returned by other functions. > " > > If your friend understands variables and functions and he can't make > the "leap" (and assuming

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Sean Tierney
Just tell him that "functions are like all other variables and can therefore be passed by other functions or returned by other functions. " If your friend understands variables and functions and he can't make the "leap" (and assuming you're right, of course) then your friend doesn't understand va

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Cristian <[EMAIL PROTECTED]> wrote: ... > To someone who's learning to program wouldn't a syntax like the > further give them all they need and also reinforces the idea that > functions are data just like everything else? > > my_function = function(foo, bar): pass

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread J. Cliff Dyer
Cristian wrote: > On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > > >> I think key may be to discuss names and name binding with your friend. How >> a name is not the object it self, like a variable is in other languages. >> For example show him how an object can have more than one na

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
On Sep 21, 3:44 pm, Ron Adam <[EMAIL PROTECTED]> wrote: > I think key may be to discuss names and name binding with your friend. How > a name is not the object it self, like a variable is in other languages. > For example show him how an object can have more than one name. And discus > how names

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Ron Adam
Cristian wrote: > My hope is to subtly reinforce the notion that functions are data > and can be passed around. The current function declaration doesn't > help with this. Creating a function and assigning it to a name is > exactly what Python does, why not have it come out in the syntax? It's > n

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
On Sep 21, 3:22 pm, [EMAIL PROTECTED] wrote: > On Sep 21, 6:07 pm, Cristian <[EMAIL PROTECTED]> wrote: > > > > > On Sep 21, 2:48 pm, [EMAIL PROTECTED] wrote: > > > > There are already anonymous functions in Python. > > > > lambda x, y, z: x + y + z > > > > is the same as: > > > > def _(x, y, z): re

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread chris . monsanto
On Sep 21, 6:07 pm, Cristian <[EMAIL PROTECTED]> wrote: > On Sep 21, 2:48 pm, [EMAIL PROTECTED] wrote: > > > > > There are already anonymous functions in Python. > > > lambda x, y, z: x + y + z > > > is the same as: > > > def _(x, y, z): return x + y + z > > > As for the method stuff, check out sta

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
On Sep 21, 2:48 pm, [EMAIL PROTECTED] wrote: > There are already anonymous functions in Python. > > lambda x, y, z: x + y + z > > is the same as: > > def _(x, y, z): return x + y + z > > As for the method stuff, check out staticmethod(). If you assign > staticmethod() to an object, it will be treat

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread chris . monsanto
On Sep 21, 5:37 pm, Cristian <[EMAIL PROTECTED]> wrote: > A friend of mine is an engineer and he's been needing to do more and > more programming as he goes on with is career. I convinced him to > learn Python instead of Perl and he's really started to like it. He > usually comes to me when he can'

Would Anonymous Functions Help in Learning Programming/Python?

2007-09-21 Thread Cristian
A friend of mine is an engineer and he's been needing to do more and more programming as he goes on with is career. I convinced him to learn Python instead of Perl and he's really started to like it. He usually comes to me when he can't accomplish a task with his current knowledge and I introduce h