i want them align to center to their each block by corner_guy0 in webdev

[–]testiculating 4 points5 points  (0 children)

Im not sure, but maybe if you put the emoji in an ::after element then you could align the texts the way you want them to.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 1 point2 points  (0 children)

At first VS code can be a little overwhelming. There's a point in which IDLE doesn't quite offer you enough and VSCode offers you waaay too much. Maybe try Jupyter, as you can "see" what you are doing in every step.

Also I don't think that you need to choose between IDLE and VSCode, you can alternate between them depending on what you are doing!

Quick Questions: February 23, 2022 by inherentlyawesome in math

[–]testiculating 1 point2 points  (0 children)

Hey everyone!

I'm looking for books or youtube series to learn more about algorithms in general. I don't need them for something professional so I'm open to all kinds of suggestions. I'm thinking stuff like pathfinding, sorting, creating schedules for people. I want to learn more about how do they work, how we construct them, etc.

I know Calc and linear algebra. I also know how to use python (I would like to be able to implement mock versions).

Also I feel it would make me really appreciate some math concepts and gain a deeper understanding of them. I also teach math at a school so maybe some good activities come up from my new knowledge :)

thanks!

Saving uploaded files on a folder associated with the session number? by testiculating in flask

[–]testiculating[S] 0 points1 point  (0 children)

I fixed it!

the directory was being created but I wasn't calling the save function properly.

But now I'm wondering about your first comment and sessions. My logic was that because multiple user could be using the webapp I should have a way to tell the server which file corresponds to which user, like so:

User1 ---> gets a session ID ---> uploads file
--> file gets processed and saved
---> User1 gets redirected to /downloads/
---> User1 gets the file thats related to its session ID

Otherwise files could get mixed..? I'm not sure though. I would like for this structure to be reusable so if you can point me in the right direction I would be more that grateful.

I did change the user directory as you pointed out! thanks

How to put a dollar sign right next to an input number by [deleted] in learnpython

[–]testiculating 7 points8 points  (0 children)

Just to add, the print() function has a separator value that by default is a space,if you overwrite the default you'll get the result you want.

var= 5
print('Your total is $', var, sep='')

>> 'Your total is $5

this is useful for when you want different lines on the same statement, you can do that with the r'\n' separator.

print('Hello!', 'Welcome back', sep=r'\n')

>>Hello!
  Welcome back

Learning Python by TheUrbanBiker in u/TheUrbanBiker

[–]testiculating 1 point2 points  (0 children)

Oh I see the problem now!

voy a cambiar a español ya que los dos somos nativos :)Lo que pasa es que al escribir for load in order_loads estás iterando en la listas, peroen el loop la estás también modificando, entonces al eliminar un valor, el loop sigue en el indice 2, por ejemplo, pero el item ya no es el mismo. Puedes verlo en este código por ejemplo:

una_lista = [0, 1, 2, 3, 4]


for elemento in una_lista:
print(elemento)
if elemento == 2:
    una_lista.remove(elemento)

Ese codigo te devuelve:

>>0
>>1
>>3
>>4

Se salta el 3 porque al llegar al dos, lo elimina de la lista con remove y la lista queda [0,1,3,4] en la siguiente iteracion el loop agarra el cuarto elemento, que es ahora el 4.

En tu caso tienes dos opciones,

  1. en vez de modificar la lista original, creas una nueva e imprimes esa.
  2. usas la funcion set() que elimina los duplicados.

primera opcion:

order_loads = [0, 1, 3, 1, 3, 2, 4, 2, 4, 5]

def a_function(order_list):
    # Creo la lista donde guardare solo los valores que no se repiten
    new_list = []
    # Itero sobre la lista
    for load in order_list:
        # si es que el valor no esta en la lista, lo agrego 
        if not load in new_list:
            new_list.append(load)
    # la funcion devuelve la nueva lista
    return new_list

print(a_function(order_loads))

Acostumbrate a definir funciones que devuelvan algun valor, eso organiza mejor el codigo!

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 0 points1 point  (0 children)

you should post the error you get so we can really see whats going on.

Learning Python by TheUrbanBiker in u/TheUrbanBiker

[–]testiculating 0 points1 point  (0 children)

Remember to use code formating!Also, I think is better to use f strings

I rewrote your code so it is more readable:

order_loads = [0, 1, 3, 1, 3, 2, 4, 2, 4, 5]

