|
It's more that if you were to do:code:
code:
However, the way you were adding to the dictionary is the recommended way that would ensure the order always.
|
# ¿ Mar 14, 2017 21:19 |
|
|
# ¿ May 2, 2024 21:34 |
|
Newf posted:Do you know (or care to share) any os projects with a python / electron setup? I've only glanced at electron, and then only with JS/TS projects. Haven't seen used as a UI layer with other languages. You have to have some boilerplate to spin up electron and get python to initially communicate, but after that, it's super easy to just use Python/Flask to design your entire app. It's also pretty easy to bundle this (though again requires some more boilerplate in the node layer).
|
# ¿ Aug 1, 2017 23:55 |
|
NtotheTC posted:So my new project is sufficiently out of the quagmires of legacy code that I get to start using the latest versions of everything- including python3.6 over python2.7. It's perhaps a bit shameful that I've done virtually no commercial coding with python3, but I'm wondering if there's a list of the biggest changes I'll need to wrap my head around? f_string_literals and type hinting are two that I've been made aware of but I'm sure there's more out there. The biggest (to me) is the asyncio stuff. But here's a nice list of neat things in Python3 as compared to Python2: https://powerfulpython.com/blog/whats-really-new-in-python-3 Master_Odin fucked around with this message at 13:12 on Sep 7, 2017 |
# ¿ Sep 7, 2017 12:53 |
|
If anything, it looks like you could create a dictionary where the keys are the categories and the values are dictionaries where the keys are the names of the views and values are view object. Then you'd just need a nested for loop to iterate through all this to make the repeated function call. Moving stuff around the menus would be moving key/values around the inner dicts.
|
# ¿ Sep 8, 2017 16:09 |
|
Sphinx is the way to go here unless you're looking to generate API docs and you like how Slade (or whatever) looks like. Though you can definitely modify the Sphinx output pretty endlessly.
|
# ¿ Sep 20, 2017 22:58 |
|
Slimchandi posted:If I have a container class, holding some instances of another class, is there a simple way to get the container to aggregate the results of the inner classes, without writing separate methods for the container for each inner class methods What are you trying to do here? Your example makes little sense to me. I'd probably have each suit (spade, heart, etc) be a class that inherits Inner, setting an internal class variable common to Inner to also denote suit and value.
|
# ¿ Jan 13, 2018 14:10 |
|
HardDiskD posted:Which testing framework is the new hotness nowadays? I've been using nose for the longest time and I want to get on with the times.
|
# ¿ Apr 18, 2018 19:41 |
|
The main takeaway I got from that whole thing is that Python dependency management is becoming increasingly like Go's was with multiple different "standards" (for Python, we've got setup.py, requirements.txt, Pipfile, pyproject.toml, setup.cfg, MANIFEST.in, ...) and a bunch of churn over "the way forward" especially given that some are specified in PEPs (pyproject.toml) and accepted and others are the defacto (Pipfile) based on usage in the wild. Like, is the suggested solution right now to have a Pipfile and pyproject.toml and then to keep them manually synced for publishing/development, even though they're largely going to be the same thing (and I fail to see why we need three files considering the success of yarn/npm/cargo on a two file format).
|
# ¿ May 15, 2018 01:41 |
|
Thermopyle posted:I think the way forward is too in flux right now. SurgicalOntologist posted:I think what's often missing in these discussions is the difference between applications and libraries. I didn't read the whole reddit thread but KR does mention that pipenv is only for applications, I'm just not sure it got much attention.
|
# ¿ May 15, 2018 04:23 |
|
SurgicalOntologist posted:Genuinely asking, what are the benefits for ease of development? Once I have setup.py, if I want to develop a new machine I just run pip install -e. and I'm ready to go.
|
# ¿ May 15, 2018 04:59 |
|
Thermopyle posted:Though, if you wanted to use pipenv for some reason, you can of course download the numpy-mkl wheel and install it by pipenv install numpy-mkl.whl.
|
# ¿ May 15, 2018 21:42 |
|
Sad Panda posted:Very. I'll be logging in to each site and there's not going to be much standardisation.
|
# ¿ May 16, 2018 01:14 |
|
The March Hare posted:I've got a real puzzling guy on my hands right now, could use outside thoughts.
|
# ¿ May 18, 2018 01:07 |
|
SpaceSDoorGunner posted:Anyone know why this: Your algorithm returns something different? It returns all possible factors, not the prime factorization of the number. code:
|
# ¿ Jun 2, 2018 22:30 |
|
I almost always have a "main()" function that "if __name__ == '__main__'" block calls if the script is to be run directly. pylint trained me that doing anything in the if statement complicated is bad, and also to never do tests based around testing if __name__ is equal to __main__ within your actual function code. This makes it way easier also to turn your script into an installed application on the commandline if you go that route.
|
# ¿ Jun 7, 2018 23:24 |
|
Is there a good list of released python versions somewhere that is easy to grep? I'm trying to make a docker image that's based on stretch-slim but can be used for python 3.4+ (as one of the dependencies of the project will produce a different output depending on version so I can't use python:3.4-jessie-slim and python:3.5-stretch-slim). Alpine also isn't an option as it requires me to build several of my dependencies and include a third-party glibc layer which somewhat ruins the point of using alpine for me.
Master_Odin fucked around with this message at 20:36 on Jun 25, 2018 |
# ¿ Jun 25, 2018 20:25 |
|
What exactly would you want users to pass to your function? A multidimensional list of strings that evaluate to functions or Boolean operators?
|
# ¿ Jul 2, 2018 20:16 |
|
duck monster posted:Functions and booleans, but the __operator__ seems the way to go You can though use the operator module (or __operator__ magic functions on the classes) and then do what sqlalchemy does and define and_, or_, etc to then combine the functions you're calling into a meaningful way, or decompose it into a minimum set of operations if that's your aim.
|
# ¿ Jul 3, 2018 02:53 |
|
unpacked robinhood posted:I'd like to "live-update" a geographical map with rectangular overlays, as soon as background processes bring up fresh data.
|
# ¿ Jan 24, 2019 16:03 |
|
Except at least they have a folder within a project they install modules to and I don't have to explain virtualenvs to people starting out. Can't wait for PEP-582 to be implemented.
|
# ¿ Feb 5, 2019 18:30 |
|
necrotic posted:Our approach for awful projects like that was to say if you touched a file in a change you fixed it then. This made the up front lift small, but could cause small changes to take longer. It was worth it and eventually only 10% of files which were never touched remained and somebody just went in and fixed them later. Yeah, this is what I've done for large projects that hadn't yet been linted continuously. Just defined each file individually within whatever the ignore file format is (.flake8 -> exlude=) and then just over time submit a PR that fixes all style issues in a file and remove it from that list. Prevents any new files from not following the style, and then can overtime fix up old code. I do prefer to not mix PRs of bugfixes/features with PRs fixing style changes as that just leads to it being a pain to actually properly review a change amongst all the noise.
|
# ¿ Apr 18, 2019 17:15 |
|
What's the suggest structure for tests for a module that is not installable? I've got the standard structure of:pre:pkg/ __init__.py module_1.py tests/ __init__.py test_module_1.py and so I can use code:
code:
|
# ¿ Apr 20, 2019 16:22 |
|
Neslepaks posted:I'd suggest invoking through pytest instead yeah. Tends to be less finicky that way. e: Actually, I think I found why I'm so confused on the manner. Using the example from above, why it is that unittest seems to choke if I do an import like this: code:
Master_Odin fucked around with this message at 20:14 on Apr 21, 2019 |
# ¿ Apr 21, 2019 19:53 |
|
Thermopyle posted:Chris has a few errors in that blog post, but anyway thats old news that doesn't need rehashed.
|
# ¿ May 6, 2019 03:50 |
|
Thermopyle posted:Sounds like there was some drama at the Python language summit. Also, I like how a talk that focuses on how we should more to pypi doesn't mention at all the huge mess that is python package installation.
|
# ¿ May 18, 2019 22:25 |
|
Well, I guess that talk resonated with the core python developers with the proposed PEP-0594 to deprecate and remove some real old/unused stdlib modules.
|
# ¿ May 23, 2019 00:39 |
|
e;f: double post
Master_Odin fucked around with this message at 16:09 on May 25, 2019 |
# ¿ May 25, 2019 16:06 |
|
It's not necessarily "bad" for what it does, but it does mean that Python ships with a Tcl interpreter and some other stuff to make it work which causes some amount of explosion in the building python. This isn't a great thing given how little tkinter is really used out in the real world.Ghost of Reagan Past posted:But yes just rip off the Python 2 bandaid. Now that supervisor 4 has Python 3 support there is basically zero excuse for it. Your lovely legacy application needs to get ported to Python 3, and that's all there is to it.
|
# ¿ May 25, 2019 16:09 |
|
the yeti posted:Is there a way to organize a Flask app that doesn't involve hypothetical end users either relying on the developer to host the app or arranging their own server?
|
# ¿ May 26, 2019 03:51 |
|
You can pretty easily just iterate through possible python versions available on the path? In bash for Linux with "future-proofing": code:
I believe pipenv does something similar when you specify --three or whatever when creating an environment. Could also test for tools like pyenv if you wanted to get really fancy for people who install versions of python but do not add them to their path, but trying to deal with users who have python installed, but not on the path is a pointlessly hard endeavor. For the second point, you could potentially use the code:
Master_Odin fucked around with this message at 17:17 on Jul 15, 2019 |
# ¿ Jul 15, 2019 17:13 |
|
I guess Kennith Reitz is getting out of the game? https://github.com/not-kennethreitz/team/issues/21 I sincerely hope that requests falls into the PSF organization and that they take over governance. It'll also be interesting to see if we do end up with another event-stream event.
|
# ¿ Jul 18, 2019 22:59 |
|
Thermopyle posted:I hope someone hires him.
|
# ¿ Jul 19, 2019 00:34 |
|
What's the suggested way to handle dependencies for a larger system installation getting installed on the local machine and that we expect local system users to be manually executing some number of the python scripts? The python scripts are going to be located at /usr/local/butts/bin and that we expect the users to just cd into the directory and directly run ./script.py and not do python3 script.py. Would the best option just be to put a virtualenv in the directory and make the shebang point to the python executable in the venv or is there some better way that I'm missing. These are not power users and I'd like to avoid having to explain what is virtualenv or pipenv or anything like that to them.
|
# ¿ Aug 16, 2019 16:59 |
|
For cx_freeze or nuikta, I'm guessing I go into a virtualenv with my necessary dependencies, compile, leave the virtualenv and then the scripts can be executed as is?
|
# ¿ Aug 16, 2019 18:49 |
|
necrotic posted:The output is a single binary with everything embedded.
|
# ¿ Aug 16, 2019 20:15 |
|
Boris Galerkin posted:I’m making a toy script to check the git repo status of all the repos I have on my computer. Right now I’m just using subprocess.run and doing some regex on stdout to check things like if I’m behind or have new files or whatever.
|
# ¿ Aug 29, 2019 17:42 |
|
Can you not use the --user parameter to also specify only install to your user account? Or just a virtualenv? You could also go with https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en and be able to do a bit more fine-grained HTML updating through JS. What I mean here would be that your python code writes the results to a JSON file, an then a basic HTML file that just shows the body and has a JS function that pings the JSON file every x seconds and updates the HTML structure accordingly.
|
# ¿ Sep 8, 2019 13:59 |
|
|
# ¿ May 2, 2024 21:34 |
|
Generate your requirements.txt file via pip freeze. Itwill output a full list of installed packages, including what version they are.
|
# ¿ Aug 18, 2020 18:29 |