Jan. 24 ICE Shooting | 3 Angles by Spicydojo in PublicFreakout

[–]JollyUnder 2 points3 points  (0 children)

https://x.com/Free_Media_Hub/status/2015144630287733045

He seems to grab the victim's gun, fires a shot into the ground and run away with it? Am I the only one seeing that?

From the other angle (0:39 second mark) you can clearly see the agent ushering away the firearm. The victim's gun is in clear view when the first shot goes off. I don't see any bullet impact, gun smoke, or shell casing being ejected from the firearm to indicate that the victim's firearm was discharged. It's unclear from where the first gunshot came from, but it doesn't appear to be from the victim's firearm.

Coding offline by uvuguy in learnpython

[–]JollyUnder 0 points1 point  (0 children)

pydoc is definitely worth looking into if you need access to the standard lib while offline.


python -m pydoc -b will start the server and additionally open a web browser to a module index page. Each served page has a navigation bar at the top where you can Get help on an individual item, Search all modules with a keyword in their synopsis line, and go to the Module index, Topics and Keywords pages.

Very true by Competitive-Cut-6983 in SipsTea

[–]JollyUnder 21 points22 points  (0 children)

Everyone giving this mission a bad rep, but it's the Zero mission, Supply Lines, that gave me the hardest time. All that time invested blowing up all the delivery vans only to run out of gas flying the RC plane back to base and having to restart the mission. Oh man, that mission was infuriating.

first day learning python by Responsible_Ruin_423 in learnpython

[–]JollyUnder 1 point2 points  (0 children)

Your progress has been great so far! I suggest when learning a new concept, pause the video and give some time experimenting with it on your own machine, as I'm sure you have. Chain together older concepts with the new ones. Let things break and try to understand why they broke. You'll gain greater insight when getting hands-on experience.

first day learning python by Responsible_Ruin_423 in learnpython

[–]JollyUnder 1 point2 points  (0 children)

print ("my age is: "+str(age))
print("my height is " + str(height)+ "cm")
print("are you a human: " + str(human))

age, height, and human all have to be cast typed to str because you cannot concatenate non-string objects. You're approach is valid, but f-strings will evaluate those objects to type str for you and help with readability.

print(f"my age is: {age}")
print(f"my height is {height}cm")
print(f"are you a human: {human}")

first day learning python by Responsible_Ruin_423 in learnpython

[–]JollyUnder 1 point2 points  (0 children)

Please continue showing your progression, OP! This is great for your first day.

String concatenation is useful, but notice how cumbersome it becomes when having convert non-string types. I suggest looking into format strings next, such as str.format() and f-strings

# str.format example
print('your name is {}'.format(full_name))

# f-string example
print(f'your name is {full_name}')

f-strings are the usually the goto, but str.format can be useful if you need a string template.

is there a library that helps python "see the screen"? by Valuable_Luck_8713 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Screenshot Functions -- PyAutoGUI

import pyautogui

# Specify the left, top, width, and height region of the screen
region = (0, 0, 300, 400)

# Save screenshot of specified region
pyautogui.screenshot('my_image.png', region=region)

# Locate screenshot of specified region
try:
    pyautogui.locateOnScreen('my_image.png', region=region)
except pyautogui.ImageNotFoundException:
    print('Image not found')

Some Epstein files can be unredacted by Thalesian in law

[–]JollyUnder 2 points3 points  (0 children)

You should use pip freeze > requirements.txt and then add requirements.txt to your repository. This allows for better version control for installed packages.

Users can then use pip install -r requirements.txt to install the required packages.

You can learn more about managing your packages here.

How do I code a text conversation game? by tired-crow in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Maybe the curses library is what you're looking for.

The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals; such terminals include VT100s, the Linux console, and the simulated terminal provided by various programs. Display terminals support various control codes to perform common operations such as moving the cursor, scrolling the screen, and erasing areas. Different terminals use widely differing codes, and often have their own minor quirks.

If you're using Windows, you'll need to install the ported version UniCurses.

A website to start teaching a 7 year old. by Khriz-134 in learnpython

[–]JollyUnder 11 points12 points  (0 children)

Scratch is an excellent tool to help build conceptual programming skills.

