help-circle
rss
Trying to open a PDF with spaces in its filename (Windows)
I'm trying to open a PDF file with spaces in its filename and, possibly, in its path. I'm working on Windows. ``` from PyPDF2 import PdfReader def main(): path = input( 'Whatever: ' ) reader = PdfReader( path ) ``` 'Whatever' is actually a string asking the user to drag-and-drop a file on the terminal window, so that its full path is given as input to the script. On input `C:\Users\example input.pdf` I get the following error: ``` Traceback (most recent call last): File "C:\Users\[REDACTED]\test.py", line 119, in <module> main() File "C:\Users\[REDACTED]\test.py", line 20, in main reader = PdfReader( path ) ^^^^^^^^^^^^^^^^^ File "C:\Users\[REDACTED]\anaconda3\envs\delete_later\Lib\site-packages\PyPDF2\_reader.py", line 317, in __init__ with open(stream, "rb") as fh: ^^^^^^^^^^^^^^^^^^ OSError: [Errno 22] Invalid argument: '"C:\\Users\\example input.pdf"' ``` I tried lots of stuff, but the only two things that worked are: - remove whitespace from filename – acceptable when whitespace only occurs in its filename, unacceptable if it also occurs in its path - don't ask the user for a path – completely unacceptable is there any other workaround? Or even a solution?
fedilink

Some neat tricks for using `Makefiles` with Python that I hadn't seen before. The one I have seen, having a `help` target, has been super useful in team environments and for debugging when used with variables.
fedilink




[SciPy 2023 is looking for reviewers](https://docs.google.com/forms/d/e/1FAIpQLSfedUk2lor94OxuSd_uDuC3XzZ_zHX1tfRvX7uZukeQBjq5ig/viewform?usp=sf_link)
fedilink

Does Python still have a need for class without @dataclass?
(there is a discussion about this post here https://news.ycombinator.com/item?id=34787092 ...)
fedilink



Here is the paper: https://arxiv.org/abs/2209.06909 Here is tbe code: https://github.com/sebawild/powersort
fedilink


[what's new](https://docs.python.org/3.11/whatsnew/3.11.html#what-s-new-in-python-3-11)
fedilink

Build amazing TUIs (Text User Interfaces) with this innovative Python framework
fedilink




looking for a fast multi process shared dict
cross-posted from: https://feddit.de/post/248196 > I have lots of multiprocessing processes which have to add to and search in a dict. Deletion of values is not needed. > > Atm I am using multiprocessing.Manager() and > > `dict = manager.dict()` > > This works pretty well, but I think that the manager is a huge bottleneck here. Any ideas? It has to run on older Python 3 versions, otherwise I would use this cool thing I found: https://github.com/ronny-rentner/UltraDict
fedilink


via https://news.ycombinator.com/item?id=31566031 source: https://github.com/satwikkansal/wtfpython
fedilink


Useful Python decorators for Data Scientists
via https://news.ycombinator.com/item?id=31476521
fedilink






Cross platform Python app development
Can you recommend any cross platform Python app development frameworks where you write code once and it can be deployed to Linux, Android, Windows, MacOS and iOS.
fedilink



tweet2toot will replicate all tweets and threads of the Twitter user of your choice.
fedilink

SimpleHTTPServer is a python module which allows you to instantly create a web server or serve your files in a snap. The main advantage of python’s SimpleHTTPServer is you don’t need to install anything since you have python interpreter installed. You don’t have to worry about python interpreter because almost all Linux distributions, python interpreter come handy by default. You also can use SimpleHTTPServer as a file sharing method. You just have to enable the module within the location of your shareable files are located. The article below guides you on how to set up and use it. See https://www.tecmint.com/python-simplehttpserver-to-create-webserver-or-serve-files-instantly/ #technology #Linux #Python #Webserver
fedilink


Why do tuples and lists both need to exist?
The only differences are that tuples are immutable and that lists have extra methods. Is there ever a strong need for list-type data to be immutable? Evough to justify a whole extra data-type in the language? Should they release a python 4 with it removed? The only thing I can think of is as a default function parameter. This function is okay: ``` def dothings(a=(1,2)): print(a) a = (a[0], 3) ``` But this function misbehaves the second time it is called: ``` def dothings(a=[1,2]): print(a) a[1] = 3 ``` But IMO the "mutable arguments" thing is another bug to be fixed in a hypothetical python 4. And even in python 3 you just write the function the recommended way, so there is not such a big problem. ``` def dothings(a=None): if a is None: a = [1, 2] print(a) a[1] = 3 ``` The Python devs are clever guys though. There must be some really important reason to maintain both types?
fedilink






A few months ago, I built a tool to generate fake data based on a JSON payload([fakeapi](https://fakeapi.amalshaji.com)). FakeAPI worked fine, but a major downside was that a JSON payload must be sent as a post request to receive data. This is not good for someone emulating any other HTTP methods. So I decided to build [Phoney](https://phoney.ml). **Phoney** is a mock API generator that lets you create apps to manage endpoints. Features of phoney: - Create apps to manage your endpoints - Create endpoints that return data in a custom format - Default API key authentication support - All methods, GET, POST, PUT, and DELETE, supported. - Dynamic endpoints supported - Swagger UI for each endpoint. It makes testing easy. - Built-in JSON editor for creating endpoint schema - Supported response codes, 200, 201, and 202 - Syntax highlighting for JSON schema - Light/Dark theme switch > Phoney is built with Django. **Also, this is my first ever Django app**
fedilink


    Create a post

    News and discussions about the programming language Python


    • 1 user online
    • 2 users / day
    • 3 users / week
    • 5 users / month
    • 7 users / 6 months
    • 8 subscribers
    • 62 Posts
    • 37 Comments
    • Modlog
    Lemmy
    A community of privacy and FOSS enthusiasts, run by Lemmy’s developers

    What is Lemmy.ml

    Rules

    1. No bigotry - including racism, sexism, ableism, homophobia, transphobia, or xenophobia. Code of Conduct.
    2. Be respectful. Everyone should feel welcome here.
    3. No porn.
    4. No Ads / Spamming.

    Feel free to ask questions over in: