Code Monkey home page Code Monkey logo

Comments (3)

konstantinstadler avatar konstantinstadler commented on August 11, 2024 1

Ok, coco now has a named logger (merged to the current master head, a new release will come soon)
This works now:

In [1]: import logging                                                                                                                                                                                               

In [2]: import country_converter as coco                                                                                                                                                                             

In [3]: logging.basicConfig(level=logging.INFO)                                                                                                                                                                      

In [4]: coco.convert("asdf")                                                                                                                                                                                         
WARNING:country_converter.country_converter:asdf not found in regex
Out[4]: 'not found'

In [5]: logging.basicConfig(level=logging.CRITICAL)                                                                                                                                                                  

In [6]: coco.convert("asdf")                                                                                                                                                                                         
WARNING:country_converter.country_converter:asdf not found in regex
Out[6]: 'not found'

In [7]: coco_logger = coco.logging.getLogger()                                                                                                                                                                       

In [8]: coco_logger.setLevel(logging.CRITICAL)                                                                                                                                                                       

In [9]: coco.convert("asdf")                                                                                                                                                                                         
Out[9]: 'not found'

@sbrugman : For our use case we need the list output and some sentinel strings for "not found" (these can be changed by passing "not_found = whatever"). Not quite sure if your proposal is to change the output to dict. If so, feel free to implement a switch doing that. However, our standard use case is to have a list in the same order as the input - so this should be kept as the standard behaviour.

from country_converter.

sbrugman avatar sbrugman commented on August 11, 2024

@konstantinstadler Do you have a strong preference the output being a combination of warnings and a "not found" sentinel value? Another strategy you could consider is to return the result in an alternative format:

# input: france
{"result": "FR", "error": None}
# input: sadflkj
{"result": None, "error": "input not found in regex"}

from country_converter.

shimp-dror avatar shimp-dror commented on August 11, 2024

@konstantinstadler Thank you!

from country_converter.

Related Issues (20)

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.