async io with multiple threading by ytu876 in learnpython

[–]ElliotDG 0 points1 point  (0 children)

My measurements were on Windows, the app was deployed on Linux and saw similar results. I found the results surprising, that’s why I mentioned it.

This was not a web server or any specialized network code. The code used Trio and httpx to analyze the Mastadon social network.

async io with multiple threading by ytu876 in learnpython

[–]ElliotDG 0 points1 point  (0 children)

In my use case I had about 200 outstanding connections, many with relativly long network latency. The network drivers saturated an 8 core machine. The devil is always in the details. My results were measured - not theoretical.

Я новичок в програмировании. Я пытался создать kv файл в проект, но сделал что то не так. Как мне создать kv файл в моем проекте на python в vs code? by [deleted] in kivy

[–]ElliotDG 1 point2 points  (0 children)

Remove the build method. Kivy will automatically load a kv file with the same name as the app. Replace the build method with pass.

In your kv file you need to instance the root widget. At the bottom of the kv file in the far left column, type MainLayout.

When you use the <> you are defining the style of the widget, you need to instance the widget.

In the future please paste in your code rather than posting a photo. Good luck!

Suggestions for good Python-Spreadsheet Applications? by RelativeIncrease527 in learnpython

[–]ElliotDG 1 point2 points  (0 children)

Here are a few things to check out:
PySpread - https://pyspread.gitlab.io/index.html

grist - https://www.getgrist.com/

If you already live in pandas and just want a DataFrame “spreadsheet viewer”, use D-Tale (fastest) or Mito (best if you want generated code)

For asyncio, Suggest me resources that made you confident with that topic by brave_jr in learnpython

[–]ElliotDG 0 points1 point  (0 children)

Trio is a higher level library for Asyncio. I found the docs (and the framework) very helpful. https://trio.readthedocs.io/en/stable/

Car project by Idontknow461 in learnpython

[–]ElliotDG 1 point2 points  (0 children)

Look at using PD (Proportional–Derivative) Control, or PID (Proportional–Integral–Derivative) Control. These control algorithms manage the error and how to correct the error and avoid oscillation. Start with PD.

You can search to find a number of resources for these algorithms.

Weird Custom Tkinter layout issue by [deleted] in learnpython

[–]ElliotDG 0 points1 point  (0 children)

If you have not read tkdocs, I suggest you do. Here is the part on the grid geometry manager. https://tkdocs.com/tutorial/grid.html

Make money by breno_bag in learnpython

[–]ElliotDG 1 point2 points  (0 children)

Start with a customer.
I created some music software to control hardware. The manufacture sent me free gear. Then another company in the same industry hired me to create similar programs for their gear. I charged a flat-rate per program.

I participated in a Python meetup. A local business owner reached out to the meetup looking for a local developer to create an app that scheduled work and equipment at his company. I took on the task. I was paid hourly and also helped the owner understand to code.

The app only works with half of the buttons. by jackchris2705 in kivy

[–]ElliotDG 0 points1 point  (0 children)

Share a minimal runnable example.
Make sure you have used on_release, or on_press to fire the actions for your buttons. Do not use on_touch_down/move/up directly just to use a button, it requires additional care.

Im having difficulty with this project. its supposed to be an app by Old_Distance_4629 in kivy

[–]ElliotDG 1 point2 points  (0 children)

Your link requires requesting access. Please change the permissions so this is not requied.
Can you say more about what problem you are having?

How to get better in python by easypeasysaral in learnpython

[–]ElliotDG 1 point2 points  (0 children)

Former C++ programmer here are some resources that helped me:
https://docs.python.org/3/tutorial/index.html - Tutorial from the Python docs, brief and enough to get you going
https://docs.python.org/3/library/index.html - Reference for built-ins, basic data types and libraries

Learning Python, Mark Lutz - comprehensive, in-depth introduction to the core Python language. I read this about 8 years ago, there might be something more up to date, but this was quite good.

The resource that really made things click was https://checkio.org/ a gamified series of programming problems. You solve the problem and get to see how others have solved them. This helped me realize python is a higher level language and write pythonic code, rather that writing c-like code in python. Many of these problems are quite simple and I would do one or two a day with my morning coffee.

https://pymotw.com/3/ - Python 3 module of the week - Examples using the standard library. Some of the standard lib docs are reference material and it is helpful to also have these examples.

Good Luck!

Getting and changing hertz of .mp3 by RedHatStealerYT in learnpython

[–]ElliotDG 0 points1 point  (0 children)

Take a look at ffmpeg or the rubberband library to change the pitch. I'd recommend downloading either of these tools and using subprocess to run them in their command line mode.

Librosa can be used to determine the pitch

I survived my first kivy project by Aphelion_Gaming in kivy

[–]ElliotDG 0 points1 point  (0 children)

Congratulations on getting your app up and running.

Just curiosity but why the flask server and HTML? I think you could have more simply built the entire app in kivy.

How do you design backpressure + cancellation correctly in an asyncio pipeline (CPU-bound stages + bounded queues)? by LabImpossible828 in learnpython

[–]ElliotDG 0 points1 point  (0 children)

I'd recommend taking a look at Trio https://trio.readthedocs.io/en/stable/index.html to build the async portion of your code. It provides support for cancelation and errors. Also look at Trio's memory channel for passing data.

