Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49018

Re: Python development tools

Date 2013-06-23 19:54 -0500
From Tim Chase <python.list@thechases.com>
Subject Re: Python development tools
References <93adcb76-2298-41bb-b5cb-cca525c6be21@googlegroups.com> <263da442-0c87-41df-9118-6003c616895c@googlegroups.com> <roy-B8B968.19494723062013@70-1-84-166.pools.spcsdns.net> <ba5cbbcc-ff44-467d-91b6-108573da5dda@googlegroups.com> <roy-356A0C.20222123062013@70-1-84-166.pools.spcsdns.net>
Newsgroups comp.lang.python
Message-ID <mailman.3736.1372035170.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 2013-06-23 20:22, Roy Smith wrote:
> In article <ba5cbbcc-ff44-467d-91b6-108573da5dda@googlegroups.com>,
>  rurpy@yahoo.com wrote:
>> Other things like finding all uses of various objects/functions
>> etc would also be useful now and then but I suppose that is a 
>> common IDE capability?
> 
> $ find . -name '*.py' | xargs grep my_function_name
> 
> seems to work for me.  I suppose a language-aware grep would be
> even better, because then it wouldn't find my_function_name when
> it's embedded in docstrings, comments, and the like.
> 
> On the other hand, you probably want to find those too.

Most good editors (and IDEs?) should handle this as well.  I can
speak for Vim where I could do something like[1]

  sh$ vim *.py
  :set hidden
  :argdo %s/\<my_function_name\>/new_func_name/gc

then evaluate the results, optionally issuing ":wall" to write all the
changes.

Alternatively, if you just want to find all the pattern-matches and
view them, you can use

  :vimgrep /\<my_function_name\>/ **/*.py

and then navigate them either using the quick-fix window:

  :copen

or go forward/backwards in the quick-fix list with[2]

  :cnext
  :cprevious

I'd wager money that Emacs allows you to do something similar, but
I'd have to let an Emacs-user step in to answer that.  YMMV with
other editors.  Is this a "refactoring" tool, or just a valuable
tool, regardless of how it's used for refactoring :-)

-tkc


[1]
The ":set hidden" tells Vim that it's okay to leave a buffer without
writing it, but still remember the changes made.  Many folks have
this in their vimrc configuration.  If you know you want to do it
everywhere, you can avoid the "c" flag to ask for confirmation.

[2]
These can be abbreviated as just ":cn" and ":cp"






.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python development tools cutems93 <ms2597@cornell.edu> - 2013-06-23 13:40 -0700
  Re: Python development tools Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-23 22:19 +0000
  Re: Python development tools rurpy@yahoo.com - 2013-06-23 16:18 -0700
    Re: Python development tools Roy Smith <roy@panix.com> - 2013-06-23 19:49 -0400
      Re: Python development tools rurpy@yahoo.com - 2013-06-23 17:16 -0700
        Re: Python development tools Roy Smith <roy@panix.com> - 2013-06-23 20:22 -0400
          Re: Python development tools Tim Chase <python.list@thechases.com> - 2013-06-23 19:54 -0500
            Re: Python development tools Roy Smith <roy@panix.com> - 2013-06-23 21:16 -0400
        Re: Python development tools CM <cmpython@gmail.com> - 2013-06-23 17:41 -0700
    Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-23 20:17 -0700
  Re: Python development tools Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-24 00:28 +0000
    Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-23 20:13 -0700
  Re: Python development tools Michael Torrie <torriem@gmail.com> - 2013-06-23 19:41 -0600
  Re: Python development tools CM <cmpython@gmail.com> - 2013-06-23 22:19 -0700
  Re: Python development tools cutems93 <ms2597@cornell.edu> - 2013-06-23 22:34 -0700
    Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-23 23:13 -0700
      Re: Python development tools Ben Finney <ben+python@benfinney.id.au> - 2013-06-24 16:20 +1000
        Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-23 23:36 -0700
          Re: Python development tools Ben Finney <ben+python@benfinney.id.au> - 2013-06-25 09:11 +1000
            Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-24 19:24 -0700
              Re: Python development tools MRAB <python@mrabarnett.plus.com> - 2013-06-25 03:39 +0100
                Re: Python development tools rusi <rustompmody@gmail.com> - 2013-06-24 20:03 -0700
                Re: Python development tools Grant Edwards <invalid@invalid.invalid> - 2013-06-25 13:36 +0000
  Re: Python development tools Grant Edwards <invalid@invalid.invalid> - 2013-06-24 14:28 +0000
    Re: Python development tools Cameron Simpson <cs@zip.com.au> - 2013-06-25 07:36 +1000
  Re: Python development tools Wolfgang Keller <feliphil@gmx.net> - 2013-06-24 19:15 +0200
  Re: Python development tools Reed Xia <huaqin2005@gmail.com> - 2013-06-24 19:21 -0700

csiph-web