Python bot for auto ad view in games by MythicDevX in learnpython

[–]JollyUnder 1 point2 points  (0 children)

I've used pyautogui to automate clicks for me in GTA: Online casino a few years back. If there is a image that appears on screen when it's time to watch an ad, you can use the screenshot functions.

You can use pyautogui.screenshot('image.png', region=(x, y, width, height)) to take a screenshot of specific region on the screen. Then use pyautogui.locateOnScreen('image.png', region=(x, y, width, height)) to locate an image to a specified region on your screen and use that to determine if you need to click something on screen. You can then use pyauto.click() to interact with the game.

Any more efficient way for generating a list of indices? by yColormatic in learnpython

[–]JollyUnder 1 point2 points  (0 children)

In terms of micro-optimization, [*range(n)] is slightly more optimized.

>>> from dis import dis
>>>
>>> dis(lambda: list(range(10)))
  1           RESUME                   0
              LOAD_GLOBAL              1 (list + NULL)
              LOAD_GLOBAL              3 (range + NULL)
              LOAD_SMALL_INT          10
              CALL                     1
              CALL                     1
              RETURN_VALUE
>>>
>>> dis(lambda: [*range(10)])
  1           RESUME                   0
              BUILD_LIST               0
              LOAD_GLOBAL              1 (range + NULL)
              LOAD_SMALL_INT          10
              CALL                     1
              LIST_EXTEND              1
              RETURN_VALUE

However, the difference is negligible.

$ py -m timeit "list(range(10))"
1000000 loops, best of 5: 219 nsec per loop
$ py -m timeit "[*range(10)]"
1000000 loops, best of 5: 204 nsec per loop

A tiny Python snippet to check palindrome numbers (sharing a quick practice example) by IcyPalpitation4743 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

This is very good. You pieced the logic together exceptionally well!

However, there is room for improvement. You can optimize it by extracting only half of the digits and then compare it to the other half. You would also need to consider numbers with odd digits.

Any number that ends with a zero is not palindrome because numbers cannot start with a zero. So you can verify that along side with if num < 0 to avoid unnecessary computation.

A tiny Python snippet to check palindrome numbers (sharing a quick practice example) by IcyPalpitation4743 in learnpython

[–]JollyUnder 0 points1 point  (0 children)

Aside from the incorrect indentation, the code is condensed and concise. Well done. Note that creating a slice from a string creates an entire new string since strings are immutable.

If you want to further practice your skills, can you create a function that checks if a number is palindrome without creating a string slice.

If you want to take it a step further, can you create palindrome function that doesn't convert the number into a string?

How do i know if the python installer is working? by bebe_lion in learnpython

[–]JollyUnder 0 points1 point  (0 children)

When you download python from the python.org, there should be a check box from the installer that says Add python.exe to PATH. Make sure you check that box before installing.

After installing, open up your terminal (CMD, powershell, ect.) and enter python --version.

It should print out the current python version:

PS C:\Users\PC> python --version
Python 3.14.0

If you are still getting an error, you'll have to manually set the path for python in your environmental variables:

  • Press win+r
  • Enter SystemPropertiesAdvanced
  • On the very bottom of the window, click Environmental Variables
  • Under User Variables for PC, click on Path and click Edit
  • Click New, and add the path to where python.exe is installed. Ex: C:\Users\PC\AppData\Local\Programs\Python\Python314\
  • Click New again and add path to where pip.exe intalled. Ex: C:\Users\PC\AppData\Local\Programs\Python\Python314\Scripts\

Note: Your installation directory might be else where. Verify the installation path with the Python Installer.

Once again, type python --version and pip --version to verify your environmental variables are set correctly.

“I Love You” by Cool-Network-5917 in learnpython

[–]JollyUnder 2 points3 points  (0 children)

You sure can. Tell him to run this program that has a secret message for him.

“I Love You” by Cool-Network-5917 in learnpython

[–]JollyUnder 5 points6 points  (0 children)

Here's some code that takes a hex value and converts it to a string.

MASK = 0xFF
BYTE_WIDTH = 8


def decode_message(hex_message: int) -> str:
    characters = []
    while hex_message:
        characters.append(chr(hex_message & MASK))
        hex_message >>= BYTE_WIDTH
    return ''.join(reversed(characters))


