|
yeah, I'm going to the ILC tomorrow for more help. Thanks for your help, though!
|
# ? Jun 25, 2019 23:32 |
|
|
# ? May 26, 2024 23:19 |
|
The Fool posted:I believe he was counting just 'E' or just 'e', and I assume he needed the count of both. Entirely possible.
|
# ? Jun 25, 2019 23:38 |
|
Something that I haven't found a good answer to: When trying to write simpler functions to encapsulate logic/business rules that require calling out to 3rd party web APIs, should I use the module-as-singleton pattern when dealing with the API client? Instead of having some kind of controller class with the API client injected, I would use something like: code:
code:
|
# ? Jun 26, 2019 06:47 |
|
Ehh, kind of depends on what your client does. It it's inexpensive, I'd just initialize it wherever you need to use it. If it needs to track state for like throttling or something, then I'd do it like you say.
|
# ? Jun 26, 2019 15:50 |
|
Check out 'high contrast' theme in PyCharm. Ugly at first but now I love the 100% flatness of it.
|
# ? Jun 27, 2019 23:29 |
|
mr_package posted:Check out 'high contrast' theme in PyCharm. Ugly at first but now I love the 100% flatness of it. I used it for awhile. It remained ugly, but I agree about the appealingness of the flat look. I'm using Material UI nowadays.
|
# ? Jun 28, 2019 00:40 |
|
I have a project ProjectA that needs moduleFoo. ModuleFoo provides a setup.py and was installed in a conda env, it can be imported in the env's interpreter. However ProjectA doesn't work unless I also add the absolute path to moduleFoo in PYTHONPATH, which I currently do in a bash script. I'd like to know how to deal with this cleanly. Should I have ProjectA's setup.py create the bash file with the correct paths ? (Assuming both directories sit next to each other) It doesn't look clean to rely on both a local and installed version of the module. unpacked robinhood fucked around with this message at 12:01 on Jun 28, 2019 |
# ? Jun 28, 2019 11:48 |
|
You almost certainly can solve this without ever dealing with paths. But it's not quite clear what the problem is. To me, this:unpacked robinhood posted:ModuleFoo provides a setup.py and was installed in a conda env, it can be imported in the env's interpreter. unpacked robinhood posted:However ProjectA doesn't work unless I also add the absolute path to moduleFoo in PYTHONPATH, which I currently do in a bash script.
|
# ? Jun 28, 2019 12:31 |
|
SurgicalOntologist posted:You almost certainly can solve this without ever dealing with paths. But it's not quite clear what the problem is. To me, this: Î don't understand it either. Is it possible ModuleFoo isn't installed correctly, as in "import ModuleFoo" goes fine, but actually using it from ProjectA doesn't work because it's accessing missing parts ? e: Fixed. Probably a botched module install due to space issues on my vm. unpacked robinhood fucked around with this message at 14:17 on Jun 28, 2019 |
# ? Jun 28, 2019 13:30 |
|
I'm just going around and around in circles. Is there a way to set Jupyter notebook / lab to accept a local IP address range? Ie 192.168.1.0/24 Really I just want to be able to use my Jetson Nano headless. I mean I can with ssh and rdp, but Jupyter would be a great platform to utilise it with, but the documentation is so drat terrible and I can't work out how to allow connections from only my LAN. It'd only be me connecting to it so it doesn't need to be anything fancy like Jupyter Hub. It just seems kind of silly to me that a browser based IDE thing is such a drat pain to use from other computers.
|
# ? Jul 1, 2019 11:02 |
|
The easiest way is to use the argument --ip='0.0.0.0'. This will allow any connection, but assuming your Jetson isn't exposed to the WAN it won't matter. If it is exposed, then I'm not sure what to put exactly but maybe the local LAN IP of the Nano.
|
# ? Jul 1, 2019 11:53 |
|
I used to use ZopeSkel to generate package boilerplate. That seems to have been replaced by templer. And templer has been replaced by what? Because templer.core is not installing on my system and it was last updated 6 years. So there must be a Brand New Thing.
|
# ? Jul 1, 2019 12:05 |
|
General_Failure posted:I'm just going around and around in circles. Is there a way to set Jupyter notebook / lab to accept a local IP address range? Ie 192.168.1.0/24 You could also give it a static IP if it's just at home. But really just do `0.0.0.0`, that's no less safe than the local ips unless it has a direct line out to the world. If you're really worried put nginx in front of it.
|
# ? Jul 1, 2019 12:30 |
So I'm making my first program with a non-HTML GUI using PyQt and I'm running into an issue with a Table widget not updating properly. It's a simple tool I'm working on for a student organization I'm in that keeps track of their soon-to-be-implemented points system for attending events. I have this method, update_student that is supposed to go through the table and update everything that changes for the necessary people:code:
The attendance method that calls update_student from a different window is: code:
code:
|
|
# ? Jul 1, 2019 21:53 |
|
nonathlon posted:I used to use ZopeSkel to generate package boilerplate. That seems to have been replaced by templer. And templer has been replaced by what? Wow zope and plone are some blasts from the past! As I haven't used either in many years, I can't answer your question exactly other than to say that those aren't exactly cutting edge. There's not a lot of new places deploying zope/plone so there's likely not a ton of developments for spinning up new projects.
|
# ? Jul 1, 2019 22:27 |
|
Phobeste posted:that's no less safe than the local ips unless it has a direct line out to the world. ... You are right. This is why I ask questions. I've been hung up on it for ages completely blind to the obvious. Thanks! Yeah it's just a bog standard LAN behind an ADSL2+ router. General_Failure fucked around with this message at 06:42 on Jul 2, 2019 |
# ? Jul 2, 2019 03:47 |
|
Thermopyle posted:Wow zope and plone are some blasts from the past! I know, blast from the past. ZopeSkel was one of the few tools to escape the Zope/Plone blackhole and actually be widely useful - it used paster / pythonpaste to make a commandline tool that could be used for generating the boilerplate for a package, a namespace package with all the necessary metadata files and config set up for distribution. I found it really useful. It looks like it was replaced by templer (now dead) and the current options are cookiecutter, create-python-package. modern-package-template and a whole lot of v.0.0.1 tools with no documentation. (As an aside, looking for ZopeSkel lead me to look at the Zope community for the first time in years. There's an interesting social study there, a once popular tool and community that choked on its own technology and is now staggering around like a zombie.)
|
# ? Jul 2, 2019 08:39 |
|
I made A package for dimensional analysis in SI units. Looking for suggestions/critique.
|
# ? Jul 2, 2019 15:26 |
|
nonathlon posted:I know, blast from the past. Oh, see I didn't even realize you could use ZopeSkel for non-Zope stuff. AFAIK, there's nothing that's really great at this. Mainly because python distribution/packaging is still a garbage fire. I think you mentioned the main options. There's been a lot of talk in the community about the situation recently, so maybe something will improve. On a vaguely related note, I came across PyOxidizer today. It seems like it might be a neat solution to the distribute-a-python-application-as-a-single-executable problem. It embeds the python interpreter into a Rust executable and wires it all up so your code Just Works.
|
# ? Jul 3, 2019 01:30 |
|
Thermopyle posted:On a vaguely related note, I came across PyOxidizer today. It seems like it might be a neat solution to the distribute-a-python-application-as-a-single-executable problem.
|
# ? Jul 3, 2019 02:38 |
|
Dominoes posted:Can't find a non-trivial use in the guide, and there are no examples. Well it was released only last week. File an issue.
|
# ? Jul 3, 2019 18:34 |
|
Thermopyle posted:File an issue.
|
# ? Jul 3, 2019 19:46 |
|
I did some data modeling using @dataclass objects but I'm suddenly very very confused by the implementation for @property and @x.setter. Is this comment anything to really be concerned about : https://stackoverflow.com/questions/51079503/python-dataclass-and-property-decorator#comment91326305_51080197 I did also read https://blog.florimond.dev/reconciling-dataclasses-and-properties-in-python and no way am I doing this. I'm confused because I just watched a bunch of stuff re: @dataclasses and didn't even see this come up in the discussion but I may have to re-watch now that I know what I'm looking for. Is it even a problem? Do we live with it? Or do we back away and say "Python is built on dictionaries I'm just going to use a dictionary instead"?
|
# ? Jul 6, 2019 20:27 |
|
mr_package posted:I did some data modeling using @dataclass objects but I'm suddenly very very confused by the implementation for @property and @x.setter. Is this comment anything to really be concerned about : If you use @dataclass, or classes at all, you're also kind of using dictionaries anyway so it's all gravy The fix is in that blog post (labeled Attempt 5), and I don't think "no way am I doing this" makes sense to say because fixing the issue only requires 1 additional line per @property. Specifically, you need to exclude the private attribute from __init__, which will allow the setter to get invoked when @dataclass assigns a value to the public version of the attribute. This is less intuitive than it could be (it would be nice if @dataclass could be smart enough to automagically identify that one of the attributes is a @property), but it makes sense when you understand what @dataclass and @property are doing.
|
# ? Jul 6, 2019 20:57 |
|
TLDR: Is pywin32 the only/easiest way to print PDFs with python on windows? —— I want to print a few hundred PDFs per week in a specific order from a specific copier and with alternating printer properties on windows. Some are hole punched with paper from tray one, some are b&w only from tray 2. Batch printing greatly slows down the manufacturing process that follows printing (assembling documents and mailers) Pywin32 looks complicated as gently caress for what should be a trivial problem. The “shell” method looks like it wouldn’t take enough arguments leaving me reading MSDN docs and going very low level. Has there really been no progress since 2010 or so?! Edit: I only have about 4 configs and 1 printer on 1 port I’m concerned with so I am going to try installing the same printer 4 additional times with unique names and default settings. Not an elegant pythonic solution but should work. CarForumPoster fucked around with this message at 22:36 on Jul 6, 2019 |
# ? Jul 6, 2019 22:19 |
|
Have you looked at pkipplib or win32print?
|
# ? Jul 6, 2019 22:42 |
|
CarForumPoster posted:TLDR: Is pywin32 the only/easiest way to print PDFs with python on windows? If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python.
|
# ? Jul 6, 2019 23:17 |
|
QuarkJets posted:Have you looked at pkipplib or win32print? Thermopyle posted:If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python. Yea the PDFs are already created with python. (A report, an envelope and a shipping label) Win32print is the pywin32 method that gets hilariously complicated quick. Sending a PDF to a printer that’s already configured is pretty easy. The problem is configuring the printer to do what I want (eg hole punch) from Python. I think the solution is “install 4 copies of the printer driver with different default configs” but can’t test until Monday. CarForumPoster fucked around with this message at 01:05 on Jul 7, 2019 |
# ? Jul 7, 2019 00:40 |
|
QuarkJets posted:If you use @dataclass, or classes at all, you're also kind of using dictionaries anyway so it's all gravy Then there's this: quote:Caveat: this approach only holds because the property's setter is implemented. If we only implemented a getter (i.e. to make a read-only field), the __init__() method wouldn't be able to assign the attribute and would crash.
|
# ? Jul 7, 2019 06:06 |
|
mr_package posted:Ok yeah on re-read it's not so bad, I was paying too much attention to the approaches that didn't work but in the end it's fairly simple, if not intuitive at first. It just seems so weird that it doesn't work normally out-of-the-box. @property / @x.setter are standard Python to me. I am really surprised they didn't engineer @dataclass to work with them by default. I consider it fully baked, because @dataclass is meant to be an extension of named tuples, and those don't support setters/getters at all. Given that, and given that @dataclass is a pretty new feature, I can forgive how the design didn't include a more intuitive interaction with @property, and it wouldn't surprise me if a future release fixed that. And based on how the interaction works today, I don't think that any future change to @dataclass is going to require that you modify old code, so it should be fine to use both together with the explicit understanding that either A) you need to define __init__ yourself (@dataclass provides more than just __init__, so this would still make sense to do) or B) allow the private attribute to be set by the __init__ created by @dataclass or C) ensure that the private attribute is excluded from the __init__ created by @dataclass and also have a setter. Note that @dataclass does not break @property; the issue is simply that @dataclass doesn't know how to create a __init__ method that uses properties correctly, so you wind up in a weird situation where your private attribute is what's required by __init__. Properties explicitly allow that; if you want the private attribute to be set by __init__ for some reason, that's totally fine and supported. QuarkJets fucked around with this message at 07:28 on Jul 7, 2019 |
# ? Jul 7, 2019 07:25 |
|
Thanks for your replies, I do not understand the guts of these things as well as you do and appreciate your time here.
|
# ? Jul 7, 2019 07:47 |
|
FWIW, I don't understand why the guy who wrote that blog post was so surprised or outraged that his working attempt worked. It's exactly how I would expect it to work. I wouldn't worry about it.
|
# ? Jul 7, 2019 18:51 |
|
Yeah, his attempt #5 is what I would try first. I see nothing alarming here, and I very much doubt Python will ever change dataclasses to make it easier to write properties. For one, this isn't actually about supporting properties in general, it's about supporting one specific use case for them, getters and setters. And the way to do it is pretty much the same as you would set up getters and setters in a normal class. As far as I can tell there isn't anything else that could be implemented to make it easier. After all, the need for a private attribute (and it's name) depends on the implementation of the properties. There's no way to infer it without some functionality that actually writes the properties for you...but then how would you customize?
|
# ? Jul 7, 2019 21:40 |
|
My interest in @property was really from Raymond H's talk "Python's Class Development Toolkit" where he talks about it being "a big big win for our language" so that's part of why I was so surprised by this. I've been going back and re-watching his talks now that I've been writing Python for a few years and it's been worthwhile obviously, picking up a lot of stuff I missed or didn't understand the first time. https://www.youtube.com/watch?v=HTLu2DFOdTg&t=2272s
|
# ? Jul 8, 2019 16:33 |
|
mr_package posted:My interest in @property was really from Raymond H's talk "Python's Class Development Toolkit" where he talks about it being "a big big win for our language" so that's part of why I was so surprised by this. I've been going back and re-watching his talks now that I've been writing Python for a few years and it's been worthwhile obviously, picking up a lot of stuff I missed or didn't understand the first time. Just to be clear, I was criticizing the guy in that blog for being surprised and outraged about how to get them to work, not at you for being surprised that they don't work "out of the box" with dataclasses.
|
# ? Jul 8, 2019 19:04 |
|
Yeah no worries; I was just explaining why I was so surprised-- I had literally re-watched that vid the day before, made a mental note about @property/setter and got bit the next day trying to implement a @dataclass.
|
# ? Jul 9, 2019 00:59 |
|
Appreciate your guy's help, Thermopyle posted:If you're asking about printing PDFs that already exist rather than actually creating PDF files with python, I'd just look into generic windows ways to send a file to the printer. Hell, a quick google shows some results for "windows print pdf from command line", which you could just do from python. CarForumPoster posted:I am going to try installing the same printer 4 additional times with unique names and settings. Not an elegant pythonic solution but should work. This worked and is dead simple and pretty reliable. My printer or print spooler doesnt necessarily honor the order sent but a little bit of waiting fixed that. CarForumPoster fucked around with this message at 12:39 on Jul 9, 2019 |
# ? Jul 9, 2019 12:34 |
|
What I want to do: Convert a .docx file containing comments to pdf, displaying the Word comments in the PDF. Why:I have a Flask web application on Heroku where a user uploads a .docx which is sent to S3 and the app adds comments to the .docx, then returns the PDF which is displayed in the browser. The problem: Heroku runs on linux and LibreOffice doesnt print the PDF comments in a way thats pretty like Word on Win10 does, it instead embeds them as PDF comments. In Win10 Word O365, this is trivial. You save it, which you can do easily from python. I'm looking for the simplest/best solution to output a PDF with comments that looks like it does with Word. A few things I'm considering: -Have an Amazon Workspaces Win10 w/O365 running basically as a server and a Python script that somehow gets the files from S3, converts it on windows and returns the PDF to S3 and notifies my web app that the file is available for download. Not sure how to do this but seems possible. -Trying a bunch of other Linux DOCX->PDF solutions to see if they're any better. -Try installing MS Word on Heroku. Not sure if possible. (Update: It's Not) EDIT: Some better ideas possibly: -Use MS Office Online to convert the Word Doc -Find an API to do it for me. EDIT2: Finding an API seems like the best solution but gently caress me if they dont suppress the comments output. Tried 3 so far. One works, but the docs are confusing. 2 Don't work. EDIT3: Solved it using Zamzar. Just so happens thats how their DOCX-PDF works and their docs are great. CarForumPoster fucked around with this message at 20:00 on Jul 9, 2019 |
# ? Jul 9, 2019 13:14 |
|
As an absolute python noob I wanted to do something that would motivate me. I fed about 33000 trump tweets through textgenrnn. The results are horrible, but I feel some sense of achievement. It prompted me to work out how to use jupyter lab a bit more effectively and has encouraged me to add to the very basic example code. Just thought I'd post that because I came here a while back asking about jupyter.
|
# ? Jul 14, 2019 04:46 |
|
|
# ? May 26, 2024 23:19 |
|
General_Failure posted:As an absolute python noob I wanted to do something that would motivate me. Well, as people say about data: poo poo in, poo poo out.
|
# ? Jul 14, 2019 11:50 |