Coder Social home page Coder Social logo

check-usb-conn.py's Introduction

check-usb-conn.py

License: MIT License

Description: Written for unix machines, this module checks if a usb device is connected to the system or not. Works in both Python2.7 and Python 3.x environment. Note that it checks for one device at a time.
This module is more of a plugin as of now. In future, I will add more features to it and will try to make it cross-platform compatible(Ahem!).

Possible Questions:

Question: Why is there no error handling methods in testing (if __name__ == "__main__") section? What if the user gives incorrect device ID or multiple IDs at once?
Answer: One of Python's core philosophy is "We are all consenting adults here." I, for one, like to treat the user as a mature adult. If you found this module by yourself, I guess that you already know what vendor_id and product_id are, how they are used, and why you may require this module for them. Therefore I see no reason to treat you as a child and add unnecessary error-handling blocks in my module.

Question: It seems that there is no import __future__ statement in code, so how is print() function working in Python 2.7 environment?
Answer: It's not. In Python 2.7, the print statement is the working one and it is treating the message next to it as a tuple. More specifically, In python 2.7, print("Hello") prints the value "Hello" as a tuple value. I could have imported __future__ but if I can make the testing code compatible with just one hacky method, why would I burden the module with unnecessary compatibility imports?

check-usb-conn.py's People

Contributors

bsandeepan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.