Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

What do the underscores do in this line of code _, (train, valid, test), _ = dc.molnet.load_tox21() ?

I work as a Data Scientist but mainly use R day to day. I'm trying to get my head around python but there are some quirks in the syntax I would like to understand better. Could someone help me understand what they underscores are doing here? Are they wildcard type characters?

1 Answer

Steven Parker
Steven Parker
243,656 Points

I can sympathize with the difficulty of learning a very different computer language. I've never been able to "get my head around" R! :confused:

Underscores are often used in Python as placeholders for unused values.

I'd guess that the "load_tox21" method returns a 3-part tuple, but this code only uses the 2nd part, which is itself another 3-part tuple.

Hi Steven,

Thanks so much for this! That makes a lot of sense and is actually a really neat piece of functionality!

Much appreciated.

Scott