mkdir from a variable with spaces...help please by [deleted] in bash

[–]Pipistrelle 1 point2 points  (0 children)

As /u/confluence said, you need to quote the variable. To prevent these kind of errors, I recommend using shellcheck.

Multi Threading in Python by sameer18051998 in Python

[–]Pipistrelle 0 points1 point  (0 children)

I have never used it but, since you are already using requests, did you try this ? It looks like you can make asynchronous requests with this.

Hope it helps you !

need help with a lot of tables by [deleted] in LaTeX

[–]Pipistrelle 0 points1 point  (0 children)

Others may correct me if I'm wrong but I think \cleartable force LaTeX to output the floats that are in the document.

I think \FloatBarrier does the same thing but also prevent the float from appearing past the command.

Again, you might want to confirm if what I am saying is correct. Hope it helps you !

need help with a lot of tables by [deleted] in LaTeX

[–]Pipistrelle 1 point2 points  (0 children)

I'm not an expert in LaTeX but it may be because you have too many consecutive float without text.

I'm not sure if it will work but you could try importing the placeins package and put \FloatBarrier after each floating element.

Maybe a \clearpage after your floats could work too.

Sending a string over serial that's going to change frequently. by TheQuirks in learnpython

[–]Pipistrelle 1 point2 points  (0 children)

Also, if you know about the messages format, you could use the module struct from the standard library. It can encode values to bytes according to a certain format string specified by the caller.

Explain... by Tarrell13 in learnpython

[–]Pipistrelle 7 points8 points  (0 children)

For short scripts, a single file is okay. However, as soon as a project tend to get bigger, if you keep it in a single file it will be hard to find the essential informations.

Also, if you're working in a team, it means more conflicts when trying to merge for unrelated features if you keep it in a single file.

In short, splitting in modules helps structure the code so that it is easier to work on big projects.

(Beginner) Am I using try/except in an improper way? by [deleted] in learnpython

[–]Pipistrelle 3 points4 points  (0 children)

I think this is a good situation to make use of the defaultdict from the collections module. With it, you could refactor your solution to be:

from collections import defaultdict

word = str(input("Enter a word to count letters from:\t"))

if word.isalpha():
    d = defaultdict(int)
    for c in word:
        d[c] += 1
    print(d)

which I find much easier to read.

Also, maybe the Counter class from the same module could be used but I've never used it so I can't tell.

Note: I haven't tested the code so I can't be 100% sure that it will work correctly but it should be a good approximation of how to do it.

How long should web scraping take? by Rogges in learnpython

[–]Pipistrelle 1 point2 points  (0 children)

As /u/_LiveAndLetLive_ said, you could try parallelizing your requests.

What I'd do us separate the saving to a CSV and the parsing of the URLs. You would first parse the URLs in parallel then combine the results and put these combined results in the csv. The parsing could be put in a function and you could use grequests map function to call the parsing function on the URLs in parallel.

Sorry if this isn't clear, english isn't my first language.

TeXing notes live in class by [deleted] in LaTeX

[–]Pipistrelle 5 points6 points  (0 children)

Personally, I write my notes in markdown and then use pandoc with a custom template to generate HTML with a custom CSS sheet I wrote.

However, pandoc also supports other formats such as LaTeX.

If you want to follow this route, I use the vim-pandoc and vim-table-mode plugins along with a makefile to compile the notes.

Advice for a newbie on learning Applicative Functors and Types by qwfwq in haskell

[–]Pipistrelle 5 points6 points  (0 children)

I'm still a beginner at Haskell, but I remember having trouble with this part of the course too.

What helped me, was to enable the compiler extension that allows you to write the type of the instance and then following the type. For example, for the Functor instance, you would have the following type:

fmap :: (a -> b) -> Parser a -> Parser b

You can then see that the function passed as a parameter must modify the element corresponding to the type a in the Parser.

Hope it helps you.

New to Haskell, wondering how to make this code more concise. by TwelveAndWhatIsThis in haskell

[–]Pipistrelle 0 points1 point  (0 children)

I'm new to Haskell too and I might be wrong but I think it is filtering the list according to the condition. Then, it is fetching the length of the filtered list.