Giter Club home page Giter Club logo

Comments (4)

henriquebastos avatar henriquebastos commented on August 14, 2024

Try list instead of []. It's a callable and should work.

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Sorry. I misread default for cast. Can you provide the error message and/or a failing test?

from python-decouple.

rougeth avatar rougeth commented on August 14, 2024
  File ".../settings.py", line 36, in <lambda>
    cast=lambda v: [s.strip() for s in v.split(',')])
AttributeError: 'list' object has no attribute 'split'

decouple will call cast(default), in this line. It just seems strange.

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Hum... ok.

So we have a design decision to discuss. It seems that everything starts with: What is default?

Today, default is the fallback string value for an undefined option. So if you don't define the ALLOWED_HOSTS option, it will use the default as input for cast.

This enables you to have shorter config files/env by defining sane default values on your python code. Example:

ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='127.0.0.1', cast=csv())

In the above case, even if you don't define ALLOWED_HOSTS on your config file/env it should work fine.

What you seem to be questioning is: Should default be the end python value or should we have another parameter for that?

I don't know.

The purpose of decouple is to make it easy to load config from text data files/env. Maybe we could improve the documentation to clarify this.

What do you think about it?

from python-decouple.

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.