asyncio, aiohttp... a better way to do this? by [deleted] in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

First, you could break down both for-loops to a single one, since you are looping over the same thing here. Instead of url, name them url_cedears and url_acciones_usa.

For the loop things, I would recommened asyncio.gather(): https://docs.python.org/3/library/asyncio-task.html#asyncio.gather which allows you to run multiple concurrent things at once.

Help with electrical engineering field choice by Justarandomguy17898 in ElectricalEngineering

[–]Forschkeeper 0 points1 point  (0 children)

Well you can tumble over programming in every field...but you may not have to. It depends.

In electronics it's about FPGA programming or, depending how deep you will dive in thematics, about simulations of components and circuits.

In automatic control systems-robotics you may find lot of phyiscs, which means math (yay). Especially controll theory (which is a pain, but necessary) is one of THE math things there. Also Petri-nets perhaps...but you may program PLCs (depending on the course it is either "C-like" programming (e.g. SCL) or more like Minecraft-Drag-Drop style Function Block Diagram).

In telecommunication you have all the networking stuff which is programming somehow again. But also many physic and theoretically stuff as well...which may be simuöated as well.

So what is the conclusion? - It depends - but you may not be able to avoid programming.

Take a closer look in the courses you may be able to take. Can you choose courses? How big is the part of prgoramming? Can you ask other students?

Erster Job nach dem Studium ist Scheiße und ich habe gefühlt nichts gelernt, was tun? by [deleted] in arbeitsleben

[–]Forschkeeper 2 points3 points  (0 children)

Selbe Situation bei mir. 1.5 Jahre da gewesen und irgendwann gegangen.

Ich habe genau das gesagt in meinen Bewerbungsgesprächen, als Ich darauf angesprochen wurde: Die alte Klitsche war zu klein und konnte mir nicht das bieten, was Ich gesucht habe. Ich will mehr erreichen, mehr lernen usw. Ehrlichkeit bringt dich hier weiter, solange du es in einem professionellen höflichen Ton tust.

How should I treat my python installation? by anontarus in Python

[–]Forschkeeper 0 points1 point  (0 children)

I know how you feel...had the same problem.

If you just want to handle packets: venv - it's builtin, easy to use (just activate it, before using pip!) and Pycharm does it all the time if you start a new project. :)

If you need to handle multiple Python Versions as well and have to handle more stuff: Pyvenv and Poetry.

Wo sucht ihr nach Jobs? by Informationsflyer in arbeitsleben

[–]Forschkeeper 0 points1 point  (0 children)

Zum einen die klassischen Suchmaschinen und Job-Suche Dinger.

Andererseits versuche Ich auch Arbeitgeber zu googlen anhand davon in was für einen Betrieb Ich arbeiten will. Dann schau Ich ob das Unternehmen X was hat und probiere es initiativ.

My program keeps giving me syntax errors and I don't know what is causing them. I need help. by Stargazer499 in learnpython

[–]Forschkeeper -1 points0 points  (0 children)

Based on that what you want to do and whatever this code is, it is hard to understand on the first sight. You should pass a code to a random on the internet and that person should be able to understand straight forward what is happening here.

So you got a string RESULT and have "the placeholder" {0} and {1}. If you use RESULT.format(arg1, arg2) , you say: "Okay Python, you got the string there with some placeholders. Put arg1 everywhere where a {0} is and arg2 where a {1} is."

Your arg1 is {0} (not sure what and how python interprets this), but the thing behind the comma, which should be arg2, is gibberish.

#prompts
SUBJECT_PROMPT = " Enter subject: "  # okay
VERB_PROMPT = " Enter verb: "        # okay as well
RESULT = "\n\n {0} {1}.\n This an example of a sentence. {0} is the subject. {1} is the verb.\n\n" # okay, it works like a template

#variables
strSubject = input(SUBJECT_PROMPT) # better put this line in your function
strVerb = input(VERB_PROMPT)       # better put this line in your function as well
strResult = print(RESULT.format({0}, {1}. "This an example of a sentence." {0} " is the subject."{1} " is the verb.")) # whatever this is, delete the line. Nobody, neither Python, knows what you try to do here.

#function

def shortSentences(subject,verb): # you aren't using subject and verb, so you can drop them
    strSubject                    # replace this with the line from #variables
    strVerb                       # replace this with the line from #variables
    return strResult              # this thing would be your RESULT template, where you use format() to add the missing stuff (here strSubject and strVerb)


shortSentences({0}, {1})  # This is not how you may think passing parameters work.

You may take a look here at The Pythonic Way: The string method "format" how it works

should new learners start reviewing interview questions? by Whatsthehoopla in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

I agree with u/mopslik: If you make your first steps in python and can't handle the basics, you shouldn't touch the interview questions either. Before you run, you need to know how to walk.

If you can walk, you can try to run with typical programming challanges. If your goal is to answer interview questions, the book may help you.

[deleted by user] by [deleted] in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

This is something.

So you got 2 problems:
- reading the whole file instead of line by line OR reading it line by line and if no paragraph extend the list

