Re: Fibonacci series recursion error

2011-04-29 Thread Chris Angelico
On Sat, Apr 30, 2011 at 4:32 PM, Peter Otten <__pete...@web.de> wrote: >> ...  because each recursion level 'return' calls fib() twice, and each >> of those calls fib() twice, and you get the point... > > I don't understand what you are trying to say -- but it's wrong ;) Fortunately, most Python i

Re: Fibonacci series recursion error

2011-04-29 Thread Peter Otten
harrismh777 wrote: > Ian Kelly wrote: >> since the fact is that if >> the function were properly coded, the call stack for fib(20) would >> never be more than 20 entries deep at any one time. >> > > Not so much... and much more ! > > > ... because each recursion level 'return' calls fib()

Re: Fibonacci series recursion error

2011-04-29 Thread Peter Otten
harrismh777 wrote: > def fib(i=1): > a=1;n=1;l=[] > for j in range(0,i): > l.append(a) > p=a;a=n;n=p+a Hm, did you run out of newlines? > return l > > list=fib(7) > > > > ... and the above, is how I would actually code it > > > > Nah, that can't be i

Re: Fibonacci series recursion error

2011-04-29 Thread Paul Rudin
harrismh777 writes: > lalit wrote: >> The above function return the >> return (fib(n-1)+fib(n-2)) >> >> RuntimeError: maximum recursion depth exceeded in comparison >> [36355 refs] > > There is much debate about this generally, but general wisdom is that > recursion is to be avoided when possible

Re: Fibonacci series recursion error

2011-04-29 Thread Hans Georg Schaathun
On Fri, 29 Apr 2011 23:45:30 -0500, harrismh777 wrote: : There is much debate about this generally, but general wisdom is that : recursion is to be avoided when possible. That is context dependent at best. You have given reasons to avoid recursion in /executable code/, but that's a compiler

Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777
Ian Kelly wrote: since the fact is that if the function were properly coded, the call stack for fib(20) would never be more than 20 entries deep at any one time. Not so much... and much more ! ... because each recursion level 'return' calls fib() twice, and each of those calls fib() tw

Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777
def fib(i=1): a=1;n=1;l=[] for j in range(0,i): l.append(a) p=a;a=n;n=p+a return l list=fib(7) ... and the above, is how I would actually code it kind regards, m harris -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 9:57 PM, Jason Friedman wrote: > The first call to fib() recursively calls fib() twice.  Each of those > will call fib() twice.  Each of those will call fib() twice.  Pretty > soon, you've got a lot of calls. Which is hell for the running time, but doesn't answer the quest

Installing programs that depend on, or are, python extensions.

2011-04-29 Thread James A. Donald
I have noticed that installing python programs tends to be hell, particularly under windows, and installing python programs that rely on, or in large part are, python extensions written in C++ tends to be hell on wheels with large spiky knobs and scythes on the wheels. Is this because such install

Re: (beginner) logging config not working

2011-04-29 Thread Peter Otten
Unknown Moss wrote: > Hi > > This is a beginner question. Thanks for the hand. > > I've been asked to maintain some poorly constructed python code. > Logging is weak. Getting it to work with python logging > programmatically was easy. > > However, I'd like to refactor all the logging code into

Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777
===begin== def fib(i=1): l=[] p=0 a=1 n=p+a for j in range(1,i+1): l.append(a) p=a a=n n=p+a return l list=fib(7) ===end== ... the above, if you want to return the lis

Re: Fibonacci series recursion error

2011-04-29 Thread harrismh777
lalit wrote: The above function return the return (fib(n-1)+fib(n-2)) RuntimeError: maximum recursion depth exceeded in comparison [36355 refs] There is much debate about this generally, but general wisdom is that recursion is to be avoided when possible. Another way to say this is, "Only us

Re: Fibonacci series recursion error

2011-04-29 Thread Jason Friedman
> import os > def fib(n): >        if n == 1: >          return(n) >        else: >          return (fib(n-1)+fib(n-2)) > > list=fib(20) > print(list) > > The above function return the > return (fib(n-1)+fib(n-2)) > > > RuntimeError: maximum recursion depth exceeded in comparison > [36355 refs] > >

Re: Development tools and practices for Pythonistas

2011-04-29 Thread Roy Smith
In article , CM wrote: > While we're on the topic, when should a lone developer bother to start > using a VCS? No need to use VCS at the very beginning of a project. You can easily wait until you've written 10 or 20 lines of code :-) > Should I bother to try a VCS? Absolutely. Even if you

