2021-03-22 21:36:51

So, I created this program of printing the numbers from one to ten using while loop, except it for some reason keep crashing NVDA of all things.

spam = 0

while spam < 11:
    print(spam)

Is this creating an infinite loop? If yes, then why exactly is it crashing NVDA? Did anyone suffered this problem before?

I did restarted NVDA with NVDA + control + n, but after a while, it crashes once more, and does not work until the windows is restarted.

This is so strange, I have caused many infinite loops in c, but not one of them crashed the screen reader.

2021-03-22 21:40:27

when nvda gets too many things to speak pretty quick it crashes,, Also you forgot to put spam+=1

2021-03-22 21:45:20

Because spam is still at 0 and you keep printing
This might work.
spam = 0
while spam <11:
    print(spam)
    spam +=1

2021-03-22 22:01:41

Yeah, this is a long-standing NVDA bug.  If you flood the terminal, NVDA can crash.

It will be fixed in a version or two.  There's an outstanding PR being worked on to finally improve this situation, but it's a whole thing to do with subprocesses and locks and whatever else that broke it for people and so on.  I don't have the link handy, but there is at least finally hope that the dark days of omg the C++ compiler errors took out NVDA will come to an end.

My Blog
Twitter: @ajhicks1992

2021-03-22 22:02:58

I slapped my forehead after reading the replies. I swear, learning a new language can be so embarrassing sometimes.

2021-03-22 23:06:05

@5
Never be embarrassed mate. We've all been there, and most of us still are.

-----
I have code on GitHub

2021-03-22 23:56:05

@6:
Thanks for the encouragement.

2021-03-22 23:58:01

Oh I've certainly made those kind of mistakes in my time too. I'm not sure if you're to for loops yet, but this could also work.

for spam in range(11):
    print(str(spam))

2021-03-23 00:18:07

@8
No need for str for what that's worth.

My Blog
Twitter: @ajhicks1992

2021-03-23 00:46:14

@9: Oh, thanks, I always include it just in case, unless I *know* the value is going to be a string.

2021-03-23 09:47:55

Actually, another interesting thing happened with the dynamic variables.

There was this program which was supposed to print three things depending on what integer value is stored in a variable.

I forgot that, and thus, the only third condition got triggered. Until I remembered that I have to turn it into an integer, by using int()

2021-03-23 10:10:45

yeah... Print could handle integers just fine, The only case where you may require using str() Is if you are linking another string with it, Or If using another functions than print that requires strings only.

2021-03-23 14:02:15

@10.
It shouldn't matter anyway, since print will automatically coerce the value to a string. Unless you are concatenating, say a string with an int, that shouldn't be an issue. But I guess that to be fair, even in the concatenating case there are f strings for example. Or format.

Paul

2021-03-23 16:24:49

If you're having to randomly add int() to variables that should already be ints, the program has some other bug that's making them not ints and you should figure out what it is.

My Blog
Twitter: @ajhicks1992

2021-04-04 13:22:13

How do you guys stop vs code from screwing the indentation?

Currently, when I use loops, or if else statements, each time I enter vs code keeps adding spaces. As a result, my statements are getting nested inside each time I enter.

While this thing gave me a headache with first few programs, this problem does not occur when I actively look out for the spaces. But considering how many people program in python here, I thought that it might be worth asking at least once, to see maybe you guys have the same problem or not, and whether you have any solutions to this or not.

I do have both format editor and linter for python configured to use within vs code, so that is not the problem.

I remember Camlorn warned me once, that you shouldn't rely on editors all the time. At that time, I did not understood what exactly he was referring to, but I think I understand what he was talking about.

2021-04-04 16:55:37

once you get used to it, it saves you doing the indentation yourself. Each time you write a if, for, while, etc., you want to indent the next line anyway, so it saves you the effort.

Personally, I have indentation reporting set to beeps while I use vs code, so it helps remind me the auto-indentation is happening.

But, if you really want, you can turn it off. Just google it.

2021-04-04 18:11:41

Yeah, I don't know how to turn that off.  I want it on.  It's somewhat nice in Python, and much nicer in C/C++ where everything indentation is just handled. Killing the "I must press tab" reflex is bleh, but doable enough after a bit.

Saying not to always rely on the editor is definitely something I would say.  There's lots of cases where your autoformatting will screw you and you have to at least be aware of what's going on, at least in a professional context.  In fact at some point I need to write a line length ruler for VSCode so I can switch off Notepad++ at work.  But this particular feature is one of the things we're missing as blind people, not one of the things we should get rid of.  At least, if I understand what you're complaining about.

My Blog
Twitter: @ajhicks1992

2021-04-04 19:52:37

The problem is that vs code is inserting spaces at the wrong place. I don't have any problems with formatting the code, since I did formatted my c and JavaScript code. But I needed something to solve this issue, since it is making the time to write programs increase.

That, and it is kind of distracting to keep an eye on spaces after each enter.

2021-04-04 20:02:10

That sounds like a bug, and you probably need to report it upstream.  I would try disabling the extensions entirely and seeing if it goes away.

My Blog
Twitter: @ajhicks1992

2021-04-05 07:29:56

@15
When you say screwing the indentation, what do you mean?

You should have to outdent (control ]) when you've reached the end of your indented block, but other than that, it should just work as it should. The only time this doesn't work right for me is when raising exceptions for some reason, If I type RuntimeError(, and press enter it outdents rather than indents.

-----
I have code on GitHub

2021-04-05 12:54:05

@20:
Please read post 18, I explain the problem there in more detail.

Still, I'll try your command.

2021-04-05 14:42:27

@21
Either yuou don't, or I'm missing something. You only say it's putting spaces in the wrong place. What do you mean by that? Wrong line? Wrong file? Too many? Not enough? Indenting, Outdenting? Using tabs instead of spaces, or vice versa? I personally don't feel I have enough information to adequately address your question.

-----
I have code on GitHub

2021-04-05 14:56:57

as far as i know,  you need to press CTRL+left bracket and CTRL+right bracket to indent and outdent your code... it does not automaticly do the out denting for you... you need to apply it your self

best regards
never give up on what ever you are doing.

2021-04-05 15:28:13

@23
You're absolutely right. I doubt VS Code could even know when to outdent, or at least how to outdent reliably.

-----
I have code on GitHub

2021-04-05 16:04:49

yeah... outdenting with 100 % accuracy won't work to well... unless it's connected to your brain some how... then it would know when you want to end the block.

best regards
never give up on what ever you are doing.