Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Rustom Mody
On Tuesday, March 24, 2015 at 11:50:40 AM UTC+5:30, Rustom Mody wrote: > On Tuesday, March 24, 2015 at 10:51:11 AM UTC+5:30, Ian wrote: > > On Mon, Mar 23, 2015 at 4:53 PM, Terry Reedy wrote: > > > Iteration with caching, using a mutable default arg to keep the cache > > > private and the function

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Rustom Mody
On Tuesday, March 24, 2015 at 10:51:11 AM UTC+5:30, Ian wrote: > On Mon, Mar 23, 2015 at 4:53 PM, Terry Reedy wrote: > > Iteration with caching, using a mutable default arg to keep the cache > > private and the function self-contained. This should be faster. > > > > def fib(n, _cache=[0,1]): > >

paramiko-expect with Python 2->3 'str' buffer interface issues?

2015-03-23 Thread Nick Ellson
Hello, Newly trying out programming, Python for Network Engineers, and loving it. So I found paramiko for SSH, and now paramiko-expect for ssh expect like behavior. I am using Python 3.4 and have been through a number of examples of changing code to work in the 3.x environment. But is anyone u

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 08:27 PM, Chris Angelico wrote: On Tue, Mar 24, 2015 at 11:09 AM, Dave Angel wrote: Repeat to self: comment first, then write test, then write the code. Reply to self: Maybe next time. Commenting is like dieting. You can always start tomorrow. It reminds me of flow charts.

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Ian Kelly
On Mon, Mar 23, 2015 at 4:53 PM, Terry Reedy wrote: > Iteration with caching, using a mutable default arg to keep the cache > private and the function self-contained. This should be faster. > > def fib(n, _cache=[0,1]): > '''Return fibonacci(n). > > _cache is initialized with base values

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Rustom Mody
On Tuesday, March 24, 2015 at 8:33:24 AM UTC+5:30, Chris Angelico wrote: > Mathematics doesn't like defining sequences, except by defining > functions, and so it has to convert the concept of "defining the > Fibonacci sequence" into "defining a function F(N) which returns the > Nth Fibonacci number

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Rustom Mody
On Tuesday, March 24, 2015 at 8:33:24 AM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 24, 2015 at 12:52 PM, Steven D'Aprano wrote: > > On Tue, 24 Mar 2015 11:59 am, Chris Angelico wrote: > > > > > >> I've never thought of the mathematical definition as being inherently > >> recursive; but as inher

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 12:52 PM, Steven D'Aprano wrote: > On Tue, 24 Mar 2015 11:59 am, Chris Angelico wrote: > > >> I've never thought of the mathematical definition as being inherently >> recursive; but as inherently sequential. Sure, you can define counting >> numbers based on sets (0 is the c

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Rustom Mody
On Tuesday, March 24, 2015 at 7:22:25 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 24 Mar 2015 11:59 am, Chris Angelico wrote: > > > > I've never thought of the mathematical definition as being inherently > > recursive; but as inherently sequential. Sure, you can define counting > > numbers base

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
On Tue, 24 Mar 2015 11:59 am, Chris Angelico wrote: > I've never thought of the mathematical definition as being inherently > recursive; but as inherently sequential. Sure, you can define counting > numbers based on sets (0 is the cardinality of the empty set, 1 is the > cardinality of the set co

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Terry Reedy
On 3/23/2015 7:12 PM, Dave Angel wrote: On 03/23/2015 06:53 PM, Terry Reedy wrote: Iteration with caching, using a mutable default arg to keep the cache private and the function self-contained. This should be faster. def fib(n, _cache=[0,1]): '''Return fibonacci(n). _cache is init

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
Given the standard recursive version of the Fibonacci series: def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) I asked: > The question is, just how inefficient is is? How many calls to `fib` are > made in calling fib(n)?

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 11:19 AM, Steven D'Aprano wrote: > It is pretty inefficient, but it is a good toy example of recursion. It's > also a good example of how *not* to write the Fibonacci series in practice, > what is mathematically straightforward is not always computationally > efficient. > >

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 08:19 PM, Steven D'Aprano wrote: On Tue, 24 Mar 2015 03:16 am, Chris Angelico wrote about the standard recursive version of the Fibonacci series: On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal wrote: def fib(n): if n == 0: return 0 elif n == 1: return

Re: Best way to calculate fraction part of x?

