Re: coercing to Unicode: need string or buffer, NoneType found

2006-07-27 Thread blue99

Jon Bowlas wrote:

> Here's my script:
>
> results = context.module_retriever().tuples() # call to ZSQLMethod
> converted = []
> for result in results:
>result = list(result) # make a list from the tuple
>for i in range(len(result)):
> # for each element in the listified tuple, make decode to a
> # unicode from the latin-1 string

try this:
   if result[i] is None: continue

> result[i] = unicode(result[i], 'latin-1')
>converted.append(tuple(result)) # tuplify again
> return converted

regards,
Rob

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


Re: Detecting key presses

2006-06-19 Thread blue99

> Someone suggested using curses, but that does crazy things with my
> output, and leaves the terminal unusable after the program closes.

It's very good suggestion but you should use also initscr
and endwin functions.

Regards,
Rob

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


Re: python equivalent of the following program

2006-05-11 Thread blue99

AndyL wrote:
> Hi,
>
> What would by a python equivalent of following shell program:
>
>   #!/bin/sh
>
>   prog1 > file1 &
>   prog2 > file2 &
>
>
> As you see, I need to spawn a few processes and redirect stdout to some
> files.

For example :

--cut here---
#!/usr/bin/env python

import os

# 1-st variant

os.system("prog1 > tmp1.txt &")

# or 2-nd variant

os.popen("prog1 > tmp2.txt &")
---cut here-

Regards,
Rob

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