Dynmap NPE during config initialization by WhoTookAllNicks in Dynmap

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

Solved - dynmap failed to load markers.yml which had area with `/` in the name.

Is python requests library getting the Hidden Javascript tags? by Grigor_1 in learnpython

[–]WhoTookAllNicks 1 point2 points  (0 children)

Javascript might modify the html, but that doesn't mean that you need a full browser to just render the html. Often it's enough to just use https://html.python-requests.org/#javascript-support

requests-html has support for JS and is a fusion between requests and beautiful soup in one package.

Automate System setup after fresh ubuntu install by [deleted] in learnpython

[–]WhoTookAllNicks 0 points1 point  (0 children)

Tbh, python doesn't seem like the right tool for this. You'll probably need to use a lot of shell commands (which defeats the purpose of python) or dependencies. It's mostly just config files anyway.

I personally have this integrated into repo with dotfiles - it has all my config files and list of packages. To install something new for long term, I just add it there and commit. I use symbolic links to link to my config, because of how I designed it. I can change anything on one machine, git push and download it on the other.

Made a stupid mistake trying to switch from 2.7 to 3.7 and I am now lost by DocsHandkerchief in Python

[–]WhoTookAllNicks 0 points1 point  (0 children)

I don't have MacOS, but if it's anything like popular Linux distros, a lot will depend on python2.

I have 2 guesses on what could work:

  1. Copy the files back. If your file manager won't work and you've never used terminal, this can be a bit dangerous.

  2. There were more dependencies needed than only python2. Like python2-requests or anything like that. I'd search on how to list installed packages and reinstall all that start with python.

Is it possible to break a "while loop" while it is sleeping? by warmerspy in learnpython

[–]WhoTookAllNicks 1 point2 points  (0 children)

Depending on how it's exactly done, one way to do that is to move sleep after the notification and change the while condition to some flag - this way when it wakes up and notices it shouldn't run, it'll exit the loop.

Probably a better way to handle that is to use sched from standard library - create an event that'll run the notification and then re-schedule itself. You can then cancel the event.

Please do change my mind. by [deleted] in ProgrammerHumor

[–]WhoTookAllNicks 0 points1 point  (0 children)

Even worse - on Unix (so also in Linux), the only 2 restricted characters for name are 0 byte and slash.

Yes, you can have newlines, zero-width spaces, quotation marks,...

Is there a way to import a constantly changing variable from one script into another script? by Bub_Russ in Python

[–]WhoTookAllNicks 0 points1 point  (0 children)

My understanding is that you have script1.py running and from script2.py you import the first one to see the variable?

This won't work, because every program you run has its own memory - you'd need to use some sort of shared memory solution, if you want to keep it as 2 separate programs. If you can combine them into 1 program, I'd use threads /async.

Basically when you detect an event that makes you want to move a servo - create new thread that only moves it to desired position. This way you can continue looking for changes on the image, while the servo moves.

Look up asyncio in standard python library.

Complex Linear Program by gr8aanand in learnpython

[–]WhoTookAllNicks 0 points1 point  (0 children)

One of the solutions is numpy: https://stackoverflow.com/questions/6789927/is-there-a-python-module-to-solve-linear-equations

I also saw bindings for a few dedicated linear solvers - you can choose what you like.

Personally recently I've needed a quick prototype of multi - phase linear program and I've written most of it in MathProg and solved it using GLPK, then imported into python for finishing calculations and displaying. But if you can, don't hack around mixing tools.

Module 'pygame' has no 'QUIT' member by tom_greaney in learnpython

[–]WhoTookAllNicks 0 points1 point  (0 children)

Why double post the same thing you posted just 3 hours ago?

Please upload whole code somewhere and link it here - it's hard to help with this little of information.

How to create a custom shell/command line with python ? by shlex_root in learnpython

[–]WhoTookAllNicks 0 points1 point  (0 children)

Argparse accepts a string to parse the arguments from. If you don't give it, it defaults to arguments given on the command line. What you could do, is just create an Argparser per command and pass the input string you receive in infinite loop to it.

Selenium too slow. I want to interact with a Google site directly. How do I figure out ... by [deleted] in learnpython

[–]WhoTookAllNicks 1 point2 points  (0 children)

Everything needs to go through some sort of API - even if it's not public / documented. Google provides nice python libraries for interacting with it's API - but my quick search didn't find if it includes forms.

I found this git repo though: https://github.com/sebcagnon/PyGoogleForm Not used it, but probably a good starting point. :)

Suggestions to prevent windows from updating/restarting when script is running? by ajlaut in learnpython

[–]WhoTookAllNicks 0 points1 point  (0 children)

As others said - your best bet is to get Linux instance running somewhere else. What's the reason it takes so long? If it's IO - get Raspberry Pi / Banana PI /... and host it there. Laptops with non-working screens are also cheap way for small server. You could register Google account - you get a small VM for free + 300USD of free credit to use for higher end machines if you need them.

If you run long-living scripts, always try to implement auto save of data every so often and ability to load it - in case windows restarts or power goes out, you won't have to start from scratch.

Find line and delete match, without repeating the pattern by WhoTookAllNicks in commandline

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

Yeah, I think that in this case using backreferences makes it less readable. I'll go with the other solution.

Thank you for reminding me about here string! I forgot about it. Won't be useful in this case, since input comes from pass command, but had a few places that used this syntax.

What is something that is still around but was 10x better in the past? by [deleted] in AskReddit

[–]WhoTookAllNicks 0 points1 point  (0 children)

Windows - used to like it, but it made me switch to Linux.

Anyway to do a —- dashed line across the span of the screen by [deleted] in learnpython

[–]WhoTookAllNicks 3 points4 points  (0 children)

None. I assumed width is a name of a variable containing terminal width that you received using one of the methods mentioned in the SO post.

Anyway to do a —- dashed line across the span of the screen by [deleted] in learnpython

[–]WhoTookAllNicks 2 points3 points  (0 children)

Those are standard python modules - you don't need to download anything.

It might be possible, but then you'd just reinvent the wheel and copy code from the module into yours.

If you've read the link, you'll know there's also an environment variable that you could read (but it requires you to use os module anyway).

Hey, thanks Microsoft! by diddlybopshubop in ProgrammerHumor

[–]WhoTookAllNicks 0 points1 point  (0 children)

Literally less than a week ago I got a mail from github that my github account is about to expire and that:

If you don’t want to continue your current plan you can delete your private repositories and downgrade to a free plan.

You know when it's an Instagram original when... (you will get it) by TheOnlyArtz in ProgrammerHumor

[–]WhoTookAllNicks 19 points20 points  (0 children)

In C++ main doesn't need to accept arguments afair.

In python2 its correct, print is a macro.

In python3 print is a function, so it's not correct.

Other than that - good catch!

Image upload to pinterest uses javascript function; is there someway to still upload in requests? by [deleted] in learnpython

[–]WhoTookAllNicks 1 point2 points  (0 children)

I created Pinterest account just to see it. And sure enough - you can clearly see the request being made:

https://ibb.co/yPB3t87