Rename name argument to tag_name to avoid conflict with HTML standard 'name' attribute.

Bug #1639580 reported by Dennis Kugelmann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Won't Fix
Undecided
Unassigned

Bug Description

The methods `find` and `find_all`, as well as every other `find` method, take as an argument for the `tagName` the argument `name`.

Then there is the possibility in the `find` to define extra `attributes` the dom node should have, e.g.:

    soup.find_all(id='link2')
    # [<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>]

So you can't select for example this:

    soup.find_all('input' name='email')
    # [<input name="email"></input>]

In JavaScript the name of the tag is called `tagName`, so it would only be logical to rename the argument `name` to `tag_name`.

I know that there is the `attr` argument and this is a breaking change, but to be consistent with the W3C spec this step is only logical.

Especially the attribute `name` is such frequently used.

I could understand if you don't want to do this change, but I think this would lead to a more unified developer experience.

Of course, this is no change to make in `bs4`, but should be considered for `bs5`.

Tags: node tag tags
summary: - Rename find and find_all args
+ Rename name argument to tag_name to avoid conflict with HTML standard
+ 'name' attribute.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This is a reasonable request, but I've decided not to make this change. The 'name' argument has been called that for twelve years and this is the first request to change it. Given the magnitude of the change and the long time frame necessary to change how 'name' works, I think it's better to leave it alone.

I've added a section to the documentation showing how to use attrs to search by the 'name' attribute.

Changed in beautifulsoup:
status: New → Won't Fix
Revision history for this message
Dennis Kugelmann (kugelmann-dennis) wrote : Re: [Bug 1639580] Re: Rename name argument to tag_name to avoid conflict with HTML standard 'name' attribute.

Got it, thanks!
I've thought you would answer this. But your change to the documentation is
a good work around.
As I needed some more time to evaluate how to do this instead

Yours,
Dennis

On Sun, 11 Dec 2016 at 16:35 Leonard Richardson <email address hidden>
wrote:

> This is a reasonable request, but I've decided not to make this change.
> The 'name' argument has been called that for twelve years and this is
> the first request to change it. Given the magnitude of the change and
> the long time frame necessary to change how 'name' works, I think it's
> better to leave it alone.
>
> I've added a section to the documentation showing how to use attrs to
> search by the 'name' attribute.
>
> ** Changed in: beautifulsoup
> Status: New => Won't Fix
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1639580
>
> Title:
> Rename name argument to tag_name to avoid conflict with HTML standard
> 'name' attribute.
>
> Status in Beautiful Soup:
> Won't Fix
>
> Bug description:
> The methods `find` and `find_all`, as well as every other `find`
> method, take as an argument for the `tagName` the argument `name`.
>
> Then there is the possibility in the `find` to define extra
> `attributes` the dom node should have, e.g.:
>
> soup.find_all(id='link2')
> # [<a class="sister" href="http://example.com/lacie"
> id="link2">Lacie</a>]
>
> So you can't select for example this:
>
> soup.find_all('input' name='email')
> # [<input name="email"></input>]
>
> In JavaScript the name of the tag is called `tagName`, so it would
> only be logical to rename the argument `name` to `tag_name`.
>
> I know that there is the `attr` argument and this is a breaking
> change, but to be consistent with the W3C spec this step is only
> logical.
>
> Especially the attribute `name` is such frequently used.
>
> I could understand if you don't want to do this change, but I think
> this would lead to a more unified developer experience.
>
> Of course, this is no change to make in `bs4`, but should be
> considered for `bs5`.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/beautifulsoup/+bug/1639580/+subscriptions
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.