Code Monkey home page Code Monkey logo

Comments (6)

gruns avatar gruns commented on June 7, 2024

A user's expectation of None would be ?param=, not ?param. The former is
more common. To be explicit

>>> f = furl('http://www.google.com/')
>>> f.args['sup'] = None
>>> f.url
'http://www.google.com/?sup='

instead of

>>> f = furl('http://www.google.com/')
>>> f.args['sup'] = None
>>> f.url
'http://www.google.com/?sup'

I can't recall the last time I saw the latter in the wild.

The current behavior serializes None to a string

>>> f = furl('http://www.google.com/')
>>> f.args['sup'] = None
>>> f.url
'http://www.google.com/?sup=None'

But I agree: None would be useful as a special value.

I'll ruminate on a potential solution for ?param. None as such would break a
lot of people's expectations.

Do you have any other ideas?

from furl.

nvie avatar nvie commented on June 7, 2024

Why not ?sup for sup = None and ?sup= for sup = ''?

from furl.

ulope avatar ulope commented on June 7, 2024

Why not ?sup for sup = None and ?sup= for sup = ''?

Yes, thats how I meant it.

@gruns:
You wrote yourself that None currently isn't producing a very useful result - so I think there has to be no concern regarding backwards compatibility.

from furl.

gruns avatar gruns commented on June 7, 2024

Why not ?sup for sup = None and ?sup= for sup = ''?

That's how I understood @ulope.

The problem is the aforementioned breaks user expectations. ?sup=
is much more common than ?sup, so a new user would expect f.args['sup'] = None to become ?sup=, not ?sup.

That said, I don't see an obviously better way of supporting ?sup. Ruling out
the above, a furl constant could be used, like subprocess.PIPE

>>> f = furl('http://www.google.com/')
>>> f.args['sup'] = furl.EMPTY
>>> f.url
'http://www.google.com/?sup'

But that's mediocre at best.

Any other ideas before I implement f.args['sup'] = None as ?sup and f.args['sup'] = '' as ?sup=?

from furl.

gruns avatar gruns commented on June 7, 2024

Support for query parameters without a trailing =, as discussed above, was added to furl v0.3.6.

>>> f = furl('http://sprop.su')
>>> f.args['param'] = None
>>> f.url
'http://sprop.su/?param'

Upgrade with

pip install furl --upgrade

Thank you for bringing this issue to my attention @ulope.

from furl.

nvie avatar nvie commented on June 7, 2024

👍

from furl.

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.