title: How can I get a list of available serial ports using 'serial.tools.list_ports' python module?
body: <p>I'm new to python and I need a list of available serial ports to choose one of them in a program. According to <a href="https://pyserial.readthedocs.io/en/latest/tools.html#module-serial.tools.list_ports" rel="nofollow noreferrer">This</a>, the <code>serial.tools.list_ports</code> module can do that for me by executing <code>serial.tools.list_ports.comports()</code> method. Accordingly,I executed the following code in python interpreter:</p>
  
  <pre><code>import serial.tools.list_ports
  a=serial.tools.list_ports.comports()
  print(a)
  </code></pre>
  
  <p>the result is:</p>
  
  <pre><code>[&lt;serial.tools.list_ports_linux.SysFS object at 0x7f2503d27be0&gt;]
  </code></pre>
  
  <p>while when I use the following command in <code>ubuntu</code> terminal</p>
  
  <pre><code>python3 -m serial.tools.list_ports
  </code></pre>
  
  <p>it returns what I want:</p>
  
  <pre><code>/dev/ttyUSB0        
  1 ports found
  </code></pre>
  
  <p>where is the problem?</p>