Ask Your Question
1

Do not understand how to create snippets with variables

asked 2020-08-25 04:35:43 -0500

piscvau gravatar image

updated 2020-08-25 08:32:44 -0500

I do not understand how to enter code for snippets with variable names. I create a new snippet and I get aan empty window in the editor. From there I would like to enter the code for a new test: def test_file_variable(self): string =

res = dstring_parse(string)
display_PathPoints(res, variable)

shouldbe = [

]
self.assertEqual(res, shouldbe)

I need a variable name instead of variable How can I do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-25 08:35:08 -0500

updated 2020-08-25 08:35:28 -0500

The syntax is %(name|type|default)s and the type and default are optional. Examples:

  %(name)s
  %(created|datetime)s
  %(email||nobody@nowhere.com)s

You can also use environment variable references for the defaults:

  %(user||${USER})s

The documentation for this is at https://wingware.com/doc/edit/snippets and there are examples in the default set of snippets in the Snippets tool.

edit flag offensive delete link more

Comments

Hello Please excuse me but I still do not understand and I am afraid I need more details. I did look into the documentation and the examples but it did not help. For example if I look at the 'from' snippet I see: |m|from %(module)s import |!| I see there a variable named module but I have not idea about what |m| and |!| is about. Coming back to my need for a snippet about a test, is I put %(name)s in the name of the function after def, I get a syntax error

piscvau gravatar imagepiscvau ( 2020-08-26 04:36:16 -0500 )edit

|m| tells Wing to match the indent of the context when placing the snippet and |!| is the final resting place of the caret after data entry for the snippet is complete. These and the other syntax options are described in the documentation at https://wingware.com/doc/edit/snippet...

Wingware Support gravatar imageWingware Support ( 2020-08-26 08:24:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-25 04:35:43 -0500

Seen: 194 times

Last updated: Aug 25