newbie problem with str.replace

BobAalsma bob.aalsma at aalsmacons.nl
Wed Aug 4 09:10:09 EDT 2010


I'm working on a set of scripts and I can't get a replace to work in
the script - please help.

The scripts show no errors, work properly apart from the replace, all
variables are filled as expected, the scripts works properly when the
commands are copied to the Python shell.

Text Main:
..
from LeadDevice_klant_nieuw_bewerken_bestanden import omkattenBoom,
omkattenNaam
...
#
# (3) omkatten bestandsnamen:
#
print 'Omkatten bestandsnamen'
omkattenNaam(AANGRIJPINGSPUNT, KLANTNAAM_OUT, KLANTNAAM_IN,
ZOEKSET1_OUT, ZOEKSET1_IN, ZOEKSET2_OUT, ZOEKSET2_IN)
#
....


Text LeadDevice_klant_nieuw_bewerken_bestanden:
import os
import distutils.core

...

def omkattenNaam(AANGRIJPINGSPUNT, KLANTNAAM_OUT, KLANTNAAM_IN,
ZOEKSET1_OUT, ZOEKSET1_IN, ZOEKSET2_OUT, ZOEKSET2_IN):
	#
	# Strings opbouwen voordat aan de lussen gewerkt wordt:
	#
	beginpunt = AANGRIJPINGSPUNT + KLANTNAAM_IN + '/'
	#
	ZOEKSET1_OUT_LOWER = ZOEKSET1_OUT.lower()
	ZOEKSET1_IN_LOWER = ZOEKSET1_IN.lower()
	ZOEKSET2_OUT_LOWER = ZOEKSET2_OUT.lower()
	ZOEKSET2_IN_LOWER = ZOEKSET2_IN.lower()
	#
	# Lussen:
	#
	for root, dirs, files in os.walk(beginpunt, topdown = False):
		for bestandsnaam in dirs and files:
			#
			bestandsnaam_nieuw = bestandsnaam
			bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN)



More information about the Python-list mailing list