If you have to do if/elif/else... then so be it, but it from a first reading it sounds like you're trying to effectivly do something like the example given here: docs.python.org/3/library/bisect.html
@CoolCloud So you asked a question that wasn't the one you needed an answer to? That seems calculated to lower the probability of getting the answer you need somewhat.
So this morning I'm noodling with fastapi, pydantic, wtforms and mongoengine and rather liking what's happening. Fascinating stuff!
Morning Jon, how are things. We haven't emailed in a blue age. Now I'm in Hastings the logical place to meet for a pint would be Ashford. How doable is that for you?
@CoolCloud that's a good idea. It seemed to me you were grasping for the understanding that elif is pretty much syntactic sugar for nested ifs that avoids multiple levels of indentation. I'm guessing the class is seeking to have you understand the need to indent with nested ifs so you appreciate the value of elif when they produce it out of a hat, but I'm just guessing.
As I said, elif is just syntactic sugar. Your teacher has a point, but doesn't appear to be teaching the language particularly thoroughly (not uncommon nowadays).
I couldn't really tell what your interpretation was. That would ding you in providing written answers, but I get the impression you're being groomed for a multiple choice question like "elif is used in" and where the required answer is "nested ifs". Blerch.
Haven't been doing a great deal of that myself as I too have the 15-second commute. I'm supposed to visit our Zurich office asap a year ago, but that hasn't happened yet.
@CodyGray @MisterMiyagi I'm sorry for my bad description. I really have trouble with descriptions. Here is a proper summary.
The python code downloads and unzips the files. The game was written in C++, so interacting with any element in the game would use C++. Basically, the game has been modified so that it shows download progress in game. The python code when it is downloading outputs to the console. The main Dev was asking, instead of the python code outputting to the console, can it interface with the c++ code? So the c++ takes the download progress from the python code and shows it in game.
@CodyGray that is what I was trying to say first. When the game exe launches it calls something in the folder, the main Dev said it's a DLL. This this checks if the game folder has all the right files. If it does not, the python exe is called to download the file. How would the c++ code read from here on?
It's kind of a gnarly problem. You want to communicate with the code, written in C++, in a running process? Presumably the game is what triggers the execution of a separate Python process? In that case the best you can do is agree some protocol that has your Python program output a chunk of data, terminated with a newline, periodiically to indicate current progress. Would that do?
Yeah, that's basically what I'm suggesting. The Python program would write that data (in an agreed-upon format, since you control both programs) to its standard output stream. The C++ program, which launches the Python program, would be given a handle to the output stream of its child process, and it could read the output of the Python program directly from that stream.
That isn't necessarily the most efficient approach, but it requires minimal development work.
This is a great idea, but I don't know how to even code this. What is an output stream? What do you mean about protocol. Thank you guys for the ideas though.
Protocol is just some established format that both sides agree on, so they can understand each other.
An output stream is... what every program can output to. When you have a console application, its output stream is stdout, which gets redirected to the console window, resulting in the text that you can see in the console.
I don't even know what Python's built-in command to print/output a message is, but whatever it is, it sends that to the standard output stream.
Ok I understand. Let me explain to see if it's right. The python code would output in such a way that the c++ code understands. So it takes that output and then displays it.
I mean more that not every operation takes exactly the same amount of time. Some complete faster than others, so the progress bar is almost definitely going to jump. Unless you're just running a timer....
Some software produced by my company has progress bars that will routinely run backwards.
They get to 90% or 100%, realize there's more work to be done, and then jump back to 70%. Repeat again, and again, and again...
This is not software for which I have access to the source code, or this maddening behavior would have been changed a long time ago. Even if all I could do was replace the progressive progress bar with an indeterminate one.
heh... not sure if bad or not, but every time I see something that comes up computer wise with "time to install".. (or update or similar) . I just shove it to another virtual desktop
A couple of things wrong with that... One, it runs slower if it's running in the background, and will slow down your stuff if it's hitting the disk a lot (which is common for installers). Second, way too many applications don't properly handle multiple processes running during their installation. I'd be afraid of something getting corrupted.
@CodyGray based upon your experience, can you give an an ideal progress bar that would work for both my python and C++ code. The one I use right now uses some python modules which the c++ cannot access.
@roganjosh yup... took some voodoo... got it back to a state that was probably 2 minutes from where it should have been - but it's close enough... need to look at logs to see if there's anything in that 2 minutes that should be there... but that's not my job (might well become mine but it's my day off - so they can sod off)
@roganjosh ironically, the same guy that's "looking at it to fix it", is also the one the f*ed it in the first place... so could well be expecting a message later :p
@AndrasDeak I'm not in charge of hiring/firing who my clients use... were it me though... they'd be out the door pronto
@AndrasDeak heh... getting some pennies for correcting f* ups is always nice... just don't want 'em in the first place
as I said before ^^^, I've made 'em, everyone makes 'em...
still make mistakes and won't write perfect code... pretty damn sure I have the wits about me to double check what DB I'm doing truncate some_stable on though before executing it :p