Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,946
» Latest member: blackopsdlc
» Forum threads: 22,057
» Forum posts: 23,024

Full Statistics

Online Users
There are currently 1020 online users.
» 0 Member(s) | 1015 Guest(s)
Applebot, Baidu, Bing, Facebook, Google

Latest Threads
How to play Groot in Marv...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 12
[WoW Retail News] Update ...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 12
[WoW Retail News] Astalor...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 18
How to unlock AMR Mod 4 s...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 24
[Dev News] Meta Horizon C...
Forum: Game Development
Last Post: xSicKxBot

» Replies: 0
» Views: 23
[WoW Retail News] Wowhead...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 19
[WoW Retail News] Brewfes...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 30
Marvel Rivals Winter Cele...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 36
[Py Blog] The Python docu...
Forum: Python
Last Post: xSicKxBot

» Replies: 0
» Views: 13
#3DBenchy - The jolly 3D ...
Forum: Printers & CAD Projects
Last Post: xSicKxBot

» Replies: 0
» Views: 31

 
  [Tut] Show Don’t Tell: Commenting Python Best Practices
Posted by: xSicKxBot - 11-27-2020, 12:41 AM - Forum: Python - No Replies

Show Don’t Tell: Commenting Python Best Practices

This tutorial taken from my upcoming programming book “From One to Zero” (NoStarch, 2021) will show you how to write great comments. While most online tutorials focus on a bullet list of commenting tips, we dive deeper into the meat exploring the underlying reasons for the commonly recommended commenting principles. So, let’s get started!

Code For Humans Not Machines


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” — Martin Fowler

The main purpose of source code is to define what machines should do and how to do it.

Yet, if this was the only criteria, you’d use a low-level machine language such as assembler to accomplish this goal because it’s the most expressive and most powerful language.

The purpose of high-level programming languages such as Python is to help people write better code and do it more quickly. Our next principle for clean code is to constantly remind yourself that you’re writing code for other people and not for machines.

If your code will have any impact in the real world, it’ll be read multiple times by you or a programmer that takes your place if you stop working on the code base. Always assume that your source code will be read by other people. What can you do to make their job easier? Or, to put it more plainly: what can you do to mitigate the negative emotions they’ll experience against the original programmer of the code base their working on? Code for people not machines!

Reduce Time to Understanding


If you write code for humans not machines, you’ll need to use comments to help readers of your code understand it better and quicker. A short comment can greatly reduce the time to cognitively grasp the meaning of the code base. Consider the following code example:

import re text = ''' Ha! let me see her: out, alas! he's cold: Her blood is settled, and her joints are stiff; Life and these lips have long been separated: Death lies on her like an untimely frost Upon the sweetest flower of all the field. ''' f_words = re.findall('\\bf\w+\\b', text)
print(f_words) l_words = re.findall('\\bl\w+\\b', text)
print(l_words) '''
OUTPUT:
['frost', 'flower', 'field']
['let', 'lips', 'long', 'lies', 'like'] '''

Bad code example without comments.

The previous code snippet analyzes a short text snippet from Shakespeare’s Romeo and Juliet using regular expressions. If you’re not very familiar with regular expressions, you probably struggle understanding what the code does. Even the meaningful variable names don’t help much. Let’s see if a few comments can resolve your confusion!

import re text = ''' Ha! let me see her: out, alas! he's cold: Her blood is settled, and her joints are stiff; Life and these lips have long been separated: Death lies on her like an untimely frost Upon the sweetest flower of all the field. ''' # Find all words starting with character 'f'
f_words = re.findall('\\bf\w+\\b', text)
print(f_words) # Find all words starting with character 'l'
l_words = re.findall('\\bl\w+\\b', text)
print(l_words) '''
OUTPUT:
['frost', 'flower', 'field']
['let', 'lips', 'long', 'lies', 'like'] '''

Good code example with comments.

The two short comments greatly help understanding the regular expression patterns '\\bf\w+\\b' and '\\bl\w+\\b'. While I won’t dive deeply into regular expressions here, the example shows how comments can help you getting a rough understanding of other people’s code without understanding each and every syntactic sugar. For introductory tutorials into the powerful technology regular expressions, check out our two technical books Python One-Liners and The Smartest Way to Learn Python Regular Expressions.

You’re the Expert—Share Your Wisdom!


Helpful comments give a glimpse into your thinking—as you’ve written the code, you possess valuable insight into it only matched by very few persons. Don’t miss out on sharing your insights with other people! Comments can be very useful to “abstract” over blocks of code. For example, if you have five lines of code dealing with updating customer information in a database, add a short comment before the block to explain this. This will help the reader get a quick overview of your code and accelerates their and your “code loading time”. You can find an example of such an instance next:

