Registryvsx-ericsiapythonsnippets3

@vsx-ericsia/pythonsnippets3

Public
VSX CompatibleOXP Native: Planned

// Description

New auto suggestion for Python updated in 2023

// Readme

Open VSX

###Best Python3 Snippets Pack (2023) for Visual Studio Code (python 3.x)

status.svg light.svg easy.svg

A beginner friendly Python Snippets auto suggestion pack making you more productive

Please help to rate this extensions 5 stars and share it, feedback is welcome

Tips: uninstall similar python snippet extension first. Then install and Reopen

  • Click Here if you don't want # Comment
  • added with new python function, update legacy code
  • fixes a few unintended typo left by previous developer
  • use TAB to rename field in every method / feature
  • added def.function.main-() as a main method, type main-
  • added def.function.class-(init) for class, type class- or init-
  • added label to method belong to string/list/tuple/set/dict
  • added python <datatype> and snippet initialisation, try typing str
  • added match snippet - python 3.10
  • added np-init snippet for numpy array [pip3 install numpy]
  • added import snippet, documentation snippet
  • added random snippet try random-TextGen
  • added for-loop snippet
  • added print- snippet
  • added matplotlib template plt
  • added algorithm template algo-
  • added PyMySQL template PyMySQL
  • added Django template django
  • added dp decimal place, swap, slice, sleep, end, benchmark, timeit, env, self snippet
  • new format for easier selection, to see built in example type apply-, random-, class
  • get example use <datatype>- while for available method use -<datatype> ex: -string
  • welcome to contribute through feedback to add more ideas, make it as complete as possible

###Extra

  • check out my site

Don't worry if you never see that method before, this extension provided a lot of code examples for that.

