|
NtotheTC posted:I mean thats two separate points really. You want to avoid using system python for installing an apps dependencies into because you may have multiple apps on the same system that have conflicting requirements. If you already isolate the python environment becsuse you use containers or whatever then absolutely you can install things into system python. If you're on Windows (47% of respondents) then you don't even have a system python so it's moot. On linux a lot of those folks are probably using yum or apt-get to install whatever modules are provided for their flavor of linux, and that's almost definitely not going to hurt anything but will be able to take care of any dependencies for the most popular applications A lot of operating systems even offer packages that are basically venvs. I know for a fact that RHEL does this, RHEL7's system python is still python2.7 but you can download and install all sorts of python flavors via yum and then at that point you're definitely not going to be harming the system because all of that poo poo is definitely not being used by the operating system. QuarkJets fucked around with this message at 07:38 on Feb 8, 2019 |
# ? Feb 8, 2019 07:35 |
|
|
# ? May 16, 2024 04:37 |
|
NtotheTC posted:Related: https://www.jetbrains.com/research/python-developers-survey-2018/ Kind of interesting that 30-ish percent of users are using containers for a pure python environment. I always thought it was a novel way to do isolation (it's my preferred method) but I never thought it would catch on beyond 15% or so
|
# ? Feb 8, 2019 07:37 |
|
Foxfire_ posted:Write it back out to disk as a big binary array, memmap it, and let the OS swap it in and out as needed? Not sure I follow this. I tried a memmap but seemed to just hose my machine.
|
# ? Feb 8, 2019 14:46 |
|
When doing type annotation is it conventional to import a module not otherwise needed solely to reference a type it defines in a parameter annotation, or to use a string literal instead? (Not asking about the issue of circular references.) The one prompting this question would be a datetime.date, standard library and presumably inexpensive, if that's a consideration, but I'm sure I'll come across others that aren't.
|
# ? Feb 8, 2019 23:12 |
|
KICK BAMA KICK posted:When doing type annotation is it conventional to import a module not otherwise needed solely to reference a type it defines in a parameter annotation, or to use a string literal instead? (Not asking about the issue of circular references.) The one prompting this question would be a datetime.date, standard library and presumably inexpensive, if that's a consideration, but I'm sure I'll come across others that aren't. Yes. However, this is a potential gotcha if the module is something that takes a while to import. PEP-563 should address that issue.
|
# ? Feb 8, 2019 23:40 |
|
Thermopyle posted:Yes.
|
# ? Feb 9, 2019 00:05 |
|
SirPablo posted:Not sure I follow this. I tried a memmap but seemed to just hose my machine. If you try to read 50GB into memory, you'll get an out-of-memory error since you don't have that much RAM (or if you have 50GB+ of swap enabled, you'll effectively get a crappy memmaped behavior). Memory mapping it is telling the OS "When I try to access something in this region of memory, go read the surrounding little area from disk and pretend that was in the memory+cache it so that if I access it again you don't have to go all the way to disk". If you touch a new area and there's no free RAM to use to cache it, some other disk-backed page will get kicked out of RAM according to the OS's policies and the next program that touches that will have to wait while it reads in from disk (and boots something else). If you're accessing the 50GB in a random unpredictable way (so that every read/write is likely to have to be loaded from disk and boot some other page to make space), there's not really anything you can do to make it run well besides get more RAM. But if the access pattern is sequential or has locality like most do, accesses will tend to be to regions that are already cached.
|
# ? Feb 9, 2019 08:09 |
|
You can use the dask read_csv function to load in multiple files the way you want. Read the docs. You may want to pass over the data once though and put it in a format like parquet so it is faster to load and work with. You could consolidate the number of files so that the average size is about 100MB which is what I believe they recommend is a good size of a chunk. vikingstrike fucked around with this message at 16:33 on Feb 9, 2019 |
# ? Feb 9, 2019 16:08 |
|
When I try to use a virtual environment a big warning comes up from little snitch (a firewall) saying it is super insecure as "The code signature of “python3.7” is invalid. It may have been maliciously modified.". Is the new environment python meant to have a different code signature, and is it ok to allow this? e: doesn't have an issue using venv, but virtualenv and pipenv apparently have modified code signatures. Crack fucked around with this message at 14:12 on Feb 11, 2019 |
# ? Feb 11, 2019 13:59 |
|
Crack posted:When I try to use a virtual environment a big warning comes up from little snitch (a firewall) saying it is super insecure as "The code signature of “python3.7” is invalid. It may have been maliciously modified.". Is the new environment python meant to have a different code signature, and is it ok to allow this? No one can answer this without more information such as what this firewall actually is, and exactly what you're doing. Did you download virtualenv from a torrent or something? What's the software that's yelling at you? FWIW, heuristic-based security software like this always throws a lot of false positives; particularly when doing things like virtualenv does...moving and modifying binaries.
|
# ? Feb 11, 2019 19:09 |
|
I found this in the end (although I'm just using system python and packages from pip, not brew). It's a known bug and the conclusion is that the OS itself determines that the code signature is invalid, and noone knows why. VVVVV Ha, I actually tried to clarify with the parentheses but I can see how it might have actually had the reverse effect. Crack fucked around with this message at 23:07 on Feb 11, 2019 |
# ? Feb 11, 2019 20:33 |
|
Well see, I didn't even know what I was talking about. When you said "little snitch" I thought you were just calling some software a name...I didn't realize that was actually a thing.
|
# ? Feb 11, 2019 20:57 |
|
Just found out earlier you can run python -m http.server from a directory and it'll host it as a basic webserver
|
# ? Feb 12, 2019 01:34 |
|
baka kaba posted:Just found out earlier you can run python -m http.server from a directory and it'll host it as a basic webserver
|
# ? Feb 12, 2019 04:26 |
|
Is there a better way to do this? I have a string variable srv_name of the format: _sip._udp.servertype.domain.com. I want to trim it to produce: domain.com. Only the _sip._udp. portion is static and the rest of the values will be dynamic. I'm using srv_domain_suffix = srv_name.split('.')[-3] + '.' + srv_name.split('.')[-2] + '.' It seems to work fine but is there a better, more efficient way, of doing it?
|
# ? Feb 12, 2019 04:58 |
|
Scrapez posted:Is there a better way to do this? You can use .join on a slice of the the last N entries from split: code:
|
# ? Feb 12, 2019 06:57 |
|
rsplit with a limit might be slightly more efficient, if you know you just want the last 2 elements
|
# ? Feb 12, 2019 11:07 |
|
baka kaba posted:Just found out earlier you can run python -m http.server from a directory and it'll host it as a basic webserver Just found out later this can give me corrupt zip files where Mongoose works just fine - revoked
|
# ? Feb 12, 2019 14:43 |
|
I think its very much not recommended for production. I like using it for testing port access on servers
|
# ? Feb 12, 2019 19:51 |
|
I just wanted an easy way to host files I can access through http on an android emulator, so I'm not bothered about the security - getting CRC errors is a no-no though :/
|
# ? Feb 12, 2019 20:36 |
|
I just caught up on this thread after I had something like 200 unread posts lingering, and just wanted to thank Thermopyle for the example using Protocol. That might solve one of my remaining type-hint problems. Somewhat related, I tend to use Union[<possible_types>, None], rather than Optional[<possible_types>] for readibility since I find it makes the intention a bit clearer and fits better into the paradigm to specify all possibly outcomes explicitly. Unrelated: I went to FOSDEM two weeks ago, and there was a cool talk by a Redhat engineer about using oslo.config for config management. Config management is something I have been struggling with for a while, especially tying together environment variables, config files and command-line arguments, as well as development environments. I played around with that last weekend a bit, and while some things are a bit odd (I opted not to use their global "Conf" object, since that seems to be something that exists because OpenStack uses it), I like that it lets you define options in one place (including defaults) and expose as config/env/command-line arguments with very little overhead, including generating the required argparse stuff automatically. It's not the slimmest library considering the principal components for config/env/command-line could also simply come from the stdlib, but I think it might just be worth it. Here is a simple example that exposes options both as config file options as well as command-line options: code:
Hollow Talk fucked around with this message at 23:40 on Feb 17, 2019 |
# ? Feb 17, 2019 23:37 |
|
Hollow Talk posted:I just caught up on this thread after I had something like 200 unread posts lingering, and just wanted to thank Thermopyle for the example using Protocol. That might solve one of my remaining type-hint problems. Thanks. I really like Protocol and think structural typing is a much better fit for Python than "regular" types. Python is all about duck typing, and Protocols seem to mesh with that paradigm better. Hollow Talk posted:Somewhat related, I tend to use Union[<possible_types>, None], rather than Optional[<possible_types>] for readibility since I find it makes the intention a bit clearer and fits better into the paradigm to specify all possibly outcomes explicitly. I lean toward using Optional on function arguments and Union on function return values. "Optional" seems to describe the intention of arguments with default values. However, I also get your argument against this.
|
# ? Feb 18, 2019 17:07 |
|
Oh, some other typing-related thoughts/news: 1. There is finally a Literal type in typing_extensions, which should make numpy/scipy users happy. This lets you specify a literal value as the type to check. It's pretty common in python to use various string values instead of an enum. So, in a totally contrived example: Python code:
3. @overload is pretty neat Python code:
4. I can't remember if I said this before, but typing_extensions is how mypy devs get around the fact that python's typing module can only be updated on new releases of python. Generally how it works is new types get discussed on the mailing list and github issues. They get experiemented on in mypy_extensions, get moved to typing_extensions when everyone is happy with them, then a PEP gets published and they get moved into python's typing module when PEP is accepted. Thermopyle fucked around with this message at 17:36 on Feb 18, 2019 |
# ? Feb 18, 2019 17:33 |
|
Thermopyle posted:Oh, some other typing-related thoughts/news: That’s pretty neat and I didn’t know about that. Is there a place I can read, watch, or listen about these types of “hidden/advanced” features? Searching for anything Python related seems to be a shitshow cause it’s just endless pages of blog posts that fall into one of two categories: extremely basic stuff on the level of “this is a list” or the “here is a curated list of awesome libraries” where it’s the same things listed as every other list without actually going into detail about why it’s awesome.
|
# ? Feb 19, 2019 09:36 |
|
Boris Galerkin posted:That’s pretty neat and I didn’t know about that. Is there a place I can read, watch, or listen about these types of “hidden/advanced” features? Searching for anything Python related seems to be a shitshow cause it’s just endless pages of blog posts that fall into one of two categories: extremely basic stuff on the level of “this is a list” or the “here is a curated list of awesome libraries” where it’s the same things listed as every other list without actually going into detail about why it’s awesome.
|
# ? Feb 19, 2019 16:29 |
|
Boris Galerkin posted:That’s pretty neat and I didn’t know about that. Is there a place I can read, watch, or listen about these types of “hidden/advanced” features? Over the years, I've found a good way is to follow the issue trackers of various projects. Github makes this pretty easy (except their notification system is terrible). That last post of mine was as a result of me clicking through an email notification to the python/typing issue tracker and getting caught up wikipedia-style reading other related issues where core devs talk about how to solve different problems, what they're working on, pull requests they're discussing, etc.
|
# ? Feb 19, 2019 16:59 |
|
Hadlock posted:Kind of interesting that 30-ish percent of users are using containers for a pure python environment. I always thought it was a novel way to do isolation (it's my preferred method) but I never thought it would catch on beyond 15% or so In the field i am with people making "easy" testing tools in python they will always surprise you with what requirements they want. containers is the only way to making any of these god drat enviroments portable.
|
# ? Feb 20, 2019 16:26 |
|
Thermopyle posted:Over the years, I've found a good way is to follow the issue trackers of various projects. Github makes this pretty easy (except their notification system is terrible). Where can I read what you wrote in the second paragraph?
|
# ? Feb 21, 2019 11:37 |
|
Umm, look at the python/typing repo on github.
|
# ? Feb 22, 2019 02:14 |
|
shoutout to MSS for being the best image capture library for real time analysis https://python-mss.readthedocs.io/examples.html pros: -it's fast as hell -it's really really fast there are still many blogs and tutorials that recommend PIL's imagegrab or even weirder pyautogui's screenshot which is just imagegrab imported on demand. that might be ok if you're not time constrained, but if you're like me trying to write cheat software you should probably use mss which can capture your entire monitor at 20 fps pretty easily. most of you might already know this but after using it the past few weeks it's good, folks.
|
# ? Feb 22, 2019 03:50 |
|
Has anyone figured out how to re-enable pylint message codes in vscode? This was added as a "feature" in 2019.1.0 ... GitHub issue #2906 Personally I like the message codes as it's easy to #pylint: disable=W0105 or whatever when necessary, so my linter problems stay clean and I can focus on actual problems Also googling a message code is way way more efficient Hadlock fucked around with this message at 07:49 on Feb 22, 2019 |
# ? Feb 22, 2019 07:43 |
|
Thermopyle posted:Umm, look at the python/typing repo on github. Oh, I thought you meant like another message board or something. Thanks. I'm digging into tox right now and it's a bit confusing. Is tox suppose to only run tests or do people use it for more than that? Here's what my simple tox.ini file looks like right now: code:
e: In a way this feels like a makefile but specifically for python. Boris Galerkin fucked around with this message at 10:10 on Feb 22, 2019 |
# ? Feb 22, 2019 10:03 |
|
I'm trying to compile a pattern to match a basic linear equation of the format 3y<=1+2x However, my regex expression is giving me an empty group at the end: (?<sign>\+|\-?) (?<coeff>[1-9]*) (?<var>[a-z]?) (?<equality>>=|<=|=?) I understand it's because all of my capture groups are optional. In actuality, there will always be at least one variable or one coefficient, so my capture groups aren't reflecting that reality correctly. My efforts to use the OR operator have failed. I can't figure out how to make it work. Might somebody be able to point me in the right direction?
|
# ? Feb 23, 2019 12:01 |
|
Vegetable posted:I'm trying to compile a pattern to match a basic linear equation of the format 3y<=1+2x Which parts do you need separetely? Realistically, I think I would probably go at this a bit differently. I would probably split this into three via ([^><=]+)([=<>]+)([^><=]+). This splits the left-hand, equality, and right-hand side pretty much regardless of actual content. Afterwards, you can then go and parse out individual bits out of these, while you can be reasonably sure that at least something has to be in each one of those groups. You can then go and and do something like [+-]{0,1} to capture +/- signs etc. I think some of your problems might disappear if you specify occurences explicitly, i.e. via the {min,max}-syntax, rather than the zero-or-more/one-or-more syntax. edit: More generally, depending how complex the equations you deal with get, you will probably have to either loop through the split parts, or use recursive regex, since there isn't necessarily a limit to how many operators/operands your equation might have. Hollow Talk fucked around with this message at 13:27 on Feb 23, 2019 |
# ? Feb 23, 2019 13:11 |
|
I'm doing this as homework for a course. With the example of input string '3x <= 6 + 2y + 7z', I'm supposed to get this: [('', '3', 'x', '<='), ('', 6, '', ''), ('+', '2', 'y', ''), ('+', '7', 'z', '')] The only thing I'm able to provide is the pattern -- I can't clean the input string, can't split it. The system takes the pattern and runs a findall with the string. e: You were right, I just needed to specify the coefficient group ([1-9]*) as mandatory rather than optional. Glaring oversight. Thanks! Vegetable fucked around with this message at 16:22 on Feb 23, 2019 |
# ? Feb 23, 2019 16:15 |
|
... that's a loving goofy homework problem
|
# ? Feb 23, 2019 19:41 |
|
I like using debuggex and other online regexp tools to debug those.
|
# ? Feb 23, 2019 21:26 |
|
Meyers-Briggs Testicle posted:shoutout to MSS for being the best image capture library for real time analysis is there a good resource/example tutorial i can read about this kind of thing? sounds extremely cool
|
# ? Feb 23, 2019 22:55 |
|
punished milkman posted:is there a good resource/example tutorial i can read about this kind of thing? sounds extremely cool if your goal is something like this https://www.youtube.com/watch?v=iXUIOx8ZSPw then https://automatetheboringstuff.com/chapter18/ is a good baseline, its also pretty easy. Real Image Analysis is like https://www.pyimagesearch.com/2018/07/16/opencv-saliency-detection/ and can get as complex as you want to make it. check opencv docs, a lot of different methods are available. the tools are all there, developing an efficient heuristic is the hard part. how does one take a static image and find an enemy's head to zoom to click on? good question, I'll let you know when I find one. it's certainly not the best way to do it (learn cpp and write a dll wrapper if your goal is sicknasty headshots in apex legends) but it sounded interesting to try.
|
# ? Feb 24, 2019 00:29 |
|
|
# ? May 16, 2024 04:37 |
|
Meyers-Briggs Testicle posted:shoutout to MSS for being the best image capture library for real time analysis I've played with MSS before, but have gone back to using PyAutoGUI with OpenCV as a backend. The jump from the Python backend to the OpenCV backend is crazy. One of the things that I use the most is pyautogui.locateCenterOnScreen(). I flicked through the MSS API but don't see an equivalent. How would I use that if I switch to MSS?
|
# ? Feb 24, 2019 00:45 |