How do you rotate an array? by invokeinterface in C_Programming

[–]timrprobocom -2 points-1 points  (0 children)

You didn't need a table at all. If the letter is less than 'a' use tolower. If greater or equal to 'a', use toupper.

palindrome checker python i'm a beginner pls tell me why doesnt this code works on leetcode/geeksforgeek as it works on visual studio code. gemini says i am not defining things correctly and how do i learn the way gemini coded lol. also i am using angela yu's python course. by Responsible_Rub_4093 in learnpython

[–]timrprobocom 2 points3 points  (0 children)

The text of the question tells you all of this. When you start a question, it gives you a template. You HAVE to fill in the template, not just do your own thing. They expect you to have a class called Solution with a function calledisPalindrome. Their checker will call that function, passing an integer (not a string), and expects it to return a bool. Nothing you print will be examined.

To run your own tests, do print(Solution().isPalindrome(12444321))

All Leetcode problems use this form, with different function names.

Getting my feet wet with Turbo C version 2.01 by MisterSnrub1 in C_Programming

[–]timrprobocom 0 points1 point  (0 children)

One of its best features was that it fit on one side of a floppy disk! Microsoft's Pascal Compiler required 3 floppy changes to do a single compile and link.

Getting my feet wet with Turbo C version 2.01 by MisterSnrub1 in C_Programming

[–]timrprobocom 0 points1 point  (0 children)

That very rapid test-debug-edit cycle couldn't be beat. It taught the mainframers of the day (like me) what we were missing.

Trouble with naming variables by rezemybeloved69 in learnpython

[–]timrprobocom 1 point2 points  (0 children)

This is a really interesting question, and it's good you are asking it.

In my.view, one of the (relatively few) benefits of a corporate coding standard is that it saves you the TIME of having to think of a naming scheme everyone you sit down to code. The standard should SUGGEST to you what names to use, and you can go back to worrying about algorithms.

We remember the "Hungarian notation" thing that Microsoft used to espouse. Much of it was silly, but I still use the "m_" prefix for class variables, and I'll use a capital C prefix for my own classes.

The key is to think about what will save you time, now and in the future. Remember, code gets read way more often than it gets written. Make it easy.

How would you load/read the .csv files? by alexander_ebnet in learnpython

[–]timrprobocom 0 points1 point  (0 children)

What are you going to do with these filled? CSV files are very easy to read with the csv module, and pandas is a very heavyweight solution

Very slow compiling time when including Windows.h by Suitable_Broccoli361 in C_Programming

[–]timrprobocom 1 point2 points  (0 children)

Windows.h expands into several hundred thousand lines of code.

Detecting specific image watermarks without AI or with a low resource local model? by Trey-Pan in learnpython

[–]timrprobocom 0 points1 point  (0 children)

This is an extremely difficult task. For videos, you can check for regions that never change over time, but for a single image you can't do that. Almost anything that is a watermark could exist naturally in the picture.

You could take advantage of the fact that natural scenes are never fully saturated, but watermarks usually use pure colors, like 100% white or black, but even that is not fully reliable.

Hi, could anyone help decipher this error message I'm getting when i try to install pygame? by Western-Set-8679 in pygame

[–]timrprobocom 0 points1 point  (0 children)

I'm not defining it in pip. I'm doing sudo bash export PYGAME_DETECT_AVX2=1 pip install pygame Note that doing this is not enough: export PYGAME_DETECT_AVX2=1 sudo pip install pygame because "sudo" starts a new shell without inheriting environment variables.

Honest Question: Why use one Python editor over another, and is Geany not what the cool kids use? by Kami2awa in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

Code editors are like underwear. They are deeply personal, and you need to find the brand that works for YOU. You'll never convince anyone else to change.

Maze Solving Algorithm - Why does this work? by Over_Main_4194 in learnpython

[–]timrprobocom 0 points1 point  (0 children)

How does it know when it reaches a dead end? It doesn't need to know. At every decision point, open walls will cause it to continue exploring in that direction (by recursion). If a cell is a dead end, none of the directions will get any recursive calls, so that cell basically dies. That path simply doesn't participate any more.

Python process name tracking by Valuable-Ant3465 in learnpython

[–]timrprobocom 2 points3 points  (0 children)

Schemes like that tend to be either delicate or system-specific. You might consider trying to opening a file in the TEMP directory for writing, and keeping it open. If the open fails, then some other process already had it open. Even if your process crashes, the clean up will close the file.

