# Content Assistants

Some content assistants to make your life easier...

They are ALL activated through Ctrl+1, but which one(s) will show depend on the context it is activated.

# Content assistants

# Make import for undefined token / Ignore error

Let's say that you have the code below, and that the code-analysis has just seen that the 'xmlreader' token was undefined (this is important, as we cannot make this analysis before the token was generated). In this case, we have 2 options offered, one to fix that importing the token and another one saying that PyDev should ignore that error. The example below shows it in action:

If we let the cursor at the undefined token line and press Ctrl+1, we get:

After choosing the second import we have:

Now, if we had chosen the third option (@UndefinedVariable), a note would have been entered in the code, to warn PyDev to ignore that error, as pointed below...

# Don't analyze module

PyDev can accept a 'note' to warn it not to make code-analysis at all in some module. In order to do that' you can go to the first line of the module and press 'Ctrl+1' and choose the @PydevCodeAnalysisIgnore flag. Doing that will add a note in the code to warn that this module should not be analyzed by PyDev.

If you use automatically generated files, it might be useful to put that warning on those files, as it would not be useful to analyze those files. The example below shows the result of this action.

After choosing choosing it, we have:

# Move import to global scope

Before

After

# Create docstring

*NOTE:*Must be called in the 'def' line.

Before

After

# Assign result to new local variable (or field)

Before

After

# Assign parameters to attributes

Before

After

# Surround code with try..except or try..finally

*NOTE:*Must have some code selected

Before

After