Skip to content
Sign upLog in

3 quick tips to help you code a little more efficiently

Profile icon
AustinZhang1

HELLO EVERYBODY

This is a tutorial on how to code a little more efficiently in Python.


TIP #1

Have you ever forgotten to put quotations/parentheses around a string? Well here is a tip to save you a few seconds. Double click/highlight the text that you want to put quotations around, then just press the ' or " or ( key and the highlighted text will have quotations/parentheses around it!


TIP #2

Have you ever made a bunch of functions with attributes, but when you needed to add another attribute, it took forever to change all of the functions? Well, there are two solutions to this problem.

SOLUTION A:

It is possible to have Multiple Cursors in Repl. Click where you want to edit the text, then use Control + Click and click where you want to add the second cursor. Then, when you type something, all cursors will respond, typing the same thing in multiple places

SOLUTION B:

The second solution is that you can use Ctrl + H to open up a find & replace bar. On the top, paste in the code you want to replace, and on the bottom input the code that you want to replace it with. You can now replace everything easily.


TIP #3

This is a quicker way to write your import statements: instead of writing

import random import time import os import sys

You can use:

import random, time, os, sys

which can save you from typing a few lines of code.


TIP #4

Have you ever had to indent a lot of code? You can indent a large block of code by highlighting all of it, then pressing Tab(to indent) or Shift + Tab(to unindent).


I hope this little tutorial helps you code a little bit more efficiently. Please consider upvoting!

You are viewing a single comment. View All
Profile icon
CodeLongAndPros
  1. Ok
  2. REGEX
  3. Not as readable
Profile icon
AustinZhang1

@CodeLongAndPros
I am confused please explain further

Profile icon
CodeLongAndPros

@AustinZhang1

#1 is a valid tip
#2: Regex search-and-replace is much faster:
If you have

foo = 1 #foobar bar = 2 #dfa floo = 3

and you want to change them to _foo_2, _bar_2, and _floo_2, you can use:
Search:

(.*) = (.*)

replace:

_$1_2 = $2

#3 is hard to read. You don't do #include<stdio.h stdbool.h).

Profile icon
AustinZhang1

@CodeLongAndPros
what is #include<stdio.h stdbool.h)?

Profile icon
CodeLongAndPros

@AustinZhang1
C preprocesser directives, like import