This extensions not only provide snippets but also is helpful for learning python programming language.

  • all python built-in snippets and with at least one example => for each method
  • For example if you want to use string replace method type .replace
  • But if you don't know how to use replace method then type str find str-replace=>
  • Contains a lot of other code snippets (like if:else, for, while, while:else, try:catch, fileIO and oop class snippets examples (polymorphism, encapsulation, inheritance)

##Old gif from (2018) pay tribute to Ferhat Yalçın

oldScreenshot

##Snippets | Descriptions (from 2018, new one is at top)

There are string/list/tuple/set/dict datatype snippetE.g. Type Out
To get __main__ type def or function or main-main-
To see built-in method example type apply- scroll downapply-
Tips: to see specific method type example name=count=
To see datatype method example type <datatype>-str-
To see datatype method only type -<datatype> scroll down-string
To see python datatypedtype
To initialise type <datatype> initialise snippetbool init
To get fileIO type file- then scroll downfile-
To get block comment type documentationdoc
To get algorithm snippet like is_primealgo-
Built-in methods code snippetsDescription
absReturns the absolute value of a number
allReturns True if all items in an iterable object are true
anyReturns True if any item in an iterable object is true
asciiReturns a readable version of an object. Replaces none-ascii characters with escape character
binReturns the binary version of a number
boolReturns the boolean value of the specified object
bytearrayReturns an array of bytes
bytesReturns a bytes object
callableReturns True if the specified object is callable, otherwise False
chrReturns a character from the specified Unicode code.
delattrDeletes the specified attribute (property or method) from the specified object
dictReturns a dictionary (Array)
dirReturns a list of the specified object's properties and methods
divmodReturns the quotient and the remainder when argument1 is divided by argument2
enumerateTakes a collection (e.g. a tuple) and returns it as an enumerate object
evalEvaluates and executes an expression
execExecutes the specified code (or object)
filterUse a filter function to exclude items in an iterable object
floatReturns a floating point number
frozensetReturns a frozenset object
getattrReturns the value of the specified attribute (property or method)
globalsReturns the current global symbol table as a dictionary
hasattrReturns True if the specified object has the specified attribute (property/method)
hashReturns the hash value of a specified object
helpExecutes the built-in help system
hexConverts a number into a hexadecimal value
idReturns the id of an object
inputAllowing user input
intReturns an integer number
isinstanceReturns True if a specified object is an instance of a specified object
issubclassReturns True if a specified class is a subclass of a specified object
iterReturns an iterator object
lenReturns the length of an object
localsReturns an updated dictionary of the current local symbol table
mapReturns the specified iterator with the specified function applied to each item
maxReturns the largest item in an iterable
memoryviewReturns a memory view object
minReturns the smallest item in an iterable
nextReturns the next item in an iterable
objectReturns a new object
octConverts a number into an octal
openOpens a file and returns a file object
ordGiven a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit str.
powReturn x to the power y
printPrints to the standard output device
propertyGets, sets, deletes a property
rangeReturns a sequence of numbers, starting from 0 and increments by 1 (by default)
reprReturns a readable version of an object
reversedReturns a reversed iterator
roundRounds a numbers
sliceReturns a slice object
sortedReturns a sorted list
staticmethodConverts a method into a static method
strReturns a string object
sumSums the items of an iterator
superReturn a proxy object that delegates method calls to a parent or sibling class of type.
typeReturns the type of an object
unichrReturn the Unicode string of one character whose Unicode code is the integer i.
varsReturns the dict property of an object
zipReturns an iterator, from two or more iterators
import code snippetsDescription
importimport module
function code snippetsDescription
def or functionDefining Function
def=>with_default_valueDefining Function with default values
file code examples file-Description
withFile-listFileList files in that path
withFile-listFileWithPathList files with path
withFile-openFileOpen a file
withFile-openFileReadLineRead file line by line
withFile-openFileReadSingleLineRead one line of the file
withFile-appendFileWrite to an Existing File
withFile-overwriteFileOpen a file and overwrite the content
withFile-deleteFileDelete a file
if/else statementcode snippetsDescription
if-if
if-elifor ifelifif:else if
if-elif-elseor ifelifelseif:else if:else
if-elseor ifelseif:else
if-shortor ifshortternary if
elseelse
match aka switch code snippetsDescription
switch or matchmatch Statement
try catchcode snippetsDescription
try-try:except
try-for tryftry:except:finally
try-eor tryetry:except:else
try-e-for tryeftry:except:else:finally
for loop code snippetsDescription
for-for Statement
for loop code examples
for=>for example
for=>through_a_stringfor example
for=>break_statementfor example
for=>continue_statementfor example
for=>range_function_1for example
for=>range_function_2for example
for=>range_function_3for example
for=>for_elsefor example
while loop code snippetsDescription
while-while Statement
while loop code examplesDescription
while=>while example
while=>break_statementwhile example
while=>continue_statementwhile example
List Comprehensions code snippetsDescription
comp=>List Comprehensions
lambda code examplesDescription
lambdaA lambda function can take any number of arguments, but can only have one expression.
class code snippetsDescription
class=>python class
__init__=>class init method
__iter__=>class iter method
__next__=>class next method
class code examplesDescription
class=>_1oop inheritance example
class=>inheritance_1oop inheritance example
class=>inheritance_2oop inheritance example
class=>with_attribute_1class with attribute example
class=>with_attribute_2class with attribute example
class=>with_attribute_3class with attribute example
class=>with_method_1class with method example
class=>with_method_2class with method example
class=>encapsulationclass encapsulation example
class=>polymorphismclass polymorphism example

###For example

Class Template - thanks for snippsat mention f-string

class=>with_attribute_1

class Parrot:

# class attribute
 species = 'bird'

# instance attribute
 def __init__(self, name, age):
 self.name = name
 self.age = age

# instantiate the Parrot class
blu = Parrot('Blu', 10)
woo = Parrot('woo', 15)

# access the class attributes
print(f'Blu is a {blu.__class__.species}')
print(f'Woo is also a {woo.__class__.species}')
# access the instance attributes
print(f'{blu.name} is {blu.age} years old')
print(f'{woo.name} is {woo.age} years old')

##Release Notes

This extension aim to cover as many new Python3 method make it as complete as possible, please help to contribute from feedback link above.

###For more information - Thanks to

Enjoy! Type less do more

###1.0.2

Initial release and update README.md

###2.0.2

Updated and maintain in year 2022

###3.0.2

Change .format into f-string and remove unnecessary files

###3.3.5

change . become - due to vscode clash ex apply. become apply-

###3.3.11

added PyMySQL, Algo, Random snippet by Lakshmikanth

###3.3.12

remove dot in built-in methods for good, to see type -<datatype> then scroll down. Tips, tick in setting: Python › Analysis: Complete Function Parens

###3.3.18

##added Django, timezoneconversion snippet by Lakshmikanth

// Install

Open this extension directly in your IDE — no CLI, no extra tools.

Extension ID
ericsia.pythonsnippets3

If your IDE doesn't open automatically, copy the ID above and paste it into the Extensions view (⌘P ext install <id>).

// Source signals

Publisher
Verified ✓
Rating
5.0 (1)
Downloads
6.4M
Published
2023-08-20
License
MIT
Source
repo
Homepage
link

Live from open-vsx.org. Refreshed hourly.

// Are you the author?

This listing is mirrored from Open VSX. Claim it to ship a native OXP build, customise the page, and respond to reviews.

Claim this listing

// Package Info

Version
3.3.18
Owner
@vsx-ericsia
Downloads
6.2M
Stars
0