beginner whitespace question

Dan Bishop danb_83 at yahoo.com
Thu Aug 9 23:25:19 EDT 2007


On Aug 9, 8:28 pm, James Stroud <jstr... at mbi.ucla.edu> wrote:
> eggie5 wrote:
> > But this still isn't valid:
>
> > from django.db import models
>
> > class Poll(models.Model):
> >    question = models.CharField(max_length=200)
> >    pub_date = models.DateTimeField('date published')
>
> >     def __unicode__(self):
> >            return self.question
>
> > class Choice(models.Model):
> >     poll = models.ForeignKey(Poll)
> >     choice = models.CharField(max_length=200)
> >     votes = models.IntegerField()
>
> >     def __unicode__(self):
> >            return self.choice
>
> You want this:
>
> from django.db import models
>
> class Poll(models.Model):
>         question = models.CharField(max_length=200)
>         pub_date = models.DateTimeField('date published')
>
>         def __unicode__(self):
>                 return self.question
>
> class Choice(models.Model):
>      poll = models.ForeignKey(Poll)
>      choice = models.CharField(max_length=200)
>      votes = models.IntegerField()
>
>      def __unicode__(self):
>         return self.choice
>
> But this mixes tabs and spaces.
>
> Rules:
>
> 1. Don't use tabs!
> 2. If you are clueless enough to violate (1), then don't mix tabs and
> spaces.
> 3. Don't use tabs!
>
> Tabs are for tables, hence the name. "Use spaces for space and use tabs
> for tables" can be a little mnemonic to help you remember the rules. We
> can make a little song together if you can think of some things that
> rhyme with "don't" and "use" and "tabs".

"won't"

"blues", "booze", "bruise", "choose", "cruise", "fuse", "hues",
"Jews", "lose", "muse", "news", "snooze", "views", etc.

"abs", "cabs", "crabs", "dabs", "grabs", "labs", "scabs", "slabs",
"stabs", etc.




More information about the Python-list mailing list