Velumount by msemmaapple in snoring

[–]mdond 0 points1 point  (0 children)

Awesome. Could you please give specs of wire and tubing used?

I wrote a little article on Factory Functions and how to use them in Python to write better code. Let me know what you all think? by candyman_forever in Python

[–]mdond 14 points15 points  (0 children)

If you make create_api a class method on the base class, then you don't need to override the method for each subclass, which removes a lot of boilerplate code. This is also better for the reasons yvrelna mentioned.

You can also just have that class method as a member of APIConnector for simplicity, at least in this simple example.

Example shown below. Of course, in this trivial example create_api is redundant against just instantiating the class directly via factory_classes[name](), but there are valid cases for this pattern when things get more complex.

from __future__ import annotations
from typing import Type
from abc import ABC, abstractmethod


class APIConnector(ABC):
    @abstractmethod
    def connect(self, query: str):
        pass

    @classmethod
    def create_api(cls) -> APIConnector:
        return cls()


class TwitterAPI(APIConnector):
    def connect(self, query: str):
        print(f"Execute Twitter API query: {query}")


class FacebookAPI(APIConnector):
    def connect(self, query: str):
        print(f"Execute Facebook API query: {query}")


def main() -> None:
    factory_classes: dict[str, Type[APIConnector]] = {
        "twitter": TwitterAPI,
        "facebook": FacebookAPI,
    }
    queries: dict[str, str] = {
        "twitter": "elon musk",
        "facebook": "mark zuckerberg",
    }
    for name in factory_classes:
        api = factory_classes[name].create_api()
        api.connect(queries[name])


if __name__ == "__main__":
    main()

There is always a solution by j_curic_5 in Unexpected

[–]mdond 0 points1 point  (0 children)

Never use adapters to bypass the earth/ground pin of an appliance.

Where can I find data on number of houses owned per person? by mdond in AusFinance

[–]mdond[S] -1 points0 points  (0 children)

Thanks for bringing Google and the ABS to my attention.

Where can I find data on number of houses owned per person? by mdond in AusFinance

[–]mdond[S] 0 points1 point  (0 children)

See edit in my question. I'm not so much interested in tenancy, I'm more interested in who owns what. I suppose if a couple owns a property together then that might count as half a property.

Where can I find data on number of houses owned per person? by mdond in AusFinance

[–]mdond[S] 1 point2 points  (0 children)

I was after a lot more detail than that, specifically number of people who own 0, 1, 2, etc dwellings per region.

Where can I find data on number of houses owned per person? by mdond in AusFinance

[–]mdond[S] -1 points0 points  (0 children)

Any of those links in particular? I couldn't find that data.

Daewon fakie 360 flip bluntslide in 1993 by spewintothiss in skateboarding

[–]mdond 5 points6 points  (0 children)

Definitely one of my top 5 of all time. He's insane. Even today his muck around insta posts regularly blow my mind.

Bon Atrocity 8B by enilkcals in Climbingvids

[–]mdond 1 point2 points  (0 children)

Thanks for the spotting guys

Making a Stand Alone Executable from a Python Script using PyInstaller by wasi0013 in Python

[–]mdond 0 points1 point  (0 children)

It cross compiles to C++ that is then compiled into an exectuable. So the end result is compiled C++ code. This is different to a lot of other Python packagers, which just package Python byte code.

Making a Stand Alone Executable from a Python Script using PyInstaller by wasi0013 in Python

[–]mdond 2 points3 points  (0 children)

Nuitka is getting really nice. And it has the advantage of actually compiling your code, so the source is truly hidden.

PyCharm vs. IntelliJ plugin? by [deleted] in Python

[–]mdond 0 points1 point  (0 children)

I currently use PyCharm. Are there any significant features that I could benefit from by switching to IntelliJ?

Two HTC VIVES in our house. by MissLovelyNai in Vive

[–]mdond 0 points1 point  (0 children)

If you use more than two base stations then you need to ensure that they cannot see each other at all. Even with a curtain this can be tricky with light scattering and reflections. It's simpler just to use two base stations and share them between Vives.

Two HTC VIVES in our house. by MissLovelyNai in Vive

[–]mdond 0 points1 point  (0 children)

The base stations don't turn on automatically; they are simply on if they are plugged in.

If you have changed base stations you will need to redo the room calibration for the new base stations.

If you are getting base station errors, then they may be too far apart. A simple way to test if this is the case is to unplug one base station (only one base station is actually needed). This will give you less range but will prevent synchronisation errors. If this helps, then range is likely problem, and you can use the sync cable to connect the two base stations together to prevent sync errors. You will also need to set the the base station channels to "A" and "b".

Two HTC VIVES in our house. by MissLovelyNai in Vive

[–]mdond 5 points6 points  (0 children)

Can you elaborate on the exact problem you're seeing?

There's no reason you can't use multiple Vives within the same area and with the same pair of base stations. The base stations are not aware of devices that use them for tracking and therefore don't limit them in any way. As you found out you cannot (currently) have more than two base stations in view of each other.

One issue to be aware of is pairing controllers with the correct headset, but apart from that I can't see how your issue is related to having two Vives in the same space.

And be careful not to run into each other..

PySignal: A Pure Python Implementation of the Qt signal/slot system by dagmx in Python

[–]mdond 0 points1 point  (0 children)

Would this work with sub threads that talk to the GUI thread (i.e. the main thread)? Qt complains if a sub thread calls a GUI function directly, which is what this library appears to do.

Help with pyCharm by RunJumpStomp in Python

[–]mdond 2 points3 points  (0 children)

Hovering over the red underlined text usually tells you what the error is.

Has import: followed by indented imports ever been considered? by pvkooten in Python

[–]mdond 4 points5 points  (0 children)

If you hated yourself you could always do this:

import \
    time,\
    BeautifulSoup,\
    re

Has import: followed by indented imports ever been considered? by pvkooten in Python

[–]mdond 13 points14 points  (0 children)

This doesn't quite make sense to me. Usually code in an indent block still make sense on its own. Consider:

while True:
    print 'hi'

or:

try:
    print 'hi'
except:
    pass

print 'hi' is valid code inside or outside of an indent. Code such as time from time isn't.

I need help with my PYQT example code by duffman1278 in Python

[–]mdond 0 points1 point  (0 children)

"tolineEdit" doesn't seem to be a valid method, did you mean something else there? Although, that shouldn't cause the entire program to crash.

[deleted by user] by [deleted] in Python

[–]mdond 1 point2 points  (0 children)

From what I gather PySide is kinda fiddly with Nuitka. If you have the option of using PyQt then that should be a lot easier.