2015-03-23 Thread Emile van Sebille
On 3/23/2015 5:52 AM, Steven D'Aprano wrote: Are there any other, possibly better, ways to calculate the fractional part of a number? float (("%6.3f" % x)[-4:]) Emile -- https://mail.python.org/mailman/listinfo/python-list

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 11:09 AM, Dave Angel wrote: > Repeat to self: comment first, then write test, then write the code. > > Reply to self: Maybe next time. Commenting is like dieting. You can always start tomorrow. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
On Tue, 24 Mar 2015 03:16 am, Chris Angelico wrote about the standard recursive version of the Fibonacci series: > On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal wrote: >> def fib(n): >> if n == 0: >> return 0 >> elif n == 1: >> return 1 >> else: >> return fib(n-

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
On Tue, 24 Mar 2015 03:01 am, Ganesh Pal wrote: > Hello team , > > > [root@localhost Python]# cat fibonacci-Sequence-3.py > > ## Example 2: Using recursion > def fib(n): > if n == 0: > return 0 > elif n == 1: > return 1 > else: > return fib(n-1) + fib(n-2) >

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 07:49 PM, Chris Angelico wrote: On Tue, Mar 24, 2015 at 10:12 AM, Dave Angel wrote: On the other hand, my loop makes some non-obvious assumptions, like that append is always the right place to put a new value. Yes, I had to stop and think about that one a bit. And that strongly

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 10:12 AM, Dave Angel wrote: > On the other hand, my loop makes some non-obvious assumptions, like that > append is always the right place to put a new value. Yes, I had to stop and think about that one a bit. And that strongly suggests (to me, at least!) that it's comment-

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 06:53 PM, Terry Reedy wrote: On 3/23/2015 2:44 PM, Dave Angel wrote: ## Example 2: Using recursion with caching cache = [0, 1] def fib4(n): if len(cache) <= n: value = fib4(n-2) + fib4(n-1) cache.append(value) return cache[n] This one takes less than a

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Terry Reedy
On 3/23/2015 2:44 PM, Dave Angel wrote: ## Example 2: Using recursion with caching cache = [0, 1] def fib4(n): if len(cache) <= n: value = fib4(n-2) + fib4(n-1) cache.append(value) return cache[n] This one takes less than a millisecond up to n=200 or so. Iteration

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 05:31 PM, Carsten Lechte wrote: On 23/03/15 19:44, Dave Angel wrote: I'll give you a worse version. Back in the day I had occasion to write a simple program in a language which had no add or subtract. It could only increment and decrement indices. Oh yes, the olden days. I have

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Carsten Lechte
On 23/03/15 19:44, Dave Angel wrote: I'll give you a worse version. Back in the day I had occasion to write a simple program in a language which had no add or subtract. It could only increment and decrement indices. Oh yes, the olden days. I have not quite lived through the punch card era,

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Ian Kelly
On Mon, Mar 23, 2015 at 12:44 PM, Dave Angel wrote: > On 03/23/2015 12:16 PM, Chris Angelico wrote: >> [1] Cue the demonstration of a worse version from someone's student? >> > > I'll give you a worse version. Back in the day I had occasion to write a > simple program in a language which had no a

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 12:16 PM, Chris Angelico wrote: On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal wrote: Hello team , [root@localhost Python]# cat fibonacci-Sequence-3.py ## Example 2: Using recursion def fib(n): if n == 0: return 0 elif n == 1: return 1 else:

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread CHIN Dihedral
On Tuesday, March 24, 2015 at 1:00:11 AM UTC+8, Chris Angelico wrote: > On Tue, Mar 24, 2015 at 3:16 AM, Dave Angel wrote: > > An entirely separate question is whether you can gain performance by caching > > intermediate values. For example, if you capture values in a list, you > > could potentia

ANN: Wingware Python IDE version 5.1.3 released

2015-03-23 Thread Wingware
This release includes the following improvements: Support running and debugging pytest unit tests Allow debugging Flask with auto-reload enabled Keep matplotlib plots active in Debug Probe also when using MacOSX backend Ability to send NUL and EOF to the shells and debug I/O

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 12:59 PM, Chris Angelico wrote: On Tue, Mar 24, 2015 at 3:16 AM, Dave Angel wrote: An entirely separate question is whether you can gain performance by caching intermediate values. For example, if you capture values in a list, you could potentially save a lot of time, at least fo

Statically linking part of a C extension module?

2015-03-23 Thread Dan Stromberg
Hi folks. I want to build a pair of wheels - one for numpy, one for scipy. And I want to statically link atlas (with blas and lapack) into these wheels. I don't want to statically link numpy or scipy into the Python interpreter. The goal is to decrease the frequency with which new wheels need t

Re:

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 3:57 AM, Grant Edwards wrote: > On 2015-03-23, Tim Chase wrote: >> On 2015-03-23 21:19, Chandra Prashad mishra wrote: >>> I want to know hint about web development... can any one get me... >> >> Use your text editor and deploy your project to a web server. > > The most imp

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 3:16 AM, Dave Angel wrote: > An entirely separate question is whether you can gain performance by caching > intermediate values. For example, if you capture values in a list, you > could potentially save a lot of time, at least for non-trivial values of n. If you take a s

Re:

2015-03-23 Thread Grant Edwards
On 2015-03-23, Tim Chase wrote: > On 2015-03-23 21:19, Chandra Prashad mishra wrote: >> I want to know hint about web development... can any one get me... > > Use your text editor and deploy your project to a web server. The most important hint is don't use PHP. PHP is some sort of cruel practic

Re:

2015-03-23 Thread Ian Kelly
On Mon, Mar 23, 2015 at 7:19 AM, Chandra Prashad mishra wrote: > I want to know hint about web development... can any one get me... Hint: use CSS to separate your HTML content from its presentation. If you're looking for something more specific, you'll have to ask a more specific question. -- h

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Chris Angelico
On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal wrote: > Hello team , > > > [root@localhost Python]# cat fibonacci-Sequence-3.py > > ## Example 2: Using recursion > def fib(n): > if n == 0: > return 0 > elif n == 1: > return 1 > else: > return fib(n-1) + fib(n-2) >

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Dave Angel
On 03/23/2015 12:01 PM, Ganesh Pal wrote: Hello team , [root@localhost Python]# cat fibonacci-Sequence-3.py ## Example 2: Using recursion def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) print fib(5) # python fi

fibonacci series what Iam is missing ?

2015-03-23 Thread Ganesh Pal
Hello team , [root@localhost Python]# cat fibonacci-Sequence-3.py ## Example 2: Using recursion def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return fib(n-1) + fib(n-2) print fib(5) # python fibonacci-Sequence-3.py 5 what Iam I missing in the

Re:

2015-03-23 Thread Tim Chase
On 2015-03-23 21:19, Chandra Prashad mishra wrote: > I want to know hint about web development... can any one get me... Use your text editor and deploy your project to a web server. -tkc (you'd need to provide a few more details about what you want to get anything more detailed in response)

[no subject]

2015-03-23 Thread Chandra Prashad mishra
I want to know hint about web development... can any one get me... -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to calculate fraction part of x?

2015-03-23 Thread Mark Lawrence
On 23/03/2015 12:52, Steven D'Aprano wrote: I have a numeric value, possibly a float, Decimal or (improper) Fraction, and I want the fractional part. E.g. fract(2.5) should give 0.5. Here are two ways to do it: py> x = 2.5 py> x % 1 0.5 py> x - int(x) 0.5 x % 1 is significantly faster, but has

Re: Best way to calculate fraction part of x?

2015-03-23 Thread Skip Montanaro
On Mon, Mar 23, 2015 at 7:52 AM, Steven D'Aprano wrote: > x % 1 is significantly faster, but has the disadvantage of giving the > complement of the fraction if x is negative I suppose abs(x) % 1 would be just as slow as x - int(x) ? (haven't checked) Skip -- https://mail.python.org/mailman/

Best way to calculate fraction part of x?

2015-03-23 Thread Steven D'Aprano
I have a numeric value, possibly a float, Decimal or (improper) Fraction, and I want the fractional part. E.g. fract(2.5) should give 0.5. Here are two ways to do it: py> x = 2.5 py> x % 1 0.5 py> x - int(x) 0.5 x % 1 is significantly faster, but has the disadvantage of giving the complement of

Re: Using Python to put a 27-year-old Macintosh on the web

2015-03-23 Thread Michiel Overtoom
On Mar 23, 2015, at 06:36, Steven D'Aprano wrote: > http://www.keacher.com/1216/how-i-introduced-a-27-year-old-computer-to-the- > web/ I saw it too, on Hacker News ;-) Awesome. I love(d) my Classic Mac but I couldn't stand the slow network connection, I think. Also, creative use of Flask and B

convert pdf to excel xls file

2015-03-23 Thread elviramorfi
Now you can make modifications in Word file with AnyBizSoft pdf to excel for Mac, you insert may also resize or delete images. After editing PDF text, if you prefer to replace the modified pages towards the original PDF. You're able to create PDF from Concept on Mac, and after that draganddrop the

Re: Automation of Windows app?

2015-03-23 Thread Albert-Jan Roskam
-- On Sun, Mar 22, 2015 6:41 PM CET Emile van Sebille wrote: >On 3/20/2015 10:55 AM, Grant Edwards wrote: > >> I need to automate operation of a Windows application. > >I've been productively using python to create macro scheduler [1] scripts to >automate windows prog