Re: Supply condition in function call

2015-03-29 Thread Manuel Graune
Cameron Simpson writes: > > In xterm and I think several other X11 terminals, Shift-Insert > pastes. I found that _way_ more convenient than middle click. The > mouse is not your friend. > This information might prove as useful as your answer to my original question. ;-) Thanks for both! -- A

Re: Supply condition in function call

2015-03-27 Thread Manuel Graune
Cameron Simpson writes: > This passes the local variables inside test1() to "condition" as a > single parameter. Now, I grant that vars['i'] is a miracle of > tediousness. So consider this elaboration: > > from collections import namedtuple > > condition_test = lambda vars: vars.i + vars.j > 4

Re: Supply condition in function call

2015-03-27 Thread Manuel Graune
Peter Otten <__pete...@web.de> writes: > Cameron Simpson wrote: > >> test1([0,1,2,3], [1,2,3,4], condition_test) >> >> This passes the local variables inside test1() to "condition" as a single >> parameter. Now, I grant that vars['i'] is a miracle of tediousness. So >> consider this elaboration

Re: Supply condition in function call

2015-03-25 Thread Manuel Graune
Gary Herron writes: > On 03/25/2015 10:29 AM, Manuel Graune wrote: >> >> def test1(a, b, condition="True"): >> for i,j in zip(a,b): >> c=i+j >> if eval(condition): >> print("Foo") >> >>

Re: Supply condition in function call

2015-03-25 Thread Manuel Graune
Joel Goldstick writes: > On Wed, Mar 25, 2015 at 1:29 PM, Manuel Graune wrote: >> >> def test1(a, b, condition="True"): >> for i,j in zip(a,b): >> c=i+j >> if eval(condition): >>print("Foo") >&

Supply condition in function call

2015-03-25 Thread Manuel Graune
Hi, I'm looking for a way to supply a condition to an if-statement inside a function body when calling the function. I can sort of get what I want with using eval (see code below) but I would like to achieve this in a safer way. If there is a solution which is safer while being less flexible, that

numpy/scipy: calculate definite integral of sampled data

