Re: a strange SyntaxError

2007-12-10 Thread Peter Otten
John Machin wrote:

> As viewed with Google Groups, lines 40/41, 63/69, and 89 are indented 8
> spaces more than they should be.
> 
> When I save your file and try to run it, I get this: C:\junk>coolgenie.py
>   File "C:\junk\coolgenie.py", line 40
> self.w = 520
> ^
> IndentationError: unexpected indent
> 
> Possibilities:
> (1) Your file contains junk like tabs or no-break spaces. Use a text
> editor that will not mask what is really there to find the junk and edit
> it out.

As a first step towards sanity, make sure that your current editor is
configured to use a tabwidth of 8 spaces (it is probably set to 4
at the moment). You should then be able to at least see the offending
lines.

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


Re: a strange SyntaxError

2007-12-10 Thread Vladimir Rusinov
>   self.numlines = self.config['numlines']
>
>   self.w = 520
>   self.h = 12*self.numfeeds*(self.numlines+1)

why extra ident here?

-- 
Vladimir Rusinov
GreenMice Solutions: IT-решения на базе Linux
http://greenmice.info/
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: a strange SyntaxError

2007-12-09 Thread Steve Howell

--- CoolGenie <[EMAIL PROTECTED]> wrote:

> OK, sorry, this was about indents. Stupid VIM!

One more piece of VIM advice.  You can use "set list"
to show where tabs are.  I prefer to convert my own
tabs to spaces automatically, but you inevitably come
across code that you don't own where it's nice to see
the tabs.


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a strange SyntaxError

2007-12-09 Thread Steve Howell

--- CoolGenie <[EMAIL PROTECTED]> wrote:

> OK, sorry, this was about indents. Stupid VIM!

No prob.  Add something like this (untested) to your
~/.vimrc:

set expandtab
set sw=4
set ts=4






  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a strange SyntaxError

2007-12-09 Thread Samuel
On Sun, 09 Dec 2007 12:35:46 -0800, CoolGenie wrote:

> OK, sorry, this was about indents. Stupid VIM!

$ mkdir -p $HOME/.vim/ftplugin/

$ echo "setlocal sw=4
setlocal ts=4
noremap  py o/**/
" >> ~/.vim/ftplugin/python.vim

$ echo "syntax on
set sw=2
set ts=2
set nu
set nuw=3
set autoindent
set expandtab" >> $HOME/.vimrc
--- 

Problem solved, never to be found again.

Bye,
-Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a strange SyntaxError

2007-12-09 Thread Steve Howell

--- CoolGenie <[EMAIL PROTECTED]> wrote:
> self.feed = self.config['feedsrc']
> self.numfeeds = self.config['numfeeds']
> self.numlines = self.config['numlines']
> 
>   self.w = 520
>   self.h = 12*self.numfeeds*(self.numlines+1)
> adesklets.window_resize(self.w, self.h)
>
> Unfortunately, I'm getting this bug for some time
> now and I just don't
> know what's going on:
> 
>   File "./fparser.py", line 40
> self.w = 520
> ^
> SyntaxError: invalid syntax
> 

Indentation.  See above how the code arrived to me.  I
recommend configuring your editor to convert tabs to
spaces.



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a strange SyntaxError

2007-12-09 Thread John Machin
On Dec 10, 7:15 am, CoolGenie <[EMAIL PROTECTED]> wrote:
> Hi!
> I'm trying to write a small adesklet that will read newsfeeds. Here's
> the code:
>
> #
> #
> # fparser.py
> #
> # P. Kaminski <[EMAIL PROTECTED]>
> # Time-stamp: <>
> ##
> import feedparser
> import adesklets
> from os import getenv, spawnlp, P_NOWAIT
> from os.path import join, dirname
>
> class Config(adesklets.ConfigFile):
> cfg_default = { 'feedsrc' : 'http://slashdot.org/index.rss',
> 'numfeeds' : 5,
> 'numlines' : 4
> }
>
> def __init__(self, id, filename):
> adesklets.ConfigFile.__init__(self, id, filename)
>
> class Events(adesklets.Events_handler):
> def __init__(self, basedir):
> if len(basedir)==0:
> self.basedir='.'
> else:
> self.basedir=basedir
> adesklets.Events_handler.__init__(self)
>
> def __del__(self):
> adesklets.Events_handler.__del__(self)
>
> def ready(self):
> self.config = Config(adesklets.get_id(),
>  join(self.basedir, 'config.txt'))
> self.feed = self.config['feedsrc']
> self.numfeeds = self.config['numfeeds']
> self.numlines = self.config['numlines']
>
> self.w = 520
> self.h = 12*self.numfeeds*(self.numlines+1)
> adesklets.window_resize(self.w, self.h)
> adesklets.window_reset(adesklets.WINDOW_UNMANAGED)
> adesklets.window_set_transparency(True)
> adesklets.window_show()
>
> def quit(self):
> print 'Quitting...'
>
> def alarm(self):
> print 'Alarm. Next in 360 seconds.'
> self._display()
> return 360
>
> def _display(self):
> print "Getting feed..."
> y = 0
> x = 0
> d = feedparser.parse(self.feed)
> print d.channel.title
> print d.channel.description
>
> # clear the buffer
> buffer = adesklets.create_image(self.w, self.h)
> adesklets.context_set_image(buffer)
> adesklets.context_set_blend(False)
> adesklets.context_set_color(0,0,0,0)
> adesklets.image_fill_rectangle(0,0,self.w,self.h)
> adesklets.context_set_blend(True)
>
> adesklets.context_set_font(adesklets.load_font('Vera/7'))
> adesklets.context_set_color(255, 0, 0, 255)
> adesklets.text_draw(0, y, str(d.channel.title))
> y+=12
> l = len(d.entries)
> l = min(l, self.numfeeds)
> for i in range(l):
> ent=d.entries[i]
> adesklets.context_set_color(255, 255, 0, 255)
> adesklets.text_draw(0, y, str(ent.title))
> print ent.title
> y+=12
> adesklets.context_set_color(255, 255, 255, 255)
> for k in range(0, min(len(ent.summary)/100,
> self.numlines)):
> print str(ent.summary)[k*100:(k+1)*100]
> adesklets.text_draw(0, y, str(ent.summary)[k*100:(k
> +1)*100])
> y+=12
> adesklets.free_font(0)
> adesklets.free_image(buffer)
>
> Events(dirname(__file__)).pause()
>
> Unfortunately, I'm getting this bug for some time now and I just don't
> know what's going on:
>
>   File "./fparser.py", line 40
> self.w = 520
> ^
> SyntaxError: invalid syntax
>

As viewed with Google Groups, lines 40/41, 63/69, and 89 are indented
8 spaces more than they should be.

When I save your file and try to run it, I get this:
C:\junk>coolgenie.py
  File "C:\junk\coolgenie.py", line 40
self.w = 520
^
IndentationError: unexpected indent

Possibilities:
(1) Your file contains junk like tabs or no-break spaces. Use a text
editor that will not mask what is really there to find the junk and
edit it out.
(2) You don't understand that:
if some_condition:
blah1
blah2
blah3
is not valid. Blah2 has to be at the same level as blah1 and blah3.

HTH,
John
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a strange SyntaxError

2007-12-09 Thread CoolGenie
OK, sorry, this was about indents. Stupid VIM!
-- 
http://mail.python.org/mailman/listinfo/python-list