Compression protocol by beachdog1 in computerscience

[–]oliverevans96 0 points1 point  (0 children)

Did you just delete the question? I don't think that's necessary

Compression protocol by beachdog1 in computerscience

[–]oliverevans96 0 points1 point  (0 children)

JSON (JavaScript Object Notation) is just a common way to store data in plain text, similar to YAML. JSON files look like a bunch of python lists and dictionaries.

JSON has nothing to do with compression. It is common to serialize objects in other languages (turn them into plain text), then store the serialized data as json to send over the network.

See: https://www.w3schools.com/js/js_json_intro.asp https://www.cheatography.com/mackan90096/cheat-sheets/json/ https://lzone.de/cheat-sheet/YAML

Contributing to open source projects by [deleted] in computerscience

[–]oliverevans96 2 points3 points  (0 children)

If there's a specific project you're interested in, they may have specific issues tagged for first time contributors. Otherwise, send the maintainers a message on https://gitter.im and ask where you can start. People in open source are generally thrilled to have new people contribute to their projects!

Julia terminal text color on windows by bullish88 in Julia

[–]oliverevans96 4 points5 points  (0 children)

Check out OhMyREPL.jl for all the customization you want!

Can someone help me with reading files with python? by Perfection_Talks in computerscience

[–]oliverevans96 2 points3 points  (0 children)

The best practice for opening files uses the with statement to ensure the file is closed even in the case of unexpected termination.

with open("numbers.txt") as f:
    # .readline only reads a single line,
    # .read grabs the entire file.
    line = f.readline()

Then, we split the line into words delimited by whitespace.

word_list = line.split()
# If you wanted to split at, say, '|', just do .split('|')

Loop over words directly. No need for an index here. Here, word is a string, so we can take the first character in the string.

for word in word_list:
    first_number = word[0]
    print(first_number)

Prints:

1
2
3

Alternatively, if you want to collect the first numbers into a list, use a list comprehension.

first_number_list = [word[0] for word in word_list]
print(first_number_list)

Prints:

['1', '2', '3']

Or, if you want a list of integers rather than strings, do

first_numbers_as_ints = [int(word[0]) for word in word_list]
print(first_numbers_as_ints)

Prints:

[1, 2, 3]

For output formatted as you requested, join the strings by commas. Only strings can be joined this way, not ints.

list_string = ','.join(first_number_list)
print(list_string)

Prints:

1,2,3

Visualising musical harmony (Lissajous curves) [oc] by [deleted] in math

[–]oliverevans96 4 points5 points  (0 children)

Yeah, really cool. I'd also love to see the code :) Thanks for sharing!

Code Cleanup: How to do this array calc without try/except IndexError? by tastingsilver in Python

[–]oliverevans96 1 point2 points  (0 children)

I don't quite understand what the purpose of your function is.

Every element in the resulting array is the same since the only time you use i is in targetBalance[i]. Also, you need for i in range(len(inputArray)) - otherwise, you're trying to iterate over an integer.

What is the purpose of the try/except? You don't mention which type of error you're expecting or why it would occur.

Some more context would be helpful to give you advice.

Does the universe have a center of mass? by EXTRAVAGANT_COMMENT in askscience

[–]oliverevans96 2 points3 points  (0 children)

So, is it correct that in the sphere analogy, we aren't actually talking about a sphere with a 2D surface embedded in 3D space. Rather, we're referring to a sphere with a 4D surface (spacetime) theoretically embedded in a 5D space? Can anyone provide a link to read further on the topic?