Re: Find in ipython3

2015-06-07 Thread Chris Angelico
On Sun, Jun 7, 2015 at 8:27 PM, Peter Otten <__pete...@web.de> wrote: > Just wait for Python 3.5. The switch from os.listdir() to the (new) > os.scandir() in the implementation of os.walk() is likely to improve the > situation Why wait? I've been using 3.5 for ages (and actually, my /usr/local/bin

Re: Find in ipython3

2015-06-07 Thread Steven D'Aprano
On Sun, 7 Jun 2015 07:33 pm, Laura Creighton wrote: > In a message of Sun, 07 Jun 2015 08:20:46 +0200, Cecil Westerhof writes: >>> You may get faster results if you use Matthew Barnett's replacement >>> for re here: https://pypi.python.org/pypi/regex >>> >>> You will get faster results if you buil

Re: Find in ipython3

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 12:27:05 +0200, Peter Otten writes: >> There is no gain to get in standard Python? By switching from fnmatch >> to re I got almost a speed gain of two. So I was wondering if I could >> do more. > >Just wait for Python 3.5. The switch from os.listdir() to the (new)

Re: Find in ipython3

2015-06-07 Thread Peter Otten
Cecil Westerhof wrote: > On Saturday 6 Jun 2015 13:07 CEST, Laura Creighton wrote: > >> The !find version is C code optimised to do one thing, find files in >> your directory structure, which happens to be what you want to do. >> General regular expression matching is harder. >> >> Carl Friedric

Re: Find in ipython3

2015-06-07 Thread Laura Creighton
In a message of Sun, 07 Jun 2015 08:20:46 +0200, Cecil Westerhof writes: >> You may get faster results if you use Matthew Barnett's replacement >> for re here: https://pypi.python.org/pypi/regex >> >> You will get faster results if you build your IPython shell to use >> PyPy, but I would still be v

Re: Find in ipython3

2015-06-07 Thread Cameron Simpson
On 07Jun2015 08:20, Cecil Westerhof wrote: There is no gain to get in standard Python? By switching from fnmatch to re I got almost a speed gain of two. So I was wondering if I could do more. Maybe write a few versions: one really dumb using filename == matchstring (like -name foo), one using

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Saturday 6 Jun 2015 13:07 CEST, Laura Creighton wrote: > The !find version is C code optimised to do one thing, find files in > your directory structure, which happens to be what you want to do. > General regular expression matching is harder. > > Carl Friedrich Bolz investigated regular expre

Re: Find in ipython3

2015-06-06 Thread Laura Creighton
In a message of Sat, 06 Jun 2015 15:42:27 -0700, Albert-Jan Roskam via Python-l ist writes: >"To run any command at the system shell, simply prefix it with !" >See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html Please don't top post. 2. He knows this. He's doing this for fun and

Re: Find in ipython3

2015-06-06 Thread Albert-Jan Roskam via Python-list
"To run any command at the system shell, simply prefix it with !" See: https://ipython.org/ipython-doc/dev/interactive/tutorial.html-- https://mail.python.org/mailman/listinfo/python-list

Re: Find in ipython3

2015-06-06 Thread Laura Creighton
The !find version is C code optimised to do one thing, find files in your directory structure, which happens to be what you want to do. General regular expression matching is harder. Carl Friedrich Bolz investigated regular expression algorithms and their implementation to see if this is the sort

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Friday 5 Jun 2015 01:04 CEST, Cameron Simpson wrote: > On 04Jun2015 13:09, Michael Torrie wrote: >> Why not use Python for what it's good for and say pipe the results >> of find into your python script? Reinventing find poorly isn't >> going to buy you anything. > > And several others made si

Re: Find in ipython3

