Skip to content
Advertisement

Tag: python-3.7

List available cameras OpenCV/Python

I have multiple webcams connected to my PC and I would like to select one camera based on its info (name, resolution etc.). Is there a way to list all the cameras available on a PC, instead of trying all the indices in cv2.VideoCapture()? Answer The answer is negative. OpenCV doesn’t have a method for listing the available video capture

Handle specific exception from python package

I would like to handle the following Exception from py_vollib/py_lets_be_rational in specific way. Tried this without success: what am I doing wrong? any help would be appreciated. Answer Looking at the implementation, you’re missing the period at the end of the sentence: I don’t see the point in this check because that will always be the message the exception is

Data Classes vs typing.NamedTuple primary use cases

Long story short PEP-557 introduced data classes into Python standard library, that basically can fill the same role as collections.namedtuple and typing.NamedTuple. And now I’m wondering how to separate the use cases in which namedtuple is still a better solution. Data classes advantages over NamedTuple Of course, all the credit goes to dataclass if we need: mutable objects inheritance support

Installing numpy with pip on windows 10 for python 3.7

I installed python 3.7 on my Windows 10 laptop since it has been officially released as of today (06/28/2018). Then i tried to install numpy package using pip The install proceeds but finally fails with the below error : Any ideas as to how to overcome this install Error? Thanks. Answer Installing NumPy on Windows is a common problem if

Dataclasses and property decorator

I’ve been reading up on Python 3.7’s dataclass as an alternative to namedtuples (what I typically use when having to group data in a structure). I was wondering if dataclass is compatible with the property decorator to define getter and setter functions for the data elements of the dataclass. If so, is this described somewhere? Or are there examples available?

Advertisement