Questions tagged [variable-names]

256 questions
17
votes
6 answers

Create variables with names from strings

Let's assume that I want to create 10 variables which would look like this: x1 = 1; x2 = 2; x3 = 3; x4 = 4; . . xi = i; This is a simplified version of what I'm intending to do. Basically I just want so save code lines by creating these variables…
Potaito
  • 1,181
  • 2
  • 10
  • 32
17
votes
6 answers

What variable name do you use for file descriptors?

A pretty silly trivial question. The canonical example is f = open('filename'), but f is not very descriptive. After not looking at code in a while, you can forget whether it means "file" or "function f(x)" or "fourier transform results" or…
endolith
  • 25,479
  • 34
  • 128
  • 192
16
votes
1 answer

How to pandas df.assign() with variable names?

I want to add a new column in a dataframe with values from some other dataframe. My new column name is a variable and I cannot hardcode it. new_column = "my_new_column_name" df = df.assign(new_column=other_df['Column1'].values) The problem is…
eiram_mahera
  • 950
  • 9
  • 25
16
votes
2 answers

How to extract variable names from a netCDF file in R?

I am writing a function in R to extract some air quality modelling data from netCDF files. I have the Package "ncdf" installed. In order to allow other users or myself to choose what variables to extract from a netCDF file, I would like to extract…
elarry
  • 521
  • 2
  • 7
  • 20
15
votes
3 answers

Variable with same name as type - which compiler is right?

In this code: typedef int foo; struct S { foo foo; }; int main() {} all versions of clang -std=c++14 accept this code, however all versions of g++ -std=c++14 report: 5 : error: declaration of 'foo S::foo' [-fpermissive] foo foo; ^ 1 : error:…
M.M
  • 138,810
  • 21
  • 208
  • 365
12
votes
1 answer

Using the component ID as widgetVar name

I have a simple question about component IDs and dialog (or other components) widget variable name. Is there a problem of using the component ID as widget variable name of the same component? E.g.
Cold
  • 787
  • 8
  • 23
10
votes
2 answers

Pass variable name to plotting function title

I was wondering if anyone could help me use a variable name within a function. I've put together a dot plot that sorts variables and then produces a bitmap, but I can't get R to pass the variable name to the plot title. Example…
Marco M
  • 623
  • 1
  • 8
  • 15
9
votes
3 answers

Why can't variable names have spaces in them?

Related: Why can't variable names start with numbers? Is there a technical reason why spaces aren't allowed in variable names or is it down to convention? For example, what's stopping us from doing something like this?: average score = sum of scores…
Volatility
  • 31,232
  • 10
  • 80
  • 89
8
votes
1 answer

Non-ASCII Python identifiers and reflectivity

I have learnt from PEP 3131 that non-ASCII identifiers were supported in Python, though it's not considered best practice. However, I get this strange behaviour, where my identifier (U+1D70F) seems to be automatically converted to τ (U+03C4). class…
iago-lito
  • 3,098
  • 3
  • 29
  • 54
8
votes
1 answer

Why do I receive a FunctionClauseError ("no function clause matching") in this Elixir program, translated from Erlang?

**So, I've worked with Erlang, before, and am pretty comfortable with it. I am just trying to learn Elixir. I was recently trying to translate a 'lazy caterers' example into elixir and am befuddled as to why it either doesn't compile, or compiles…
jpsthecelt
  • 81
  • 1
  • 1
  • 3
8
votes
2 answers

Does variable name length matter for performance in PHP?

I have been seen this Does variable name length matter for performance C#? topic and have same question about php. My co-worker (Front-end) have been encoded everything like $o, $r, $x, $m, $c and motivated it best performance. I really very doubt…
Stepchik
  • 275
  • 1
  • 3
  • 14
7
votes
6 answers

Safest way to change variable names in a project

So I've been working on a relatively large project by myself, and I've come to realise that some of the variable names earlier on were.. less than ideal. But how does one change variable names in a project easily? Is there such a tool that can go…
kamziro
  • 7,882
  • 9
  • 55
  • 78
7
votes
13 answers

Really long class/variable/property/method names

Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still…
Zachary Yates
  • 12,966
  • 7
  • 55
  • 87
6
votes
3 answers

Why isn't LocalBuilder.SetLocalSymInfo emitting variable names?

I tried running the sample code which appears on the documentation page for the System.Reflection.Emit.LocalBuilder class but it appears that the calls to LocalBuilder.SetLocalSymInfo(string, int, int) aren't doing anything since the IL Dissasembler…
Wesley Wiser
  • 9,491
  • 4
  • 50
  • 69
6
votes
2 answers

How Does Local-Scope Work in C#

Possible Duplicate: Child Scope & CS0136 C# Variable Scoping Though I have been using C# for quite some time, I have just stumbled upon this error. If I have the following: if(true) { int x = 0; } int x = 0; I get an error that says: A local…
Eric
  • 2,098
  • 4
  • 30
  • 44
1
2
3
17 18