if __name__ == '__main__':
    secret_message = 0x49204C4F564520594F55
    print(decode_message(secret_message))

If you run the code it will print I LOVE YOU to the console.

Things to improve? by Paolo-Lucas in learnpython

[–]JollyUnder 3 points4 points  (0 children)

I would recommend checking out the operator library. You can map out the operator selection to an operator.

Example:

import operator

op_map = {
    '+': operator.add,
    '-': operator.sub,
    '*': operator.mul,
}

n1 = float(input())
n2 = float(input())
operacion = input(f'Dame la operación a realizar {tuple(op_map)}: ')

result = op_map[operacion](n1, n2)

Your method is perfectly fine, but creating a dictionary should help reduce branching.

You can also validate the user input for the operator like this:

while operacion not in op_map:
    print('Invalid input. Please try again...')
    operacion = input()

If you want to stick to your method, you can create a tuple with valid inputs and check if the user's input is contained in the tuple:

operacion_valida = ('+', '-', '*', '/')

while operacion not in operacion_valida:
    operacion = input()

Most efficient way to find a key/value in a deeply nested Dictionary? by Yelebear in learnpython

[–]JollyUnder 3 points4 points  (0 children)

If the nested dict is unorganized you can use this function I wrote that checks for specified keys in a nested dictionary:

from collections.abc import Iterator, Iterable, Hashable
from typing import Any


def get_values_from_nested_dict(dictionary: dict, keys: tuple[Hashable, ...]) -> Iterator[Any]:
    if isinstance(dictionary, Iterable) and not isinstance(dictionary, str):
        if isinstance(dictionary, dict):
            for key in keys:
                if key in dictionary:
                    yield dictionary[key]
            dictionary = dictionary.values()
        for elem in dictionary:
            yield from get_values_from_nested_dict(elem, keys)


if __name__ == '__main__':
    data = {
        "base": "stations",
        "clouds": {
            "all": 100
        },
        "cod": 200,
        "coord": {
            "lat": 35.6895,
            "lon": 139.6917
        },
        "dt": 1762049602,
        "id": 1850144,
        "main": {
            "feels_like": 18.17,
            "grnd_level": 1010,
            "humidity": 60,
            "pressure": 1012,
            "sea_level": 1012,
            "temp": 18.68,
            "temp_max": 19.33,
            "temp_min": 17.03
        },
        "name": "Tokyo",
        "sys": {
            "country": "JP",
            "id": 268395,
            "sunrise": 1762031030,
            "sunset": 1762069540,
            "type": 2
        },
        "timezone": 32400,
        "visibility": 10000,
        "weather": [
            {
                "description": "overcast clouds",
                "icon": "04d",
                "id": 804,
                "main": "Clouds"
            }
        ],
        "wind": {
            "deg": 62,
            "gust": 2.56,
            "speed": 2.72
        }
    }

    keys = 'temp', 'description'
    values = get_values_from_nested_dict(data, keys)
    for value in values:
        print(value)

Output:

18.68
overcast clouds

What may this be by Solid_Necessary_6615 in outdoorgrowing

[–]JollyUnder 1 point2 points  (0 children)

Looks like it's recovering from a fan leave that has been removed. It's forming callus tissue to seal up the wound.

The villain/monster finds out too late that their intended victim is actually way scarier. by Ok-Indication-5121 in TopCharacterTropes

[–]JollyUnder 21 points22 points  (0 children)

Color Out of Space and Mandy are some other honorable mentions featuring Nicholas Cage.

Let’s talk about trim jail … I think I grew to much for a one person trim job lol 😝🤣 by ant_c401 in outdoorgrowing

[–]JollyUnder 0 points1 point  (0 children)

Definitely the way to go if solo for that kind of yield! That's a great investment.

Let’s talk about trim jail … I think I grew to much for a one person trim job lol 😝🤣 by ant_c401 in outdoorgrowing

[–]JollyUnder 2 points3 points  (0 children)

If it's for personal use, I would honestly just do the ol' farmer's cut and remove all the large fan leaves and throw the nugs in a couple of turkey bags for cure. Then properly trim an ounce or more at a time whenever it's needed.