Re: [Tutor] class decorator question

2013-10-05 Thread Steven D'Aprano
On Sun, Oct 06, 2013 at 01:06:18AM +0100, Alan Gauld wrote: > On 05/10/13 20:26, Albert-Jan Roskam wrote: > > >General question: I am using pastebin now. Is that okay, > > For code as short as this it's probably best kept with the message. > But once you get to 100+ lines its more debatable and i

Re: [Tutor] class decorator question

2013-10-05 Thread Steven D'Aprano
On Sat, Oct 05, 2013 at 12:26:14PM -0700, Albert-Jan Roskam wrote: > >> On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw > >> a very cool and useful example of a class decorator. It (re)implements > >> __str__ and __unicode__ in case Python 2 is used. For Python 3, the > >>

Re: [Tutor] how to generate random numbers in Python

2013-10-05 Thread Bhanu Pratap Singh
/* Generating random number */ from random import randint print(randint(0,5)) >>> # anyone from 0 to 5 For generating only 0 or 1 print(randint(0,1)) >>> 0 or 1 Best, Bhanu Pratap www.bhanubais.com -Original Message- From: Tutor [mailto:tutor-bounces+bha

Re: [Tutor] class decorator question

2013-10-05 Thread Alan Gauld
On 05/10/13 20:26, Albert-Jan Roskam wrote: General question: I am using pastebin now. Is that okay, For code as short as this it's probably best kept with the message. But once you get to 100+ lines its more debatable and if you get to 200+ lines I'd definitely say a pastebin is better. fro

Re: [Tutor] class decorator question

2013-10-05 Thread Albert-Jan Roskam
___ > From: Steven D'Aprano >To: tutor@python.org >Sent: Saturday, October 5, 2013 3:14 PM >Subject: Re: [Tutor] class decorator question > >On Sat, Oct 05, 2013 at 05:33:46AM -0700, Albert-Jan Roskam wrote: >> Hi, >> >> On http://lucumr.pocoo.org/2013/5/21/porting-t

Re: [Tutor] writing python on the web

2013-10-05 Thread roberto
Thank you guys, I'll take a look at what you suggested! Have a nice day. On Friday, October 4, 2013, Walter Prins wrote: > Hello, > > Just thought I'd mention the following which I came across today which may > fit your purposes as well: https://koding.com > > Reg

Re: [Tutor] class decorator question

2013-10-05 Thread Steven D'Aprano
On Sat, Oct 05, 2013 at 05:33:46AM -0700, Albert-Jan Roskam wrote: > Hi, > > On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw > a very cool and useful example of a class decorator. It (re)implements > __str__ and __unicode__ in case Python 2 is used. For Python 3, the > dec

[Tutor] class decorator question

2013-10-05 Thread Albert-Jan Roskam
Hi, On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw a very cool and useful example of a class decorator. It (re)implements __str__ and __unicode__ in case Python 2 is used. For Python 3, the decorator does nothing. I wanted to generalize this decorator so the __str__ metho