Python Forum
A humble VsCode Python Snippets 2.0
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A humble VsCode Python Snippets 2.0
#1
Photo 
Hi guys, I'm a bit new here. To be frank, after I publish the updated extension I do not know how to make it appear in the search section of vscode so I figure I just register a new account here and share it here since this extension is free.
Do help me rate and share if this extension is useful to you. P.s before install disable other similar extensions first.
This is the link
Happy New Year everyone, the code is available in github so you can see it yourselves:
[Image: python.gif]

[Image: oldpython.gif]

And this is the changelog:
  • 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 label to method belong to string/list/tuple/set/dict
  • added python <datatype> and snippet, try typing str
  • added match snippet - python 3.10
  • added np.init snippet for numpy array [pip3 install numpy]
  • added import snippet
  • added documentation, timeit snippet
  • added random snippet
  • added for-loop snippet
  • added matplotlib template plt
  • added dp decimal place, end, env, benchmark, self, sleep, swap 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 to add more ideas, make it as complete as possible
Reply
#2
Have tested it,and it work fine.
I which that some update where done like using f-string on all code.
#class with method example (python snippets 2)

class Parrot:

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

# instance method
    def sing(self, song):
        return '{} sings {}'.format(self.name, song)

    def dance(self):
        return '{} is now dancing'.format(self.name)

# instantiate the object
blu = Parrot('Blu', 10)
# call our instance methods
print(blu.sing('Happy'))
print(blu.dance())
Become.
I did just run flynt here to convert.
# class with method example (python snippets 2)

class Parrot:

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

# instance method
    def sing(self, song):
        return f'{self.name} sings {song}'

    def dance(self):
        return f'{self.name} is now dancing'

# instantiate the object
blu = Parrot('Blu', 10)
# call our instance methods
print(blu.sing('Happy'))
print(blu.dance())

medlexo Wrote:To be frank, after I publish the updated extension I do not know how to make it appear in the search section of vscode so I figure I just register a new account here and share it here since this extension is free.
That's fine,will maybe get some users from here,but you need to figure out so it appears in search to get more users.
medlexo likes this post
Reply
#3
(Jan-02-2022, 10:42 PM)snippsat Wrote: Have tested it,and it work fine.
I which that some update where done like using f-string on all code.
#class with method example (python snippets 2)

class Parrot:

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

# instance method
    def sing(self, song):
        return '{} sings {}'.format(self.name, song)

    def dance(self):
        return '{} is now dancing'.format(self.name)

# instantiate the object
blu = Parrot('Blu', 10)
# call our instance methods
print(blu.sing('Happy'))
print(blu.dance())
Become.
I did just run flynt here to convert.
# class with method example (python snippets 2)

class Parrot:

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

# instance method
    def sing(self, song):
        return f'{self.name} sings {song}'

    def dance(self):
        return f'{self.name} is now dancing'

# instantiate the object
blu = Parrot('Blu', 10)
# call our instance methods
print(blu.sing('Happy'))
print(blu.dance())

medlexo Wrote:To be frank, after I publish the updated extension I do not know how to make it appear in the search section of vscode so I figure I just register a new account here and share it here since this extension is free.
That's fine,will maybe get some users from here,but you need to figure out so it appears in search to get more users.

I see, thank you for f-string, I actually ran a benchmark on .format and f-string but they seem similar.
I would love to know if f-string is faster.
Regardless f-string sure look more elegant, thank you for that I will change it.
I'm collecting more feedback first for maybe 1 month and then pushing a new update together, if not there will be a lot of versions.
Reply
#4
(Jan-03-2022, 08:12 AM)medlexo Wrote: I would love to know if f-string is faster.
It's faster,but more important it's more readable.
You can see speed test in links under.
Python 3's f-Strings: An Improved String Formatting Syntax (Guide)
F-strings — make your python code more readable today

It's a interesting project as it can be quite useful to have it insert working code example's of many aspect of Python usage.
The name can be a little confusing python snippets 2,can sound like is code snippet for Python 2 Confused
Python3 code generator would be me advice,but that's up to you.

It's fine with GIF file to show usage,but it's way to big.
Should have information over,then show concept with a shorter GIF under.
medlexo likes this post
Reply
#5
(Jan-03-2022, 01:29 PM)snippsat Wrote:
(Jan-03-2022, 08:12 AM)medlexo Wrote: I would love to know if f-string is faster.
It's faster,but more important it's more readable.
You can see speed test in links under.
Python 3's f-Strings: An Improved String Formatting Syntax (Guide)
F-strings — make your python code more readable today

It's a interesting project as it can be quite useful to have it insert working code example's of many aspect of Python usage.
The name can be a little confusing python snippets 2,can sound like is code snippet for Python 2 Confused
Python3 code generator would be me advice,but that's up to you.

It's fine with GIF file to show usage,but it's way to big.
Should have information over,then show concept with a shorter GIF under.

The gif was provided by the original developer, I will re-record a new gif then.
Sincerely thank you for the advice, I will change to f-string asap. Maybe this Sunday.
I will name it python snippets 3 thanks for mention it
Reply
#6
There are project that is quite similar that you should be aware of like python snippets.
Python UltiSnippets not maintained anymore.
So your name only add 3 python snippets 3.
I would certainty think of other name so it stand more out.
Looking at Github so it not updated last two year.

medlexo Wrote:Sincerely thank you for the advice, I will change to f-string asap. Maybe this Sunday.
That's fine it you make it more updated to modern Python,it will be much more useful.
Reply
#7
(Jan-03-2022, 05:18 PM)snippsat Wrote: There are project that is quite similar that you should be aware of like python snippets.
Python UltiSnippets not maintained anymore.
So your name only add 3 python snippets 3.
I would certainty think of other name so it stand more out.
Looking at Github so it not updated last two year.

medlexo Wrote:Sincerely thank you for the advice, I will change to f-string asap. Maybe this Sunday.
That's fine it you make it more updated to modern Python,it will be much more useful.
It is from Python Snippet (the first link u mentioned), yes I updated some legacy code.
4 Jan 2021:
I have renamed the extensions and thus required a new update of the link, and of course changed to f-string.
For those who had installed it please uninstall the old one then use the new link in this thread.
Please help to rate the extension in the new link.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python on VSCode GiBandoleiro 1 492 Nov-01-2023, 03:35 PM
Last Post: deanhystad
  Automate Word snippets PHbench 0 562 Jun-06-2023, 06:59 PM
Last Post: PHbench
  Python package not seen in VSCode fmccabe80 6 3,247 Mar-06-2023, 10:01 PM
Last Post: fmccabe80
  Python Snippets Source kucingkembar 0 646 Oct-18-2022, 12:50 AM
Last Post: kucingkembar
  I use VsCode with Python and it currently won't let me run any code NordicMonkey 2 1,535 Sep-18-2022, 08:42 PM
Last Post: Larz60+
  VSCode Setup and configuring to run with Python apollo 2 3,078 Jan-13-2021, 04:55 PM
Last Post: jefsummers
  How to connect Mysql databse with python and VSCode IDE madhusoodhananER 1 8,739 Oct-31-2019, 10:15 AM
Last Post: Larz60+
  Code snippets for building multi column Listviews and or Treeview KevinBrown 3 3,332 Apr-14-2019, 06:50 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020