# Process next order
order = get_next_order()
user = order.get_user()
database.update_user(user)
database.update_product(order.get_order()) # Ship order & confirm customer
logistics.ship(order, user.get_address())
user.send_confirmation()

Commented blocks help get an overview of the code.

The code exemplifies how an online shop completes a customer order in two high-level steps: (1) Processing the next order, and (2) Shipping the order. The comments help you understand the purpose of the code in a few seconds without the need to look at each individual method call.  

Comments as WARNINGS!


You can also use comments as a warning of potentially undesired consequences. This increases the level of attention of the programmer working with your code. The following code shows such an example where programmers are warned before calling a function ship_yacht() that will actua ship an expensive yacht to a customer.

##########################################################
# WARNING #
# EXECUTING THIS FUNCTION WILL SHIP A $1,569,420 YACHT!! #
##########################################################
def ship_yacht(customer): database.update(customer.get_address()) logistics.ship_yacht(customer.get_address()) logistics.send_confirmation(customer)

Comments as warnings.

There are many more ways to use comments in a useful way. Comments are always there for the human reader, so always keep in mind that you’re writing code for humans not machines!

Avoid Unnecessary Comments


Not all comments help readers understand code better. In fact, there are many cases where comments reduce the clarity and confuse the readers of a given code base. If your goal is to write clean code, you must not only use valuable comments but also avoid unnecessary comments. But what are unnecessary comments? Let’s dive into those next.

During my time as a computer science researcher, many of my senior-level students described me in great detail how their job interviews at various companies went. A very skilled student had successfully applied for a job at Google. He told me that the Google headhunters—they’re usually Google engineers—criticized his code style because he added too many unnecessary comments. These types of comments are so called “code smells”—expert coders can figure out very quickly whether you’re a beginner, intermediate, or expert coder yourself. Unnecessary comments make this very obvious. But what are unnecessary comments? In most cases, they add a level of redundancy to the code. A great coder will use meaningful variable names (Principle: Use the Right Names), so the code often becomes self-explanatory—at least in comparison to code that doesn’t use the right names. Let’s revisit the code snippet with meaningful variable names.

investments = 10000
yearly_return = 0.1
years = 10 for year in range(years): print(investments * (1 + yearly_return)**year)

No comments needed.

The code calculates your cumulative investment return for ten years assuming a 10% yield. Now, let’s add some unnecessary comments!

investments = 10000 # your investments, change if needed
yearly_return = 0.1 # annual return (e.g., 0.1 --> 10%)
years = 10 # number of years to compound # Go over each year
for year in range(years): # Print value of your investment in current year print(investments * (1 + yearly_return)**year)

Unnecessary comments.

All comments in the previous code snippet are redundant. Some of them would’ve been useful if you’d chosen less meaningful variable names such as x, y, or z. But explaining a variable named yearly_return by means of a comment doesn’t provide any relative value. Quite contrarily, it reduces the value because it adds unnecessary clutter to the code. The additional clutter makes your code less readable and less concise. There are a few rules that may help you avoid unnecessary comments—although the best rule is to use your common sense to identify whether a comment really improves the readability of your code.

Code Smells — Negative Commenting Principles


  • Don’t use inline comments. They have little value and can be completely avoided by choosing meaningful variable names.
  • Don’t be redundant. Redundancy is the enemy of clarity—this also holds for comments!
  • Don’t add obvious comments. You can see an obvious comment in the previous code snippet just before the for loop statement. Any coder knows the for loop, so what additional value do you provide with the comment # Go over each year when the for loop already states for year in range(years)?  
  • Don’t comment out code. If you’re a programmer, it’s very likely that you’ve been guilty of this. We programmers often hang on to our beloved code snippets even if we already (grudgingly) decided to remove them. The shy approach to removing unnecessary code is to comment it out. However, commented code is a readability killer and you should avoid it at all costs if you want to write clean code. Instead of commenting out the unnecessary code, boldly remove it. For your piece of mind, you should use a version history tool such as Git that allows you to get any old code snippet if you need it.

Many programming languages such as Python come with documentation functionality that allows you to describe the purpose of each function, method, and class in your code. If you’ve carefully chosen the abstraction level of each function (Single-Responsibility Principle), it’s often enough to use the build in documentation functionality instead of comments to describe what your code does. This largely removes the need for additional comments in your code.


Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Leaving the Rat Race with Python Book

Where to Go From Here?


Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Show Don’t Tell: Commenting Python Best Practices first appeared on Finxter.



https://www.sickgaming.net/blog/2020/11/...practices/

Print this item

  (Indie Deal) FREE Brigade E5, Big Bandai Deals, GalaQuiz
Posted by: xSicKxBot - 11-27-2020, 12:41 AM - Forum: Deals or Specials - No Replies

FREE Brigade E5, Big Bandai Deals, GalaQuiz

