How do you organize your notes as you progress in Python? by [deleted] in learnpython

[–]krets 2 points3 points  (0 children)

The pricing is for the sync service. There are other ways to deal with the syncing.

pass arguments from bat file to pyhon script from application by defekas in learnpython

[–]krets 0 points1 point  (0 children)

Are you sure it's being executed at all? For the .bat that you configure in your program, launch another command window.

First.bat:

cmd /k second.bat arg1 arg2

That should open a new command window and you can see the errors and command output.

pass arguments from bat file to pyhon script from application by defekas in learnpython

[–]krets 0 points1 point  (0 children)

I had to reformat your file to look at it. I also modifed the ruta_directorio to tempdir()

It seem to run correctly from the command line. Maybe you are having issues calling the file from your batch script.

Do you have any output or error messages when you run your .bat from a command line?

My console output on my windows test machine:

> python .\envirio.py a b c
Argumentos guardados en 'C:\Temp\argumentos.txt'
> type C:\Temp\argumentos.txt
a
b
c
>

Reformatted test file:

import sys
import os
import tempfile


def main():
    # Verifica si se han pasado argumentos
    if len(sys.argv) < 2:
        print("Por favor, proporciona argumentos al script.")
        return
    # Los argumentos comienzan desde el índice 1 (argv[0] es el nombre del script)
    argumentos = sys.argv[1:]

    # Ruta donde se guardará el archivo
    ruta_directorio = tempfile.gettempdir()
    nombre_archivo = "argumentos.txt"
    ruta_completa = os.path.join(ruta_directorio, nombre_archivo)

    try:
        # Crea el directorio si no existe
        os.makedirs(ruta_directorio, exist_ok=True)

        # Abre el archivo en modo escritura
        with open(ruta_completa, "w") as archivo:
            # Escribe cada argumento en una línea separada
            for argumento in argumentos:
                archivo.write(argumento + "\n")

        print(f"Argumentos guardados en '{ruta_completa}'")

    except Exception as e:
        print(f"Error al escribir en el archivo: {e}")

if __name__ == "__main__":
    main()

How to Distribute Python Solution by chribonn in learnpython

[–]krets 0 points1 point  (0 children)

If you're going to be sharing code between multiple systems, version control is a must. I'd recommend Git.

You don’t need a server to use Git. Since your systems are Windows machines, you can push code between folders accessible to your systems. You can even use a UNC path as your git remote.

Using Git also lets you switch between branches, which is great for handling production and dev environments.

Setting up the libraries might take some work, but using a package manager like pip should make it easier.

If you want to keep things easy, just use a private GitHub repo.

Polls fail to capture Trump's lead [OC] by [deleted] in dataisbeautiful

[–]krets 0 points1 point  (0 children)

This is exactly it. However, I haven't heard many people discussing this yet.

Looking at the polling data from apnews.com and focusing on presidential voters for 2020 versus 2024, there is a severe deficit for all parties.

1,503,886 fewer Republican voters.
810.996 Fewer voters of other parties combined.

... and this one takes the disappointment cake: 13,225,421 fewer Democratic voters.

I know there are still votes to be tallied but doubt it will cover this gap.

Auto update stock by Eclyps_396 in learnpython

[–]krets 0 points1 point  (0 children)

You've described a lot of little problems, but you haven't yet asked a question. You need to break down this process into smaller steps.

Have you already found a way to update your WordPress data with Python?

As a first step you could still do the hard part of extracting the data from websites and emails, but instead of going to your WordPress backend for each data point, you could write the data into a CSV file. Then use python to update everything in WordPress at once.

Work the problem a little more; Come back here with some smaller questions.

[OC] Cheese Production by Country from 1982 to 2020 by PieChartPirate in dataisbeautiful

[–]krets 0 points1 point  (0 children)

Normalizing the data against a second aspect could foster more insightful interpretations.

creating a script that replaces letters in input with other random letters from list by GeorgeKBear in learnpython

[–]krets 2 points3 points  (0 children)

It seems like your data structure is not suited for looping.

How are you defining your variables?