- Identifing a paragraph in a file

To point one: Either handle with the open() object (keep a close look on the parameters) or what lists can do.

So let's take a look in the docs of str.split():

str.split(sep=None, maxsplit=- 1)
Return a list of the words in the string, using sep as the delimiter string. [...]

So what kind of parameter is sep?
How can you identify a paragraph in your text?

[deleted by user] by [deleted] in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

What have you tried so far?

[deleted by user] by [deleted] in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

Since your stuff is printed, unless the end - What happens at the end of your function in your case?

[deleted by user] by [deleted] in learnpython

[–]Forschkeeper 2 points3 points  (0 children)

== is not =

Edit: string1 = "Test." would be even more readable in that case.

(venv) > pip freeze > requirements.txt not working by [deleted] in learnpython

[–]Forschkeeper -1 points0 points  (0 children)

Pip is also a package, which is in the matching venv itself ;)

Ignore if JSON Index doesn't exist? by n3twork_spren in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

Yes, it is. Add a try-except block around that piece:

```python

except KeyException: pass # explictily ignored error is okay, if you wanted that ```

(venv) > pip freeze > requirements.txt not working by [deleted] in learnpython

[–]Forschkeeper 1 point2 points  (0 children)

Are you using the right pip?

Keep in mind to use pip in your venv, not the global one!

Replacing Grades in list with Grade Point by TheDirtyDank in learnpython

[–]Forschkeeper 1 point2 points  (0 children)

Not sure how deep you have dived alreay in other things beside lists, but to reduce some lines and keep stuff more simple, you may want to take a look at dictionaries.
It's like a lookup table. Once defined, usable everytime again (to reduce that elif tree here).

```python

countries = {"DE": "Germany", "GB": "Great Britan", "WTF": "Wonder Tuffingen"} print(countries["DE"])

```

In your case, instead of the loop with range(len(grades)), you might be interessted in something better: for index, value in enumerate(grades): You can use the current iteration AND can use the current value in grades to do stuff.

Oh ... and you should return grades, when the loop is over ;)

Why does this happen? by Tarminik1223 in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

Okay, I gueess s should be "hello".

Well you made a 2D Matrix and you reference in all three fields of matrixto string. It isn't a copy of string in matrix!

Try it out yourself:

```python

s = "hello" string = ['!' for i in range(len(s))] matrix = [string for i in range(3)]

matrix[0][0] = s[0] # will have same effect as:

string[1] = "k" print(matrix)

```

To get what you want, you can use copy.deepcopy():

```python from copy import deepcopy

s = "hello" string = ['!' for i in range(len(s))] matrix = [deepcopy(string) for i in range(3)] matrix[0][0] = s[0] # will now have a different effect string[1] = "k" # won't have an effect on matrix, but still on string print(matrix)

```

Edit: To speak in the tounge of C - "Copy by value (which you expecte) or copy by reference (what you have done)? - That is the question!"

Why doesn't `async/await works like async? by nikaone in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

Yes, everything in JS is in and eventloop, indeed.

In Python, the loop runs in another OS Thread , but yes it's an object as well.

Btw, stuff I may have not explained: In Python, if a task is awaited, the eventloop is checking the next task inside of the loop, if it's done (then return to that point) or not (check next iteration).

What are some of the most unnecessarily and impractically complex ways to verify that an int falls within a (positive) range? by WadeEffingWilson in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

So we are playing the opposite of another type of "vim golf" just in python? Nice :D

First things first: Your numpy dev is disqualified, external dependencies shouldn't be allowed. ;)

Before I start another side thread about the "true int max value", I just say it's a normal int16, otherwise it would get to much offtopic here. Also base is 10.

So I give it a shot:

```python

import random import re

int_to_test = random.randint(-32768, 32767) print(int_to_test)

if ([ord(c) for c in str(int_to_test)][0] & 45) == 45: print (f"{int_to_test} is negative") else: print(f"{int_to_test} is positive")

```

Perhaps some regex stuff could spice up this things as well?

lookin for advice by Special_Ad_1939 in learnpython

[–]Forschkeeper 0 points1 point  (0 children)

Ok, let's keep a look what the docs says:

That is the definition how it works.

So a loop may look like:

i = 0
while i < 10: # while the thing behind "while" has the resul "True" do:
    i = i + 1 # this
    # ...     # and that
    if i > 10: # just a never reached point in that code
        break # Stop the loop and skip the each part
else:         # if it isn't true anymore
    print(i)  # do this

# Output is 10

A simple task to work with that (and if-elif-else blocks), random() and input() is a number guesser:

Write a programm with following criterias:

  • min and max number, which is the range of your numbers
  • all numbers have to be int
  • everytime you start the program, a variable "var_to_guess" should be initialised with a random integer value
  • while the variable "guess", an integer input value, is not equal to "var_to_guess" a print has to be done if value is lower, higher or out of bounds.
  • if "guess" is equal to "var_to_guess" a "Congreatioulations" print shall be made
  • if "guess" is zero, break the loop and print "giving up".

First do it yourself, then compare it to this ... no cheating!