2011-08-09 Thread Manuel Graune
Hi everyone, to calculate the definite integral of a function or an array of sampled data scipy provides (among others) the quad and trapz functions. So it is possible to compute e. g. the definite integral of cos(t) over some range by doing definite_integral= scipy.integrate.quad(cos,lower_limit

Re: python as pen and paper substitute

2010-04-10 Thread Manuel Graune
Michael Torrie writes: > > Did you look at the link to Owen Taylor's reinteract program? I think > it's closer to what you want than any other thing mentioned here, with > the exception that it's a standalone GTK (graphical) app. Yes, I did. And I think this program is a great lightweight alerna

Re: python as pen and paper substitute

2010-04-08 Thread Manuel Graune
Giacomo Boffi writes: > Manuel Graune writes: > >> Hello everyone, >> >> I am looking for ways to use a python file as a substitute for simple >> pen and paper calculations. > > search("embedded calc mode") if manuel in emacs_fellows_set or sys.exit

Re: python as pen and paper substitute

2010-04-07 Thread Manuel Graune
Hello Johan, thanks to you (and everyone else who answered) for your effort. Johan Grönqvist writes: > Manuel Graune skrev: >> Manuel Graune writes: >> >> Just as an additional example, let's assume I'd want to add the area of >> to circles. >> [.

Re: python as pen and paper substitute

2010-04-07 Thread Manuel Graune
Hello Johan, thanks to you (and everyone else who answered) for your effort. Johan Grönqvist writes: > Manuel Graune skrev: >> Manuel Graune writes: >> >> Just as an additional example, let's assume I'd want to add the area of >> to circles. >> [.

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Manuel Graune writes: > > The use-case is acually fairly simple. The point is to use a python > source-file as subsitute for scrap-paper (with the opportunity to > edit what is already written and without illegible handwriting). > The output should 1) show manually selected

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Manuel Graune writes: > > The use-case is acually fairly simple. The point is to use a python > source-file as subsitute for scrap-paper (with the opportunity to > edit what is already written and without illegible handwriting). > The output should 1) show manually selected

Re: python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Thanks for your reply. Johan Grönqvist writes: > Manuel Graune skrev: >> To clarify, I just start an editor, write a file that >> might look something like this: >> >> -snip- >> code=""" >> a = 1 >> b = 2 >> c = 3 >

python as pen and paper substitute

2010-04-06 Thread Manuel Graune
Hello everyone, I am looking for ways to use a python file as a substitute for simple pen and paper calculations. At the moment I mainly use a combination of triple-quoted strings, exec and print (Yes, I know it's not exactly elegant). To clarify, I just start an editor, write a file that might lo

Tracing variable scope (local vs. global)

2009-12-01 Thread Manuel Graune
tion. Since I consider this behaviour a possible source of bugs due to personal sloppiness (e. g. forgetting to put "a=4" inside the function-body): Is there any way to automatically check that all variables in a function are either local or passed in as arguments? Regards, Manuel Graune

Re: Questions about list-creation

2009-12-01 Thread Manuel Graune
Thanks to all of you. You have been most helpful. Regards, Manuel Graune -- A hundred men did the rational thing. The sum of those rational choices was called panic. Neal Stephenson -- System of the world http://www.graune.org/GnuPG_pubkey.asc Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A 5828

Questions about list-creation

2009-11-30 Thread Manuel Graune
yed afterwards: print "a",a print "i",i using the similar code b=list(j for j in xrange(10)) the local variable is destroyed after use: print "b",b print "j",j and 2) a=list([]) vs. b=[[]] Regards, Manuel Graune -- A hundred men did the rational thin

Re: Usage of main()

2009-09-04 Thread Manuel Graune
Sean DiZazzo writes: > I'm trying to come up with an answer for you, but I can't... > > The if __name__ == "__main__": idiom *is* the standard way to write > python programs, but it's not there to speed up programs. It's there > so that your program can be executed differently whether it is call

Usage of main()

2009-09-03 Thread Manuel Graune
Hello everyone, the standard structure of a python-program which is taught in all of the books I on python I read by now is simply something like: #!/usr/bin/python print "Hello, world!" ^D While reading about structuring a larger code-base, unit-testing, etc I stumbled on the idiom #!/usr/bin

Nested Classes and Instances

2009-07-10 Thread Manuel Graune
Hello, as an example of what I would like to achieve, think of a street where each house has a door and a sign with a unique (per house) number on it. I tried to model this like this: class House(object): class Door(object): def __init__(self,color): self.color=color

Re: An Editor that Skips to the End of a Def

2007-09-24 Thread Manuel Graune
Lawrence D'Oliveiro <[EMAIL PROTECTED]> writes: > In message <[EMAIL PROTECTED]>, Manuel Graune wrote: > >> Matthew Woodcraft <[EMAIL PROTECTED]> writes: >> >>> Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:> >>> >&g

Re: An Editor that Skips to the End of a Def

2007-09-23 Thread Manuel Graune
Matthew Woodcraft <[EMAIL PROTECTED]> writes: > Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:> > >> > > An interesting story. They say they picked a test for the express > purpose of proving that in some circumstances cursor keys ca

Re: Objects, lists and assigning values

2007-04-07 Thread Manuel Graune
"7stud" <[EMAIL PROTECTED]> writes: > > What book are you reading? > I worked my way through most of the online-docs. A bit to casual obviously. As printed desktop-reference I use a german book called "Python ge-packt". -- A hundred men did the rational thing. The sum of those rational choic

Re: Objects, lists and assigning values

2007-04-06 Thread Manuel Graune
Hello Gabriel, hello William, thanks to both of you for your answers. I seem to need a better book about python. Regards, Manuel "Gabriel Genellina" <[EMAIL PROTECTED]> writes: > class new_class(object): > def __init__(self, internal_list=None): > if internal_list is None: >

Objects, lists and assigning values

2007-04-05 Thread Manuel Graune
Hello, while trying to learn how to program using objects in python (up to now simple scripts were sufficient for my needs) I stumbled over the a problem while assigning values to an object. The following piece of code shows what I intend to do: <---snip---> class new_class(object): de

Re: Are there sprintf in Python???

2007-01-23 Thread Manuel Graune
"questions?" <[EMAIL PROTECTED]> writes: > Are there any sprintf in Python? > I know you can print to files(or redefine sys.stout) and later open the > file content. Are you looking for something like this? http://norvig.com/python-iaq.html or http://aspn.activestate.com/ASPN/Cookbook/Python/