Re: Fibonacci series recursion error

2011-04-29 Thread Gary Herron
On 04/29/2011 08:22 PM, lalit wrote: import os def fib(n): if n == 1: return(n) else: return (fib(n-1)+fib(n-2)) list=fib(20) print(list) The above function return the return (fib(n-1)+fib(n-2)) RuntimeError: maximum recursion depth exceeded in comparison

Re: Development tools and practices for Pythonistas

2011-04-29 Thread Shawn Milochik
Depends on the project, but I'd start with git the time I created the first file in my project. If you're in the habit of committing then you can easily rollback missteps. If you're in the habit of making branches you can experiment without breaking the currently-working code. -- http://mail.

Fibonacci series recursion error

2011-04-29 Thread lalit
import os def fib(n): if n == 1: return(n) else: return (fib(n-1)+fib(n-2)) list=fib(20) print(list) The above function return the return (fib(n-1)+fib(n-2)) RuntimeError: maximum recursion depth exceeded in comparison [36355 refs] can any one help -- http:

Re: Development tools and practices for Pythonistas

2011-04-29 Thread CM
> A lone developer using such a VCS reaps the benefits of this by getting > good merging support. While we're on the topic, when should a lone developer bother to start using a VCS? At what point in the complexity of a project (say a hobby project, but a somewhat seriousish one, around ~5-9k LOC

Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 5:54 PM, Carl Banks wrote: >> Really, *any* class that uses super().__init__ should take its >> arguments and pass them along in this manner. > > If you are programming defensively for any possible scenario, you might try > this (and you'd still fail). > > In the real worl

(beginner) logging config not working

2011-04-29 Thread Unknown Moss
Hi This is a beginner question. Thanks for the hand. I've been asked to maintain some poorly constructed python code. Logging is weak. Getting it to work with python logging programmatically was easy. However, I'd like to refactor all the logging code into configuration since I see the need for

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Friday, April 29, 2011 2:44:56 PM UTC-7, Ian wrote: > On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks > wrote: > > Here is my advice on mixins: > > > > Mixins should almost always be listed first in the bases.  (The only > > exception is to work around a technicality.  Otherwise mixins go first.)

Re: Development tools and practices for Pythonistas

2011-04-29 Thread Ben Finney
Hans Georg Schaathun writes: > Exactly, and with svn that can be a true nightmare when directories > are involved. The rumour is that git handles this much better. Any of the top-tier distributed VCS (Bazaar, Git, Mercurial) handle branching and merging very well. They have to, because branchi

Re: cx_Freeze 4.2.3

2011-04-29 Thread PuffTheMagic
I get this error too using Apple's system python. On Mar 31, 7:49 pm, James Mills wrote: > On Sun, Mar 20, 2011 at 9:52 AM, Anthony Tuininga > > wrote: > > Where do I get it? > > >http://cx-freeze.sourceforge.net > > Just as a matter of interest, I tried to install cx_Freeze with > pip/distribut

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
Ian Kelly wrote: On Thu, Apr 28, 2011 at 11:15 AM, Ethan Furman wrote: For anybody interested in composition instead of multiple inheritance, I have posted this recipe on ActiveState (for python 2.6/7, not 3.x): http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multi

Re: Composition instead of inheritance

2011-04-29 Thread Ian Kelly
On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks wrote: > Here is my advice on mixins: > > Mixins should almost always be listed first in the bases.  (The only > exception is to work around a technicality.  Otherwise mixins go first.) > > If a mixin defines __init__, it should always accept self, *arg

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
Carl Banks wrote: Here is my advice on mixins: [snip] Cool. Thanks! ~Ethan -- http://mail.python.org/mailman/listinfo/python-list

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Thursday, April 28, 2011 6:43:35 PM UTC-7, Ethan Furman wrote: > Carl Banks wrote: > > The sorts of class that this decorator will work for are probably not > > the ones that are going to have problems cooperating in the first place. > > So you might as well just use inheritance; that way peop

Re: Deditor

2011-04-29 Thread Kruptein
On 29 apr, 20:25, jmfauth wrote: > On 28 avr, 22:16, Kruptein wrote: > > > > > > > On 28 apr, 07:46, jmfauth wrote: > > > > On 27 avr, 19:22, Alec Taylor wrote: > > > > > Thanks, any plans for a Windows version? > > > > - Download the deb > > > - Unpack it with a utility like 7zip > > > - Throw

Re: Composition instead of inheritance

2011-04-29 Thread Ethan Furman
James Mills wrote: On Fri, Apr 29, 2011 at 11:43 AM, Ethan Furman wrote: Hmmm. Okay -- any ideas for a better term? Something that describes taking different source classes and fusing them into a new whole, possibly using single-inheritance... Frankenstein, maybe? ;) I'd have to say that th

