GithubHelp home page GithubHelp logo

python-snippets's Introduction

Python snippets

Python snippets collections.

Initially ported from PyCharm, TextMate, SublimeText and other editors/IDEs.

If you'd like to contribute, feel free to submit a pull request on github

Thanks!

Features

Base snippets

Abbreviation Description
env #!/usr/bin/env python
env3 #!/usr/bin/env python3
enc # -- coding=utf-8 --
enco # coding=utf-8
fenc from future import ...
fenco from future import ... (no -*-)
im import
fim from ... import ...
class New class
classd New dataclass
defs New method
def New function
dowhile Do while structure
adef Async function
property New property
enum New Enum
if if
for for
lambda lambda expression
while while
try try:except:
tryef try:except:else:finally:
trye try:except:else:
tryf try:except:finally:
s self
__ magic
ifmain if name == "main"

Comprehensions

Abbreviation Description
lc List comprehension
lcie List comprehension if else
lci List comprehension if filter
dc Dictionary comprehension
dci Dictionary comprehension if filter
sc Set comprehension
sci Set Comprehension if filter
gc Generator comprehension
gci Generator comprehension if filter

Unittest

Abbreviation Description
ase Assert equal
asne Assert not equal
asr Assert raises
ast Assert True
asf Assert False
asi Assert is
asint Assert is not
asino Assert is None
asinno Assert is not None
asin Assert in
asni Assert not in
as Assert
fail Fail (a test)

Debugging

Abbreviation Description
pdb PDB set trace
ipdb iPDB set trace
rpdb rPDB set trace
pudb PuDB set trace

Tkinter

Abbreviation Description
imtk Import Tkinter py2
imtk3 Import tkinter py3
config Root configuration
button Button
label Label
frame Frame
entry Entry
grid Grid
sticky Sticky
checkbutton Check button
mainloop Main loop
pack Pack
side Side
bind Bind
menu Menu
addcascade Add cascade
addcommand Add command
addseperator Add seperator

Release Notes

See changelog for all changes and releases.

Troubleshooting

If you experience problems with the auto-formatting of certain snippets, make sure you have the option editor.tabCompletion set on onlySnippets or on.

python-snippets's People

Contributors

andriyor avatar cstrap avatar h3ct0rjs avatar lraphael avatar macintacos avatar pchoisel avatar rksys avatar rohananandpandit avatar santosh avatar sundhaug92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-snippets's Issues

Basic logging shortcut interest?

In my ifmain block i often put:

from logging import basicConfig, DEBUG, INFO, debug, info, warning, error
basicConfig(level=DEBUG)

Then I can easily use debug("hello main") and so on in my code, instead of print...

Is this something you want a pr for? If yes, any requirements or wishes for the binding?

Add celery debugger snipper

Would it be possible to add the celery debugger snippet:
crdb -> from celery.contrib import rdb; rdb.set_trace()

Probably some mistake in `class` snippet

Hi,
class snippet is not working correctly.
obraz
Expression from here is such complicated that I will not try to understand it :) but it's not working correctly. There's a problem with this second arg. It's not where it should be.
I've added PR solving that issue.

new-style properties

I found this library through VSCode extensions tab and it's great. My only complaint is that the property snippet uses the more basic non-decorator based property format. So I wrote a new snippet body which defines the newer decorator-based format:

    "New property": {
        "prefix": "property",
        "body": "@property\ndef ${1:foo}(self):\n    \"\"\"${2:The $1 property.}\"\"\"\n    ${3:return self._$1}\n@${4:$1}.setter\ndef ${5:$1}(self, value):\n    ${6:self._$1} = value"
    },

This will produce a python property which looks like this:

    @property
    def foo(self):
        """The foo property."""
        return self._foo
    @foo.setter
    def foo(self, value):
        self._foo = value

Leaving this here in case anyone wants this style property. You can edit your snippets collection locally by editing base.json under

Windows %USERPROFILE%\.vscode\extensions\cstrap.python-snippets-0.0.5\snippets
Mac ~/.vscode/extensions\cstrap.python-snippets-0.0.5\snippets
Linux ~/.vscode/extensions\cstrap.python-snippets-0.0.5\snippets

I don't really have the time nor inclination to do a pull request since the author would need to decide what to call this form anyway, so I'll leave that for the owner :)

Publish `python-snippets` to Open VSX

Dear extension author,
Please publish this extension to the Open VSX marketplace.

Context

Unfortunately, as Microsoft prohibits usages of the Microsoft marketplace by any other products or redistribution of .vsix files from it, in order to use VS Code extensions in non-Microsoft products, we kindly ask that you take ownership of the VS Code extension namespace in Open VSX and publish this extension on Open VSX.

What is Open VSX? Why does it exist?

Open VSX is a vendor neutral alternative to the MS marketplace used by most other derivatives of VS Code like VSCodium, Gitpod, OpenVSCode, Theia-based IDEs, and so on.

You can read on about Open VSX at the Eclipse Foundation's Open VSX FAQ.

How can you publish to Open VSX?

The docs to publish an extension can be found here. This process is straightforward and shouldn't take too long. Essentially, you need an authentication token and to execute the ovsx publish command to publish your extension. There's also a doc explaining the whole process with an example GitHub Action workflow.

author

Hi, is there a way to add machine user name into snippets,

Regards

Suggestion: Make compatible with .ipynb extensions

Hi.

This extension seems to me the best of all for Python development. However, when using the Jupyter Notebook extension for VSCode, the snippets doesn't work. I think it's because this extension doesn't work for *.ipynb extension files. Please, in a next release could you add this file types? Thank you so much.

Suggestion: Change `.` to `..`

I'm really fond of this extension, by far the nicest python snippet pack I'm aware of.

However, there is one issue for me:
When I write docstrings, I often end a sentence with a period, and start a new line afterwards. This means, that I hit . and then enter a lot.
With the snippets enabled, this results in intellisense suggesting self on typing . and me accepting it with enter. I end up with lots of code like this:

def some_function():
    """Some functionself

    This function does somethingself
    """
    pass

Clearly, this is not exactly desirable. And I somehow can't imagine myself being the only one with this issue.

Would it be an option, to rename the self-snippet from . to ... It wouldn't be much more typing effort to get self, and it would prevent this problem from happening.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.