2015-06-06 Thread Cecil Westerhof
On Friday 5 Jun 2015 09:17 CEST, Cecil Westerhof wrote: > I was already thinking along those lines. I made it: > def find(directory, to_match): > to_match = to_match.lower() > results = [] > for dirpath, dirnames, filenames in os.walk(expanduser(directory)): > for filename in filenames: > if(fnma

Re: Find in ipython3

2015-06-05 Thread Cecil Westerhof
Op Thursday 4 Jun 2015 22:13 CEST schreef random: > On Tue, Jun 2, 2015, at 12:13, Cecil Westerhof wrote: >> I am thinking about using ipython3 instead of bash. When I want to >> find a file I can do the following: >> !find ~ -iname '*python*.pdf' >> but is there a python way? > > Python really is

Re: Find in ipython3

2015-06-04 Thread Rustom Mody
On Friday, June 5, 2015 at 9:59:22 AM UTC+5:30, Cameron Simpson wrote: > On 04Jun2015 20:23, Michael Torrie wrote: > >On 06/04/2015 05:04 PM, Cameron Simpson wrote: > >> On 04Jun2015 13:09, Michael Torrie wrote: > >>> Why not use Python for what it's good for and say pipe the results of > >>> fin

Re: Find in ipython3

2015-06-04 Thread Cameron Simpson
On 04Jun2015 20:23, Michael Torrie wrote: On 06/04/2015 05:04 PM, Cameron Simpson wrote: On 04Jun2015 13:09, Michael Torrie wrote: Why not use Python for what it's good for and say pipe the results of find into your python script? Reinventing find poorly isn't going to buy you anything. An

Re: Find in ipython3

2015-06-04 Thread Michael Torrie
On 06/04/2015 05:04 PM, Cameron Simpson wrote: > On 04Jun2015 13:09, Michael Torrie wrote: >> Why not use Python for what it's good for and say pipe the results of >> find into your python script? Reinventing find poorly isn't going to >> buy you anything. > > And several others made similar dis

Re: Find in ipython3

2015-06-04 Thread Cameron Simpson
On 04Jun2015 13:09, Michael Torrie wrote: Why not use Python for what it's good for and say pipe the results of find into your python script? Reinventing find poorly isn't going to buy you anything. And several others made similar disparaging remarks. I think you're all missing some of the p

Re: Find in ipython3

2015-06-04 Thread random832
On Tue, Jun 2, 2015, at 12:13, Cecil Westerhof wrote: > I am thinking about using ipython3 instead of bash. When I want to > find a file I can do the following: > !find ~ -iname '*python*.pdf' > but is there a python way? Python really isn't a good substitute for a shell, but the normal python

Re: Find in ipython3

2015-06-04 Thread Tim Chase
On 2015-06-04 13:09, Michael Torrie wrote: > Why not use Python for what it's good for and say pipe the results > of find into your python script? Reinventing find poorly isn't > going to buy you anything. Until you port your app to Windows where find(1) is unavailable natively ;-) -tkc -- h

Re: Find in ipython3

2015-06-04 Thread Michael Torrie
On 06/04/2015 09:12 AM, Cecil Westerhof wrote: >> Can't IPython just call the find and du utilities? > > That is what > !find ~ -iname '*python*.pdf' > does. But I do not find that aesthetically. Like I said, I find ipython to be hackish, but invoking find this way is no more hackish than wri

Re: Find in ipython3

2015-06-04 Thread Michael Torrie
On 06/02/2015 10:13 AM, Cecil Westerhof wrote: > I am thinking about using ipython3 instead of bash. When I want to > find a file I can do the following: > !find ~ -iname '*python*.pdf' > but is there a python way? No more than there is a bash-native way of doing find. Bash scripts use a myri

Re: Find in ipython3

2015-06-04 Thread Cecil Westerhof
Op Thursday 4 Jun 2015 16:27 CEST schreef Grant Edwards: > On 2015-06-04, Cecil Westerhof wrote: >> Op Thursday 4 Jun 2015 04:54 CEST schreef Cameron Simpson: >> >>> On 02Jun2015 18:13, Cecil Westerhof wrote: I am thinking about using ipython3 instead of bash. When I want to find a fil

Re: Find in ipython3

2015-06-04 Thread Grant Edwards
On 2015-06-04, Cecil Westerhof wrote: > Op Thursday 4 Jun 2015 04:54 CEST schreef Cameron Simpson: > >> On 02Jun2015 18:13, Cecil Westerhof wrote: >>> I am thinking about using ipython3 instead of bash. When I want to >>> find a file I can do the following: >>> !find ~ -iname '*python*.pdf' >>> b

Re: Find in ipython3

2015-06-03 Thread Cameron Simpson
On 04Jun2015 07:09, Cecil Westerhof wrote: Op Thursday 4 Jun 2015 04:54 CEST schreef Cameron Simpson: On 02Jun2015 18:13, Cecil Westerhof wrote: I am thinking about using ipython3 instead of bash. When I want to find a file I can do the following: !find ~ -iname '*python*.pdf' but is there a

Re: Find in ipython3

2015-06-03 Thread Cecil Westerhof
Op Thursday 4 Jun 2015 04:54 CEST schreef Cameron Simpson: > On 02Jun2015 18:13, Cecil Westerhof wrote: >> I am thinking about using ipython3 instead of bash. When I want to >> find a file I can do the following: >> !find ~ -iname '*python*.pdf' >> but is there a python way? > > That succinct? No

Re: Find in ipython3

2015-06-03 Thread Cameron Simpson
On 02Jun2015 18:13, Cecil Westerhof wrote: I am thinking about using ipython3 instead of bash. When I want to find a file I can do the following: !find ~ -iname '*python*.pdf' but is there a python way? That succinct? Not out of the box, but something can easily be built on top of the os.w

Find in ipython3

2015-06-02 Thread Cecil Westerhof
I am thinking about using ipython3 instead of bash. When I want to find a file I can do the following: !find ~ -iname '*python*.pdf' but is there a python way? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/l