beginner whitespace question

2007-08-09 Thread eggie5
I keep getting an error for line 7, what's wrong with 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

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()

def __unicode__(self):
return self.choice

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


Re: beginner whitespace question

2007-08-09 Thread eggie5
On Aug 9, 4:52 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
> On Aug 9, 6:47 pm, eggie5 <[EMAIL PROTECTED]> wrote:
>
> > I keep getting an error for line 7, what's wrong with 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
>
> The "def" statements have to be at the same indentation level as
> what's before it.

will they still be a part of the classes?

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


Re: beginner whitespace question

2007-08-09 Thread eggie5
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


On Aug 9, 5:52 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
> On Aug 9, 7:02 pm, eggie5 <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 9, 4:52 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
>
> > > On Aug 9, 6:47 pm, eggie5 <[EMAIL PROTECTED]> wrote:
>
> > > > I keep getting an error for line 7, what's wrong with 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
>
> > > The "def" statements have to be at the same indentation level as
> > > what's before it.
>
> > will they still be a part of the classes?
>
> If you indent them twice, it's a syntax error.
> If you indent them once, they'll be methods of the class.
> If you don't indent them at all, they'll be global functions.


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


Re: beginner whitespace question

2007-08-09 Thread eggie5
On Aug 9, 6:31 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> James Stroud wrote:
> > def __unicode__(self):
That's so goofy.

> > return self.choice


>
> Laughing to hard at the tab & spaces thing to notice the lack of
> indentation here.
>
> James
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
>
> http://www.jamesstroud.com/


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


Re: beginner whitespace question

2007-08-10 Thread eggie5
On Aug 9, 10:37 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Dan Bishop wrote:
> >> 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.
>
> When you want to screw your whitespace--don't!
> Take this little pledge and I know you won't:
>
> When I was in school I would take of booze
> While my typing teacher said I'm free to use
> Space or formfeed or even tabs
> And I punched so hard with my pinkie that scabs
> Covered my Jake and Elwood tatoos.
> (You didn't see that one coming did yous?)

I'm so confused, I have no idea what's going on...

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