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://mail.python.org/mailman/listinfo/python-list


AJAX Calander like Google Calender

2007-03-02 Thread lalit
Hi all,

I would like to make the the calender cery similar to google
event calander in python. can any one help me where
i will get library that uses AJAX is this feasible

reg,
Lalit

-- 
http://mail.python.org/mailman/listinfo/python-list


copying files through Python

2008-02-13 Thread Lalit
I am new to python. Infact started yesterday and feeling out of place.
I need to write a program which would transfer files under one folder
structure (there are sub folders) to single folder. Can anyone give me
some idea like which library files or commands would be suitable for
this file transfer task. I am sure its matter of few commands. It
would be even more great if I could get some sample code with
instructions

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


syntax error in python

2008-02-20 Thread Lalit
Hi
I am executing following commands.
>>> test = os.path.isfile('c:\\src\\kasjdfl.txt')
>>> print test
True
working fine but for below statement it is giving syntax
error.

>>> if (os.path.isfile('c:\\src\\kasjdfl.txt'))
SyntaxError: invalid syntax

any idea what is incorrect in my syntax
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax error in python

2008-02-20 Thread Lalit
On Feb 20, 2:03 pm, Lalit <[EMAIL PROTECTED]> wrote:
> Hi
> I am executing following commands.>>> test = 
> os.path.isfile('c:\\src\\kasjdfl.txt')
> >>> print test
>
> True
> working fine but for below statement it is giving syntax
> error.
>
> >>> if (os.path.isfile('c:\\src\\kasjdfl.txt'))
>
> SyntaxError: invalid syntax
>
> any idea what is incorrect in my syntax

oops got the mistake I was nt ending if with :
sorry and thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


NameError: global name 'Response' is not defined

2008-04-24 Thread Lalit
Hi

I am very new to web development.  I started with Pylons. I am using
http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to
create a sample web page using pylons.

I got stuck up at step 4.3 i.e when modifying controller to "return
Response('firstapp default')"

I am getting error of : global name
'Response' is not defined

It seems I am missing some package. I am not really sure. I installed
python 2.5 and through easy_install imported pakages (pylons).

Any clues would be appreciated

Thanks
Lalit
--
http://mail.python.org/mailman/listinfo/python-list


Re: copying files through Python

2008-02-16 Thread Lalit Krishna
Hi this is the code which I wrote till now. It is giving permission 
denied error for sub folders of source directory. Does anyone have any 
idea what is going wrong

import os
import shutil
def copytreetosinglefolder(src, dst):
names = os.listdir(src)
if (os.path.isdir(dst)==False):
os.mkdir(dst)
for name in names:
srcname = os.path.join(src, name)
try:
shutil.copy2(srcname, dst)
except (IOError, os.error), why:
print "Can't copy %s to %s: %s" % (`srcname`, `dst`, str(why))

copytreetosinglefolder('c:\\src','d:\\dest')

Tim Chase wrote:
>> I am new to python. Infact started yesterday and feeling out of place.
>> I need to write a program which would transfer files under one folder
>> structure (there are sub folders) to single folder. Can anyone give me
>> some idea like which library files or commands would be suitable for
>> this file transfer task. I am sure its matter of few commands. It
>> would be even more great if I could get some sample code with
>
> The shutils.copytree() command[1] will do what you describe
>
> Depending on your source, and if you want to make the dest writeable 
> (such as copying off a CD), you may also need to use os.walk() [2] 
> combined with os.chmod(filepath, stat.S_IWRITE) [3]
>
> -tkc
>
> [1]
> http://docs.python.org/lib/module-shutil.html#l2h-2297
>
> [2]
> http://docs.python.org/lib/os-file-dir.html#l2h-2707
>
> [3]
> http://docs.python.org/lib/os-file-dir.html#l2h-2677
-- 
http://mail.python.org/mailman/listinfo/python-list