Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Heshan Suriyaarachchi
Hi Python 3.0 provides the best solution to my problem with annotations.But for the time being I am able to work with the way Sidharth proposed using decorators. :) Thanx guys Heshan Suriyaarachchi ___ BangPypers mailing list BangPypers@python.org htt

Re: [BangPypers] My book on Python for newbies

2008-04-03 Thread Diabolic Preacher
On Thu, Apr 3, 2008 at 6:53 PM, Kushal Das <[EMAIL PROTECTED]> wrote: > On Thursday 03 April 2008 06:53:18 pm Shameer Khadar wrote: > > Hi Kushal, > > > > This is nice, > > But it is always painful to read a whole book through html links :) > > Can you please put a pdf copy of the current vers

Re: [BangPypers] My book on Python for newbies

2008-04-03 Thread Kushal Das
On Thursday 03 April 2008 06:53:18 pm Shameer Khadar wrote: > Hi Kushal, > > This is nice, > But it is always painful to read a whole book through html links :) > Can you please put a pdf copy of the current version of your book. The toolchain I am using for writing this book is currently little bi

Re: [BangPypers] My book on Python for newbies

2008-04-03 Thread Shameer Khadar
Hi Kushal, This is nice, But it is always painful to read a whole book through html links :) Can you please put a pdf copy of the current version of your book. Cheers, Shameer On Thu, Apr 3, 2008 at 5:31 PM, Kushal Das <[EMAIL PROTECTED]> wrote: > Hi, > I am writing a book on Python for newbies

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Sidharth Kuruvila
Hi, You can simulate annotation using decorators. I might be missing something about annotation but you can do this. def annotate(returns, **params): def decorate(func): params['returns'] = returns func.__annotations__ = params return func return decorate @

[BangPypers] My book on Python for newbies

2008-04-03 Thread Kushal Das
Hi, I am writing a book on Python for newbies. You can see it here http://kushal.fedorapeople.org/book/ I am looking for feedback. Flowers and stones both are welcome Kushal -- Fedora Ambassador, India http://kushaldas.in http://dgplug.org (Linux User Group of Durgapur) _

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Anand Balachandran Pillai
No, I don't think so. Python has the trick of "peeking into the future" by backporting a feature in a future version to the current version by using the __future__ module. However I run Python 2.5 and I do not see any mention of function annotations in __future__ module. Python 2.5.1 (r251:54863,

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Heshan Suriyaarachchi
> > Hi Anand, This is what I exactly mean. This is the thing I want to do. I am now using python 2.5.1 . So is there a way that I can do a thing like this in python 2.5.1 ( an alternative way). Heshan Suriyaarachchi > > > >>> def f(x : "an integer", y: "another integer") -> "Sum of x and

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Anand Balachandran Pillai
I had started a couple of blog posts aiming at discussing the new features, changes and gotchas in Python 3.0. I had made the first couple of posts 2 weeks back. The plan is to try and post as much as possible before Py3k releases in Aug this year. This question has reminded me to restart the post

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Anand Balachandran Pillai
Functions in Python are first-class objects, so you can add arbitrary attributes to them like any other object. Like Siddharth said, you can do, def f(x, y): return x + y f.x = 100 >>>f(20, 30) 50 However as of 2.x Python does not provide any syntax for formal function annotations like Java. Th

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Sidharth Kuruvila
H Heshan, Can you explain why you'd want to do this? You can write def f(): print f.a f.a = 4 f() But I can't see you would want to do something like that. Maybe if you give a use case. Someone can come up with a solution. Regards, Sidharth On Apr 3, 2008, at 2:03 PM, Heshan Suriya

Re: [BangPypers] Expressing meta-data about classes, methods, variables, parameters in python

2008-04-03 Thread Heshan Suriyaarachchi
Hi What I meant was a situation like this. In javascript I'm used to associating metadata with a function as follows. foo.bar = "foobar"; function foo(){ } What is the normal python practice to do this kind of a thing. Your help is very much appreciated. Thanks, Heshan Suriyaarachchi _