Dear Guru, I have added def and it doesnt work Sincerly, F

Gerhard Häring gerhard at bigfoot.de
Thu Mar 14 21:58:50 EST 2002


Oscar wrote in comp.lang.python:
> I have added 
> 
> def joinsplit = (join(split(lines, '"'), ' '))
>         return joinsplit

This is no valid Python, so you're getting syntax errors.

> to watch.txt in an effort to replace " and / with " " to no avail. Old
> watch.txt works fine, without my new def.

A function to replace " and / with spaces would look like this (Python
1.5 compatible):

def replace_them(s):
    import string
    return string.replace(string.replace(s, '/', ' '), '"', ' ')

> [...]
> 
>         formatted = str(list[0]) + str(list[1]) + fixdate(list[2]) +
> joinsplit.fixnumeric(list[3],10) + joinsplit.fixnumeric(list[4],10)
  ^^^^^^^^^

Apparently, the original joinsplit is a module and not a function.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))



More information about the Python-list mailing list