What modules do I use to perform data sharing for a Python file?

Asked

Viewed 85 times

4

I have a list of repository addresses git classified according to your accommodation location.

@GitHub ('@' demonstra que a linha representa um local de hospedagem)
url do repositório a (repositório a ser baixado)
url do repositório b (repositório a ser baixado)
@GoogleCode ('@' demonstra que a linha representa um local de hospedagem)
url do reposiorio c (repositório a ser baixado)
url do repositório d (repositório a ser baixado)

I want to separate this data (what is a repository and what is a hosting location), which will be in a file written by the user, in the best way possible. My idea is to use some module like Configparser, which creates a pattern for me and prevents failures, unnecessary spaces, etc.

For now I am doing it in hand with conditionals (if the first element is '@', set as hosting location), Entering would like to optimize my code. Any suggestions?

  • 2

    I wouldn’t say modules. I would say that with native Python you can do something great. You have some ready-made code that you can put in your question?

1 answer

2


If the format is simple like this, without any novelty planned, use some parser library, such as the ANTLR, can take more work than doing what you’ve already done.

If you have some control over the format, I would suggest first try to avoid creating a new format and try to use something with an existing parser, like JSON, XML or YAML (the most readable of these three).

  • I didn’t stop to think while writing the code using a JSON format. Until I realized that the users of this script are developers, and supposedly JSON will not be a problem. I’m using it, thanks for the tip!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.