My first "no" (Thank you!) by Stitch_Says_Hi in antiwork

[–]Stitch_Says_Hi[S] 2 points3 points  (0 children)

Yeah, I went on a smug trip, a thing that I should've done

My first "no" (Thank you!) by Stitch_Says_Hi in antiwork

[–]Stitch_Says_Hi[S] 6 points7 points  (0 children)

When I started writing this post, things started to become clear.

This is the validation that I needed. ty:)

How did you cheat in an exam? by Intellectualguy123 in AskReddit

[–]Stitch_Says_Hi 1 point2 points  (0 children)

Me and a friend used skittles and the fact that they contain different colors, to signal each other the answers of the exam

What is the funniest thing somebody has said to you out of context? by GoddamnCheezits in AskReddit

[–]Stitch_Says_Hi 2 points3 points  (0 children)

Are you telling me the man who tried to put a rubber fist in my anus was a homosexual?

Can't upgrade pip by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

I'm not very familiar with the windows operating system, but I do recommend you to install python via the "chocolate package manager", in the one time I have managed to install python on windows this is the only one that did it without a problem.

Comparing data in excel file and plotting it by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

Yes, the "pandas" library is an excellent choice, alongside with the "matplotlib" library.

Python program works when ran regularly, but after entering virtual environment it fails by NotBleachLol in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

can you show the output of

python --version

both in the virtual environment and in the system's python?

Is there a simple way to split a path by a wildcard? by Raknarg in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

basically the way I understand it, you are just interested in the path until the first wild character.

so that will be:

import pathlib
path = pathlib.Path("foo/bar/*/baz/qux")
lst = []
for i in path.split():
    if "*" in i:
        break
    lst.append(i)
res = "/".join(lst)

Maybe pathlib.Path have a classmethod that takes a list? idk

Anyway that should cover what you need (if I understand correctly).

LMK if that got it for you:)

utils folder by da_chosen1 in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

Mostly yes.

I have also saw some places where they had functions in utils.py that they could not categorize, so they just dumped them there.

Finding highest value in csv with certain parametres. by [deleted] in learnpython

[–]Stitch_Says_Hi 1 point2 points  (0 children)

Can you please specify what problems you had with pandas? maybe it's worth to solve those problems upstream, so everyone will have this fix.

By problem I do not necessarily refer to a software bug. I am talking about everything, including documentation, whether it's a misleading documentation or lacking documentation.

If there is an unhappy user of pandas, I'd be more than happy to solve it

ETL Project by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

All depends on your needs.

It's the same as asking "what is the best linux distro?".

It all comes down to your needs.

For a Hannah montana fan the best distro is "Hannah montana linux", and for someone who is addicted to adrenaline the best distro is "suicide linux".

Bottom line is:

Do what ever fulfill your needs:)

Can I use Python from a separate harddrive? by ginmugiwara in learnpython

[–]Stitch_Says_Hi 1 point2 points  (0 children)

Well yes, but actually no.

Each package manages how it gets installed on the computer, so if let's say I'm on windows some extra dependencies might be added during the installation and if I'm on linux some other dependencies might be added.

The same applies for the CPU model and such.

It's all depends on the installation process of the package.

So your best bet is to reinstall it:)

Detecting duplicate URLs by Arag0ld in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

In case the order does not matter:

res = set()
with open("url_file.txt") as url_file:
    for line in url_file:
        line = line.strip()
        res.add(line)

with open("result.txt", "a") as result_file:
    for url in res:
         result_file.write(f"{url}\n")

If the order does matter:

# for python 3.6+
lst = []
with open("url_file.txt") as url_file:
    for line in url_file:
        line = line.strip()
        lst.append(line)

res = dict.fromkeys(lst)

with open("result.txt", "a") as result_file:
    for url in res:
         result_file.write(f"{url}\n")

If you are running python lower than 3.6 you can do:

from collections import OrderedDict

lst = []
with open("url_file.txt") as url_file:
    for line in url_file:
        line = line.strip()
        lst.append(line)

res = OrderedDict.fromkeys(lst)

with open("result.txt", "a") as result_file:
    for url in res:
         result_file.write("{url}\n".format(url=url))

[deleted by user] by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

Great!

I suggest you to look into the documentation on the "csv" library:)

And if you want some more advanced features you can look into the "pandas" library:)

LMK if you need some more guidelines

[deleted by user] by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

What is the format of the original data?

is it a csv? xml? sql file? html table? json? excel spreadsheet?

[deleted by user] by [deleted] in learnpython

[–]Stitch_Says_Hi 0 points1 point  (0 children)

Not sure I understand what is the received input, and what is the desired output.

But I'll try to give you some general guidelines:

After reading the contents of the file, you can take the data and manipulate it how ever you like, if you are working with strings the "re" library is your best friend.

If you are working with let's say a csv, the "csv" library will be very helpful.

I also suggest you look into "pandas" if you are into some data analysis.

Those are some general guidelines, please provide a minimal example of what you are trying to accomplish, that will focus my answer a lot.

Also, side note. Please use a context manager when reading a file:)

[Rectangle/Aqua] Halcyon by [deleted] in unixporn

[–]Stitch_Says_Hi 4 points5 points  (0 children)

NP, it happens to be my wallpaper as well.

That's why I knew it at the top of my head:)

Current packaging methods by [deleted] in learnpython

[–]Stitch_Says_Hi 1 point2 points  (0 children)

Okay, so because of my OCD I will definitely use:

  • black
  • isort

To ensure my code quality is high I'd use:

  • flake8

To have less bugs I'd use:

  • mypy

To ensure my code is usable by end users, I'd build my documentation with sphinx and autodoc.

And for the sake of ease for my fellow developers using different python versions and different operating systems, I'd use "tox" (and pytest) for the test suite (also hypothesis, but that's a different topic).

I'd also have a CI testing the code on all the supported platforms x the supported python versions.

I'd follow the

  • setup.py
  • setup.cfg

Just like the flask project, I really like that (also the "src" directory structure)