|
I am setting up a python dev environment on Windows 11, only ever used Linux or Mac. On those I just `conda install python3` and let conda manage all my dependencies cause I typically need the scientific poo poo. Just do the same thing in Windows?
|
# ? Feb 6, 2024 02:43 |
|
|
# ? May 11, 2024 12:19 |
|
Boris Galerkin posted:I am setting up a python dev environment on Windows 11, only ever used Linux or Mac. On those I just `conda install python3` and let conda manage all my dependencies cause I typically need the scientific poo poo. If you've used Anaconda and it works for you, keep using conda. I hope you don't need any packages from bioconda, because they do not support Windows.
|
# ? Feb 6, 2024 02:53 |
|
Boris Galerkin posted:I am setting up a python dev environment on Windows 11, only ever used Linux or Mac. On those I just `conda install python3` and let conda manage all my dependencies cause I typically need the scientific poo poo. That's pretty much it, yeah
|
# ? Feb 6, 2024 23:20 |
|
Yeah if you're doing science / analysis stuff and already familiar with it I've yet to hear about any killer feature to justify moving from conda to something dev oriented like poetry or whatever.
|
# ? Feb 7, 2024 00:55 |
|
Boris Galerkin posted:I am setting up a python dev environment on Windows 11, only ever used Linux or Mac. On those I just `conda install python3` and let conda manage all my dependencies cause I typically need the scientific poo poo. Have you considered running WSL2 instead? I use it for dev with poetry and works great.
|
# ? Feb 12, 2024 00:26 |
|
Slimchandi posted:Have you considered running WSL2 instead? I use it for dev with poetry and works great. Why would you setup a whole OS layer for python installs? Like WSL is great and all but there's nothing about WSL you can't do with windows as far as python installs and stuff goes. Edit: Forgot the person you were replying to specifically said they were familiar with Linux. Ignore me.
|
# ? Feb 13, 2024 03:40 |
|
Setting up a windows dev environment serves two purposes for me: 1. I’ve never done any programming in a non-*nix based environment. I’m genuinely curious. 2. At my job we use some various command line tools ran via Cygwin, some being python scripts, and let’s just say that these tools are “statically” (i mean, the paths are hard coded, everything is hard coded) linked to a random python.exe file inside a completely and entirely unrelated software folder in c:/program files. These python scripts are like mission critical. Like seriously one of the default things they do is download and install an old version of a program that we don’t use just because all the python scripts we do use point to a python.exe inside that folder. I’d like to change that but now that I typed this all out I feel like I should just leave it alone. E: So setting up python in windows for my own personal use was to get python running. I’m (obviously) not going to copy company code onto my personal computer or work for free at home to figure this out, but I figure I could develop a simple concept for my own learning purposes, and then from there see if I can propose to get some support/funding to at the very least set up a dedicated and reproducible python environment for work poo poo. Boris Galerkin fucked around with this message at 13:47 on Feb 13, 2024 |
# ? Feb 13, 2024 13:42 |
|
I have never had good experiences setting up python in windows, so I just use a VM with linux on it.
|
# ? Feb 13, 2024 16:18 |
|
simple python envs work fine in windows depending on what you're doing some packages may not work cleanly that being said, my daily driver is a windows machine but I do 90% of my work in WSL or a docker container.
|
# ? Feb 13, 2024 16:23 |
|
Yeah I am bad at windows development and setting up environments, if it's for a project I know I'll eventually want/need to dockerise it anyway so I just start with that and then use python from within the container
|
# ? Feb 13, 2024 16:34 |
|
Well I'll weigh in then. On my home computer I use exclusively Windows for dev. I've used both poetry and venv without any trouble and also have used pyenv to manage my various python base installs too. That one took some extra setup but still worked pretty well. I dev on Linux at work so I guess I could have used WSL, but it just seemed unnecessary. All the confusing parts for me were getting vscode to find the install which isnt an os specific problem as far as I can tell
|
# ? Feb 13, 2024 20:18 |
|
Is using docker to do builds with pyinstaller a dumb idea or a great idea? It seems like a venv could work just as well but there's always something weird going on
|
# ? Feb 13, 2024 21:24 |
|
StumblyWumbly posted:Is using docker to do builds with pyinstaller a dumb idea or a great idea? Ive only ever pip installed my requirements in the container's dockerfile but is always for AWS Lambda.
|
# ? Feb 13, 2024 21:31 |
|
What I mean is, we use pyinstaller to make executables for our stuff. It always seems like this is a very delicate process because we have dlls and special files to include, so I've been encouraging folks to set up a docker that can make the build. I feel like a venv should fix these problems but it also sounds like it hasn't in the past, and I'm not sure if I'm remembering the ancient past or if there are things that just work better outside a virtual environment
|
# ? Feb 14, 2024 13:11 |
|
I dunno, sounds like a container might be perfect if you have weird dlls and stuff. No experience with building that into venvs etc. If a solution works it's probably not that stupid.
|
# ? Feb 14, 2024 17:41 |
|
Doing your build in docker is not a terrible idea except for the fact that windows containers are horrible.
|
# ? Feb 14, 2024 17:47 |
|
Anyone got a technique or tips for having a globally available script run from a venv without making a user source the activate script? It also needs to support tab completion (using the argcomplete module). I've got a script that needs some newer modules than the base OS provides, and I'm not able to mess with OS packages. I've done some googling and found some suggestions for making a wrapper script or setting up an alias setting with environment variables, but nothing really works all that well. The tab completion is the biggest hangup. I know I'm going to have to drop a script in profile.d to do some setup and that's fine, but it would be nice if it could work transparently without interfering with other python scripts that aren't in the venv.
|
# ? Feb 14, 2024 20:06 |
|
StumblyWumbly posted:What I mean is, we use pyinstaller to make executables for our stuff. It always seems like this is a very delicate process because we have dlls and special files to include, so I've been encouraging folks to set up a docker that can make the build. A build container is the ideal usecase for this kind of thing, you're right. With venv you get a partial sandbox, pyinstaller can be dependent on more than what venv alone provides.
|
# ? Feb 14, 2024 20:16 |
|
xzzy posted:Anyone got a technique or tips for having a globally available script run from a venv without making a user source the activate script? It also needs to support tab completion (using the argcomplete module). Write a wrapper script that activates the environment and then runs the script. Place that wrapper script in a common PATH location.
|
# ? Feb 14, 2024 20:22 |
|
xzzy posted:Anyone got a technique or tips for having a globally available script run from a venv without making a user source the activate script? It also needs to support tab completion (using the argcomplete module). Look at how pipx works, or just use it directly: https://github.com/pypa/pipx A virtual environment for each script, and an entrypoint script put somewhere on the users path that launches the right python.
|
# ? Feb 14, 2024 20:33 |
|
There's also Pex: https://pex.readthedocs.io/en/v2.1.163/ It requires that an interpreter matching your constraints be present on the system already, but otherwise, it includes all runtime dependencies and acts as a hermetic environment like a venv does.
|
# ? Feb 14, 2024 22:08 |
|
I used pex for a thing and I liked it. We ended up shelving it and writing a rust version of the tool instead, and if we need to do more stuff in this area later, I have "try nuitka" on my todo list.
|
# ? Feb 14, 2024 22:13 |
|
I'm doing some projects and coding challenges to try and whip myself back into shape, and I encountered this:quote:Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front; My solution was as follows: code:
code:
|
# ? Feb 15, 2024 05:14 |
|
Actually, I think I can probably even do everything in a single line:code:
|
# ? Feb 15, 2024 05:15 |
|
The official solution is really verbose, non-Pythonic code, and the verbosity doesn't add anything useful like error checking. I don't think you're missing anything. E: It's possible the official solution is written that way for teaching purposes, since each step in the logic is explicit. Like, by taking 4 lines of code to get "front," that avoids needing to know that if you slice a string to a higher end index than the string's length, you just get whatever's in the string. Zugzwang fucked around with this message at 06:36 on Feb 15, 2024 |
# ? Feb 15, 2024 06:30 |
|
I think that if you’re learning to code, it’s better to be more explicit like their solution. If you’re just learning Python do what you’re doing. Kinda like math, how you’re very much encouraged to "show your work" so to speak. I wouldn’t expect students in like physics 400+ to show every single step of a derivative … but the intro to calculus 101 students would be expected to. Boris Galerkin fucked around with this message at 12:39 on Feb 15, 2024 |
# ? Feb 15, 2024 12:34 |
|
Seventh Arrow posted:Actually, I think I can probably even do everything in a single line: Your code is correct and generally better, but simple is not always shorter. Using that type of if statement is generally just unnecessarily dense. In some places like list comprehension I think it can make things more efficient, but if you can use a standard if statement instead you probably should
|
# ? Feb 15, 2024 13:55 |
|
yeah i'd just omit it and add a commentPython code:
as far as im aware the above code wont break for any value of text or num, so long as they're strings and integers respectively. 0, -1, or an empty string should all work and just return '' (i.e. an empty string). and value[:3] will just return whatever it has if the length is less than 3 +1 for not being a fan of conditionals coming after the action, feels like a minor code smell to me e: also you should keep an eye on your variable names, calling a string variable "str" is a bad habit to get into boofhead fucked around with this message at 14:12 on Feb 15, 2024 |
# ? Feb 15, 2024 14:08 |
|
Seventh Arrow posted:Actually, I think I can probably even do everything in a single line: I'd prefer your first conditional approach, both for clarity and because it would be more Pythonic to raise a ValueError rather than saying what's wrong in the return value.
|
# ? Feb 15, 2024 15:06 |
|
Yes I was thinking of a better way to handle that, so ValueError seems ideal. Thanks!
|
# ? Feb 15, 2024 15:29 |
|
e: ah jeez i misread the post lmao, ignore
|
# ? Feb 15, 2024 15:49 |
|
Seventh Arrow posted:I'm doing some projects and coding challenges to try and whip myself back into shape, and I encountered this: imo the actual solution is outright bad code, these things need to go or be changed: - Argument name "str" - String concatenation in a for loop - Bullshit function name - No docstring
|
# ? Feb 15, 2024 18:00 |
|
QuarkJets posted:imo the actual solution is outright bad code, these things need to go or be changed: Beyond the function name, these are all things that would get caught by a linter like flake8 or pylint, and it's a good idea to get in the habit of running code through these sorts of tools to see where they deviate from accepted style or hit things that, at scale, would become obvious performance torpedoes. Vulture Culture fucked around with this message at 13:43 on Feb 16, 2024 |
# ? Feb 16, 2024 13:40 |
|
Vulture Culture posted:Other than the input variable shadowing a builtin, which has the potential to create gnarly bugs later on, these aren't the kinds of things new devs, or arguably any devs, really need to spend cognitive energy on. (IMO, all internal utility function names are bullshit no matter how much you pretend they aren't. Beyond a small handful of developers, none of them will ever see actual reuse.) I still avoid using id as an attribute of a model because of that best practice, but yeah I don't think I've ever seen id() being used in the wild.
|
# ? Feb 16, 2024 13:46 |
|
Vulture Culture posted:Other than the input variable shadowing a builtin, which has the potential to create gnarly bugs later on, these aren't the kinds of things new devs, or arguably any devs, really need to spend cognitive energy on. (IMO, all internal utility function names are bullshit no matter how much you pretend they aren't. Beyond a small handful of developers, none of them will ever see actual reuse.) Doesn't saying "flake8 will see some these and then spit in your face" dispute the notion that new developers don't need to think about them? The missing docstring and bad function name are probably the two most important items on that list, new developers should definitely be thinking about these things when writing a new function. Every time.
|
# ? Feb 16, 2024 17:29 |
|
QuarkJets posted:Doesn't saying "flake8 will see some these and then spit in your face" dispute the notion that new developers don't need to think about them? QuarkJets posted:The missing docstring and bad function name are probably the two most important items on that list, new developers should definitely be thinking about these things when writing a new function. Every time. Vulture Culture fucked around with this message at 13:40 on Feb 20, 2024 |
# ? Feb 20, 2024 13:37 |
|
It's easy to say that anything is bad if you "overinvest" in it, that's not a real argument. Writing concise function names and concise docstrings are fundamental coding skills, they're as important as knowing how to define a function in the first place, and you get better at those skills with practice and review. You're not doing a new developer any favors by letting them skimp
|
# ? Feb 20, 2024 18:17 |
|
QuarkJets posted:It's easy to say that anything is bad if you "overinvest" in it, that's not a real argument. Writing concise function names and concise docstrings are fundamental coding skills, they're as important as knowing how to define a function in the first place, and you get better at those skills with practice and review. You're not doing a new developer any favors by letting them skimp I agree with this. I also agree that it's fine for them to backfill that during code review. I think it's challenging for noobs to really realize how frustrating debugging or improving code without docstrings etc can be, especially in Python where type hinting is optional.
|
# ? Feb 20, 2024 20:19 |
|
If we're saying that pull requests with badly named and undocumented functions should be blocked until those issues are fixed then we're all on the same page. If you're just messing around in a notebook then go nuts
|
# ? Feb 20, 2024 23:24 |
|
|
# ? May 11, 2024 12:19 |
|
Any pandas experts here? I've got an adhoc spreadsheet I need to clean for ETL (why this is my job as a data analyst, I don't know) but I'm having trouble even articulating the problem decently enough to leverage ChatGPT or Google. Spreadsheet (.XLSX file) is structured like this code:
Reading it in as a data frame with defaults has pandas assigning the "category" column as the index, but despite reading docs and googling I still can't really wrap my head around multi - indexes. Lots of tutorials on creating them, or analysing them, but can't find anything for the reverse (taking a multi-level index and transforming it into a repeating column value). The target model should be something like this: code:
edit: should specify that we'll like receive these types of spreadsheets with different labels and values. So I'd like to write it to be somewhat parameterized and reusable, which is why I'm not just hacking through this for a one-time ETL Oysters Autobio fucked around with this message at 02:32 on Feb 21, 2024 |
# ? Feb 21, 2024 01:14 |