Wikipedia:Reference desk/Archives/Computing/2016 September 10
Computing desk | ||
---|---|---|
< September 9 | << Aug | September | Oct >> | September 11 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
September 10
editIs there a "close tab and I mean it" keystroke ?
editThat is, one that won't let it pop-up a dialog asking if I really want to close the browser tab. I use Google Chrome on Windows 7, but would also be interested if such a keystroke exists, or can be set up, in IE, Firefox, or any other browser. Thanks, StuRat (talk) 14:01, 10 September 2016 (UTC)
- Ctrl-w tends to be the "close what I am doing without asking me" shortcut key for everything. It is also the "Where Is?" shortcut for many old Unix programs, so whenever I want to find something on a web page or find something in a text document, I tend to press Ctrl-w and suddenly realize that I've lost everything I was doing without any form of confirmation. 66.190.149.73 (talk) 16:25, 10 September 2016 (UTC)
- Ctrl-F4 works for me in Chrome under Windows 10 for the Wikipedia editing window (which gives a prompt when closed from the X). See Table of keyboard shortcuts. Tevildo (talk) 19:27, 10 September 2016 (UTC)
- Is that "Where is?" shortcut used in anything but nano and editors imitating it? I'm just curious. – b_jonas 11:47, 14 September 2016 (UTC)
Thanks, StuRat (talk) 22:39, 11 September 2016 (UTC)
Can python crash from adding just by having more lines?
editI am doing some procedural map generator on python, the program load, and the player can tell the program to change the size of the map that will be generated, tell the program to generate the map......
The program generated maps that had tiles of 16x16, but this didn't allowed the amount of detail a tile needed, so I decided to change the program to a 32x32.
The only changes needed to do it, was to change just one variable value from 16 to 32, and add the extra ifs needed to know what specific pixel of the 32x32 tile I will be generating and the colors they will have. This added 50000 lines to the program.
Anyway, after changing the single variable to 32, and just adding the extra ifs ("if your tile type value is X and you are at row A and column B of tile image you are generating, put rgb color Y,Z,W there"), the program crashs before starting.
What can be the problem of this?201.79.66.96 (talk) 19:33, 10 September 2016 (UTC)
- If you try to allocate more memory than is available, the Python runtime will throw a MemoryError which, if uncaught, will case the program to terminate. If you're not catching it, the runtime will print "MemoryError" on stdout as it exits. -- Finlay McWalter··–·Talk 21:13, 10 September 2016 (UTC)
- When opening the program from cmd, it just crash before opening (but not the cmd prompt) and it return no message.
- One example of the old code
if object.tile_list[colcheck][rowcheck] == '0': if whererow == 0 and wherecol == 0: pixels[(acol),arow] = (15,215,255) elif whererow == 0 and wherecol == 1: pixels[(acol),arow] = (15,215,255) elif whererow == 0 and wherecol == 2: pixels[(acol),arow] = (15,215,255) elif whererow == 0 and wherecol == 3: pixels[(acol),arow] = (0,138,85)
- This is part of the code, its the tiletype is 0 it generate the pixels colors on their specific place, on old code the ifs continued until elif whererow == 15 and wherecol == 15:, the new one goes up to elif whererow == 32 and wherecol == 32:201.79.66.96 (talk) 21:38, 10 September 2016 (UTC)
- What is "pixels"? It's not a list, because Python doesn't have multidimensional lists (you can have lists of lists, but that's not the syntax for them) and doesn't allow tuples as indices. I guess it's a dictionary (or equivalent), which does allow tuples as indices (which is what you're doing, despite that eccentric syntax you've chosen). And a dictionary even with millions of entries will work fine (again, until you run out of memory). Really, you're asking us to explain to you how a program works (or fails) but you've not shown us the whole program, leaving us guessing what it does. If you want real help, you'll need to come up with a minimal program that generates the problem you get (please don't post the whole program as it is). 84.92.175.198 (talk) 22:12, 10 September 2016 (UTC)
- When you say "more lines", do you mean "more lines of python source code"? Even then, even if you've decided to have some program write a massive Python program, that still shouldn't be an issue. I tested by having one Python program create another, million-line, program, and that program works fine. If that's what you're doing, it's a fairly odd thing to do - machine generating massive programs just to set or translate data like this is unlikely to be a sensible solution. -- Finlay McWalter··–·Talk 23:49, 10 September 2016 (UTC)
- Yes its more lines of python source code, anyway, I started to clean this part of the source code and the current method dont need all ifs, it made the program cleaner and the image generation faster, 16x times faster.
- Now the program instead of looking at every pixel of final image to see what it goes there, it just check the first pixel of the tile and instead of as some example pixels[(acol),arow] = (0,138,85), it has pixels[(acol)+2,arow+3] = (0,138,85), with +1 and +2 as some example being the X and Y coordenates on the pixel, and the acol and arow being the collumn and row the first pixel of this tile [0,0] is .
- In theory I didnt changed enought to make the program not crash, but it stopped to crash.201.79.53.232 (talk) 22:02, 11 September 2016 (UTC)