Brigade E5: New Jagged Union FREEbie
[freebies.indiegala.com]
The mission: hire a band of mercenaries and take control of the deteriorating situation before the country finds itself in complete ruin.

BEST OF BANDAI NAMCO, up to -85%
[www.indiegala.com]
Good things might not last and great deals end fast,so do not miss the best of the best,these Bandai offers aren't like the rest. Don't forget you may also get a BONUS BLACKHOLE Steam Key for select store purchases.
The 237th GalaQuiz will be LIVE soon, win up to $50:dollars: in GalaCredit!
[www.indiegala.com]
The GalaQuiz will take place in less than 15 minutes from this announcement
Today's GalaQuiz[www.indiegala.com] hints are up. The theme will be Weird Al Yankovic Redux.

Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...9205006916

Print this item

  (Free Game Key) Mudrunner - Free Epic Game
Posted by: xSicKxBot - 11-27-2020, 12:41 AM - Forum: Deals or Specials - No Replies

Mudrunner - Free Epic Game

Visit the store page, scroll down and select the regular Mudrunner edition, then after claiming it, you can then scroll down again and claim the DLC's

Mudrunner[www.epicgames.com]

The game is free to keep until Dec 3rd, 2020 - 16:00 UTC.

We are welcoming everyone to join our discord[discord.gg]. We are more active there on finding giveaways, small or large, and there are daily raffles you can participate.

?GrabFreeGames.com ?Twitter ?Steam Curator ?Facebook[fb.me]?Discord[discord.gg]
❤️Support us: ✔️HumbleBundle Partner[www.humblebundle.com] Epic Tag: GrabFreeGames ✌


https://steamcommunity.com/groups/GrabFr...2366167254

Print this item

  Godot On Steam Using GodotSteam
Posted by: xSicKxBot - 11-27-2020, 12:41 AM - Forum: Game Development - No Replies

Godot On Steam Using GodotSteam

If you are creating a commercial PC game using Godot there is a good chance you are going to want to publish on Steam. If that is a case if your game requires any network services such as achievements, a leaderboard or DLC you are probably tempted to use Steam’s own Steamworks suite of APIs. In that case you most likely want to know about GodotSteam an open source implementation of the SteamWorks API for Godot 2/3, providing convenient GDScript interfaces for the vast majority of the Steamworks features.

GodotSteam is an open source project hosted on GitHub that is implemented using the Godot module system. The source code is under the flexible and permissive MIT license. There is a GDNative branch available although sadly it appears to have been abandoned. Being a module means you will have to download and build your own version of Godot, a process I describe in this video. If the world of Godot, modules and GDNative are all new to you, don’t worry, we have an overview available here.

If you want to get started with GodotSteam there are excellent tutorials and comprehensive documentation available here. You can learn more about Godot, Steamworks and GodotSteam in the video below.




https://www.sickgaming.net/blog/2020/11/...odotsteam/

Print this item

  News - Nintendo’s Huge Cyber Deals Sale Is Now Live, Up To 75% Off Top Games (Europe)
Posted by: xSicKxBot - 11-27-2020, 12:40 AM - Forum: Nintendo Discussion - No Replies

Nintendo’s Huge Cyber Deals Sale Is Now Live, Up To 75% Off Top Games (Europe)

Ryan can list the first 151 Pokémon all in order off by heart – a feat he calls his ‘party trick’ despite being such an introvert that he’d never be found anywhere near a party. He’d much rather just have a night in with Mario Kart and a pizza, and we can’t say we blame him.



https://www.sickgaming.net/blog/2020/11/...es-europe/

Print this item

  News - Prime Gaming Rewards
Posted by: xSicKxBot - 11-26-2020, 01:58 PM - Forum: Lounge - No Replies

Prime Gaming Rewards

New Prime Gaming rewards are now available in Destiny 2!

Bungie is continuing to team up with Prime Gaming for the next 12 months to deliver in-game rewards to any player with an active Amazon Prime membership. Once you have your membership (if not, start your free trial here), visit this page and link your Bungie.net account to start receiving your 12 monthly gear drops. Each drop will contain four rewards, including Exotic weapons, Ghost Shells, ships, Sparrows, and weapon ornaments from previous Seasons.

Along with more gear drops, we are also excited to announce that beginning of each new Season will have also special Seasonal theme item for that month’s gear drop, for Season of the Hunt, the item is the Unchained Exotic Emote.

The first gear drop that also has special Seasonal themed items will run from November 25 until December 23 and will include the Unchained Exotic Emote (Seasonal theme), The Regal Howl Exotic Sparrow, Transpose JT-24-X Exotic Ship, and Arch Shell Legendary Ghost Shell.


When a gear drop is available, eligible players can claim the rewards here. Once claimed, follow a visual indicator to Amanda Holliday in the Tower’s hangar. Amanda will have the rewards available in her inventory. As long as you claim the rewards on the Prime Gaming page by 10 AM on the last day of the drop, the gear will still be available from Amanda after the deadline.
Still have questions? We have a Help article with more details on how everything works.