Re: windows 7 x64 shutdown

2011-04-29 Thread Brian Curtin
On Mon, Apr 25, 2011 at 16:15, rjmccorkle wrote: > does anyone know a solution to shutting down windows 7 x64 via python > script? the win32 obviously doesn't work... something similar? > > "the win32 obviously doesn't work" -- It does. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python wide-python-build unicode for Windows

2011-04-29 Thread Terry Reedy
On 4/29/2011 7:52 AM, sathe...@e-ndicus.com wrote: How could i increase the unicode range beyond 1 ? Use Python3, which, after renaming unichar to chr, changed it to always accept the full range of codepoints, even when that means returning a two-char string on narrow builds, like window

Re: Python wide-python-build unicode for Windows

2011-04-29 Thread Martin v. Loewis
> But how could i do this in Windows. It's not supported. Hopefully, it will be supported in Python 3.3, due to PEP 393. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Development tools and practices for Pythonistas

2011-04-29 Thread Hans Georg Schaathun
On Wed, 27 Apr 2011 14:24:30 +0200, Jean-Michel Pichavant wrote: : I was talking about merge *issue* i.e merge resulting in conflicts that : are not easy to solve. With a single user most of the merge will be : solved automatically by any decent VCS. Exactly, and with svn that can be a tru

Re: [OT] VCS tools

2011-04-29 Thread Martin Schöön
On 2011-04-28, Ben Finney wrote: > Martin Schöön writes: > >> This has been a pretty informative thread so far. Please keep it coming. >> I am a hardware development guy and do very little software development. >> I have been vaguely aware of tools for version control but inspired by >> this thre

Re: Deditor

2011-04-29 Thread jmfauth
On 28 avr, 22:16, Kruptein wrote: > On 28 apr, 07:46, jmfauth wrote: > > > > > On 27 avr, 19:22, Alec Taylor wrote: > > > > Thanks, any plans for a Windows version? > > > - Download the deb > > - Unpack it with a utility like 7zip > > - Throw away the unnecessary stuff, (keep the "deditor part")

Re: [OT] From svn to something else?

2011-04-29 Thread Tim Chase
On 04/29/2011 12:01 PM, Hans Georg Schaathun wrote: wrote: : I'd say that one of the things SVN has going for it is that it's : the lingua-franca of VCSes, so just about everything (especially : the 3 big names mentioned in this thread: hg, bzr, git) can talk : to svn pretty uneventfully