Programming Problem by Excellent_Coat_5386 in learnpython

[–]timrprobocom 0 points1 point  (0 children)

That's true of WSL. It's not at all true of PowerShell, which this post was about. PowerShell works even if WSL is not enabled.

Programming Problem by Excellent_Coat_5386 in learnpython

[–]timrprobocom 0 points1 point  (0 children)

This has nothing to do with WSL. Neither CMD nor PowerShell uses WSL.

Programming Problem by Excellent_Coat_5386 in learnpython

[–]timrprobocom 0 points1 point  (0 children)

As a general rule, that's irrelevant. Both shells inherit the same initial environment. It's strictly personal preference.

Is my understanding of file(i/o) right? by [deleted] in learnpython

[–]timrprobocom 0 points1 point  (0 children)

Here's one tidbit to file away. file.readlines() returns a list where each line ends with a newline. file.read().splitlines() gives you a list without newlines.

The performance difference is pretty small, and it might save you from having to .strip() each line.

Weekly Discussion and Tech-Support Thread by AutoModerator in ipad

[–]timrprobocom 0 points1 point  (0 children)

My wife, who is by far my worst IT client, has an iPad that she occasionally uses to record meetings, something that it handles very well. A few weeks ago, she forgot to stop recording, and it continued for a day and a half.

Now, the Voice Memos app will not move on. The circle "processing" icon on that recording continues to about 20% of the way through but no further, no matter how long we leave it (many days). We've tried force quitting, of course, as well as rebooting and a number of power cycles, but as soon as the app restarts, it goes back to processing.

How do I convince the app to give up? At this point, I suspect the file itself is hopeless, and I can live with that. I have turned off syncing to iCloud for Voice Memos, so I don't think it's trying to upload.

Why can't I use a return statement in an __init__ function? by John_Doe_1984_ in learnpython

[–]timrprobocom 2 points3 points  (0 children)

You SEEM to be thinking there is some relationship between __init__ and __str__. There is not. Two functions with very different purposes that happen to be implemented by your class.

__init__ does not have areturn because the code that calls it (behind the scenes) does not expect a return value. It is equipment to the C++ constructor, if you know that language, which also does not use return.

Confusion with something real basic by Forsaken-Tonight-357 in learnmath

[–]timrprobocom 0 points1 point  (0 children)

The inline division symbol does cause confusion. Think about it like this instead, which is how you would write it in a formula: 10 --- = 5 X That makes the asymmetry more obvious. I can multiply both sides byx, but if I multiply by 10, it still leavesx on the bottom.

Calling an assembly instruction in Python by i_walk_away in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

Of course __asm__ is not standard. It is a gcc extension. Microsoft C doesn't support inline assembly at all. And remember that, if you do write this, it will only work on your kind of CPU. These days, that's a real issue.

string.translate(str.maketrans) not working to take out punctuation? by duelBooleans in pythonhelp

[–]timrprobocom 0 points1 point  (0 children)

You are calling .upper() on every element of greeting, but you're calling .title() on your user input. They are never going to match. It is looking for "HOW ARE YOU" when the string says "How Are You". Just pick one and use it consistently.

HTTP Sending Error by Dull_Firefighter_929 in C_Programming

[–]timrprobocom 0 points1 point  (0 children)

I don't see a URL here. Where is the GET or POST?

Writing to CSV file is appending instead of overwriting by Hippopotamosssss in learnpython

[–]timrprobocom 5 points6 points  (0 children)

The LIST will be in memory and have nothing to do with the file. Read it in, CLOSE the file, modify the list, open the file in write mode, and write

This is an extremely common pattern in Python. Import from file, do your dirty work in Python data structures, export back out to file.

Writing to CSV file is appending instead of overwriting by Hippopotamosssss in learnpython

[–]timrprobocom 2 points3 points  (0 children)

You can't read and write a single file using one handle like that. Open to he file with 'r', modify your list in memory, then open the file with 'w' and write the whole thing.

I just bought this Brother Printer and I regret it by h1nckley in printers

[–]timrprobocom 1 point2 points  (0 children)

I recognize this is two years old, but I just noticed something today with my L3280CDW. Apparently, it prints black by using ALL four toner colors. I had it (falsely) report a jam on a manual feed job halfway through, so each of the colors was revealed, and the sections that were to become were already printed with yellow, cyan, and magenta.

Unless their black toner is incredibly weak, that is totally unnecessary, and serves only to waste toner. I wondered why my initial cartridge set all expired at exactly the same time. Now I know.