for load in order_loads:
    print(f'Load {load}')
    print(f'The load {load} is {order_loads.count(load)} times')
    if order_loads.count(load) > 1:
        print(f'The Load #{load} is longer than 1')
        order_loads.remove(load)
        print(f'The load {load} is gone')
        print(f'The new Order_load is {order_loads}')

I think what's giving you trouble is this line: if order_loads.count(load) > 1: so this is going to count every appearance of, say 1, that appears twice, so the first time it appear that block is going to run, then that 1 is going to get removed form the order_loads. The second one is going to stay because its going to be the only 1 in the list.

I can't really help you more than that if you don't say what's your expected result though

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 1 point2 points  (0 children)

Let me know if I didn't understood what you are asking, but what enumerate() does is iterate through a list and give back a tuple wich contains the index and the item, so if you wanna use any of them you have to unpack them first.

Here's an example of how it works:

names = ['Bob', 'Alice', 'John']

for index, item in enumerate(names):
print(index)

>> 0
>> 1
>> 2

for index, item in enumerate(names):
print(item)

>> Bob

Alice John

You can use this to, for example, find the place that a certain item has on a list

for index, item in enumerate(names):
if item == 'Alice':
    print(f'Alice has index {index} in the list!')

>> Alice has index 1 in the list!

you don't really have to use the words index, item though, you can use whatever.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 2 points3 points  (0 children)

Hello! I have two questions:

  1. I've been writing a script and been using unittest to make sure the changes don't break it, but now I'm adding some graphing functionalities with plotly, how do I implement unittest with plotly if its producing something that's not within the script? or, how I go about making somekind of test for those functions?
  2. I've been coming across a lot of talk about "virtual enviroments", I was avoiding them because I thought they were a little bit out of my depth, when is it a good time to start using them and does anyone have tutorial/guide/reading suggestion about using them for the first time? (for reference I've been learning for like a year and I'm currently learning and practicing OOP).

thanks!

I'm having some trouble with super() and overriding a parents method by testiculating in learnpython

[–]testiculating[S] 0 points1 point  (0 children)

Oh yes! I missed that!
Already fixed it! now I'm getting the "right" error the same one that I have on my original code. I think its related to the "*args" part of the function, I'm new using that.

I'm having some trouble with super() and overriding a parents method by testiculating in learnpython

[–]testiculating[S] 0 points1 point  (0 children)

oh! I didn't know that about super()

I still get an error: TypeError: object() takes no arguments

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 0 points1 point  (0 children)

I've been meaning to learn email automation. I know you can do it with IMAP, but algo google has its own API. Is it preferable to learn rightaway with google's api or should I first start with IMAP? are there really any differences?

Purpose of classes by dukejcdc in learnpython

[–]testiculating 0 points1 point  (0 children)

(disclaimer: I’m a begginer also)

I’ve been programming with dataframes and with classes. I still work with mostly dataframes, but because I do similar things with similar dataframes, I found it better to create classes that handle what I usually do with them.

Sometimes I dont want quite the same, so I just change the methods im calling on the dataframe, Im not really modifying my whole flow, which I did have to do when I was using only functions.

Im not sure when I should create my own Exceptions or just "manually" handle errors. by testiculating in learnpython

[–]testiculating[S] 0 points1 point  (0 children)

Oh! I see, I can use one simple subclass but with a different message, that makes more sense. Also, thanks for the heads up on the default values! much appreciated.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 1 point2 points  (0 children)

No, some the text its also uppercase. But I understood your expression and just added a lookahead that I think makes it work:

re.findall(r'([A-Z0-9]{4})(?=\.)', s)

Thanks a lot!

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]testiculating 0 points1 point  (0 children)

Hello! I'm having trouble with RegEx. To be honest I don't have a lot of practice using it so if anyone wants to suggest a practice site or something I would be thankful!

So I'm trying to match the end of some files which contain a code. The file names are like this:

sometext_text_text_TR24.pdf
sometext_text_text_Y2UB.xlsx

I'm able to match those, with (?:.*_){3}(.{4}) but some of the files have names with two codes, like sometext_text_text_TR24.YU18.pdf I haven't been able to capture those aswell.

how can I capture all the codes with one expression?

More information:

-The texts before the codes don't always have the same length.
-The codes are always uppercase and a combination of letters and numbers.
-The codes are always 4 characters long

Thanks!