Re: [OT] Comparing VCS tools (was ""Development tools and practices for Pythonistas")

2011-04-29 Thread Daniel Kluev
We were looking for some simple integrated SCM, issue tracker and wiki in our university for software design and software testing courses, and fossil seems to be perfect match, thanks for sharing. -- With best regards, Daniel Kluev -- http://mail.python.org/mailman/listinfo/python-list

Thank You Re: use of index (beginner's question)

2011-04-29 Thread Rusty Scalf
An overdue Thank You to everyone who responded. I got well more than I bargained for, including needed reinforcement (beyond the beginner's guides) of how Python actually works and some good programming habits. I am grateful. I liked Steven D'Aprano comment: Define "does not work". Wha

Re: Deditor

2011-04-29 Thread Alec Taylor
I'll create an installer or two (an NSIS or InnoSetup .exe and an MSI) if you like, once you've released the windows version. On Fri, Apr 29, 2011 at 6:16 AM, Kruptein wrote: > On 28 apr, 07:46, jmfauth wrote: >> On 27 avr, 19:22, Alec Taylor wrote: >> >> > Thanks, any plans for a Windows versi

Re: [OT] From svn to something else?

2011-04-29 Thread Hans Georg Schaathun
On Fri, 29 Apr 2011 06:50:52 -0500, Tim Chase wrote: : I'd say that one of the things SVN has going for it is that it's : the lingua-franca of VCSes, so just about everything (especially : the 3 big names mentioned in this thread: hg, bzr, git) can talk : to svn pretty uneventfully. As a

Re: Read-write lock for Python

2011-04-29 Thread Geoff Bache
On Fri, Apr 29, 2011 at 12:38 AM, Ryan Kelly wrote: > On Thu, 2011-04-28 at 07:02 -0700, Geoff Bache wrote: >> Hi all, >> >> I currently find myself needing a Python read-write lock. I note that >> there is none in the standard library, but googling "python read-write >> lock" quickly produced 6 d

Re: [OT] Comparing VCS tools (was ""Development tools and practices for Pythonistas")

2011-04-29 Thread Kevin Walzer
Fossil is another SCM to consider: http://www.fossil-scm.org/ It's written by the author of SQLite, D. Richard Hipp. It's not as well-known as some of the other DCVS's, but the Tcl/Tk language projects have moved their core development to it (http://core.tcl.tk). This is relevant to Python bec

Re: [OT] From svn to something else?

2011-04-29 Thread D'Arcy J.M. Cain
On Fri, 29 Apr 2011 22:53:47 +1000 Ben Finney wrote: > Bazaar's support for Subversion repositories is great (it requires the > ‘bzr-svn’ plug-in, of course). Use the ‘svn-import’ subcommand to import > an entire Subversion repository to a Bazaar repository with all branches > and history intact.

Re: [OT] From svn to something else?

2011-04-29 Thread Ben Finney
Hans Georg Schaathun writes: > How easy and reliable is it to import my svn version history into > one of the three big DVCS-s mentioned here? Bazaar's support for Subversion repositories is great (it requires the ‘bzr-svn’ plug-in, of course). Use the ‘svn-import’ subcommand to import an entire

Re: Active Directory user creation with python-ldap

2011-04-29 Thread Michael Ströder
Nello wrote: > I need to create an Active Directory user using python-ldap library. So, I > authenticate with an admin account and I use "add_s" to create the user. This is possible. Which version of AD are you working with. > Anyway, by default users are disabled on creation, That's the correct

Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Adam Tauno Williams
On Fri, 2011-04-29 at 13:24 +0200, Paul Kölle wrote: > Am 29.04.2011 12:01, schrieb Adam Tauno Williams: > >> 3. The web based application will be used internally in the network to > >> moniter servers in that network only. > > You mean like OpenNMS or ZenOSS? > >> 4. Web based application will be

Python wide-python-build unicode for Windows

2011-04-29 Thread satheesh
Hi All, How could i increase the unicode range beyond 1 ? In python 2.5.4 by default the unicode range is 0x1, but in some cases i have unicode char beyond the limit. For those conditions it th an error. """File "E:\OpenERP\OpenERP AllInOne\Server\library.zip\reportlab\pdfbase\ttfonts.py

Re: [OT] From svn to something else?

2011-04-29 Thread Tim Chase
On 04/29/2011 05:07 AM, Hans Georg Schaathun wrote: How easy and reliable is it to import my svn version history into one of the three big DVCS-s mentioned here? I'd say that one of the things SVN has going for it is that it's the lingua-franca of VCSes, so just about everything (especially t

Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Paul Kölle
Hi, Am 29.04.2011 12:01, schrieb Adam Tauno Williams: On Thu, 2011-04-28 at 23:47 -0700, Anurag (anu) Agarwal wrote: Hi All, I want to build an application for one of my client which has following features 1. Client has some driver software which can be installed on Windows and Linux based syst

Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Adam Tauno Williams
On Thu, 2011-04-28 at 23:47 -0700, Anurag (anu) Agarwal wrote: > Hi All, > I want to build an application for one of my client which has > following features > 1. Client has some driver software which can be installed on Windows > and Linux based systems. This driver software is fetching some > ope

Re: [OT] From svn to something else? (was: VCS tools)

2011-04-29 Thread Hans Georg Schaathun
Hmmm. I am still using svn. How easy and reliable is it to import my svn version history into one of the three big DVCS-s mentioned here? I am fairly happy with svn, but then I use it more as a backup system and a means to synchronise multiple systems. Something better would not hurt, but lo

Re: Composition instead of inheritance

2011-04-29 Thread Jean-Michel Pichavant
Ben Finney wrote: Ethan Furman writes: Carl Banks wrote: That's not what we mean by composition. Composition is when one object calls upon another object that it owns to implement some of its behavior. Often used to model a part/whole relationship, hence the name. Hmmm. Okay -

Re: unpickling derived LogRecord in python 2.7 from python2.6

2011-04-29 Thread ivdn...@gmail.com
On Apr 28, 9:22 am, Peter Otten <__pete...@web.de> wrote: > Vinay Sajip wrote: > > On Apr 27, 5:41 pm, Peter Otten <__pete...@web.de> wrote: > > >> The Problem is that as of Python 2.7logging.LogRecord has become a > >> newstyle class which is pickled/unpickled differently. I don't know if > >> the