Coder Social home page Coder Social logo

grepfunc's People

Contributors

ronenness avatar sylvainroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grepfunc's Issues

Issues on Grep_Iter

Hi,

I found this issue when I tried grep_iter

StopIteration Traceback (most recent call last)
~\Anaconda3\lib\site-packages\grepfunc\grepfunc.py in grep_iter(target, pattern, **kwargs)
234 # done iteration
--> 235 raise StopIteration
236

StopIteration:

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
in
6
7 # print all people with first name 'Bob'
----> 8 for POT in grep_iter(infile, "WPOT_TOTAL2"):
9 print (POT)

RuntimeError: generator raised StopIteration

It might need to end loop when the codes read the end of the line?

Example is confusing

\https://pythonhosted.org/grepfunc/

Read the Grep on File section:

The following example will return a list of movie names without the word 'dog' in them, read from a file.


Yet, the actual code is as below:

from grepfunc import grep

the file contains the following list of words: ['Ghost Dog', 'Die Hard', 'Matrix', 'The Ring', 'Cats and Dogs', 'Batman', 'Superman', 'Reservoir Dogs']

infile = open('movies.txt', 'r')

grep titles without the word 'dog' in them from file. Note: i=True will ignore case.

grep(infile, "dog", i=True)

output:

>>> ['Ghost Dog', 'Cats and Dogs', 'Reservoir Dogs']


Note two things:

  1. The v=True option is not included in this code, so there is no inversion of the logic, and we are looking for 'dog'
  2. The output includes all of the entries with the word dog in them, even though the text comment says that we are working to grep the titles without the word 'dog' in them. This is very confusing, and wrong... the output is correct for the code given, but the descriptions are wrong.

While this seems trivial, this puts the average user who is simply trying to grep through a file with python into a confusing quest to understand why the results are backwards.

Two fixes needed: Both the high level description and the comment in the code need to say that we are looking for the movie names WITH the word Dog in them.

Doesn't seem to work with Python 3

Hello. I was looking for something similar to grep and came across to your project.

Unfortunately, it doesnt seem to work with Python 3.

When I tried

from grepfunc import grep

I got:

In [56]: from grepfunc import grep
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-56-5f3ea5e5b70f> in <module>()
----> 1 from grepfunc import grep

c:\python\python36\lib\site-packages\grepfunc\__init__.py in <module>()
      8 __license__ = 'MIT'
      9
---> 10 from grepfunc import (grep, grep_iter)
     11

ImportError: cannot import name 'grep'

Raise error

I have had this error:

File ".\wpy64\python-3.8.5.amd64\lib\sre_parse.py", line 668, in _parse
# raise source.error("nothing to repeat",

error: nothing to repeat

Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.