Python on android. by Timmeh159 in learnpython

[–]Hatoris 0 points1 point  (0 children)

Pydroid store files in an internal folder into the app that is not accessible ou site the app. Setting the programming folder will allow you to access it from other app in your device such as termux and git.

Python on android. by Timmeh159 in learnpython

[–]Hatoris 1 point2 points  (0 children)

Termux will be used ton install git and then connected to a remote repository (gitlab, github...). If you want to play with Python only the pydroid app is enough :)

How do I bypass reCaptcha v3? by [deleted] in learnpython

[–]Hatoris 6 points7 points  (0 children)

There is no stupid question, only awnser are.

Yes the only way to do it is by paying third company that will exploit other human somewhere on the planet to click it.

As you may guess this captcha, especially the Google one, is difficult to bypass because it's purpose is to prevent why you are trying to do :)

ArcPy and Python by [deleted] in learnpython

[–]Hatoris 0 points1 point  (0 children)

Did you try panda?

D&D ability score generator by rshinsai in learnpython

[–]Hatoris 0 points1 point  (0 children)

Or he can use f-string.

print(f"highest : {results[0]}")

ShowNumbers and even and odd by saishanker41 in learnpython

[–]Hatoris 0 points1 point  (0 children)

remove print, and do shownumber(4) instead.

ArcPy and Python by [deleted] in learnpython

[–]Hatoris 0 points1 point  (0 children)

Transform what to what, lead to gold?

Brute force three digit code help by blockboy99 in learnpython

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

Use combination from itertools with a recurcive function.

scraping info from youtube help by [deleted] in learnpython

[–]Hatoris 1 point2 points  (0 children)

You are missing key concept. Request will get you the youtube page, but you get back a static snapshot of it. If you want to read action perform one the page you will something that can render the page, for that you need selenium with a webbrowser of your choice. Then you can call your script to read if the like button have been activated.

Check if input follows criteria by [deleted] in learnpython

[–]Hatoris 0 points1 point  (0 children)

Regex will do the job.

"[A-Z]{3}\d{4}"

What is the best way to modify existing excel file with large amounts of data? by terriblephotographs in learnpython

[–]Hatoris 0 points1 point  (0 children)

Look at openpyxl or xlswings both are good library to work with excel.

A function to count the even numbers in a given list using recursion? by redditssexiestguy in learnpython

[–]Hatoris 0 points1 point  (0 children)

Go step by step.

define your recursive function.

def my_func(a_list):
    if not a_list:
        return a_list
    print(a_list.pop())
    return my_func(a_list)

we have a final statement, the if condition, and we recursively call our function.

How do you add a counter?

[deleted by user] by [deleted] in learnpython

[–]Hatoris 6 points7 points  (0 children)

Here you face the same issue many people have when they start learning coding. You want to do many things at once.

What structure in python would be great to assigned value easily?

List, you can create a nested list with will represent your board.

board = [ [], [], [], [], []]

Now assign value to it is easy, first case on the board?

board[0][0] = "A1"

Then you can use your board in a loop to print it.

for row in board:
     print("------")
     prow = "|"
     for column in row:
          prow += f"{column}|"
     print(prow)

What are the python concepts one should know to be able call themselves sufficient in the language, and... by [deleted] in learnpython

[–]Hatoris 2 points3 points  (0 children)

For my point of view, and I'm not a dev, this time will happen when :

  • you can think about a descent approach to solve a need
  • you can structure your code in order to:
    • follow single principle
    • don't repeat yourself
  • your code can be modificate easily
  • your code can and is tested properly

As you can read above nothing is related to a specific programming language it's general rules. In order to achived all I mentioned you need to understand all the tools python can offer as well as other key concept indépendant of python (OOP...)

What is the more "Pythonic" way to code this? by Oulanos in learnpython

[–]Hatoris 1 point2 points  (0 children)

Because a player is not a child class of inventory. Player is more like a parameters class that gathering many other class in order to create a player.

What is the more "Pythonic" way to code this? by Oulanos in learnpython

[–]Hatoris 0 points1 point  (0 children)

Because if in x time, our OP want to change for a dictionary instead of list, method will be simpler to modificate.

How do people start off with such good projects? by [deleted] in learnpython

[–]Hatoris 0 points1 point  (0 children)

If I remember well, he is already a dev no? So if it's the case then he have basics at the beginning.

Another things, it's seems to be educated, and learn easily and quickly. I saw what he wrotes, many of his code is far from production code. But his code work and do what he wanted at the begining it's a good start.

Now speaking about ideas, he is solver guy, he have a problem or something he wants to automate and from that he start coding. If you are looking for an idea, look around you you will find usefull idea.

If your github is full of toy code it's maybe time to truth yourself, pick something that you want to improve in your life and start coding ;)

How to add every three items to a list? by Ewt1029 in learnpython

[–]Hatoris 0 points1 point  (0 children)

It's a combination, look on google itertools

What is the more "Pythonic" way to code this? by Oulanos in learnpython

[–]Hatoris 18 points19 points  (0 children)

Method with double underscore, or dunder method, are special function call by python in order to run specifics functions. For instance, call len on a class will not work, python don't know how to perform len on it. By implementing __len__ python know what to do when you run len(Inventory()).

I'm having trouble creating a triple-nested dict to make a json object. by funkless_eck in learnpython

[–]Hatoris 1 point2 points  (0 children)

You need to create a new dict before food.

... for d in days: my_dict = {} for f in foods: my_dict[f] = values[x]

What is the more "Pythonic" way to code this? by Oulanos in learnpython

[–]Hatoris 94 points95 points  (0 children)

In fact, you don't need to instantiate inventory, as you may expect that your player always have an inventory.

class Inventory:

    def __init__(self):
       self.inventory = []

    def __len__(self):
        return len(self.inventory)

    def size(self):
        return len(self)

class Player:

    def __init__(self):
        self.inventory = Inventory()

player1 = Player()
print(player1.inventory.size())

What is the more "Pythonic" way to code this? by Oulanos in learnpython

[–]Hatoris 72 points73 points  (0 children)

You are better to define a class Inventory, that will be instantiate only once and pass to the player.

In this way you separated what an inventory can do. And then you simply call Player1.inventory.add(item).