Did not work

Mike Fletcher mfletch at tpresence.com
Fri Aug 18 18:24:05 EDT 2000


The line I gave you included some sample text which was being scanned.  You
needed to indicate the text you wanted scanned as the last argument:
	blah = re.sub( '\(([0-9]+) downto ([0-9]+)\)',r'[\1:\2]', blah)

> What do the sdfsdf do?
(It was sample text including the pattern being searched for to test the
substitution).

The last argument to sub is the string in which substitutions are to be
made.  Also note, you've got a lot of wordy code in that sample:

	p = re.compile('--.*')
	blah= p.sub('', blah)

Can be written as:
	blah = re.sub( '--.*', '', blah )

Since you don't actually store the results of re.compile, there's no real
benefit to using the wordier form.

You could also write the whole set of substitutions as:
	for pattern, replacement in ( ( "--.*", ""), ('^use.*', ""),
('\'include', "end.*"), <insert the rest of the patterns here>, ):
		blah = re.sub(pattern, replacement, blah )

HTH (I'm copy the Python List so others can get the clarification as well),
Mike

-----Original Message-----
From: Salman Sheikh [mailto:salman at vlsi9.gsfc.nasa.gov]
Sent: Friday, August 18, 2000 5:02 PM
To: mfletch at tpresence.com
Subject: Did not work


See the attached :

Run as follows:

./vhd2vlog.py frontend

this will generate a file called frontend.v

as you will see it looks like garbage.

What do the sdfsdf do?


Salman

*************************************************
* Salman Sheikh					*
* Microelectronics and Signal Processing Branch	*
* NASA/GSFC					*
* Code 564					*
* Greenbelt, MD 20771				*
* 301-286-3763 					*
* 301-286-0220 (fax)				*
*************************************************




More information about the Python-list mailing list