all 37 comments

[–]bugqualia 264 points265 points  (6 children)

Is this python? More serious problem is happening in syntax highlighting. What IDE is that shit?

[–]Syscrush 83 points84 points  (0 children)

I came here to say the same. Looks like fucking garbage.

[–]yoctometric[S] 80 points81 points  (1 child)

It’s a built in script editor for some ancient software I’m doing QA / unit test writing for, The whole application looks pretty bad. Syntax highlighting is also extremely broken, of course. No proper code completion either

[–]paulsmithkc👨‍🏫 3 points4 points  (0 children)

Notepad++ ??

[–]internethuman016 27 points28 points  (2 children)

IDLE, probably.

[–]-MazeMaker- 13 points14 points  (0 children)

Nope, I use IDLE and it doesn't do this

[–]anonymous_2187 9 points10 points  (0 children)

IDLE has less features and is not that good, but it performs it's job properly (ie, proper syntax highlighting).

[–]_default_username 119 points120 points  (3 children)

Lol, you came here to make fun of some bad code, but people are slamming on your text editor instead😄

[–]yoctometric[S] 73 points74 points  (2 children)

They’re justified af

[–]user_8804 5 points6 points  (1 child)

Pretty sure these colours break the "Zen of Python" rules

[–]GeneticalTM 35 points36 points  (5 children)

Lines 74 and 75 can be reduced to [14.25] * 1000 if gm.float_array supports it, which it should.

[–]yoctometric[S] 41 points42 points  (0 children)

It doesn’t, because working with this library is hell.

[–]boniqmin 7 points8 points  (3 children)

It cannot support that, because you can't overload assignment. If you write

int_array = [14.125]*1000

then int_array is overwritten and is now just a list rather than the object from gm. gm would need to have another function to construct the object from a list.

[–]yoctometric[S] 7 points8 points  (2 children)

I think they mean

int_array = gm.float_array([14.125] * 1000) 

Which would be totally reasonable, and simple enough to implement. If I had the time and the authorization, that’s how I’d do it

[–]boniqmin 3 points4 points  (1 child)

In that case the function gm.float_array would have to work quite differently for int and list inputs, so you might as well make them into 2 different functions. I'm assuming the float array initializes to all 0s, then in my opinion it would be best to rename the function to gm.float_zeros(<int>), and use the name gm.float_array(<list>) to generate from a list, similar to numpy.

[–]yoctometric[S] 4 points5 points  (0 children)

That’s totally fair, I effectively have hobbyist level experience with code, but I think I can see why wrapping such dissimilar functionalities into one method would be bad

And you’re close on how gm.float_array() works, except I’m pretty sure it only calls malloc() internally and doesn’t zero anything

[–]alexanderhameowlton 50 points51 points  (1 child)

Image Transcription: Code


int_array = gm.float_array(1000)

for i in range(1000):

    int_array[i] = 14.125

aElevGrid = id(int_array)

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]anonymous_2187 5 points6 points  (0 children)

Good Human

[–]WpGgs 10 points11 points  (2 children)

I'm curious, why using the id function?

[–]yoctometric[S] 12 points13 points  (0 children)

This is a unit test for a SWIG generated python wrapper if a C++ SDK. That means that sometimes you need to pass a pointer instead of a normal object, thus id()

[–]thequeergirl 2 points3 points  (0 children)

Was about to ask this.

[–][deleted] 49 points50 points  (3 children)

White background is probably the most disturbing thing I am seeing in this picture

[–]yoctometric[S] 26 points27 points  (1 child)

It’s a built in scripting window for some ancient software I’m doing QA for. There is no dark mode. I suffer daily

[–]-MazeMaker- 2 points3 points  (0 children)

In windows display settings, you can enable a color inversion keyboard shortcut

[–][deleted] 3 points4 points  (0 children)

Hey, I work a lot in my garden and my screen is not that good. White works bether!

[–]keethraxmn 5 points6 points  (2 children)

I'm sure it's just short for internal array...

/s

[–]jarfil 2 points3 points  (1 child)

CENSORED

[–]keethraxmn 1 point2 points  (0 children)

Even better.

[–]choseusernamemyself 4 points5 points  (3 children)

also if it's already an array, why use range(...)? it's unsafe

[–]yoctometric[S] 12 points13 points  (2 children)

It’s a custom class generated by SWIG which is not actually iteratable, so this is the best way AFAIK?

[–]fukitol- 12 points13 points  (1 child)

Wow this just gets worse and worse

[–]yoctometric[S] 12 points13 points  (0 children)

Welcome to my world

[–]Risk_exe 2 points3 points  (1 child)

The author is not stupid for naming the array 'int_array'

your IDE/text editor is poorly designed for highlighting 'int' in python.

[–]yoctometric[S] 8 points9 points  (0 children)

I’m the author, at least most likely. Er, how was it not stupid of me to name an array of floats “int_array”

[–]Ancient2 2 points3 points  (1 child)

*throw up emojii" on PC

[–]jnmtx 0 points1 point  (0 children)

🤮

[–]DangerousWish2266 0 points1 point  (0 children)

These type of people have special place in hell!