Helper method to easily select a single element via CSS

Bug #1349367 reported by Dan Watkins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Fix Released
Undecided
Unassigned

Bug Description

I often find myself writing code like this:

elements = parent_element.select('...')
self.assertEqual(1, len(elements))
element = elements[0]

Being able to do:

element = parent_element.select_one('...')

would make this much more expressive.

Revision history for this message
Leonard Richardson (leonardr) wrote :

Added in revision 371. This has brought to light a naming inconsistency: find()/find_all() find one/many tags, but select()/select_one() find many/one tags. But it's way too late to change those names.

Changed in beautifulsoup:
status: New → Fix Committed
Changed in beautifulsoup:
status: Fix Committed → Fix Released
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.