title: How does one transition from using a list of functions to using classes in Python?
body: <p>Let me start off by stating that I am completely self-taught in programming with python throught trial and error and a lot of googling, so please excuse my ignorance of propper programming terminology.</p>
  
  <p>That being said, lets pretend I'm writing code that scrapes a website and returns a few pieces of information. In the very early stages of testing I would have the code writen "line-by-line", as in, outside of any function:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import requests
  url = "https://en.wikipedia.org/wiki/Web_scraping"
  headers = {'User-agent':'Mozilla/5.0'}
  page = requests.get(url, headers = headers)
  soup = BeautifulSoup(page.text)
  print soup.title
  </code></pre>
  
  <p>Then as the script gets validated and more complex I might put larger "single task actions" of code into functions:</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import requests
  
  def make_soup(url):
      headers = {'User-agent':'Mozilla/5.0'}
      page = requests.get(url, headers = headers)
      soup = BeautifulSoup(page.text)
      return soup
  
  def list_table_of_contents(soup):
      toc_elem = soup.find('div', id = 'toc')
      toc_level1 = toc_elem.find_all('li', class_ = 'toclevel-1')
      toc_level1_list = [i.text for i in toc_level1]
      return toc_level1_list
  
  url = "https://en.wikipedia.org/wiki/Web_scraping"
  soup = make_soup(url)
  toc_level1_list = list_table_of_contents(soup)
  for i in toc_level1_list:
      print i
  </code></pre>
  
  <p>The problem is once it gets to the point where I have 10 different functions in one script it becomes really hard to comprehend whats going on and do revisions. I'm guessing that using classes would be the next logical step, but I'm not sure how I would implement them in something like what I described above...</p>
  
  <p>In my mind "line-by-line" programming is like writing a recipe, and using functions is like making factories that follow specific recipes (input -> output), so then what are classes?</p>
  
  <p>From what I've read about classes and learned from playing with them, they are essentially a way to easily create multiple "objects" with specific attributes. </p>