title: How to get attribute values from variable in Python
body: <p>So I'm doing a relatively simple project so I can teach myself Python. I've come to a point where I'm stuck. So I have a variable named <strong>element</strong> in pycharm debugger which shows as
  <a href="https://i.stack.imgur.com/cmVOE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cmVOE.png" alt="enter image description here"></a></p>
  
  <p>This variable is type Tag, which is correct to me. In <strong>element</strong> I want to see if the <code>class="schedule_dgrd_time/result"</code>which is not the case in the above image.</p>
  
  <p>I see that within <strong>element</strong> there is an <code>attrs</code>.
  <a href="https://i.stack.imgur.com/1aX9S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1aX9S.png" alt="enter image description here"></a></p>
  
  <p>How can I access that value? If I do <code>element.string</code> I get the text value which in this case would be <strong>Sat.</strong>(...I could make that work),  but I was wondering if I can check the class attribute value first. </p>
  
  <p>I've been searching for this for a couple days now and just can't get it. I've googled myself to death at this point. Any help or pointers would be greatly appreciated. Thanks for reading. </p>
  
  <p><a href="https://i.stack.imgur.com/ORU9R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ORU9R.png" alt="enter image description here"></a></p>
  
  <p><strong><em>Update</em></strong>
  Here is my code </p>
  
  <pre><code>import urllib2
  import datetime
  import re
  from bs4 import BeautifulSoup
  
  # today's date
  date = datetime.datetime.today().strftime('%-m/%d/%Y')
  validDay = "Mon\.|Tue\.|Wed\.|Thu(r)?(s)?\.|Fri\."
  website = "http://www.texassports.com/schedule.aspx?path=baseball"
  
  opener = urllib2.build_opener()
  ##add headers that make it look like I'm a browser
  opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
  page = opener.open(website)
  # turn page into html object
  soup = BeautifulSoup(page, 'html.parser')
  #print soup.prettify()
  
  #get all home games
  all_rows = soup.find_all('tr', class_='schedule_home_tr')
  
  # see if any game is today
  # entryForToday = [t for t in all_rows if t.findAll('nobr',text=re.compile('.*({}).*'.format(date)))]
  
  # hard coding for testing weekend
  entryForToday = [t for t in all_rows if t.findAll('nobr',text=re.compile('3/11/2017'))]
  
  time = "schedule_dgrd_time/result"
  
  for elements in entryForToday:
     for element in elements:
         #this is where I'm stuck. 
          # if element.attrs:
          #     print element.attrs['class'][0]
  </code></pre>
  
  <p>I know a double nested for loop is not ideal so if you have a better way I'm glad to hear it. Thanks</p>