Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74434 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2014-07-14 16:01 -0400 |
| Last post | 2014-07-14 16:01 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: python-aware wdiff? Terry Reedy <tjreedy@udel.edu> - 2014-07-14 16:01 -0400
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-07-14 16:01 -0400 |
| Subject | Re: python-aware wdiff? |
| Message-ID | <mailman.11807.1405368158.18130.python-list@python.org> |
On 7/14/2014 11:12 AM, Roy Smith wrote:
> Does anybody know of a wdiff-like tool
> (http://www.gnu.org/software/wdiff/) which is aware of python syntax and
> can show token changes instead of word changes. Wdiff is can turn
>
> - if not metar.is
> <http://metar.is>_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
> + if not info.is
> <http://info.is>_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
>
> into
>
> if not
> [-metar.is_in_temp_range_f(situation.weather.low_temperature,-]
> {+info.is_in_temp_range_f(situation.weather.low_temperature,+}
> situation.weather.high_temperature):
>
> but what I really want is:
>
> if not
> [-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
>
> which makes it more obvious that the change is just the one token. Does
> such a tool exist?
The under-known difflib.differ shows within line differences.
Your example would look like:
- if not metar.is_in_temp_range_f(...):
? ^^^^^
+ if not info.is_in_temp_range_f
? ^^^^
Deletions and insertions are indicated with '-' and '+'.
I use this routinely, when backporting patches, in a script that differs
the 2.7 and 3.4 versions of repository files.
--
Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web