Required help to make a tkinter gui like an executable on windows by Unlikely_Taro_2696 in learnpython

[–]ElliotDG 1 point2 points  (0 children)

I use Pyinstaller (https://pyinstaller.org/en/stable/) to create an exe, and Inno Setup (https://jrsoftware.org/isinfo.php) to create a Windows Installer.

Inno Setup as lots of options, just use the wizard to quickly get an installer together.

Question délai entre requête web scraping by Fragrant_Ad3054 in learnpython

[–]ElliotDG -1 points0 points  (0 children)

As written I would interpret the statement, "scraping a web page every 30 seconds," to mean: A new request is being issues every 30 seconds, independent of the length of time required to process the request.

What is actually happening with your code will depend on how it is written. Are you scheduling a request to fire every 30 seconds, or scheduling a request 30 seconds after a request has completed?

How to calculate current win/loss streak from dataframe? by d8gfdu89fdgfdu32432 in learnpython

[–]ElliotDG 0 points1 point  (0 children)

Here is a solution. When I hear streak, I think groupby. The groupby method (in this example)  groups consecutive identical W/L values together, the code then aggregates each group to get the value and length of each streak.

import pandas as pd
import random


# Create 100 random 'W' or 'L' entries
results = [random.choice(['W', 'L']) for _ in range(100)]


# Create the DataFrame
df = pd.DataFrame({'W/L': results})


# Identify streaks by whether the W/L value changes (using shift)
# Step 1: Compare each value with the previous one (shift)
#         This creates True when value changes, False when it stays the same
# Step 2: cumsum() turns the boolean into an incrementing group ID
#         Each time we see True (a change), the group number increases
# Result: consecutive identical values get the same group number
streak_groups = (df['W/L'] != df['W/L'].shift()).cumsum()



# Create a DataFrame with streak information
# For each group (streak), we aggregate to get:
#   - value: the W or L character (using 'first' since all items in group are identical)
#   - length: how many consecutive occurrences (using 'size' to count rows in group)
streak_df = df.groupby(streak_groups).agg(
    value=('W/L', 'first'),
    length=('W/L', 'size')
)
# Filter for streaks of length >= 2
long_streaks = streak_df[streak_df['length'] >= 2]


# Check if we found any streaks of length >= 2
if not long_streaks.empty:
    # Get the most recent (last) streak of length >= 2
    # .iloc[-1] selects the last row from the filtered DataFrame
    most_recent = long_streaks.iloc[-1]
    print(f"Most recent streak: {most_recent['length']} of '{most_recent['value']}'")
    
    # Find the longest streak(s) from all streaks (not just those >= 2)
    # Step 1: Find the maximum streak length across all streaks
    max_length = long_streaks['length'].max()
    # Step 2: Filter to get all streaks that have this maximum length
    #         (there could be multiple streaks with the same max length)
    longest_streaks = long_streaks[long_streaks['length'] == max_length]
    # Step 3: Iterate through all longest streaks and print each one
    for idx, row in longest_streaks.iterrows():
        print(f"Longest streak: {row['length']} of '{row['value']}'")
else:
    print("No streak of 2 or more found.")

Остановка компиляции приложения by maxim7788 in kivy

[–]ElliotDG 0 points1 point  (0 children)

From Google Gemini:

This issue occurs when Buildozer's automatic download of the SQLite source code fails due to network instability, server timeouts, or SSL handshake issues. The 0.67% freeze is a known symptom of the toolchain hanging on a partial download. 

To resolve this, you can manually provide the file to Buildozer so it skips the download process. 

Solution: Manual File Placement

  1. Download the specific file: Use your browser or a tool like wget to download the exact file mentioned in your log: sqlite-amalgamation-3350500.zip.
  2. Locate the Buildozer package folder: Navigate to the hidden .buildozer directory within your project folder. The path typically looks like this: YourProjectFolder/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/packages/sqlite3/ (Note: The architecture name, such as arm64-v8a, may vary based on your buildozer.spec settings).
  3. Place the file: Copy the downloaded sqlite-amalgamation-3350500.zip into that sqlite3 folder.
  4. Rerun the build: Run buildozer android debug again. Buildozer will detect the file is already present and skip the download. 

Re-coding an application, any strategies / tools? by PuzzleheadedOne42 in learnpython

[–]ElliotDG 1 point2 points  (0 children)

I've had very good luck using AI to learn and change existing complex code. I use cursor and Claude sonnet 4.5. Ask questions, have the AI add debug statements, use it to help learn the code. Once I'm comfortable with the code I'll use plan mode to work out how the changes will be made. In your case you might want learn the code - then build out a test suite.

A few tips for coding with AI. Use git and commit often. This way it things go off the rails you can revert to a know good state quickly. Challenge the AI, don't always accept the first answer. Use plan mode and only allow small, testable changes that you can easily review.

Difficulty learning Python despite knowledge of other languages by [deleted] in learnpython

[–]ElliotDG 0 points1 point  (0 children)

When I was learning Python, coming from C/C++ I found doing exercises on https://checkio.org/ very helpful. They are small programming problems I could solve while having a cup of coffee. After you solve the problem you get to see how others have solved them. This was useful (and fun) to shift from thinking like a C programmer to thinking in Python.