variables

How to get a variable name as a string in Python?

I would like to be able to get the name of a variable as a string but I don't know if Python has that much introspection capabilities. Something like: >>> print(my_var.__name__) 'my_var' I want to do that because I have a bunch of vars I'd like to turn into a dictionary like : bar=True foo=False >>> my_dict=dict(bar=bar, foo=foo) >>>...

Missing output when running system command in perl/cgi file

I need to write a CGI program and it will display the output of a system command: script.sh echo "++++++" VAR=$(expect -c " spawn ssh -o StrictHostKeyChecking=no $USER@$HOST $CMD match_max 100000 expect \"*?assword:*\" send -- \"$PASS\r\" send -- \"\r\" expect eof ") echo $VAR echo "++++++" In CGI file: my $command= "ksh ../cgi...

Dollar ($) sign in password string treated as variable

Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems connecting to the database. The database could be accessed from the shell and phpMyAdmin with the exact same credentials and it didn't make sense. Turns out the password had a $ sign in it: $_DB["password"] = "mypas$word"; The password b...

non-static variable cannot be referenced from a static context (java)

I ask that you ignore all logic.. i was taught poorly at first and so i still dont understand everything about static crap and its killing me. My error is with every single variable that i declare then try to use later inside my methods... i get the non-static variable cannot~~ error I can simply put all the rough coding of my methods ...

FORTRAN: determine variable type

hello, GOOGLE has yet to find an answer for me, so here goes: In FORTRAN, is there a way to determine the TYPE of a variable? E.G., pass the variable type as an argument in a function, to then be able to call type-specific code with that fuction; eliminating the need to have seperate similar functions for each data type. thanks. ...

Question about variable definitions in functions.

Hi. #include <stdio.h> main() { int a; for(a=1; a<=4 && printf("%d ",a); a++) { int a; static int b=a; printf("%d ",(a++)-b); } getchar(); getchar(); } In this code, the printout is 1 0 2 1 3 2 4 3. I understand why the int a; part works differently than the int a which was defined ou...

Jquery post success variable scope

Hi, I'm trying to return the ajax success array from one function to another. For some reason I don't seem to be able to pass the data stored in a variable in the success part of the ajax function into the parent function to return. I looked at this post to try and figure things out, but not such luck: http://stackoverflow.com/questio...

Is is possible to call a variable that has been assigned after the call (PHP)?

The title is in the question (EDIT: :P I mean the question is in the title), basically can I call variable $x before defining it further down the page? ...

Obj-C: ++variable is increasing by two instead of one

I am writing a program that asks users yes/no questions to help them decide how to vote in an election. I have a variable representing the question number called questionnumber. Each time I go through the switch-break loop, I add 1 to the questionnumber variable so that the next question will be displayed. This works fine for the firs...

Can I create a variable with JavaScript that PHP can recognize?

I have a series of PHP statements that I only want to run if javaScript is enabled. if($js_enabled == 'yes') { //Run a series of PHP statements } My problem is that I want to create that $js_enabled variable with javaScript. Therefore, if javaScript is enabled, the variable will be created and the PHP statements will be run, but if...

ASP.NET Session or global variables?

Hi, I am creating an ASP.NET page where I need a couple of variables which hold pathnames and a chosen language etc... Not that many, let's say about 5. Should I use session variables for this? Atm I'm using public static variables but I'm not sure if this is the right way to do this. Any thoughts? Thx ...

Is it possible to delay variable implement(?)/recognize(?) in PHP?

For example: A.php (the config file): <?php $a = array('name'=>'wine[$index][name]', 'value'=>'wine[$index][value]' ) ?> B.php: include_once(a.php) ... //for simple $index = 0; $b = $a; //actual code like foreach($data as $index=>$value) $b += $a I know this example won't work, just for explaination, i wan...

Return only the new database items since last check in Rails

I'm fairly new to Ruby, and currently trying to implement an AJAX style commenting system. When the user views a topic, all the current comments on that topic will be displayed. The user can post a comment on the page of a topic and it should automatically display without having to refresh the page, along with any new comments that hav...

jquery updating a div in ajax diesnt work properly, when using a variable

hi, i got the following code var zieldiv = $(this).attr('id'); $.ajax({ url: 'index.php?params', type: 'POST', data: { color:thenewcolor, zieldiv:zieldiv }, timeout: 50000, beforeSend: function() { $("#" + zieldiv).css({background: "#" + thenewcolor} ); } }); I use this for ...

PHP - Variable inside variable?

Hey guys... $bookA = "123"; $crack = "A"; I want to do something similar to this: echo $book$crack; Such that the output is 123. What is the correct syntax for the echo command? Thanks. ...

PHP: Over-writing session variables

Hi, Question related to PHP memory-handling from someone not yet very experienced in PHP: If I set a PHP session variable of a particular name, and then set a session variable of the exact same name elsewhere (during the same session), is the original variable over-written, or does junk accumulate in the session? In other words, shoul...

(partial apply str) and apply-str in clojure's ->

If I do the following: user=> (-> ["1" "2"] (partial apply str)) #<core$partial__5034$fn__5040 clojure.core$partial__5034$fn__5040@d4dd758> ...I get a partial function back. However, if I bind it to a variable: user=> (def apply-str (partial apply str)) #'user/apply-str user=> (-> ["1" "2" "3"] apply-str) "123" ...the code...

In actionscript, why is my static class member variable not the same when accessed from different parts of my app?

I have an actionscript class with a static member variable defined. public class A { public static var x:int; } When I try to access it from different parts in my code I don't get the same value in each spot. A.x I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file....

How to change a variable type in C#?

I wanted to use something like this: if(x==5) { var mydb= ........ ; } else { var mydb = ........ ; } but it didn't work because I can't declare a variable inside if statement. So I tried to do this: var mydb; if (x==5) { mydb= ............. ; } else { mydb=.............; } but id didn't work either because I ha...

Where can I find information about Perl's special variables?

Perl has quite a few special variables such as @F, $!, %! ... etc. Where are all Perl's special variables documented? ...