Inheritance in nested classes

2005-11-15 Thread Martin Skou
I'm experimenting with using Python for a small web interface, using
Mark Hammond's nice win32 extensions.

I use a small class hierarchy which uses inheritance and nested classes.

Here are a small extract of the code:

class page:

def __init__(self):
self.head=[]

def __str__(self):
...

class simple_tag:
... 

class p(simple_tag):
...

class table:
...

class row:
...

class data:
...
...


Will this type of code perform noticable slower than unnested classes?

I'm using the Active Server Pages integration in the win32 extensions,
does anyone have good/bad experiences using this interface?

Thanks.

/Martin

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


Re: Encoding problem with web application (Paste+Mako)

2007-06-06 Thread Martin Skou
Rob Wolfe wrote:
> 
> You have to know the encoding of user input and then you
> can use ``input_encoding`` and ``output_encoding`` parameters
> of ``Template``. Mako internally handles everything as Python unicode
> objects.
> For example:
> 
> t = Template(filename="templ.mako", input_encoding="iso-8859-2",
>  output_encoding="iso-8859-2")
> content = t.render(**context)
> 
> --
> HTH,
> Rob
> 

Thanks Rob

Using:

t=Template(content,input_encoding="utf-8", output_encoding="utf-8")

did the trick. Thanks for the help.

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


Re: Internationalised email subjects

2007-06-20 Thread Martin Skou
From:
http://docs.python.org/lib/module-email.header.html

 >>> from email.message import Message
 >>> from email.header import Header
 >>> msg = Message()
 >>> h = Header('p\xf6stal', 'iso-8859-1')
 >>> msg['Subject'] = h
 >>> print msg.as_string()
Subject: =?iso-8859-1?q?p=F6stal?=

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


Re: python website

2007-06-20 Thread Martin Skou
The Daily Python-URL
http://www.pythonware.com/daily/

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


Re: text-mode tree viewer?

2007-06-26 Thread Martin Skou
Not quite, but almost:


data=[["Peter",
["Ian",
   [["Randy",
  ["Clara"],
   "Paul",
  ["Mary",
["Arthur"]]]


def show(data,level):
for i in data:
if i.__class__.__name__=='list':
show(i,level+1)
else:
print '%s->%s' % ('-'*level,i)


show(data,0)


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


Re: text-mode tree viewer?

2007-06-26 Thread Martin Skou
Torsten Bronger wrote:
> 
> It doesn't show Paul and Mary on the same level.  I (think I) solved
> the problem with this:
> 

I could do so if Poul was in a list of his own, like "Arthur" and "Clara".

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


Re: Executing other python code

2008-01-29 Thread Martin Skou
Over-simplified yes, but it will work!

Python is beautiful :-)
-- 
http://mail.python.org/mailman/listinfo/python-list