This is a repeat of this question. It seems that I can't view instances of my classes in the variable explorer in Python, when I'm debugging.
There the answer claims that this is resolved, so I'm wondering what I'm doing wrong.
(Spyder maintainer here) By default we show builtins (ints, floats, strings, list, dicts and tuples), Numpy arrays and Dataframes in our Variable Explorer.
If you want to see all objects present in your namespace, you need to go to the menu
Tools > Preferences > Variable Explorer
and turn off the option called
Exclude unsupported data types
Related
Problem: When I just declare a variable, GoLand immediately highlights it with an error like: "The variable is not used anywhere"; I don't like this behavior of the IDE. I have not yet had time to use it anywhere, but only announced it.
Actually, subject, tell me, please, how to remove this syntax highlighting (namely, about unused variables) in GoLand?
P.S.
There is no benefit from manipulating the: Settings -> Editor -> Inspections -> Go
This does not seem possible with Goland, of VsCode Go (which has the same behavior)
Considering an unused variable is an error for Go itself, the IDE simply reflects that.
It can be jarring though, and other Goland issues reflect this: for example, GO-2374 mentions the same kind of issue with exported functions:
All exported functions (starting with a capital letter) that are not used within a library itself, are marked as unused.
This seems odd to me. Most exported functions in a library are never used within the library itself, but I think it is wrong to mark them as unused since they are not primarily meant to be used within the library.
I still prefer the current highlight, as it makes sure I do not introduce a new variable without using as soon as possible.
Perhaps if you have that new var, do a
_ = yourVar after that.
(Then it is in use)
Warning: scan for "_ =" afterwards yourself to see if you still have these.
The fact that the editor "complains" is just Go. Go doesn't allow you to declare vars that are not in use.
I'm using XCode to debug some code. Specifically, the code that I'm debugging exposes a float[][] as float**. I am unable to change this syntax, but I'm not certain it would help anyway.
After including a relevant breakpoint, I want to view the contents of the array in the Variables view of the debugger?
When I double-click on the variable in the list of Autos, I see that I can add a Summary Format which seems deceivingly like it might help, but for the life of me, I can't figure out how to use it!
In conclusion, how do I use the Variables View to see the contents of my array of arrays of this primitive type without resorting to typing commands directly to GDB (which, I believe, can also perform this function)?
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is there a way to separate open Mathematica notebooks so that they don't share any variables? How about making it so some variables are shared but not all?
Yes, there is. I recommend reading documentation related to Mathematica contexts. In a nutshell, all variables belong to some context (namespace), and all variables can be accessed via their fully-qualified names of the form "ContextName`varName". If you just use "varName", Mathematica will search contexts in $ContextPath (try evaluating the variable $ContextPath to see what it is), and will use the first context where it finds that variable. In addition, each notebook specifies a context (stored in the variable $Context) where all its variables are stored (unless fully-qualified name is used).
By default, for all notebooks the context is "Global`". Also by default, $ContextPath for all notebooks includes the "Global`" context (as well as "System`" and some others). The net result is that variables are shared across notebooks, and this can rather quickly become annoying. However, there's an easy solution. To create a "private" context for a notebook, evaluate the following:
SetOptions[EvaluationNotebook[], CellContext -> Notebook]
This notebook will be assigned a unique context (evaluate the variable $Context to see what it is). Also, global context will be removed from ContextPath (try evaluating $ContextPath before and after the SetOptions[...] above to see what's going on.)
[Update: As pointed out by rcollyer on the new Mathematica stack exchange, to set this option as the default for new notebooks, do the following: open the Options Inspector (Ctrl+Shift+O), change the scope (in the dropdown on the top) from "Selection" to "Global Preferences"; on the left expand the nodes Cell Options -> Evaluation Options, and change the CellContext setting to "Notebook."]
Now, here's how to create a shared context:
Begin["SharedContext`"];
varShared1 = "Shared string";
End[];
Alternatively, you could've just typed
SharedContext`varShared1 = "Shared string";
Now you can either use the fully qualified names ("SharedContext`varShared1" will work in any notebook), or you can add the context to $ContextPath:
AppendTo[$ContextPath, "SharedContext`"]
If you do this in all notebooks, varShared1 will become visible without a fully-qualified name.
To summarize, context work a lot like many other search paths. However, there are many subtleties (for example, if a symbol has already been defined in some other context, the Begin["SharedContext`"]/End[] block might not work as you expect -- the existing context of the symbol will be used instead of SharedContext`), so I recommend a healthy dose of experimentation and perusing the docs.
I'm not really sure if this is a wise thing to do, but anyway.
Here is a schematic solution for two Notebooks. It may be generalized, but it's not straightforward.
Open two Notebooks
In each of them go to the menu
(evaluation -> Notebook's default
context -> Unique to this Notebook)
With this, the symbols are not shared anymore.
In each Notebook enter something
like Context[] to get the Notebook
Context
Now in each Notebook enter the
following code
.
Needs["Experimental`"];
SetAttributes[f, HoldFirst];
f[s_, val_] := ToExpression#StringJoin["Notebook$$17$799580`",
ToString#Unevaluated#s, "=", ToString#val];
ValueFunction[t] = f
Where the Notebook$$17$799580 is the context of THE OTHER Notebook (this should be able to be obtained "automatically", but this is a proof of concept only.
Now when you want to share a symbol enter
f[symbolToShare]
That's it.
You may share the value bidirectionally, or just in one direction, entering f[x] only in the Notebook you want as source value for x. The other Notebook will get the updated value, but it'll not update it back.
HTH!
Edit
Towards automation:
You may get all other open Notebook Contexts to update your shared symbols as:
ctxs[]:= Complement[Contexts["Notebook$$*"],
Flatten#Union[{Context[]},
StringCases[Contexts["Notebook$$*"], __ ~~ "Private" ~~ __]]]
So your f will become something like this (not tested)
f[s_, val_] := ToExpression#StringJoin[#,
ToString#Unevaluated#s, "=", ToString#val]&/#ctxs[];
To give all notebooks unique contexts open Options Inspector and set
Cell Options → Evaluation Options → Cell Context to Notebook.
Is it possible to search or filter intellisense in visual studio?
Basically i know there is an enum in the project that contains 'column', but the enum doesnt begin with 'c'.
There has been lots of times where id rather not scroll through the hundreds (if not thousands) of valid objects it gives me.
I wonder if the real answer here is (and I won't be surprised to be voted down for this) that your enum isn't properly named. If it was then I'd expect the name to be obvious in the use context, may be consider renaming the enum?
You can search in Class View. Type "column" and hit enter.
Visual Studio 2010 changes all of this, giving you multiple very easy ways to do this type of search quickly.
If you're using ReSharper, you can use "Go To Symbol..." and type "column", and it will give you all symbols (types, properties, fields, methods, etc) that match.
Otherwise your best bet is to use the Object Browser and search.
I really don't know about doing that in intellisense itself, but assuming the objective is to actually find a member whose name you don't remember, you can write a small utility for that purpose using the underlying mechanism intellisense uses, reflection.
Open the Object Browser under View menu. From there, you can search within all the language constructs available to you.
I can't seem to find any useful documentation from Microsoft about how one would use the Delimiter and InheritsFromParent attributes in the UserMacro element when defining user Macros in .vsprops property sheet files for Visual Studio.
Here's sample usage:
<UserMacro Name="INCLUDEPATH" Value="$(VCROOT)\Inc"
InheritsFromParent="TRUE" Delimiter=";"/>
From the above example, I'm guessing that "inherit" really means "a) if definition is non-empty then append delimiter, and b) append new definition" where as the non-inherit behavior would be to simply replace any current macro definition. Does anyone know for sure? Even better, does anyone have any suggested source of alternative documentation for Visual Studio .vsprops files and macros?
NOTE: this is not the same as the InheritedPropertySheets attribute of the VisualStudioPropertySheet element, for example:
<VisualStudioPropertySheet ... InheritedPropertySheets=".\my.vsprops">
In this case "inherit" basically means "include".
[Answering my own question]
InheritsFromParent means prepend. To verify this, I did an experiment that reveals how User Macros work in Visual Studio 2008. Here's the setup:
Project p.vcproj includes the property sheet file d.vsprops ('d' for derived) using the InheritedPropertySheets tag.
d.vsprops includes the property sheet file b.vsprops ('b' for base.)
p.vcproj also defines a Pre-Build Event which dumps the environment.
Both .vsprops files contain User Macro definitions.
b.vsprops
...
<UserMacro Name="NOENV" Value="B"/>
<UserMacro Name="OVERRIDE" Value="B" PerformEnvironmentSet="true"/>
<UserMacro Name="PREPEND" Value="B" PerformEnvironmentSet="true"/>
...
d.vsprops
...
<VisualStudioPropertySheet ... InheritedPropertySheets=".\b.vsprops">
<UserMacro Name="ENV" Value="$(NOENV)" PerformEnvironmentSet="true"/>
<UserMacro Name="OVERRIDE" Value="D" PerformEnvironmentSet="true"/>
<UserMacro Name="PREPEND" Value="D" InheritsFromParent="true"
Delimiter="+" PerformEnvironmentSet="true"/>
...
p.vcproj
...
<Configuration ... InheritedPropertySheets=".\d.vsprops">
<Tool Name="VCPreBuildEventTool" CommandLine="set | sort"/>
...
build output
...
ENV=B
OVERRIDE=D
PREPEND=D+B
...
From these results we can conclude the following:
PerformEnvironmentSet="true" is necessary for User Macros to be defined in the environment used for build events. Proof: NOENV not shown in build output.
User Macros are always inherited from included property sheets regardless of PerformEnvironmentSet or InheritsFromParent. Proof: in b.vsprops, NOENV is not set in the environment and in d.vsprops it is used without need of InheritsFromParent.
Simple redefinition of a User Macro overrides any previous definition. Proof: OVERRIDE is set to D although it was earlier defined as B.
Redefinition of a User Macro with InheritsFromParent="true" prepends the new definition to any previous definition, separated by a specified Delimiter. Proof: PREPEND is set to D+B (not D or B+D.)
Here are some additional resources I found for explanation of Visual Studio .vsprops files and related topics, it's from a few years back but it is still helpful:
understanding the VC project system part I: files and tools
understanding the VC project system part II: configurations and the project property pages dialog
understanding the VC project system part III: macros, environment variables and sharing
understanding the VC project system part IV: properties and property inheritance
understanding the VC project system part V: building, tools and dependencies
understanding the VC project system part VI: custom build steps and build events
understanding the VC project system part VII: "makefile" projects and (re-)using environments
There's documentation on the UI version of this here.
A lot of the XML files seem somewhat undocumented, often just giving a schema file. Your guess as to how they function is pretty much right.
It is not the whole story.
Delimiters are not inherited. Only
the list of items they delimit are inherited: The same user macros can have different delimiters in different property sheets but only the last encountered delimiter is used. (I write "last encountered" because at project level, we cannot specify a delimiter and what gets used there is the last property sheet that specified inheritance for that macro)
Delimiters works only if made of a
single character. A delimiter longer
than one character may have its
first and/or last character stripped
in some cases, in a mistaken attempt
to "join" the list of values.
$(Inherit) appears to work inside
user macros. Like for aggregate
properties, it works as a placeholder for
the parent's values, and it can appear multiple times. When no $(Inherit) is found, it is implied at the beginning if the inheritance flag is set.
$(NoInherit) also appears to work in user's macros(makes VC behaves as if the checkbox was unticked).
User macros (and some built-ins) appears
to work when used for constructing a property sheet's path (VC's own project converter uses that feature). The value
taken by user's macros in this situation is not
always intuitive, though, especially if it gets redefined in other included property sheets.
In general, what gets "inherited" or concatenated are formulae and not values (ie. you cannot use a user macro to take a snapshot the local value of (say) $(IntDir) in a property sheet and hope to "bubble up" that value through inheritance, because what gets inherited is actually the formula "$(IntDir)", whose value will eventually be resolved at the project/config/file level).
A property sheet already loaded is ignored (seem to avoid that the same property sheet has its user macros aggregated twice)
Both "/" and "\" appear to work in
property sheet paths (and in most
places where VS expects a path).
A property sheet path starting with
"/" (after macros have been resolved) is assumed to be in "./", where '.' is the location of the
calling sheet/project). Same if the path does not start with "./", "../" or "drive:/" (dunno about UNC).