https://www.sickgaming.net/blog/2020/11/...g-rewards/

Print this item

  News - Rockstar is turning Red Dead Online into a standalone game
Posted by: xSicKxBot - 11-26-2020, 01:58 PM - Forum: Lounge - No Replies

Rockstar is turning Red Dead Online into a standalone game

Rockstar is launching Red Dead Online, the online multiplayer portion of Red Dead Redemption 2, as a standalone game on December 1, 2020.

It’s a move that underlines the value of the games-as-a-service model that’s been so successful for Rockstar, and comes over a year after the studio announced it would release GTA Online as a standalone title on the PlayStation 5.

Rockstar parent company Take Two has previously explained how recurrent consumer spending in modes like GTA Online and Red Dead Online have “significantly exceeded its expectations” as players continue to drop cash on virtual currency and in-game purchases.

The standalone version of Red Dead Online will feature an option to unlock the Red Dead Redemption 2 story mode for an additional fee. All future content updates will also be included with the standalone offering, which will retail for an introductory price of $4.99 until February 15, 2021 — after which point it will cost $19.99.

In terms of next-gen support, Rockstar explained the PlayStation 4 and Xbox One versions of the title will be playable via backwards compatibility on PlayStation 5 and Xbox Series hardware. The standalone release will also be heading to PC via the Microsoft Store, Rockstar Games Launcher, Epic Games Store, and Steam.



https://www.sickgaming.net/blog/2020/11/...lone-game/

Print this item

  (Indie Deal) Adventure Time, Ben 10, Transformers, JUMANJI and more
Posted by: xSicKxBot - 11-26-2020, 12:18 PM - Forum: Deals or Specials - No Replies

Adventure Time, Ben 10, Transformers, JUMANJI and more

Outright Games Publisher Sale, up to -75%
[www.indiegala.com]
Don't forget that you may receive a FREE BLACKHOLE Steam Key for any individual Store Cart of $5/€4/£3 or more (while stocks last).
Raiser Games Publisher Sale; up to -50%
[www.indiegala.com]
NEW RELEASE:
Synergia[www.indiegala.com] | 10%
https://youtu.be/z0YP9gc3L9Q
Civilization Franchise Sale, up to -75%
[www.indiegala.com]
Build an empire to stand the test of time in Sid Meier's Civilization, the turn-based strategy game.

[www.indiegala.com][www.indiegala.com]

Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...9204501025

Print this item

  News - Nintendo Announces Huge Cyber Deals Sale For Europe, Up To 75% Off Top Games
Posted by: xSicKxBot - 11-26-2020, 09:30 AM - Forum: Nintendo Discussion - No Replies

Nintendo Announces Huge Cyber Deals Sale For Europe, Up To 75% Off Top Games

Ryan can list the first 151 Pokémon all in order off by heart – a feat he calls his ‘party trick’ despite being such an introvert that he’d never be found anywhere near a party. He’d much rather just have a night in with Mario Kart and a pizza, and we can’t say we blame him.



https://www.sickgaming.net/blog/2020/11/...top-games/

Print this item

  News - Pokemon Go December 2020 Events: Kyurem Raids, Mega Abomasnow, And More
Posted by: xSicKxBot - 11-26-2020, 09:30 AM - Forum: Lounge - No Replies

Pokemon Go December 2020 Events: Kyurem Raids, Mega Abomasnow, And More

November is almost over, but Pokemon Go developer Niantic has already outlined some of the events it has planned for next month. December 2020 will bring a variety of activities and bonuses to the game, including a new Research Breakthrough reward encounter, a new Mega Evolution, and more. You can read more about the biggest December events happening in Pokemon Go below.

December Research Breakthrough Encounter: Lapras Or Darumaka

Niantic is rolling out a new batch of Field Research tasks and rewards starting December 1, along with a new Research Breakthrough encounter. This time around, achieving a Research Breakthrough will lead to an encounter with one of two possible Pokemon: Lapras or Unovan Darumaka. You'll also earn bonus XP for catching either Pokemon.

Kyurem And Mega Abomasnow Raids

Starting December 1 at 1 PM PT / 4 PM ET, the Legendary Ice/Dragon Pokemon Kyurem is returning to the game. You'll be able to encounter the Pokemon in five-star Raids all month long, until 1 PM PT / 4 PM ET on January 1. In addition, Mega Blastoise is leaving Mega Raids starting December 1, and it will be replaced by the debuting Mega Abomasnow. Until then, Mega Blastoise will be appearing more frequently, making this a good opportunity to challenge it and stock up on Blastoise Mega Energy.

Continue Reading at GameSpot

https://www.gamespot.com/articles/pokemo...01-10abi2f

Print this item