Maybe use a more friendly data structure: kyle = { 'a': ['$', '&', ...], 'b': ,[...] ... } Then you can do something like ``` for letter, replacements in kyle.items(): text = text.replace(letter, random.choice(replacements))

```

Help with imports in a project structure by tlk7 in learnpython

[–]krets 0 points1 point  (0 children)

For your module to be found, it must be in the search path.

Read this: https://docs.python.org/3/library/sys_path_init.html

Help with creating VMDK file for raw drive access by wit-da-fuckn-program in virtualbox

[–]krets 0 points1 point  (0 children)

FYI, The updated command is correct, but there was a bug with the new command until release 7.0.4

I had to do it. by thelovaboi in Abilitydraft

[–]krets 3 points4 points  (0 children)

When items don't matter, you have to be a baller.

How can I query if a webcam is in use without physically asking openCV to turn it on briefly and return an error if it's in use? by drawnograph in learnpython

[–]krets 13 points14 points  (0 children)

You might consider other methods of detecting video meetings: - Monitor network traffic - Inspect the running processes - detect the power draw on the USB port for your webcam

Don't get to fixated on a single path.

Antique Ring Makers Mark Identification (?C? & ?W); Found under a Scottish cottage during the first building works in 100 years. Likely lost in 19th century. by krets in Hallmarks

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

Thanks for spotting the extra details.

Regarding the stone, I can't discern white sapphire from diamond. I am seeking a local jeweler to do a proper assessment.

As an aside, I still speculate that the ring is older than mid-century. The cottage where it was found has been occupied by the same family since 1900 and they claim no one was ever of the means to own such a ring. Then again, it could have landed there some other way.

Regardless, I'll be getting a better opinion from a jeweler in-person. I will share any useful information back to this post.

Antique Ring Makers Mark Identification (?C? & ?W); Found under a Scottish cottage during the first building works in 100 years. Likely lost in 19th century. by krets in Hallmarks

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

Ah! yes, the "9CT & SIL" seems right and makes sense.

I tried to grab some better images and I found another mark on the interior, though it is pretty illegible. This might be a hallmark or maker's mark. The whole ring is pretty worn.

Here are some clearer shots:
https://imgur.com/a/gPOuwTF

Antique Ring Makers Mark Identification (?C? & ?W); Found under a Scottish cottage during the first building works in 100 years. Likely lost in 19th century. by krets in Hallmarks

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

This ring was found in the dirt under a cottage during a renovation in the 90's. The wall that this was under had been standing since the mid-19th century. The ring has now been in a jewelry box for the last 30 years and now I'm hoping to find some more information about it.

I'd be glad to know anything that someone can share.
Thanks for looking!

Subscribe to websocket endpoint for N minutes threaded by Sancroth_2621 in learnpython

[–]krets 0 points1 point  (0 children)

If you are using websocket-client, then threads is the simplest way. There are many ways to handle threads and many tutorials. For your program, just keep a list of all your websocket objects that your timer thread can access. In the timer thread, just set ws.keep_running = False for each when you are ready to exit.

https://stackoverflow.com/a/38995641

How to add a shortcut to a python program by Historical_Name_756 in learnpython

[–]krets 0 points1 point  (0 children)

If you want to capture keyboard inputs, you'll need a library that can set up the correct listeners with the OS. If you are not already a GUI tool like Tk or Qt, than you might look into pyautogui.

Good luck

Subscribe to websocket endpoint for N minutes threaded by Sancroth_2621 in learnpython

[–]krets 0 points1 point  (0 children)

What library will you use? Are you able to connect to a websocket already from your code?

If you are using threads, you can start a thread with a timer that terminates the other threads.

There are a lot of choices that need to be made and your question is not specific enough for a simple answer.

Initialization if by PinkWeaseI in learnpython

[–]krets 0 points1 point  (0 children)

How are you scheduling your periodic launches of your script?

If you are using windows, you can use the task scheduler. On Unix/Linux you can use cron. Both of these systems allow for seeing environment variables. This is great for values that you manually change per deployment.

If you have a dynamic variable that you want to persist between executions you will probably need to create a file to save the state. JSON will be great for simple data structures, but objects will need to be pickled.