<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by TheConnoisseur on Medium]]></title>
        <description><![CDATA[Stories by TheConnoisseur on Medium]]></description>
        <link>https://medium.com/@theconnoisseur?source=rss-5bf0bfa6b603------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*U-LcNwKPgsRGd2hjNOADow.jpeg</url>
            <title>Stories by TheConnoisseur on Medium</title>
            <link>https://medium.com/@theconnoisseur?source=rss-5bf0bfa6b603------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:14:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theconnoisseur/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[BlueJ: The Java IDE Designed For Learning]]></title>
            <link>https://medium.com/@theconnoisseur/bluej-the-java-ide-designed-for-learning-89692bd46d98?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/89692bd46d98</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ide]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Tue, 02 Jul 2024 19:05:00 GMT</pubDate>
            <atom:updated>2024-07-02T19:05:00.196Z</atom:updated>
            <content:encoded><![CDATA[<h4>What does an IDE that prioritizes learning over efficiency look like?</h4><p>The thing about IDEs is that everyone uses the same few, and for good reason. All the most popular IDEs prioritize the same values: <em>efficiency and performance</em>.</p><p>In industry this makes sense; the time and effort taken to create a product can be the difference between a profit and a loss.</p><p><em>But what would an IDE that prioritizes other values look like?</em></p><p>BlueJ is an example of this: a Java IDE that shifts the focus from maximizing developer efficiency to educating the programmer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3y-QG_8X1_2smD69" /><figcaption>Photo by <a href="https://unsplash.com/@sagredophotography?utm_source=medium&amp;utm_medium=referral">Richard Sagredo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What is BlueJ</h4><p>Simply put, BlueJ is a Java IDE with focus on learning and teaching over efficiency and performance, though it doesn’t ignore these features either.</p><p>It supports a simple, stripped down interface leading to a look that doesn’t feel quite as slick as your Visual Studio or IntelliJ, and lacks some of the more advanced, yet helpful, features.</p><p>But what BlueJ does <strong>very </strong>well, and what I think we take for granted as seasoned programmers, is visualization.</p><h4>BlueJ and the Power of Visualization</h4><p>BlueJ’s main dashboard doesn’t show a list of class files in a directory, it shows an interactable class diagram where you can click on each class to look at it’s contents, move classes around and know the structure of your codebase at a glance.</p><p>While other IDEs support similar features, BlueJ’s up-front approach and level of interactivity with visualizing what your class structure looks like is unique and different from what you would expect from an IDE.</p><p>This is <em>by far</em> my favorite aspect of the IDE, and something that I wish other IDE’s put more emphasis on.</p><p>Visualization is an immensely powerful technique as it allows you to express your ideas to someone else quicker than explaining it, and is a friendly representation to someone who might not be as experienced with programming.</p><p>Which begs the question: <em>why don’t more professional Java developers use BlueJ?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Txfn2gw7CXyz8D4h" /><figcaption>Photo by <a href="https://unsplash.com/@wocintechchat?utm_source=medium&amp;utm_medium=referral">Christina @ wocintechchat.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Why You Wouldn’t Use BlueJ</h4><p>In short, <em>it slows things down and its more cluttered.</em></p><p>A seasoned programmer will be able to visualize the program’s structure in their head without the need for any help from an external tool, like an IDE. This means that the more experienced you become in programming, the less you will need the visualization tools it provides.</p><p>Additionally, these tools are front and center in the IDE so you can’t avoid them, which ends up wasting space in the IDE to someone who doesn’t need to see them.</p><p>However, while a seasoned programmer may no longer rely on visualization tools, they are still helpful for explaining the code to others in a quick manner, and in a way where someone with little programming experience will understand.</p><p>I’ve bashed BlueJ a bit here, but still I believe it to still be a fantastic IDE, even though I would never recommend it to a seasoned developer. <em>So who would I recommend BlueJ for?</em></p><h4>Target Audience</h4><p>BlueJ is built for programming beginners.</p><p>It might not be as elegant or concise as some of the IDEs more popular in industry, but it actively aids someone to learn how to program, which other IDEs don’t even consider.</p><p>Many universities, colleges and schools use BlueJ as a way to introduce Java to students. A first time programmer doesn’t care if the button layout isn’t optimal or the hotkeys aren’t convenient, they care about learning what the program is doing, what it’s internal structure looks like and the fundamentals of object oriented programming.</p><p>That’s what makes BlueJ great. It’s refreshing to have an IDE not built for the average industry programmer. It makes you wonder what other interesting concepts an IDE could embody other than going for what is the most efficient and optimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uRrhsIg6G7mg1yZW" /><figcaption>Photo by <a href="https://unsplash.com/@davidgarry1?utm_source=medium&amp;utm_medium=referral">David Garry</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Wrap Up</h4><p>I wrote this article to highlight what an IDE looks like when it doesn’t have the seasoned programmer in mind.</p><p>Many developers become so accustomed to their IDE and workspace that we often forget that alternatives exist. So go ahead and try another IDE to see how it feels.</p><p>I probably won’t use BlueJ again in my life but the idea behind it and is great, and it’s an invaluable tool for it’s target audience.</p><p><em>Hope this article was insightful and have a good day!</em></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89692bd46d98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can You Get a Job as a Django Web Developer?]]></title>
            <link>https://medium.com/@theconnoisseur/can-you-get-a-job-as-a-django-web-developer-04d2baab50c8?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/04d2baab50c8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 12:22:19 GMT</pubDate>
            <atom:updated>2024-06-25T12:22:19.635Z</atom:updated>
            <content:encoded><![CDATA[<h4>In short, yes, but don’t put all your eggs in one basket</h4><p><strong>Web development in Python</strong>. Python is well known to being suited for data science, AI and other general purpose tasks, but web development?<em> Really?</em></p><p>This may shock you <em>(or not)</em> but web development is not only possible in Python, but <strong>viable</strong> as well. A Python web development framework named <strong>Django</strong> makes this possible.</p><p>But other than small side projects, <em>can you land a job developing in Django?</em></p><p>In short, <em>yes</em>. Let’s take a look at how.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SbXb9Ip3ymavTcF6" /><figcaption>Photo by <a href="https://unsplash.com/@brechtcorbeel?utm_source=medium&amp;utm_medium=referral">Brecht Corbeel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What is Django</h4><p>Simply, <em>Django is a Python based web development framework</em>. This allows the creation of professional web based products in Python, which is something you don’t normally associate with Python.</p><p>As someone who has created websites with it in the past, it’s intuitive to pick up compared to other frameworks, especially so if you know Python already. Additionally it comes with documentation which is structured more like a tutorial than a glossary, making that initial learning stage simpler.</p><p><em>Check it out</em>: <a href="https://docs.djangoproject.com/en/5.0/intro/overview/">Django at a glance | Django documentation | Django (djangoproject.com)</a></p><h4>Django as a Career</h4><p>While Django isn’t the most popular framework, the diagram shows its not even in the top 10 most popular frameworks of last year, it is still more than possible to land a career in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*L6G1DQCD55Gc5Ol6l9NbVw.png" /><figcaption>ref: <a href="https://www.statista.com/statistics/1124699/worldwide-developer-survey-most-used-frameworks-web/">Most used web frameworks among developers 2023 | Statista</a></figcaption></figure><p>In computer science, programming or any tech related job, if a niche exists then there will be some demand for it, even if small. Django is no exception here and there are companies that look for developers who specifically use Django.</p><p>There are many different advantages and disadvantages to choosing one framework over another so while one company may choose Flask or Ruby on Rails, another will opt for Django.</p><p>For example, here’s a job listing I found specifically looking for a Django developer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULW5IjVs_rxHPnYfmbsADA.png" /></figure><p>However, while you can definitely find a career as a Django developer, it’s still beneficial to learn other technologies and frameworks. Especially as roles specializing in Django aren’t as common as other technologies.</p><h4>Other Technologies</h4><p>The world of web development is wide and varied with different technology stacks to choose from. Because of this,<em> I would opt to not rely on a single framework</em>.</p><p>While specializing in a single framework will give you much better chances of landing a job working it, learning at least another framework will give you a wider perspective of why different technologies excel in different situations as well as make you more flexible in the job market.</p><p>To go a bit further, let’s say you only want to use Django: learning other technologies will increase the options you have when creating web based products and hence improve on the quality you deliver. Being able to utilize JavaScript and Ajax alongside Django opens doors on what you are capable of doing and makes you a much more well-rounded developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bCi3rAl843t9xwAG" /><figcaption>Photo by <a href="https://unsplash.com/@magict1911?utm_source=medium&amp;utm_medium=referral">Timo Volz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Take Away</h4><p>You can get a job working with Django, but I recommend learning other technologies alongside it.</p><p>Learning other technologies will enhance your job flexibility and make you a more well-rounded developer.</p><p><em>Hope this article was insightful and have a good day!</em></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04d2baab50c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[11 Fundamentals For The Skill of Learning Skills]]></title>
            <link>https://medium.com/@theconnoisseur/11-fundamentals-for-the-skill-of-learning-skills-e3d2df7a6d07?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3d2df7a6d07</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[lifestyle]]></category>
            <category><![CDATA[habits]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Wed, 19 Jun 2024 09:44:30 GMT</pubDate>
            <atom:updated>2024-06-19T09:44:30.943Z</atom:updated>
            <content:encoded><![CDATA[<h4>Every skill has fundamentals to conquer, including the skill of learning skills</h4><p>About 2 years ago I encountered one of the best educational resources I’ve ever used. Weirdly enough, it wasn’t behind a paywall, it wasn’t formal education and it wasn’t for anything I took seriously. It was a comprehensive YouTube series detailing how to get better at the game of StarCraft 2.</p><p>While sounding silly, this guide contained techniques to improvement that I started using in other areas of life, which kickstarted me learning what I believe the most important skill you can teach anyone: <strong>the skill of learning skills</strong>.</p><p>After that, with every new hobby or interest I pursued, I built on this skill of learning skills, until I am where I am today; <em>feeling capable of learning almost anything that I apply myself to</em>.</p><p>And that’s what this article is about: <em>a shortlist of some of the fundamentals I’ve learnt that make learning anything ten times easier.</em></p><p><em>Note, these are not in any particular order and don’t feel like you need to use all of them. Just pick the ones that work for you. Do experiment though.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8RcQeGNBDsil3ckR" /><figcaption>Photo by <a href="https://unsplash.com/@sickhews?utm_source=medium&amp;utm_medium=referral">Wes Hicks</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>1. Your Goals Must Be Clearly Defined and Measurable</h3><p>Good goals are <strong>measurable </strong>and <strong>clearly defined</strong>. They have zero ambiguity and you know when you’ve achieved them.</p><p>This doesn’t mean you can’t have ambiguous goals, just that you can’t have <strong>only </strong>ambiguous goals, as they are harder to act on</p><p>Let’s take this example goal: “<em>I want to get a 6 pack.</em>”</p><p>This isn’t great as there are no obvious steps to take or roadmap to achieve the goal.</p><p>This goal on it’s own isn’t easy to follow, but we can break it down into sub goals which we can act on:</p><ol><li><em>After waking up I will do 10 sit-ups</em></li><li><em>I will study the correct form to do a sit-up</em></li><li><em>I will substitute my unhealthy breakfast out for a healthy one</em></li></ol><p>Now this is a lot better. While these goals could be broken down even more, they are still much easier to follow then the original goal of “<em>get a 6 pack</em>.” Additionally, these smaller goals are easier to track; <strong>you either do them or you don’t.</strong></p><p>Over time, completing these sub goals will make progress towards your original goal until its complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fGXzUPaTsVa9YYI2" /><figcaption>Photo by <a href="https://unsplash.com/@sxoxm?utm_source=medium&amp;utm_medium=referral">Sven Mieke</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>2. Identify The Fundamentals and Start There</h3><p>When learning anything new, the first step is <em>always</em> to start with the fundamentals.</p><p>Any skill has fundamentals associated with it. These are usually subskills that required to be somewhat proficient at the overall skill.</p><p><em>For example</em>, you can’t learn how to drift a racecar without first being able to drive in a straight line. Similarly, you can’t draw complex 3D forms without being able to draw a straight line.</p><p>Hence, it makes sense to focus on these fundamentals initially to give you a much better grasp of the complex things.</p><p><em>But how do you know what the fundamentals of a skill are?</em></p><p>The easiest way to find out is to ask someone who’s already mastered the skill. The internet is full of guides and communities for everything to do a bit of research for what you’re interested in and you should find some help.</p><p>Also, never hesitate to practice the fundamentals even if you consider yourself advanced. You can never get too much practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_DcPBHf4ROmLgjFb" /><figcaption>Photo by <a href="https://unsplash.com/@araltasher?utm_source=medium&amp;utm_medium=referral">Aral Tasher</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>3. Focus on Improvement, Not Winning</h3><p>This one may seem like it only applies to games, but you could apply this to any skill with a bit of imagination.</p><p>The point here is that the immediate result of what you are currently doing is not as important as developing the skill in the long run.</p><p><em>Let’s take wanting to improve your handwriting as an example.</em></p><p>So you want to improve your handwriting, and the best way to do that is to start to hold your pen with a different grip, one you’re not used to. This means that when starting to learn this grip, your handwriting will be terrible. In times like this, you have to just stick with it. <em>If having terrible hand writing right now means you will have the best hand writing you’ve ever had in a week then who cares how it looks now.</em></p><p>This one is hard to stay focused on but do your best and keep applying yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ORkmDIPMKV_nNvQ7" /><figcaption>Photo by <a href="https://unsplash.com/@giorgiotrovato?utm_source=medium&amp;utm_medium=referral">Giorgio Trovato</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>4. Don’t Auto Pilot</h3><p>This is a skill in itself, but a pivotal step in improving greatly at anything.</p><p>When starting something new, you want to be consciously thinking about it. This means you are less likely to fall into bad habits and can be more aware of what you need to work on.</p><p><em>It’s important to mention that some amount of auto pilot is necessary</em>. You can’t be thinking about everything at once. Just make sure to never auto pilot on the thing you are focused on and never auto pilot everything.</p><p>Pro basketball players don’t actively think about their dribbling technique in a game; they are much more focused what the other team is doing and how they can score. But someone new to basketball should focus on their dribbling, at least until they’re technique is good enough to be done without thinking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gg6sbeKku3nabI9H" /><figcaption>Photo by <a href="https://unsplash.com/@evadarron?utm_source=medium&amp;utm_medium=referral">Eva Darron</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>5. Take Notes</h3><p>This one isn’t for everyone but is something I find works for me.</p><p>Taking notes is great as it means you spend enough time learning something that you are able to write about it. This helps avoid cutting corners, where you shouldn’t, and making sure you put in enough thought into whatever you are learning.</p><p>Additionally, having something physical as evidence of your learning keeps it fresh in your mind and makes it easier to recall.</p><p>How you take notes is up to you. Personally, I prefer taking notes on my phone as I can read up on them at any time. Note taking on paper is also a technique I have used which I found to be more effective but also more time intensive.</p><p>A traditional example where note taking is common is school or university studies. Some schools even enforce note taking as, in my experience, students who take good quality notes tend to perform better on average.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z6p-FKv9zG6yTII4" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>6. 70–15–15 rule</h3><p>There are many variations to this, <em>like the 50–30–20 rule or the 80–10–10 rule</em>, but they all come down to how you divide your time.</p><p>In this version, you spend 70 percent of your time doing the skill itself, 15 percent of your time watching someone who’s already mastered the skill doing it and 15 percent of your time analyzing your previous work for improvements.</p><p>You can vary these time ratios depending on preference, however I advise putting some time into all 3 and always spending the most time doing the skill itself.</p><p>You can even divide the time you spend doing the skill into time spent actively practicing it and time spent having fun with it, but this is up to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DDtLIT0qksY-3RXM" /><figcaption>Photo by <a href="https://unsplash.com/@icons8?utm_source=medium&amp;utm_medium=referral">Icons8 Team</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>7. Have a Warmup Routine</h3><p>A warmup routine is pivotal in getting yourself into peak mental and physical condition to practice your skill.</p><p>While there are many targets of well-prepared warmup, here are the two you should focus on in every warmup:</p><ol><li><em>Prepare yourself mentally</em></li><li><em>Prepare yourself physically</em></li></ol><p>Let’s take a look at these individually</p><h4>Prepare yourself mentally</h4><p>A warmup should put you into focus mode. <em>You shouldn’t be thinking about anything but what you’re about to practice</em>.</p><p>This usually involves some kind of ritual you do at the start of your warmup to signal to yourself it’s focus time now.</p><p>One technique I’ve used before is associating a song with the start of my warmup, my ritual if you will. While this song is playing I think about everything I want to achieve in my session today as well as how I’m going to do it.</p><p>Every time you repeat this, you start to associate the feeling of focus and practice with the song you are listening to. In the end, it becomes a trigger for focus by itself without you even realizing it.</p><h4>Prepare yourself physically</h4><p>You might think this applies only to activities like sports but you would be wrong. Many skills require some sort of physical action or muscle memory which you want to warm up before actually practicing the skill.</p><p>Even in something like playing competitive fighting games with a controller, you should stretch your fingers beforehand and practice the combos you will do in a real match.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*95l5-6pbCInXrD1Y" /><figcaption>Photo by <a href="https://unsplash.com/@gabinvallet?utm_source=medium&amp;utm_medium=referral">Gabin Vallet</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>8. Keep It the Same</h3><blockquote>“I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times” — Bruce Lee</blockquote><p>That quote sums it up pretty well. If you want to get good at something, keep it the same as much as possible.</p><p><em>But how can you apply this to something which requires multitasking many things at once?</em></p><p>A master martial artist will never only just practice how to perform one punch. They will focus on how they move, anticipating what the opponent will do and how they should position their body to not get hit, among many other things.</p><p>The key to applying the “<em>keep it the same</em>” principle is to do everything required by the task, <em>but focus on a single thing at a time. </em>You will only focus on improving this one thing and be forgiving of mistakes made in areas you aren’t focusing on. After you feel confident in the area you focused on, move to another area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HE-OY4kLNjZeNUGb" /><figcaption>Photo by <a href="https://unsplash.com/@h4x0r3?utm_source=medium&amp;utm_medium=referral">Thao LEE</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>9. Track Your Progress</h3><p>There are two key reasons why you need to track your progress:</p><ol><li><em>It keeps you motivated</em></li><li><em>It makes it clearer what you have done and what you should do next</em></li></ol><p>Being able to easily reflect on your progress so far is great for keeping high spirits as well as identifying what your next steps are. At some point everyone reaches burnout when learning anything: at which point it helps considerably to take a break and look back at how far you’ve come.</p><p>As for how you track your progress, that’s up to you. I previously mentioned the importance of taking notes, which is what I like to do, but any other form like recording videos or audio notes can work as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PtvoSJfE47Bl63RI" /><figcaption>Photo by <a href="https://unsplash.com/@davidgaviphoto?utm_source=medium&amp;utm_medium=referral">David Gavi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>10. Make It a Habit</h3><p>The best way to get good at something is to become that thing, and the best way to become something is to do that thing regularly. In essence, this is what a habit is; a repeated behavior embodied by a particular kind of person.</p><p>For example, an artist may have the habit of drawing every morning or a scientist may check the news at lunch for breakthroughs in their field of study. These habits are part of what make them good at what they do and make them who they are.</p><p><em>But how do you build a habit?</em></p><p>Unfortunately, creating habits is a lot more complex than understanding what a habit is. There are countless research papers and books written on this. If you’re new to the idea of creating and destroying habits then I recommend you take a look at <a href="https://jamesclear.com/atomic-habits"><em>Atomic Habits</em></a>. It’s a well-known book but it’s content is invaluable and easy to apply.</p><p>As for a couple things that you can take away now, I would start by clearly defining what habit you want to implement, how often you are going to do it and when. Then focus on doing the habit at the times you set. Initially this will require a lot of willpower, but each repetition makes the whole process easier until you find yourself doing it automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1O4tNPCIELBxGQqY" /><figcaption>Photo by <a href="https://unsplash.com/@nublson?utm_source=medium&amp;utm_medium=referral">Nubelson Fernandes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>11. Don’t Overload Yourself</h3><p>Try not to focus on learning too many things at once. This is similar to the “<em>keep it the same” </em>rule but applies to learning multiple skills in general.</p><p>Let’s say you want to learn to English, how to drive a car and programming all in a similar time frame. Depending on how much free time you have and personal preference, this could be a reasonable number of skills to learn in parallel. However be careful adding anymore to this list. Learning too many skills at once will spread yourself too thin and likely result in neglecting one or more of them.</p><p>Take breaks between practicing each skill as well. Recently, I came across the idea of “<em>context switching” </em>which states that it takes a significant amount of energy to switch your focus from a task, which requires a specific skillset, to a another task, requiring a completely different skillset. The idea is to practice different skills in blocks with breaks between them to get yourself into the right mindset before practicing a skill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bJ04ny2qZqhybwqP" /><figcaption>Photo by <a href="https://unsplash.com/@yogeshp?utm_source=medium&amp;utm_medium=referral">Yogesh Phuyal</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>That’s All!</h3><p>Don’t feel like you have to apply all of the points mentioned, or any of them, if you don’t want to. <em>However, do experiment though</em>. <strong>The best way to learn something is to try it!</strong></p><p><em>Hope this article was insightful and have a good day!</em></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3d2df7a6d07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Art of The Docstring]]></title>
            <link>https://medium.com/@theconnoisseur/art-of-the-docstring-42409eafc699?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/42409eafc699</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 13:25:47 GMT</pubDate>
            <atom:updated>2024-02-18T13:25:47.353Z</atom:updated>
            <content:encoded><![CDATA[<h4>I have nothing against abstract art but let’s keep it away from our docstrings</h4><p><em>Look at this work of art.</em></p><figure><img alt="Abstract art showing paint and colors being splashes on a canvas" src="https://cdn-images-1.medium.com/max/1024/0*REj8HjWyPcep12zz" /><figcaption>Photo by <a href="https://unsplash.com/@jenestephaniuk?utm_source=medium&amp;utm_medium=referral">Jené Stephaniuk</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I believe the beauty of this piece lies in the many ways you could interpret it. At first glance, this painting appears to be random brush strokes and paint splashes, but on closer inspection, you see all the small tailored details and well-thought grooves of texture.</p><p>The way this art piece changes the more you look at it is one of it’s greatest features, but you should<strong> <em>never</em></strong> have something like this in your code.</p><p>The best code is clear and concise; it explains itself in a concise manner.</p><p>But what if you’re writing a piece of code that will always be too complex to understand at first glance? We don’t want our code to provoke as much thought as this painting, we want it to be straightforward and intuitive to understand.</p><p>In this case, <strong>docstrings </strong>are your friends.</p><h3>What is a docstring?</h3><p><em>Going back to the art example:</em> it would be like if you hung a painting at a gallery for all to see. You want to tell people what the painting is about, so you put a plaque next to it explaining it. The plaque being placed is like a docstring, where the art piece itself is our code.</p><p><em>Formally, A docstring is a string literal that usually occurs as the first line of a block of code which aims to document what it does.</em></p><p>A good docstring will <strong>improve</strong> code readability and clarify any quirks the code may have.</p><p>A point that may be overlooked is that docstrings and comments are not the same. While they both serve to document code, they have slightly different purposes.</p><h4>Some key differences between docstrings and comments</h4><ul><li>Docstrings are used to provide explanation for blocks of code (functions, modules, etc.) whereas comments are normally for smaller, potentially individual, lines of code</li><li>Docstrings usually written as string literals whereas comments are defined usually by <em>‘#’</em> or <em>‘//’,</em> depending on language</li><li>Comments are not parsed or processed by tools like Sphinx, and they don’t provide structured documentation whereas docstrings do</li><li>Comments they don’t have a standardized format and may vary in style.</li></ul><h3>Why you need docstrings</h3><p><em>In short</em>, to make the codebase as <strong>readable</strong> and <strong>accessible</strong> as possible.</p><p>While I’m an advocate of the principle of good code being self-explanatory, it never hurts to include a docstring for additional information.</p><p>Moreover, some IDEs and tools have built-in features that read docstrings, presenting them to you seamlessly.</p><p>For example, Pycharm includes a feature which shows you the docstring of a class when hovering over an instance of it. This makes it quick to understand what a class represents without looking at it’s contents.</p><p>A good docstring will say what the input and output of a block of code is. This makes it intuitive for someone who hasn’t worked with that code block to use it.</p><p>This also makes the process of encapsulation smoother as a developer won’t have to look at the contents of a class to know how to use it; they can just use it based on what is said in the docstring.</p><figure><img alt="Cat in a box" src="https://cdn-images-1.medium.com/max/1024/0*Oa0tFHofDXO3MUbg" /><figcaption>Photo by <a href="https://unsplash.com/@magict1911?utm_source=medium&amp;utm_medium=referral">Timo Volz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What makes a good docstring</h3><p>A good docstring explains what a code block is, what it does and how to use it in as few words as possible. You want to give the reader enough information so they feel comfortable using the block of code, while being as concise as possible.</p><p>Some relevant information you may include in a docstring is:</p><ul><li><em>Description</em>: A brief summary explaining what the code block does.</li><li><em>Parameters</em>: Details about input parameters, including their data types and any restrictions.</li><li><em>Return Value</em>: Explanation of what the code block returns, along with the data type.</li><li><em>Usage Examples</em>: Practical examples demonstrating how to use the code block effectively.</li><li><em>Side Effects</em>: Any unexpected outcomes or alterations that may occur when using the code.</li><li><em>Exceptions/Errors</em>: Information about potential errors or exceptions that might be raised during execution.</li><li><em>Dependencies</em>: If the code relies on external libraries or modules, specify them.</li><li><em>Author/Contributors</em>: Credits to the original author or contributors who have significantly contributed to the code.</li><li><em>References</em>: Links or references to external resources, documentation, or relevant specifications.</li></ul><p><em>Note, I wouldn’t normally include all of these in one docstring as that’s generally too much information for someone to take in. Keep it concise and remember that the longer the code block, the longer you can make your docstring.</em></p><h3>Example</h3><p><em>Here’s an example of what a good docstring would look like:</em></p><pre>def calculate_square_area(side_length):<br>    &quot;&quot;&quot;<br>    Calculate the area of a square.<br><br>    Parameters:<br>    - side_length (float): Length of the side of the square.<br><br>    Returns:<br>    - float: Area of the square.<br><br>    Usage:<br>    &gt;&gt;&gt; calculate_square_area(4)<br>    16.0<br>    &quot;&quot;&quot;<br>    area = side_length ** 2<br>    return area</pre><p>This docstring includes all the information required to easily call the function, including it’s parameter and return types.</p><p>It explains what the function does and includes a use case to clarify exactly how to use it.</p><p>Additionally, it’s concise; we don’t have any unnecessary information.</p><p>While you could add or take away from this docstring and it would still be fine, this particular example shows what you should strive for when writing your docstrings.</p><p><strong>The key idea this docstring achieves is that someone knows exactly what this function does without looking at it’s contents. Strive for this in your docstrings.</strong></p><h3>That’s all!</h3><p><em>Hope this article was insightful and have a good day!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jT3xYMX731Cdk2cM" /><figcaption>Photo by <a href="https://unsplash.com/@cytonn_photography?utm_source=medium&amp;utm_medium=referral">Cytonn Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42409eafc699" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dry Running Code, You Should Probably Do It]]></title>
            <link>https://medium.com/@theconnoisseur/dry-running-code-you-should-probably-do-it-f10564c3e9d0?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/f10564c3e9d0</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Sun, 11 Feb 2024 17:02:28 GMT</pubDate>
            <atom:updated>2024-02-11T17:02:28.731Z</atom:updated>
            <content:encoded><![CDATA[<h4>Seriously though, dry running code has probably saved me hours of banging my head against a wall</h4><p><strong><em>Picture this</em></strong>. You’re stranded on a desert island, with nothing around, and you have this kick-ass idea for a program, but no way to execute it. What do you do?</p><p>I’m sure we’ve all been in this situation before <em>(or maybe not)</em> and looked desperately for a way to execute your code to confirm it works.</p><p><em>Well</em>, the solution is pretty simple: <em>Just dry run your code</em>.</p><figure><img alt="Person mentally tracing the flow of their program for debugging purposes" src="https://cdn-images-1.medium.com/max/1024/0*um7h2Vuklcqjv0VW" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What Exactly is Dry Running Your Code?</h3><blockquote>“Dry running code, also known as code walkthrough or code tracing, is a technique used in programming to understand and analyze the behavior of a piece of code without actually executing it on a computer. <strong>The term “dry run” comes from the idea that you are running through the code “in your head” or on paper without the need for a computer</strong>.”</blockquote><p>That ChatGPT quote sums it up pretty well. <strong>We are essentially walking through the execution of a program in our head, maybe with the help of pen and paper</strong>.</p><p>There isn’t any magic to it and anyone can do this as long as they know how to program.</p><p>But this might seem a pointless to some of you reading; After all why bother when you can just run it and see the output?</p><p><strong>There are two key reasons why you should dry run your code</strong>:</p><ol><li>It has immediate benefits to debugging your code</li><li>Dry running code is a skill</li></ol><p>Lets discuss these two points a little bit.</p><h4>It has immediate benefits to debugging your code</h4><p>When you run a program, you’re not thinking about how it’s running, you’re just looking at the output.</p><p>Unfortunately, only knowing the output is wrong isn’t enough to know why it’s wrong most of the time.</p><p>Dry running your code can help with this. When you dry run your code, you will go through each step of execution in detail, giving proper thought to what each step is supposed to do, what it’s actually doing and if it’s correct.</p><p>During this process, you’ll likely notice any errors present in the flow of your program.</p><h4>Dry running code is a skill</h4><p>Understanding exactly how a program functions and flows is imperative to debugging and maintaining it.</p><p><em>But how do you develop this understanding?</em></p><p><strong>Dry running your program will help with this</strong>. Not only will you get a better understanding of what your program is doing when you mentally trace it, but you also practice the skill of understanding how a piece of code will execute just by looking at it.</p><p>Once you’ve dry run programs enough times, the process becomes almost automatic and you start to spot patterns/similarities between certain programming constructs. You can then reuse these programming constructs in separate projects and already know how they work which makes dry running other code in that project easier.</p><figure><img alt="Professional debugger hard at work understanding the in’s and out’s of his program" src="https://cdn-images-1.medium.com/max/1024/0*9ERYTv9J4X4bRPQ9" /><figcaption>Photo by <a href="https://unsplash.com/@catherineheath?utm_source=medium&amp;utm_medium=referral">Catherine Heath</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>How Should I Dry Run Code?</h3><p>There is no correct way to dry run code, <em>it’s preference really</em>, but here’s a few pointers which have helped me:</p><ul><li>Using a pen and paper/notepad to keep track of your program execution</li><li>Commenting your code so you know what a bit of code is intended to do</li><li>Take time to properly think about what your code is doing and how it’s functioning</li><li>Using popular external libraries where appropriate as they are usually error free and so you will have less to think about</li><li>Writing your code neatly and in blocks (I.e object oriented classes) to make it easier to reason about the logic of your program</li></ul><h3>Should I Always Dry Run my Code?</h3><p>In short, <strong>probably not</strong>.</p><p>It would take way too much time to dry run everything you write. I would prioritize dry running the more complex parts of your program to get a deeper understanding of those sections. Additionally, the more complex a part of a program is, the more error prone it is so you’ll need to know how they work in more detail than other simpler sections of your program.</p><p>Though, while you shouldn’t dry run everything you write, it’s always good practice and I would never encourage not doing it.</p><h3>That’s all!</h3><p><em>I hope this article helped teach you a bit about dry running code and why it’s a good habit to get into. If not, then I hope you enjoyed reading it nonetheless.</em></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f10564c3e9d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pen And Paper Might Just be The Best Way to Write Code]]></title>
            <link>https://medium.com/@theconnoisseur/pen-and-paper-might-just-be-the-best-way-to-write-code-04b5feb37f5d?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/04b5feb37f5d</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[pseudocode]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[crack-coding-interview]]></category>
            <category><![CDATA[coding-tips]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 20:45:56 GMT</pubDate>
            <atom:updated>2023-11-01T18:19:08.731Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ok maybe not, but it’s not as useless as you might think</h4><p><strong>Ok, I lied</strong>. Pen and paper is <strong>not </strong>the best way to write code,<em> not by any metric</em>. You should be using your favorite IDE and tools to help you write code in an efficient and elegant manner.</p><p><em>But are there any situations where you should write your code in pen and paper? and should you practice doing so?</em></p><p>That’s what I’m going to answer here, <strong>so let’s dive in</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LW5falPMVTqfT0JRfveng.jpeg" /><figcaption>Software engineer writing code on a whiteboard</figcaption></figure><h3>Places Where You May Be Forced to Write Code in Pen and Paper</h3><p><em>Unfortunately, you may not have a choice.</em></p><p>Many coding interviews, exams and competitions <strong>force</strong> you to write code on paper, making you give up the comfort of an IDE. Hence, in situations like these, it is beneficial to have had some practice writing code on paper and/or a whiteboard.</p><p><em>Remember in coding interviews and competitions you may not have to follow language rules when writing code on paper, and are able to write pseudocode instead. Ask you’re interviewer/examiner for guidance on this.</em></p><p>You may be wondering why they force you to write code on paper in scenarios like this; it may seem of pointless as you’re going to be coding with an IDE anyway. While the subject of this question can be an article in itself, <em>here’s a few reasons why many interviewers force the use of pen and paper</em>:</p><ol><li><strong>Mimicking real-world scenarios</strong>: Coding on pen and paper can simulate real-world scenarios where you may need to brainstorm, design, and implement code without the aid of an integrated development environment (IDE) or code editor.</li><li><strong>Testing problem-solving skills</strong>: This format assesses a candidate’s ability to think critically, plan code, and solve problems without the crutch of autocomplete, syntax highlighting, and other features provided by modern coding tools.</li><li><strong>Assessing algorithmic and data structure knowledge</strong>: Writing code on paper emphasizes a candidate’s understanding of algorithms and data structures, as they need to write code from scratch rather than relying on code libraries or built-in functions.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjmBokxVRMLQmVdcX1-DeA.jpeg" /><figcaption>A man about to ace his coding interview at Amazon because he practiced writing pseudocode on a whiteboard</figcaption></figure><h3>Places Where Writing Code In Pen and Paper Can Be Helpful</h3><p>No one says you have to write code in <em>either</em> pen and paper or an IDE; you can use <strong>both</strong>.</p><p>In fact, there are times when writing code on paper can be helpful. <em>Here’s a few that come to mind</em>:</p><h4>Visualization</h4><p>This is more diagrams than writing code but can still be very helpful in the coding process.</p><p>Visualizing the the structure of your code on a piece of paper by drawing it out is a great way to spot any potential errors, refactors and get a deeper understanding of the underlying software architecture.</p><p>Additionally, if you’re working in a team then it makes it much easier to explain ideas to one another.</p><h4>Pseudocode</h4><p>If you didn’t already know, pseudocode is a rough implementation of what your code will look like. It’s not language specific and is meant as a way to explore what possible bits of code will look like before actually coding them out.</p><p>It can be very helpful to find mistakes in your coding ideas before actually coding them out and running them.</p><p>It also offers a way to share program ideas with other irrespective of specific coding language knowledge.</p><h4>Dry Running Code</h4><p>Dry running your code is visualizing how your code will run on execution without actually running it. You go through how it should run at each stage of the program and the expected outputs and inputs.</p><p>It can be used against some pseudocode you’ve created to get an idea of whether your algorithm will work or not.</p><h3>So How Should You Use a Pen and Paper in Your Coding?</h3><p>In short, <strong>however you want</strong>!</p><p>Everyone has their own coding style and process so don’t feel pressured to feel like you have to use pen and paper in your programming if it doesn’t work for you.</p><p>However, I would encourage you to try it and at least get some practice with it if you have a coding interview or exam coming up where you may need to write code on paper.</p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04b5feb37f5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Calculating a League Player’s Win Percentage in Python]]></title>
            <link>https://medium.com/@theconnoisseur/calculating-a-league-players-win-percentage-in-python-952509989c3f?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/952509989c3f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[riot-games]]></category>
            <category><![CDATA[programming-tutorials]]></category>
            <category><![CDATA[api-development]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Sat, 14 Oct 2023 10:34:54 GMT</pubDate>
            <atom:updated>2023-10-14T10:34:54.240Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to using the Riot API in Python Part 5, Finishing Our Mini Project and Future Steps</h4><p><strong>This is part 5 (The Last Part!) of a tutorial series where I walkthrough creating a mini project using the Riot API in Python.</strong></p><p><strong>Here is a link to the first part of the series if you want to go from the beginning: </strong><a href="https://medium.com/@theconnoisseur/using-the-riot-api-with-python-454503d6bb8d">Using The Riot API with Python. Part 1, Defining our mini project and… | by TheConnoisseur | Sep, 2023 | Medium</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AY4l-322hBdEDfJ35sPkbw.jpeg" /></figure><p>We’re here at last, <strong>the final part of this tutorial series</strong>. Congrats for making it this far! And if this is you haven’t seen any other parts of this tutorial series already, then I highly recommend checking them out.</p><p>In this part, we’ll finish of our mini project by <strong>calculating our player’s win percentage </strong>from their last 20 games, <em>using our previously defined functions</em>, and talk about some <strong>possible future steps/improvements</strong>.</p><h3>Calculating the Player’s Win Ratio</h3><p>If you remember the goal of this mini project was to <em>calculate the player’s win ratio from their last 20 played games. </em>And now, we have all the pieces in place to do this.</p><p>Let’s write a function for this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VENJFzhNpHGSIxrpht6k-w.png" /></figure><pre>def win_percent_of_last_20_games(summoner_name, region=settings.DEFAULT_REGION, region_code=settings.DEFAULT_REGION_CODE):<br>    summoner = get_summoner_info(summoner_name, region_code)<br>    matches = get_match_ids_by_summoner_puuid(summoner[&#39;puuid&#39;], 20, region)<br><br>    wins = 0<br>    for match in matches:<br>        if did_player_win_match(summoner[&#39;puuid&#39;], match):<br>            wins += 1<br><br>    return (wins/len(matches))*100</pre><p>This function utilises <em>get_summoner_info, get_match_ids_by_summoner_puuid </em>and <em>did_player_win_match, </em>all of our previously written functions, to calculate the win ratio for our player.</p><p>Our pre-existing functions do most of the heavy lifting so there isn’t much new logic to explain here. All we simply do is loop through the last 20 matches our player has played and count how many of those they won.</p><p>Then we use a simple calculation to calculate their win percentage: <em>(number of wins/number of games) * 100</em></p><p>Let’s test out our new function by adding this bit of code to <em>__main__.py</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*UiZ0DtIga2NdL0NHBxMSxg.png" /></figure><p><em>So now our __main__.py looks like this</em>:</p><pre>from helpers import get_summoner_info, get_match_ids_by_summoner_puuid,\<br>    did_player_win_match, win_percent_of_last_20_games<br><br>summoner_name = &quot;Conoisseur&quot;<br><br>summoner = get_summoner_info(summoner_name)<br>print(summoner)<br>print(summoner[&#39;name&#39;])<br><br>summoner_match_ids = get_match_ids_by_summoner_puuid(summoner[&#39;puuid&#39;], 20)<br>print(summoner_match_ids)<br><br>win = did_player_win_match(summoner[&#39;puuid&#39;],summoner_match_ids[0])<br>print(win)<br><br>win_ratio = win_percent_of_last_20_games(summoner_name)<br>print(win_ratio)</pre><p>Where the last line prints out the player’s win percentage of their last 20 games.</p><p><em>Upon running this code you should see something like this:</em></p><pre>{&#39;id&#39;: &#39;hGqlM71dcf2ftm2-3cIo8kzQafLAiQkRRzXkICH6OlznpUzdpS79yid0pQ&#39;, &#39;accountId&#39;: &#39;gzQspn1TfngAEAVHCDs7lBfVd0lmXmE0GfpRx03r55C2BpTSRLBD8VhH&#39;, &#39;puuid&#39;: &#39;qJMwrXcOhpCXLgnKGJsGRr1Ks4TLc_Pq92LR1wIpHqvP_uOU9jLca3sDk7dUQ8mASPweplXVHrtVcQ&#39;, &#39;name&#39;: &#39;Conoisseur&#39;, &#39;profileIconId&#39;: 5973, &#39;revisionDate&#39;: 1697218713425, &#39;summonerLevel&#39;: 56}<br>Conoisseur<br>[&#39;EUW1_6630219537&#39;, &#39;EUW1_6630138418&#39;, &#39;EUW1_6627617339&#39;, &#39;EUW1_6626784353&#39;, &#39;EUW1_6626717896&#39;, &#39;EUW1_6626707560&#39;, &#39;EUW1_6626605619&#39;, &#39;EUW1_6626441424&#39;, &#39;EUW1_6623931070&#39;, &#39;EUW1_6623866310&#39;, &#39;EUW1_6623814426&#39;, &#39;EUW1_6622616730&#39;, &#39;EUW1_6622561776&#39;, &#39;EUW1_6622504403&#39;, &#39;EUW1_6622481817&#39;, &#39;EUW1_6622445474&#39;, &#39;EUW1_6621140188&#39;, &#39;EUW1_6620130161&#39;, &#39;EUW1_6618818548&#39;, &#39;EUW1_6618778227&#39;]<br>False<br>35.0<br><br>Process finished with exit code 0</pre><p>As you can see, our player has a 35% win rate from their last 20 played game. <em>Not great, but at least they know now!</em></p><p><strong><em>And with that our project is complete!</em></strong></p><h3>So What Now?</h3><p>Well, if you want, you could call this project right here and go and work on something else using your newfound skills.</p><p><em>But, </em>if you want some ideas to extend or improve what we currently have, then here’s a few ideas:</p><h4>Possible Improvements</h4><ul><li>This code is in no way foolproof, and can fail at many different steps. If you want to extend this project, it would be beneficial to make sure you catch any errors thrown when interacting with the API and make sure the program doesn’t crash.</li><li>Remove all existing hard code. This would mean refactoring out things like the <em>win_percent_of_last_20_games </em>function and replacing it with something that can calculate the win percent of any given amount of games.</li><li>General code quality improvements. These are up to you.</li></ul><h4>Possible Extensions</h4><ul><li>Ability to calculate the win percentage of a certain type of game, I.e. our user may only care about their win percentage in ranked games.</li><li>Ability to calculate win percentage on a certain champion.</li><li>Ability to compare win ratios of different players.</li></ul><p>These are all possible improvements and extensions you can make but feel free to be creative with it and add whatever you want.</p><p><strong><em>That&#39;s all for this mini series!</em></strong></p><p>I know a script to calculate win percentage isn’t the most exciting or innovative thing to exist, but the skills needed to code it out form the building blocks of being able to do much more exciting things with the Riot API. <em>The possibilities are limitless!</em></p><p><em>A big thanks for reading this far and I hope you enjoyed! If there’s anything else you want me to cover or add then let me know through a comment!</em></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=952509989c3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting a Player’s League Match History Using the Riot API in Python]]></title>
            <link>https://medium.com/@theconnoisseur/getting-a-players-league-match-history-using-the-riot-api-in-python-9b1acf5f0159?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b1acf5f0159</guid>
            <category><![CDATA[programming-tutorials]]></category>
            <category><![CDATA[riot-games]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api-development]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Sat, 23 Sep 2023 15:12:55 GMT</pubDate>
            <atom:updated>2023-10-14T10:36:10.658Z</atom:updated>
            <content:encoded><![CDATA[<h4>Int<strong>roduction to using the Riot API in Python Part 4, Getting a Player’s Match History</strong></h4><p><strong>This is part 4 of a tutorial series where I walkthrough creating a mini project using the Riot API in Python.</strong></p><p><strong>Here is a link to the first part of the series if you want to go from the beginning: </strong><a href="https://medium.com/@theconnoisseur/using-the-riot-api-with-python-454503d6bb8d">Using The Riot API with Python. Part 1, Defining our mini project and… | by TheConnoisseur | Sep, 2023 | Medium</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SArSl4hws-6dMUKI_BOZHg.jpeg" /></figure><p><em>Welcome</em> to the 4th part of this small tutorial series on using the <strong>Riot API</strong> in <strong>Python</strong>.</p><p>We’re almost arriving at the end of our mini project, with just a few more things to do.</p><p>In this part, we’ll get a player’s <strong>match history</strong> using their <em>puuid</em> and learn how to <strong>analyse match data</strong>.</p><h3>Getting a Player’s Match History</h3><p><em>If you haven’t already, I highly recommend checking out the last part of the tutorial: </em><a href="https://medium.com/@theconnoisseur/querying-the-riot-api-with-python-a-simple-introduction-d945f676c950">Querying The Riot API with Python: A Simple Introduction | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><em>All the concepts we learnt from that part will be relevant here.</em></p><p>From the last part, we learnt how to get a player’s profile information by querying the Riot API in Python.</p><p>To get their match history, we will be doing the exact same thing, <strong>but using this endpoint</strong>: <a href="https://developer.riotgames.com/apis#match-v5/GET_getMatchIdsByPUUID">Riot Developer Portal (riotgames.com)</a>, <strong><em>MATCH-V5</em>.</strong></p><p>Last time, we only had the option to pass in one required parameter when using the <em>SUMMONER-V4 endpoint, </em>but this time we have a lot more options when calling the API, using the <em>MATCH-V5 endpoint</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekiCqHGlL02TjPHNyxszAQ.png" /></figure><p>As you can see, we are required to pass in a puuid but the rest of the parameters are <strong>optional</strong>. Feel free to customise these values as much as you want but we will be setting the <em>count </em>parameter to 20 for the remainder of the project.</p><p>Lets get into coding a function to call this API endpoint.</p><p><em>This process is very similar to what we did in the last part where we accessed player/summoner data, so I’ll skip over some of the smaller details.</em></p><p>Our function signature will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2WDEC9GsOZn4rhNoNjloA.png" /></figure><p>We include a <strong>descriptive function name</strong> and have 3 parameters:</p><ul><li><em>summoner_puuid, </em>puuid of player we are getting match history of</li><li><em>matches_count, </em>how many match ids we are requesting</li><li><em>region, </em>optional parameter to specify what region our player is in. Will be set to default region if not passed in</li></ul><p><em>Optionally, you can give the function a descriptive docstring. This is one Chat-GPT generated for me:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zI0dx_S4TTRktiAVPdMVtg.png" /></figure><p><em>The main body of the function will look like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8x2ph4hQ5PtvffjSLsX5w.png" /></figure><p>As you can see it has the same structure as the function we coded out in the last part:</p><ul><li><em>We format our request URL</em></li><li><em>We make the request to the API</em></li><li><em>We check for any errors along the way and report any that occur</em></li><li><em>We return the JSON from our response object</em></li></ul><p><em>If you require a deeper explanation of this function then check out the previous part in this tutorial series</em></p><p>This function will return a list of <em>match ids, </em>each of which can be used to access data on a specific match played.</p><p><em>The entire function, all together, will look like this:</em></p><pre>def get_match_ids_by_summoner_puuid(summoner_puuid, matches_count, region=settings.DEFAULT_REGION):<br>    &quot;&quot;&quot;<br>    Retrieve a list of match IDs for matches recently played by a summoner.<br><br>    Args:<br>        summoner_puuid (str): The PUUID (Player Universally Unique ID) of the summoner.<br>        matches_count (int): The number of match IDs to retrieve.<br>        region (str, optional): The region where the summoner is located. Defaults to the value in settings.DEFAULT_REGION.<br><br>    Returns:<br>        list or None: A list of match IDs if successful, None if an error occurs during the API request.<br><br>    Raises:<br>        requests.exceptions.RequestException: If there&#39;s an issue with the API request.<br><br>    Example:<br>        get_matches_by_summoner(&#39;sample_puuid&#39;, 10, &#39;na&#39;)<br>    &quot;&quot;&quot;<br>    params = {<br>        &#39;api_key&#39;: settings.API_KEY,<br>        &#39;count&#39;: matches_count,<br>    }<br>    api_url = f&quot;https://{region}.api.riotgames.com/lol/match/v5/matches/by-puuid/{summoner_puuid}/ids&quot;<br>    try:<br>        response = requests.get(api_url, params=urlencode(params))<br>        response.raise_for_status()<br>        return response.json()<br>    except requests.exceptions.RequestException as e:<br>        print(f&#39;Issue getting summoner match data from API: {e}&#39;)<br>        return None</pre><p>Let’s write some code in our <em>__main__.py</em> file to test our new function out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ne-AYPXrJmWTmi9jLDsUAg.png" /></figure><pre>from helpers import get_summoner_info, get_match_ids_by_summoner_puuid<br><br>summoner_name = &quot;Conoisseur&quot;<br><br>summoner = get_summoner_info(summoner_name)<br>print(summoner)<br>print(summoner[&#39;name&#39;])<br><br>summoner_match_ids = get_match_ids_by_summoner_puuid(summoner[&#39;puuid&#39;], 20)<br>print(summoner_match_ids)</pre><p>All this bit of code does is use the <em>summoner</em> <em>puuid,</em> obtained from the <em>get_summoner_info </em>function, and passes it into our newly created <em>get_match_ids_by_summoner_puuid </em>function, to get a list of match ids.</p><p>On a successful API call, this will return the ids of the last 20 matches our summoner has played.</p><p><em>The output of running this code will look like this</em>:</p><pre>{&#39;id&#39;: &#39;hGqlM71dcf2ftm2-3cIo8kzQafLAiQkRRzXkICH6OlznpUzdpS79yid0pQ&#39;, &#39;accountId&#39;: &#39;gzQspn1TfngAEAVHCDs7lBfVd0lmXmE0GfpRx03r55C2BpTSRLBD8VhH&#39;, &#39;puuid&#39;: &#39;qJMwrXcOhpCXLgnKGJsGRr1Ks4TLc_Pq92LR1wIpHqvP_uOU9jLca3sDk7dUQ8mASPweplXVHrtVcQ&#39;, &#39;name&#39;: &#39;Conoisseur&#39;, &#39;profileIconId&#39;: 5973, &#39;revisionDate&#39;: 1694988978563, &#39;summonerLevel&#39;: 48}<br>Conoisseur<br>[&#39;EUW1_6597728340&#39;, &#39;EUW1_6597671624&#39;, &#39;EUW1_6597620600&#39;, &#39;EUW1_6597540069&#39;, &#39;EUW1_6597465216&#39;, &#39;EUW1_6597094857&#39;, &#39;EUW1_6597015780&#39;, &#39;EUW1_6596490497&#39;, &#39;EUW1_6596054765&#39;, &#39;EUW1_6595704552&#39;, &#39;EUW1_6595321845&#39;, &#39;EUW1_6595032307&#39;, &#39;EUW1_6594163836&#39;, &#39;EUW1_6594115186&#39;, &#39;EUW1_6594067868&#39;, &#39;EUW1_6593007789&#39;, &#39;EUW1_6592613658&#39;, &#39;EUW1_6592546425&#39;, &#39;EUW1_6592496670&#39;, &#39;EUW1_6592451477&#39;]<br><br>Process finished with exit code 0</pre><p>Now let’s get into the interesting stuff, <em>how we can use a match id to analyse match data</em></p><h3>Analysing Match Data</h3><p>All we have right now is a <em>match id, </em>which is pretty useless on it’s own, but luckily <em>MATCH-V5 </em>comes with an endpoint which can be used to return a <em>lot </em>of data on a match by it’s <em>match id: </em><a href="https://developer.riotgames.com/apis#match-v5/GET_getMatch">Riot Developer Portal (riotgames.com)</a></p><p>When I say a <em>lot </em>of data, I really mean a <strong><em>lot</em> </strong>of it. To the point where it would take <em>way</em> too long to talk about everything returned in the response in this article, so instead I’ll talk about the main structure of it and the bits of information we will need.</p><p><em>We are calculating the player’s win ratio from their last 20 games, so the data we want to access is what team the player was on and did they win.</em></p><p>Let’s make a request to the API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BV667aYluj4eA0gunLoK9w.png" /></figure><p>The JSON response returned will look like this, <em>note here I am viewing it in my web browser:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1GV2doZBXhtaJyispZ8uBg.png" /></figure><p>This response in particular is a whopping <strong>3000 </strong>lines of JSON. Yeah, pretty big.</p><p><em>Don’t worry though, most of it we won’t be using in this mini project.</em></p><p>If you look at the screenshot, you can see that we have two variables at the top of the hierarchy:</p><ul><li><em>metadata, </em>holds the <em>match id </em>and <em>puuids </em>of all participants in the match</li><li><em>info, </em>holds all information relating to what happened in the match itself, including what each player did in the match</li></ul><p>The <em>info </em>variable contains a list called <em>participants </em>which holds data on what each individual player did in the match.</p><p><em>Each participant includes whether they were on the winning team on not. This is what we will use to determine if our player won the match or not.</em></p><p>But how do we know which participant is our player?</p><p><strong>The order in which the participants are in the <em>metadata </em>variable is the same order they are in the <em>info </em>variable.</strong></p><p>This means we can use our player’s <em>puuid </em>to find it’s index in the <em>metadata participants</em> variable, and it will be in the same index in the <em>info participants </em>variable.</p><p><em>Don’t worry if this sounds confusing. It’s one of those things where it sounds confusing on paper but in practise it’s not that bad.</em></p><p>So now we know how to check if a player is on the winning team, let’s code it out.</p><h3>Coding Out a Function to Check if a Player Won or Lost a Game</h3><p>Just like our other functions, we’ll start by choosing a descriptive function signature and send a request to the API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NiaXttbk1_b4VWsSrcSCoQ.png" /></figure><p>We now have access to match data JSON in our <em>match_data </em>variable.</p><p>We know need to know which index our player is in the <em>info </em>variable of the JSON response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cT8ZcstaJ23zovPwyADhjw.png" /></figure><p>We query the <em>metadata </em>field’s <em>participants </em>list to check that our player’s <em>puuid</em> is present, checking that they were in the match. We then get the index their <em>puuid </em>is in the <em>participants</em> list, which will be the same index they are in the <em>info </em>fields <em>participants </em>list.</p><p>Let’s use that index to get our player’s data in this match:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*xXb3CbGqY6shXN5fMfw54A.png" /></figure><p><em>player_info</em> holds all kinds of data about our player’s performance in this match like kills, deaths, assists, etc. But the field we are interested in is <em>win, </em>which returns if the player was on the winning team or not. We can simply return this and our function is complete.</p><p><em>The entire function:</em></p><pre>def did_player_win_match(summoner_puuid, match_id, region=settings.DEFAULT_REGION):<br>    params = {<br>        &#39;api_key&#39;: settings.API_KEY,<br>    }<br>    api_url = f&quot;https://{region}.api.riotgames.com/lol/match/v5/matches/{match_id}&quot;<br><br>    try:<br>        response = requests.get(api_url, params=urlencode(params))<br>        response.raise_for_status()<br>        match_data = response.json()<br>    except requests.exceptions.RequestException as e:<br>        print(f&#39;Issue getting match data from match id from API: {e}&#39;)<br>        return None<br><br>    if summoner_puuid in match_data[&#39;metadata&#39;][&#39;participants&#39;]:<br>        player_index = match_data[&#39;metadata&#39;][&#39;participants&#39;].index(summoner_puuid)<br>    else:<br>        return None<br><br>    player_info = match_data[&#39;info&#39;][&#39;participants&#39;][player_index]<br>    return player_info[&#39;win&#39;]</pre><p>Let’s write some code to test this in our <em>__main__.py </em>file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILbBMLQOtKhhP3y1P_N9uw.png" /></figure><pre>from helpers import get_summoner_info, get_match_ids_by_summoner_puuid,\<br>    did_player_win_match<br><br>summoner_name = &quot;Conoisseur&quot;<br><br>summoner = get_summoner_info(summoner_name)<br>print(summoner)<br>print(summoner[&#39;name&#39;])<br><br>summoner_match_ids = get_match_ids_by_summoner_puuid(summoner[&#39;puuid&#39;], 20)<br>print(summoner_match_ids)<br><br>win = did_player_win_match(summoner[&#39;puuid&#39;],summoner_match_ids[0])<br>print(win)</pre><p>This imports our newly made function into our <em>__main__.py </em>file and runs it using our example summoner and one of their recently played matches. It then prints the output:<em> whether that summoner was on the winning team or not.</em></p><p><em>On running this code, the output will look like this</em>:</p><pre>{&#39;id&#39;: &#39;hGqlM71dcf2ftm2-3cIo8kzQafLAiQkRRzXkICH6OlznpUzdpS79yid0pQ&#39;, &#39;accountId&#39;: &#39;gzQspn1TfngAEAVHCDs7lBfVd0lmXmE0GfpRx03r55C2BpTSRLBD8VhH&#39;, &#39;puuid&#39;: &#39;qJMwrXcOhpCXLgnKGJsGRr1Ks4TLc_Pq92LR1wIpHqvP_uOU9jLca3sDk7dUQ8mASPweplXVHrtVcQ&#39;, &#39;name&#39;: &#39;Conoisseur&#39;, &#39;profileIconId&#39;: 5973, &#39;revisionDate&#39;: 1695408014544, &#39;summonerLevel&#39;: 50}<br>Conoisseur<br>[&#39;EUW1_6603326975&#39;, &#39;EUW1_6603272132&#39;, &#39;EUW1_6603219671&#39;, &#39;EUW1_6603179562&#39;, &#39;EUW1_6603120780&#39;, &#39;EUW1_6602163381&#39;, &#39;EUW1_6601136289&#39;, &#39;EUW1_6601092521&#39;, &#39;EUW1_6601043435&#39;, &#39;EUW1_6600147486&#39;, &#39;EUW1_6599974662&#39;, &#39;EUW1_6599911141&#39;, &#39;EUW1_6599830493&#39;, &#39;EUW1_6599795012&#39;, &#39;EUW1_6599094064&#39;, &#39;EUW1_6599063830&#39;, &#39;EUW1_6599013736&#39;, &#39;EUW1_6598484399&#39;, &#39;EUW1_6598435598&#39;, &#39;EUW1_6598400476&#39;]<br>True</pre><p><strong>Nice!</strong> Now we have a list of match ids for our player and a way to check if they won a match.</p><p><em>In the next part, we’ll </em><strong><em>finish </em></strong><em>this mini project and tutorial series. We’ll talk about next steps you could make to extend this project and improvements that could be made on the current design.</em></p><p><em>Next Part: </em><a href="https://medium.com/@theconnoisseur/calculating-a-league-players-win-percentage-in-python-952509989c3f">Calculating a League Player’s Win Percentage in Python | by TheConnoisseur | Oct, 2023 | Medium</a></p><p><em>Previous Part: </em><a href="https://medium.com/@theconnoisseur/querying-the-riot-api-with-python-a-simple-introduction-d945f676c950">Querying The Riot API with Python: A Simple Introduction | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b1acf5f0159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Querying The Riot API with Python: A Simple Introduction]]></title>
            <link>https://medium.com/@theconnoisseur/querying-the-riot-api-with-python-a-simple-introduction-d945f676c950?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/d945f676c950</guid>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[programming-tutorials]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[riot-games]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Sat, 16 Sep 2023 12:25:00 GMT</pubDate>
            <atom:updated>2023-09-23T15:13:56.536Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to using the Riot API in Python Part 3, <em>Getting Player Profile Data in Python</em></h4><p><strong>This is part 3 of a tutorial series where I walkthrough creating a mini project using the Riot API in Python.</strong></p><p><strong>Here is a link to the first part of the series if you want to go from the beginning: </strong><a href="https://medium.com/@theconnoisseur/using-the-riot-api-with-python-454503d6bb8d">Using The Riot API with Python. Part 1, Defining our mini project and… | by TheConnoisseur | Sep, 2023 | Medium</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LjtTnvEBHI-9Ew8Ulr4R5A.jpeg" /></figure><p>Welcome to the 3rd part of this small tutorial series on using the <strong>Riot API</strong> in <strong>Python</strong>.</p><p>In this segment, we’re going to get into the exciting part of the mini project: the <strong>programming</strong>.</p><h3>The Structure of Our Mini Project</h3><p><em>For this mini project, I’m going to assume you have an idea of how to create and run a Python script as well as install dependencies using pip.</em></p><p><em>Additionally, you can also setup and virtual environment and requirements.txt if you wish to, but this is totally optional and you shouldn’t worry if you don’t.</em></p><p><em>Use whatever IDE you want, but if you’re interested I’ll be using PyCharm.</em></p><p>The final structure of this mini project will comprise of 3 main Python files:</p><ul><li><strong>settings.py</strong>, holds information like the API key</li><li><strong>helpers.py</strong>, holds functions used to access the API</li><li><strong>__main__.py</strong>, file which is run to execute script</li></ul><p>So, go into the root of your project and create these 3 Python files. They can be blank for now.</p><p><em>As you can see in the screenshot below, I have also included a requirements.txt and venv in my project but you do not have to.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*HSaA01sby7_sImBdUPu_ig.png" /><figcaption>File structure for our mini project</figcaption></figure><p>Additionally, we will be using the <a href="https://www.w3schools.com/python/module_requests.asp">Python Requests Module</a> to make queries to the API through the web.</p><p><em>If you are unfamiliar with this module, don’t worry we’ll only be using the basic features of it.</em></p><p><strong>To install the requests module, run this pip command in the base of your project:</strong></p><pre>pip install requests</pre><h3>Adding to Settings.py File</h3><p>First, let’s place our API key in the <em>settings.py </em>file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*mL2RSDDIytKs3DvOU7WPJg.png" /></figure><p>This centralises the input of your API key to one place so you can easily change it when you need to.</p><p>Additionally, I have added two constants, <em>DEFAULT_REGION_CODE </em>and <em>DEFAULT_REGION, </em>which we can use as placeholders in our script in case our user doesn’t enter a region to place their query against.</p><p>Generally, it’s useful to have a <em>settings.py </em>file in most of your projects to hold constants and widely accesses variables, like an API key.</p><h3>Creating Our Script</h3><p>Let’s code out retrieving a player’s profile data from the API in Python. We’ll do this inside a function in our <em>helpers.py </em>file.</p><p>First, import your <em>settings.py </em>file and the <em>requests </em>module:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*F0OhHCledDCbsD-Htm-DOw.png" /></figure><p>We will also import <em>urlencode</em> to format the URL neatly for making requests to the API.</p><p>Our function signature will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AoAuhi8wUOIoF98mU84QgA.png" /></figure><p>We have included a docstring to outline what the function will do. It’s a good habit to do this, even in solo projects, as it helps you keep track of what a specific bits of code do.</p><p>The function takes two optional parameters:</p><ul><li><em>summoner_name, </em>if not passed in we will ask the user for input inside the function instead</li><li><em>region, </em>if not passed in then it will be set to the default region specified in our <em>settings.py </em>file</li></ul><p>Next, let’s get that <em>summoner_name </em>from the user if it wasn’t passed in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*4dMcoT4a-kNQ9omzCr3ghw.png" /></figure><p>If a <em>summoner_name </em>wasn’t passed into the function then it’s default value will be <em>None</em>. We can check for this and then prompt the user to enter a <em>summoner_name </em>inside the function instead.</p><p>Now we can prepare the URL we’re going to use to query the API:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59f_vcDJVNJEQATt5c8gOw.png" /></figure><p>Remember from the last part of the tutorial, we went into the Riot developer portal and generated a URL we could use to query the API; that’s where the <em>api_url</em> in our code comes from.</p><p>Looking at the URL you can see it’s making a request to the SUMMONER-V4 endpoint and it’s getting that information by a summoner’s name.</p><p>All we need to do is edit this URL to include the region our summoner is in, the summoner’s name and our API key to validate the request.</p><p>We include the summoner’s name and region in the actual URL itself using Python <em>f-strings </em>but for the API key we include it in it’s own Python dict. This is because we will make our requests to the API through the web using the Python <em>requests</em> library’s <em>get </em>method, which sends a <em>GET </em>request to a URL. The <em>get </em>method accepts URL parameters as optional arguments, which is where we will be passing in our API key. This makes the code neater.</p><p>Let’s make the request to the API and return the response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84BXpC4GEtvlau_9voZrXg.png" /></figure><p>We have encased this in a try except block to catch any errors that may occur when fetching data from the API over the web. If any errors do occur, we print an error message and return <em>None </em>to the user.</p><p>On line 21 you can see the actual request being made to the API. We pass in our <em>api_url </em>and our <em>params</em> which include our API key. We use <em>urlencode </em>to convert the contents of the <em>params </em>dict to URL parameter form.</p><p>We then raise any errors with the <em>raise_for_status </em>function and, if there aren’t any, we return our response JSON.</p><p>With just these few lines of code we now have a function capable of getting a player’s <em>League of Legends </em>profile information from the Riot API.</p><p><em>The full function looks like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2sx5X8O38TE63NhuuKp66g.png" /></figure><p>Running our function is super simple: we just need to go into our <em>__main__.py</em> file, import our function and use it.</p><p>The below snippet of code does just that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*UzSn7zj7WgJ_L1IqkY0Fow.png" /></figure><p>Once your run this code, you will see an output like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zglhCTr-bBn27Mt58cI6zA.png" /></figure><p>This shows the JSON returned from the API containing our player’s profile information, which we now have access to in our Python scripts.</p><p><em>That all for now!</em></p><p>We looked at how you can make calls to the API in Python.</p><p>In the next part, we’ll use our player’s profile data obtained through our function and use it to get information on their recently played matches.</p><p><em>Next Part: </em><a href="https://medium.com/@theconnoisseur/getting-a-players-league-match-history-using-the-riot-api-in-python-9b1acf5f0159">Getting a Player’s League Match History Using the Riot API in Python | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><em>Previous Part: </em><a href="https://medium.com/@theconnoisseur/getting-game-data-using-the-riot-api-in-your-web-browser-2c830e22aa68">Getting Game Data Using the Riot API in Your Web Browser | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d945f676c950" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Game Data Using the Riot API in Your Web Browser]]></title>
            <link>https://medium.com/@theconnoisseur/getting-game-data-using-the-riot-api-in-your-web-browser-2c830e22aa68?source=rss-5bf0bfa6b603------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c830e22aa68</guid>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[programming-tutorials]]></category>
            <category><![CDATA[riot-games]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[TheConnoisseur]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 13:27:40 GMT</pubDate>
            <atom:updated>2023-09-16T12:27:01.091Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to using the Riot API in Python Part 2</h4><p><strong>This is part 2 of a tutorial series where I walkthrough creating a mini project using the Riot API in Python.</strong></p><p><strong>Here is a link to the first part of the series if you want to go from the beginning: </strong><a href="https://medium.com/@theconnoisseur/using-the-riot-api-with-python-454503d6bb8d">Using The Riot API with Python. Part 1, Defining our mini project and… | by TheConnoisseur | Sep, 2023 | Medium</a></p><figure><img alt="Empreyan Jax from League of Legends" src="https://cdn-images-1.medium.com/max/1024/1*fmHV5NUlwt-uEii4y0aSxg.jpeg" /></figure><p>Welcome to the 2nd part of this small tutorial series on using the <strong>Riot API</strong> in <strong>Python</strong>.</p><p>Previously I introduced the <strong>mini project</strong> we’d be working on and showed you how to acquire your own <strong>development API key</strong>.</p><p>In this part, we’ll take a look at some of the APIs Riot offers to us, which ones we’ll be using in our Python script and how you can call them in your web browser.</p><h3>Looking through the APIs on offer</h3><p>To see all the APIs offered by Riot, simply click the button in your toolbar at the top labelled “<em>APIs”.</em></p><p><em>Note this is the same page you generated your development API key from.</em></p><figure><img alt="Riot Developer Portal, generate development API screen" src="https://cdn-images-1.medium.com/max/1024/1*ApXVOWfgqq5ESSrNLnE31g.jpeg" /></figure><p>Now you will see a menu which looks like this:</p><figure><img alt="Riot developer portal, apis screen" src="https://cdn-images-1.medium.com/max/1024/1*rxYDYye99pgvXjJEkEoD8Q.jpeg" /></figure><p>On the left is a vertical toolbar which you can use to navigate all the different APIs you can use, and on the right are the different API end points you can use to make calls to the API.</p><p>I recommend looking through each of these and seeing what you can find. You’ll find API endpoints for all kinds of data from League of Legends, Valorant, Legends of Runeterra and more.</p><h3>Which APIs Will We Be Using?</h3><p><em>As a reminder, we are creating a script which will take in a player’s League of Legends in-game name and return their win ratio from the last 20 games played.</em></p><p>We will be using 3 API end points in our mini project:</p><ol><li><strong>SUMMONER-V4</strong>, get summoner profile by summoner name, (<a href="https://developer.riotgames.com/apis#summoner-v4/GET_getBySummonerName"><strong>Riot Developer Portal (riotgames.com</strong>)</a>) accepts a player’s in-game name (their summoner name) and returns their profile data.</li><li><strong>MATCH-V5</strong>, get match id’s by player puuid, (<a href="https://developer.riotgames.com/apis#match-v5/GET_getMatchIdsByPUUID"><strong>Riot Developer Portal (riotgames.com)</strong></a>) accepts a players puuid and returns match ids from the last 20 games they’ve played.</li><li><strong>MATCH-V5</strong>, get match information by match id, (<a href="https://developer.riotgames.com/apis#match-v5/GET_getMatch"><strong>Riot Developer Portal (riotgames.com)</strong></a>) takes a match id and returns information about that match.</li></ol><p><em>Note, League of Legends calls players ‘summoners’ and in this tutorial I will use them interchangeably.</em></p><p>Now that you know what information we can gather from the API, let’s detail the exact steps our script will make:</p><ol><li>Getting a given player’s puuid by their player name.</li><li>Using their puuid to get the ids of the last 20 matches they have played.</li><li>Get the match information associated with each match id and tally up the wins and losses</li><li>Calculate and return their win percentage</li></ol><p>Our mini project can be fully decomposed into 4 simple steps, only using 3 API endpoints. We’ll start implementing these steps in Python code in the next part of the tutorial.</p><p><strong><em>But first</em></strong>, let’s talk about how you can make an API call in your browser…</p><h3>Making API Calls in Your Web Browser</h3><p>Before we get into making API calls in Python, let’s talk about how you would call them in your web browser first.</p><p>You make API calls using HTTP Get requests, and then the data gets returned to you in JSON format.</p><p><strong><em>As such, you can simply type a valid URL into your browser to make a call to the API.</em></strong></p><p>You can use the Riot Developer Portal API interface to generate these URLs for you. Additionally, it can also make the API calls and present the returned data for you as well.</p><p><em>If this sounds a bit confusing then don’t worry, taking a look at an example will clear up any confusion you may have.</em></p><h4>Lets walk through an example of how this works</h4><p>Let’s make a call to the <strong>SUMMONER-V4</strong> API endpoint, where we pass a summoner name and get their profile details returned, including their puuid.</p><p>Navigate to the <strong>SUMMONER-V4 API</strong> endpoint in your toolbar, or follow this link to it: <a href="https://developer.riotgames.com/apis#summoner-v4/GET_getBySummonerName">Riot Developer Portal (riotgames.com)</a>.</p><p><em>You will see a drop down like this:</em></p><figure><img alt="Riot Developer Portal, SUMMONER-V4 API endpoint" src="https://cdn-images-1.medium.com/max/1024/1*YYyqj6mFbmyjLssX2O1wWg.jpeg" /></figure><p>This shows details of the information returned from a successful API call.</p><p><em>The player’s account id, profile icon id, revision date, name, id, puuid and summoner level returned to us in JSON format.</em></p><p>Just below that we can see the response errors that can go wrong with a call to the API:</p><figure><img alt="Riot API call response errors" src="https://cdn-images-1.medium.com/max/1024/1*QKAa0ZUf3uT555H702XbrQ.jpeg" /></figure><p>You don’t need to worry about these much for now. They will become more relevant when checking for them when writing our Python script.</p><p><em>The most common of these you will see is an 401 forbidden access error. Most of the time this will be caused by forgetting to attach a valid API key to your request.</em></p><p>Just below that, you will see the page where you make calls to the API in the developer portal:</p><figure><img alt="Riot API call, execute API call menu with given parameters" src="https://cdn-images-1.medium.com/max/1024/1*FxXK4Vjmr3CppL5pjTWMIA.jpeg" /></figure><p>Let’s make a call to the API where I want to get the profile details of my summoner with the in-game name “Conoisseur”.</p><p>We will need to select the region this summoner is in, <em>EUW in this case, </em>and select to include the API key in the header param to authorise access to the API.</p><p><em>Make sure your development API key is still valid</em></p><p>Now let’s execute our requests by pressing the big red button labelled “execute request”. The outcome of the request will appear in the window for you.</p><p>The first thing you want to do is check the response code:</p><figure><img alt="Response code 200" src="https://cdn-images-1.medium.com/max/1024/1*nkSg1YTTf_NwWp4B_Q-Rrg.png" /></figure><p>You want it it to be <strong>200</strong>, which says the request was successful. If it’s in the <strong>400 to 500 range</strong>, check the screenshot above about response codes to get an idea why your request wasn’t successful.</p><p>If your request was successful then the information returned by the API call will be in the<strong> response body</strong>:</p><figure><img alt="Response body from successful API call" src="https://cdn-images-1.medium.com/max/1024/1*Y7gBn3wJaimA-mRKgM0WMg.png" /></figure><p>This contains the information you requested in the API call. As you can see it contains information about the account. We will be using this information our Python script in the next part of tutorial</p><p>The last important part in our response is the <strong>request URL</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JjugLsem0aYcxdBUiV4M4A.png" /></figure><p>This is the URL we can copy into our web browser to make the API call from there, and this how we will be making calls to the API in Python.</p><p>So let’s try it. Copy the request URL generated for you, paste it into your browser and press enter.</p><p>You will get a JSON response which looks like this:</p><figure><img alt="JSON response from invalid call to API" src="https://cdn-images-1.medium.com/max/474/1*-L5D-G3lgk7IWH5KiRj-XQ.png" /></figure><p>Not a success, <strong>but can you work out why</strong>?</p><p>Well, whenever you encounter an error like this, double check your API key is <strong>valid</strong> and <strong>attached to your request</strong>.</p><p>In this case it’s not attached, so we need to add our development API key to the end of our URL like this: “<a href="https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/Conoisseur?api_key=YOUR_API_KEY"><strong>https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/Conoisseur?api_key=YOUR_API_KEY</strong></a>” where you <strong>replace “YOUR_API_KEY” with your developement API key.</strong></p><p>Now when you execute the request, you will get something which looks like this:</p><figure><img alt="JSON response in web browser from successful call to API" src="https://cdn-images-1.medium.com/max/1024/1*ei9xktpT-_6eE5KyRhkSxA.png" /></figure><p><strong>Success!</strong></p><p><em>That wraps it up for this part of the tutorial.</em></p><p>We looked at the different API calls we will be using and learnt how to make them.</p><p>In the next part, we’ll take a look at how to code this all out in Python and give Python access to that JSON response we just generated from the API.</p><p><em>Next Part: </em><a href="https://medium.com/@theconnoisseur/querying-the-riot-api-with-python-a-simple-introduction-d945f676c950">Querying The Riot API with Python: A Simple Introduction | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><em>Previous Part: </em><a href="https://medium.com/@theconnoisseur/using-the-riot-api-with-python-454503d6bb8d">Using The Riot API with Python. Part 1, Defining our mini project and… | by TheConnoisseur | Sep, 2023 | Medium</a></p><p><strong><em>Thanks for reading!<br>If you enjoyed this article then feel free to clap it and check out some of my other articles :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c830e22aa68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>