Could you clarify some ideas behind Python classes and class instances?
Consider this:
class A():
name = 'A'
a = A()
a.name = 'B' # point 1 (instance of class A is used here)
print a.name
print A.name
prints:
B
A
if instead in point 1 I use class name, output is different:
A.name = 'B' # point 1 (updated, class A itself is...
Why is it not possible to have implicitly-typed variables at a class level within C# for when these variables are immediately assigned?
ie:
public class TheClass
{
private var aList = new List<string>();
}
Is it just something that hasn't been implemented or is there a conceptual/technical reason for why it hasn't been done?
...
What is the general meaning and where did it start to have variables with leading or trailing underscores?
ex: _varName and varName_
I have always thought a leading underscore indicated the variable was a pointer but I don't know where I got this idea. Recently I have seen these naming conventions used in Java which makes that reasonin...
I would like to insert a line break into the first space between words in a string variable. Here is my code so far:
<cfset myPosition = find(" ", #myVar#)>
<cfset lineBreak = Chr(13)&Chr(10)>
<cfset myVar = insert(#lineBreak#, #myVar#, #myPosition#)>
What am I doing wrong?
...
As an extension the the question "Modify/view static variables while debugging in Eclipse", I'd like to be able to modify static variables while debugging in Eclipse.
For instance and local variables, I can just choose the variable in the "Variables" view of Eclipse, and use the context menu "Change value..." to change the value.
This ...
I've got the following problem: I have rhtml (html minced together with ruby inside <% %> and <%= %> tags) stored in a database which I want to render. The information is acquired through a query. I need to be able to evaluate the information I get from the database as though as it was normal content inside the .erb-file. What I currentl...
In jQuery you can do :
$("a[href$='.img']").each(function(index) {
alert($(this).attr('href'));
}
I want to write a jQuery function which crawls x-levels from a website and collects all hrefs to gif images.
So when I use the the get function to retrieve another page,
$.get(href, function(data) {
});
I want to be able to do s...
Hi, I have a string that contains the name of a class variable that I know exists for class A. I need to get the value of this variable (i.e. dereferencing), how do I do it?
...
i have a function which is a class method, and i want to test a attribute of the class which may or may not be None, but will exist always.
class classA():
def __init__(self, var1, var2 = None):
self.attribute1 = var1
self.attribute2 = var2
@classmethod
def func(self,x):
if self.attribute2 is None:
do something
i get th...
I have a bunch of related constants that are not identical. What's the better way to name them?
way #1
kWalkSpeed
kRunSpeed
kEatSpeed
kDrinkSpeed
Or,
way #2
kSpeedWalk
kSpeedRun
kSpeedEat
kSpeedDrink
If we evaluate these based on
readability
understandability
organization in member list (autocomplete)
not bug prone with subt...
I'm trying to do something like this:
private class aClass
{
private ArrayList<String> idProd;
aClass(ArrayList<String> prd)
{
this.idProd=new ArrayList<String>(prd);
}
public ArrayList<String> getIdProd()
{
return this.idProd;
}
}
So if I have multiple instances of ArrayLIst<String> (st1 ,st2 ,st3) and I w...
I'm trying to figure out why a variable isn't triggering a conditional that it should. var_dump reports something like this:
string(20) "0"
Why is it reporting a length of 20 when the length is clearly 1?
...
Okay, so ultimately I want a program where the user can input simple data such as their name, date of birth, address, etc. and then have that information stay through multiple views. I am having the user input their information as UITextFields but their are multiple views that they are using to input the data. Is there a way that when ...
Basically, I want to take a
Dictionary like { "a":"bar", "b":"blah", "c":"abc", "d":"nada" }
and use it to set variables (in an Object) which have the same name as a key in the dictionary.
class Foo(Object)
{
self.a = ""
self.b = ""
self.c = ""
}
So in the the end self.a = "bar", self.b = "blah", etc... (and key "d" is ...
In C++, what is the scope resolution ("order of precedence") for shadowed variable names? I can't seem to find a concise answer online.
For example:
#include <iostream>
int shadowed = 1;
struct Foo
{
Foo() : shadowed(2) {}
void bar(int shadowed = 3)
{
std::cout << shadowed << std::endl;
// What does t...
function rp_marcadesmarcaFarm(valor) {
FM_log(3, "marcadesmarcaFarm called = "+valor);
for (i = 0; i < farmList.length; i++) {
var arr = farmList[i].split("|");
var xy = arr[0].split(",");
var fvillageId = xy2id(parseInt(xy[0]), parseInt(xy[1]));
GM_setValue("farmAtivada_"+suffix...
...
...
...
try
{
string Tags_collect;
SqlDataReader Data1 = cmd.ExecuteReader();
Data1.Read();
lbl_q_title.Text = Data1["subject"].ToString();
Data1.NextResult();
while (Data1.Read())
{
...
In jQuery you can select two elements by id like: $('#elem, #elem2');
BUT
What if you have cached the elem and elem2, and what to apply the same method/function to them both?
i.e.
$elem = $('#elem');
$elem2 = $('#elem2');
This obviously wont work:
$($elem, $elem2)
Thanks!
...
I have a variable a = 1.
I want to generate a variable name of the form:
variableNumber
so in this example, I would want
a1
a2
a3
as variables.
How can I do that?
...
How do I send a variable in jquery to a callback function? function(r){ }
Look at the demo
Whilst on the demo, notice that the form above the menu can be serialised. Also notice that when clicking a folder icon whilst on an item (click a category from the left), and submit the form that way, it cannot be serialised.
I have a variable ...