I wonder if we can change the consol script color for certain sentences , for easier debuging .
yes, just pass this to the OS:
In linux it changes with every terminal emulator, Xterm is very like the above dos color command, but it will not work in Konsole, or other terminal emulators.
i meant blender’s consol , how ?
Blender has no console, it uses the OS’s console.
oh , is there a way to change the colors - for specific sentences through python window in blender - of the OS’s console of blender ?
have you tried it ? did it work ?
you can use colorcodes.
print “\033[1;31m this text here is red”
.b
Just open up Blender, right click on the bar (by the start button) for the console, click properties, and you can change the color.
print “\033[1;31m this text here is red”
that didn’t work
Just open up Blender, right click on the bar (by the start button) for the console, click properties, and you can change the color.
thanks , but actually i want to get some specific lines green and others blue , not recolor it all .
3d, maybe it would be easier to use ‘*****’ and ‘####’ or ‘^-^’ as print lines either for what you are tracking, or just where ever you think you need them to help you track an error.
You know what I mean? You can also print out what is in your vars to help solve it too. Where ever a var changes, print it out ‘((( var-before )))’ and then ‘((( var-after)))’.
You will know where the error occurs. But change the ((( ))) to (( and then to ( or (* whatever so you know when you see it in the console, where the code stopped at in the script.
Hope I explained that well enough?
maybe it would be easier to use ‘*****’ and '####
thanks , but actually i use
“#############”
and
“____________”
and … etc …
and it is lately becoming confusing with long python scripts .
Nice Avatar 3D I like it much better than your old one
Once something is working then delete the self help for those functions. You dont need them anymore.
I have used this technique to track crap in code that was over 150 printed pages (the old IBM sql cobol code, lol). That was a short version. LOL.
Use the computer to help you, Print things like:
Entered spin that dude
vars :
Exit spin that dude
Then when those are working just comment them out in the script. It much easier then reading the dump.
I dont believe you can have color in the text in the console unless you went deeper into dos. I think. You only get the bare necessities, just like when you reboot?
Also, the tried and true is to ask someone else to look at the code…sometimes you just cant see it because you have looked at it for too long. And someone else may glance at it and start laughing and say, you forgot ‘.’ at the end!
This would be a great feature to have
Maybe you could combine it with a simple debugger?
Yes, “print” is a quick way to debug something, but it’s mainly for beginners, and should only be used to represent smaller pieces of information.
Additionally, sending a lot of information to the console will slow things down quite a bit.
What you really need to do here is display your debug in blender itself in real time (something you can’t even do with console), and to do that you either:
- Send your objects to a set of properties with their [D] marker active.
- Or, get a bit fancy and write your own debug class to send output to a Text property - and then you can have any color you want.I already wrote an instructional on how to do the former. You should take a look at it:
LOL, mainly for beginners? Thats funny. Thats why professional programming software has tracking of variables and step out, step in indentation,etc., Including C++.
Actually, you could just open a file in the script, and print out everything to it, adding whatever you need. You could set it to close and open every now and then, incrementing the file number, so you could read it while you were experimenting, too.
Then you will have a hard copy, so to speak, that you can track, instead of reading it from the console. Using D for debugging properties is helpful to an extent, to find the smaller errors, but you can’t get a screen output of every change for further investigation.
IMHO.
I do you one better. I set a DEBUG variable and then based on the value do the prints. The higher the number, the more print statements. Then I never have to go back and comment out or uncomment code…because, as we professionals know, you have a 50% chance in introducing an error every time you alter a line, even if it is only to remove the C from column 7
Blender has the rt: value which you can check. It can be set by the user pre-runtime in the Anim panel.
I don’t get the argument here. The “print” statement (in BGE Python) outputs to the blender command prompt. It doesn’t do anything else, especially not all the things you list as characteristics of “professional programming software”.
Actually, you could just open a file in the script, and print out everything to it, adding whatever you need. You could set it to close and open every now and then, incrementing the file number, so you could read it while you were experimenting, too.
Then you will have a hard copy, so to speak, that you can track, instead of reading it from the console.
I think I see where you misunderstood.
I’m not talking about having a “print out” of the data in a file, I’m just talking about the print statement that outputs to console.
Using D for debugging properties is helpful to an extent, to find the smaller errors, but you can’t get a screen output of every change for further investigation.
Heh, well, that was never a problem for me, because I know enough about what I’m programming to make logical assumptions as to where the problem might be. Then I use the techniques I described to show relevant data, in real time.
It works better than just dumping 3 pages worth of everything, and trying to find that one “needle in the haystack”. (and i’ts much faster too)
However, even when I need a “list snapshot” that shows data that can’t fit on [D] prop or a text object -> printing to console with the “print statement” (you know, like “print varName”) is still not a very good way.
I’ll have to check that out. Thanks.
Well if that works for you, great!
It works better than just dumping 3 pages worth of everything, and trying to find that one “needle in the haystack”. (and it’s much faster too)
Oh thats funny too, you kinda manipulate the data to suit your agenda, dint you.
Actually, you could just open a file in the script, and print out everything to it, adding whatever you need.
I love it.(copy paste is our friend)
But as we can see , there are many other options. Thats whats this forum is for. Options.
Sorry to have stepped on your toes, certainly didn’t mean to. I love your scripts.
PapaSmurf, you are correct. But there are ways around that challenge to, by having debugged debug statements.
What? No, I just use simple logic to focus my debug scope.
Sorry to have stepped on your toes, certainly didn’t mean to. I love your scripts.
Ha, ok, but I didn’t think you were stepping on my toes.
…Wait
Mmph!..is that you?..whoa wait, Mmph! are you actually p00f?
*How did he ever find out?
lol
nope, it is just the same old voices in your head… take a pill