Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
necrotic
Aug 2, 2005
I owe my brother big time for this!
Yeah, missing qoutes around the key.

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!
He's doing that.

Just send the email as plain text so the newlines work. Otherwise you'll need something like pygments to generate stylized HTML. Bare minimum would be replacing newlines with <br> tags.

necrotic
Aug 2, 2005
I owe my brother big time for this!
If you parse it then pprint you get the native representation. But that wouldn't help with the case of injecting that output into an email any more than the JSON.dump(indent=4) approach would.

necrotic
Aug 2, 2005
I owe my brother big time for this!
There's an entry in SecurityGroups that doesn't have a Tags key, which would throw that error. You probably want to make sure the Tags key exists before reading it!

necrotic
Aug 2, 2005
I owe my brother big time for this!
That error means one of the securitygroup iterations does not have a key "Tags" defined, so the error is thrown. You basically want:

code:
for securitygroup in response["SecurityGroups"]:
    if "Tags" in securitygroup:
        for tag in securitygroup["Tags"]:
            # blah blah blah

necrotic
Aug 2, 2005
I owe my brother big time for this!
Just do f"shared.string.{i}"

edit almost

necrotic
Aug 2, 2005
I owe my brother big time for this!
https://github.com/asottile/future-fstrings/blob/master/README.md ?

necrotic
Aug 2, 2005
I owe my brother big time for this!
Based on the name I would think not, but the name could be more clear with like get_top_item_from_queue. Always returning a list for even single item gets seems annoying as hell from a usage perspective. Don't make me destructure/unwrap every time I use a method.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Master_Odin posted:

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.

Not a single file but you could clone pyenv and look at the list of version files:

https://github.com/pyenv/pyenv/tree/master/plugins/python-build/share/python-build

necrotic
Aug 2, 2005
I owe my brother big time for this!
It has backports of new python features.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Sort of. Its so new behaviors can be introduced without breaking older releases.

https://docs.python.org/3/reference/simple_stmts.html#future-statements

https://docs.python.org/3/library/__future__.html

necrotic
Aug 2, 2005
I owe my brother big time for this!
All operators are magic methods, no? Like < is __lt__? Reference those instead perhaps.

There's also the operator library: https://docs.python.org/3.4/library/operator.html

edit: not sure if you can do this for and/or.

necrotic
Aug 2, 2005
I owe my brother big time for this!
I don't think using PureWindowsPath would help here, but I could be wrong. If all you need is the extension to ignore case use glob syntax: *.[pP][yY].

edit: On using PureWindowsPath, the implementation of #match is from the superclass PurePath. Each of the "flavors" has a case-folding method applied to the input, and on Windows it simply "to-lowers" the input. Using that on a Linux system would cause even more issues with case sensitivity!

necrotic fucked around with this message at 21:28 on Jul 3, 2018

necrotic
Aug 2, 2005
I owe my brother big time for this!
MacOS is not Linux and is not case sensitive by default.

necrotic
Aug 2, 2005
I owe my brother big time for this!

mr_package posted:

On MacOS, Path instances are PosixPath by default.
code:
>>> import pathlib
>>> type(pathlib.Path())
<class 'pathlib.PosixPath'>
>>> pathlib.Path("A.PY").match("*.py")
False
>>> pathlib.PureWindowsPath("A.PY").match("*.py")
True
This case sensitivity extends to files on disk too even if the underlying filesystem isn't e.g. if you loop Path.iterdir() trying match("*.zip") and someone has named their file AWESOME.ZIP it will fail.

That's pretty nutty... the OSX file system is case insensitve, I'd expect my Path/Glob library to treat pretend access the same. The Windows implementation does the downcase to emulate this, I assumed they did the same for OSX.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Double linked lists with fixed length blocks, with new block data starting in the center of the block.

https://github.com/python/cpython/blob/master/Modules/_collectionsmodule.c

necrotic
Aug 2, 2005
I owe my brother big time for this!

Linear Zoetrope posted:

I wish PyLint and PEP8 checkers were better about metaclasses, but there's only so much you can do. It's a running problem for me because I'm using protobuf and the generated files are 100% metaclasses and I hate to turn helpful lints off just because a bunch of classes from one file break the poor linter's brain when used.


flake8 lets you configure directories or files to exclude entirely, not sure about pylint.

necrotic
Aug 2, 2005
I owe my brother big time for this!
That is the server telling you it will not accept the request for not matching whatever schema it expects. Inspecting the traffic wouldn't help you there. It does look like you're using requests correctly. Does the API also expect a body in the request instead of only the file part?

necrotic
Aug 2, 2005
I owe my brother big time for this!
What would you proposed it look like instead?

