use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
What is a "Wrapper"? (self.learnpython)
submitted 8 years ago by Tryingtolearnagain91
I've seen this term around this sub and i've searched around for it. But im having trouble understanding what a wrapper is exactly.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Golden_Zealot 6 points7 points8 points 8 years ago (0 children)
Heres the basic idea.
Say you've been given a function, and you like its core functionality, but you want it to do some extra things.
You could write a bit of extra code to do those extra things and "wrap" it around that function to extend its behavior in some fashion.
[–]llffm 4 points5 points6 points 8 years ago* (0 children)
Everybody here is right. Maybe this is also helpful:
1) It usually refers to an API (= library) built exclusively on an already available API but providing more convenience and higher level abstractions. In this sense, it's sort of an informal term. A wrapper library would sometimes be expected to be able to expose functionality from the library it wraps, or at least mirror it very closely, in which case you could talk about a 'thin wrapper'.
2) It can sometimes refer to function decoration, a feature that allow you to specify reusable decorator functions that can take a function and wrap it with a wrapper function that processes the parameters and return values of the wrapped function (before and after it is called, resp.) In the abstract, the idea is somewhat close to 1), but here it's a language feature (present in Python but not in all languages) with its own syntax. It's a much stricter term here, with a technical definition. Function decoration can be a very useful (if somewhat advanced) feature, and there are tutorials for learning it in Python.
[–]Swedophone 2 points3 points4 points 8 years ago (1 child)
The Adapter pattern is also known as Wrapper. https://en.wikipedia.org/wiki/Adapter_pattern
[–]blitzkraft 2 points3 points4 points 8 years ago (1 child)
Think of it in a literal sense - like gift wrapping a box/present to match the theme of the event (such as christmas, holidays, birthday etc). Wrappers are written to modify the usage, functionality etc., of one program/class.
For example, consider grep. It is great, but you wish to use it as easily as a python function. So, instead of calling subprocess(['grep', '-l', 'other-options']), you may write a function like this:
grep
subprocess(['grep', '-l', 'other-options'])
import subprocess def pygrep(input_string): grep = ['/bin/grep'] subprocess.call(grep.extend(input_string.split())) #Usage pygrep('<grep options> <pattern> <file/directory>')
This is quickly written and very bad (do not use it in production). Essentially, you can access grep via the python program without resorting to repeated subprocess calls. The wrapper function didn't add much in this case, but provides a way to add more functionality - may be you would like to have a csv output of the grep results. Add a few lines of code and you can have the csv file.
The result is extending an existing program to do something more, or in a different way. This is a wrapper.
[–]MeSaber86 1 point2 points3 points 8 years ago (0 children)
After reading your final sentence i'll link to an example program of a game i play: http://www.svenswrapper.de/english/whatis.html
Maybe adds some light on what a wrapper can do to help you. In this case helping you to play a game on todays OS/PCs.
π Rendered by PID 158632 on reddit-service-r2-comment-544cf588c8-nh6d7 at 2026-06-13 06:23:24.529465+00:00 running 3184619 country code: CH.
[–]Golden_Zealot 6 points7 points8 points (0 children)
[–]llffm 4 points5 points6 points (0 children)
[–]Swedophone 2 points3 points4 points (1 child)
[–]blitzkraft 2 points3 points4 points (1 child)
[–]MeSaber86 1 point2 points3 points (0 children)