necrotic
Aug 2, 2005
I owe my brother big time for this!
Looks like it is expecting a specific mime type on the file payload. I dont know how to do that with requests off the top of my head, but look around for customizing the mime type on the file in the request.

necrotic
Aug 2, 2005
I owe my brother big time for this!
No, the file itself is attached with a different content type. It's multipart, like email.

here https://stackoverflow.com/questions/15746558/how-to-send-a-multipart-related-with-requests-in-python

necrotic
Aug 2, 2005
I owe my brother big time for this!

baka kaba posted:

Can't you just do it like this?
http://docs.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file
(second example, specifying the content-type explicitly)


Yeah that looks way better. I just did a phone search :effort:

necrotic
Aug 2, 2005
I owe my brother big time for this!
Do any scripting languages allow using main as an entry point, without explicitly calling it?

necrotic
Aug 2, 2005
I owe my brother big time for this!
IntelliJ IDEs have known performance issues with Retina displays and I've been unable to use them as my daily driver because of it. Noticable lag moving the cursor around or typing, and even worse lag resizing or using GUI elements.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Lambdas in python are purposefully awful which is unfortunate.

necrotic
Aug 2, 2005
I owe my brother big time for this!
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.

This is tricky with CI though since you can only run the lint against files changed in the commit or it'll fail for you constantly.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Yeah, mixing lint fixes in with a PR can get messy. We tried to enforce a "first commit has the lint fixes" which worked most of the time (you could review all but that commit easily enough), but sometimes a mid-PR change would then touch another file.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Can you just use the official docker container as your base? https://www.tensorflow.org/install/docker

necrotic
Aug 2, 2005
I owe my brother big time for this!

Sad Panda posted:

Is there a way to find the changelogs for packages that are updated but don't necessarily have anything useful? For example I'm using PyAutoGui. 3 days ago 0.9.43 was released. If I look at the Github (https://github.com/asweigart/pyautogui/commits/master) the latest is 0.9.42 but PyPi (https://pypi.org/project/PyAutoGUI/0.9.43/#history) shows that 0.9.43 exists but I have no idea what changed.

It doesn't necessarily have to be showdiff, it's just that I'm reticent to upgrade without know what's happened given it's going to a semi-important project

I'd open an issue on the repo and ask why there are releases but no changes to the repo. Their changes document hasn't been updated since 0.9.40 either.

They just released another one today, even. You're only option at this point is to diff the package contents.

necrotic
Aug 2, 2005
I owe my brother big time for this!
You're just counting how many strings are literally just the letter entered.

necrotic
Aug 2, 2005
I owe my brother big time for this!
You can do that on an instance of any class.

https://docs.python.org/3/tutorial/classes.html#odds-and-ends

necrotic
Aug 2, 2005
I owe my brother big time for this!

KICK BAMA KICK posted:

e: wtf how does it pull an Ubuntu image in 26mb?

Its not the same as the server ISO, which includes a lot of packages. The image is basically just the rootfs.

https://github.com/tianon/docker-brew-ubuntu-core/blob/9db8c72dd02e8f9fd5dba82ff9266174b088e2e6/bionic/Dockerfile

Docker images can grow in size pretty quickly if you aren't good about cleaning up each run step. I went through one of ours recently and stripped out nearly a gig of trash from the image. It's still 600mb, but the majority of that are artifacts for the application itself.

necrotic
Aug 2, 2005
I owe my brother big time for this!
The output is a single binary with everything embedded.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Use while true and set the answer at the top of the loop. As written you only read the input once.

necrotic
Aug 2, 2005
I owe my brother big time for this!
The break is already in the right spot, but an input other than Y will not reach it and loop forever without requesting a new input.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Given the "problem" requires repeating the question unless "Y" is given, and having different responses for "N" vs any other character, that doesn't seem like a great approach...

edit: I'm pretty sure you just wanted to give an example of the approach but it totally fails for the "problem" presented.

necrotic
Aug 2, 2005
I owe my brother big time for this!
If you've already pushed you have to either force push the newly amended commit, or do what PyCharm is making you do. Maybe a setting changed and it's pushing automatically, if you didn't do that manually.

Or it just force pushed before and they realized that was dumb, so now it doesn't.

necrotic
Aug 2, 2005
I owe my brother big time for this!
If you can't rename them then a for i in range(len(file_list)) and constructing the filename from i+1 would be easy, assuming no numbers are skipped in the filenames.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Use pyenv or anaconda to use different python versions.

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!
It could be timeouts on the wait for. Not sure how the python driver works but it bit me in the past with random slow page loads. We increased the default timeout and that fixed it.

Edit: though that doesn't look to involve a full page load. Still worth a quick check.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply