variables

How can I pass my locals and access the variables directly from another function?

Let's say I have this : def a(dict): locals().update(dict) print size def b(): size = 20 f(locals()) What do I have to do to access the size variable directly from the a function? I know of : size = dict["size"] but I think there should be a more direct way. I tried using locals().update(dict) but it didn't work. Is ther...

Does [My]SQL have a Pre-Processor-like Facility?

I'm writing a small deployment SQL script for my first database-driven app. In the process, I find that I repeat myself a lot, for instance: GRANT USAGE ON *.* TO 'foo'@'localhost'; DROP USER 'foo'@'localhost'; CREATE USER 'foo'@'localhost' IDENTIFIED BY 'password'; It would be fantastic if I could use a variable or a macro to replac...

Is there any difference in speed in manipulating different types of variables?

Hello everyone, This is in reference to C++ and using the Visual Studio compilers. Is there any difference in speed when reading/writing (to RAM) and doing mathematical operations on different types of variables such as bool, short int, int, float, and doubles? From what I understand so far, mathematical operations with doubles takes...

jquery append to string variable

Hello guys. How can I append a word to an already populated string variable with spaces? ...

Variable variables to call programmatically-created arrays

Hello, I am creating a series of arrays from template tags in a content management system, and outputting the titles of these arrays as arrays labeled with variables: <Loop> $<GeneratedArrayName1> = array( "foo" => "bar" ); $<GeneratedArrayName2> = array( "foo" => "bar" ); </Loop> I'm also generating another array of possible Gen...

PHP variables in classes

I have the following code (I'm a Dot Net developers and I thought if I can bring my OOP knowledge to PHP) class user { var $_un; function user($un) { $_un = $un; } function adduser() { } function checkuser() { } function printuser () { echo $_un; } } $newuser = new user('Omar Abid'); $newus...

how do i use php to read an external file and put insides into variables?

I had no idea to correctly form the title of this question, because I don't even know if what I'm trying to do has a name. Let's say I've got an external file (called, for instance, settings.txt) with the following in it: template:'xaddict'; editor:'true'; wysiwyg:'false'; These are simple name:value pairs. I would like to have php ...

Jquery count number of hidden elements within div

How can I count the number of items in div that are hidden? Thanks in advance ...

Why does popping from one stack actually pop from multiple separate stacks?

I have tried to simplify and annotate the code which is giving me a headache below. It demonstrates my problem. Simply put, I have two separate stacks and I am trying to pop from one stack. For some reason, when you pop one of the stacks, it actually seems to pop the other one as well?! Is this by design and if so, why and how should...

PHP - Get variables from another PHP file without executing the code?

Hi All, I'm trying to create a script to extract the variables from a file on the same server. The problem is, I don't know what else is going to be in the file all of the time (the script is for other people to use), so I don't really want to load all of the contents or execute any of the code. I've thought of using file_get_contents...

How do I use symbolic references in Perl?

In Perl, if a variable holds the name for another variable, how do I use the first variable to visit the other one? For example, let $name = "bob"; @bob = ("jerk", "perlfan"); how should I use $name to get to know what kind of person bob is? Although I'm not quite sure, my vague memory tells me it might related to typeglob. ...

Curious: is it possible to have dynamic Ajax data variable names?

Some background: On a recent project, I tried to write a streamlined jQuery plugin that would handle some Ajax calls made when various inputs were updated. I wrote the JavaScript function as a plugin so that I could just call it on various inputs, like so: $("#email").updateChanges(); Then, from within the plugin, I collected the inp...

How to list variables declared in script in bash?

In my script in bash, there are lot of variables, and I have to make something to save them to file. My question is how to list all variables declared in my script and get list like this: VARIABLE1=abc VARIABLE2=def VARIABLE3=ghi Is there some EASY way for this? ...

Is it possible to export a value of an variable from one javascript to an other?

Hi All I have made a Web page using jquery and php where all files are used in a modular style. Now I have two JavaScript files which must communicate with each other. One Script generates a variable (*id_menu_bar*) which contains a number. I want that this variable gets transported to the second JavaScript and is used there. How do I ...

problem with variable (firefox extension)

I try to make firefox extension, that display two buttons: 1 and 2. When you press button1 to var path get value, that is address of current open page, then new tab is opening becoming active. In this tab there is button2, that allow to put (innerHTML) value of var path (this address of first tab). And now the problem: button1 uses funct...

Rails variable in model not working

Hello. In my controller, I have this: user.save if user.leveled_up==true flash[:notice]="HOOOORAY!!!" end and in my model I have: before_save :check_xp # .... def leveled_up=(leveled_up) @leveled_up=leveled_up if @leveled_up==true self.statpoints+=5 hp=max_hp end end def leveled_up @le...

Passing varible types though mod-rewrite

Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point in the the right direction. my site has 1 main file [index.php] all the navigation is done by passing vars in the url string eg index.php?page=about this is working ok with my .htaccess [below] domain.com/about some of the pages have a second variabl...

read-only property

Is it possible to make a javascript object property read-only? I want to set a property that cannot be modified... ...

How to determinate: Is Python variable is instance of built-in type?

I need to determinate is Python variable is instance of native type: str, int, float, bool, list, dict and so on. Is there elegant way to doing it? Or if myvar in (str, int, float, bool): are only way to do it? ...

Adding variables together using Actionscript

Hi Everyone - I am trying to translate this statement into Actionscript: "Sally is 5 years old. Jenny is 4 years old. The combined age of Sally and Jenny is 9 years." This is what I have so far: function getAges (sallyAge:Number,jennyAge:Number,combinedAge:Strin g) { trace("Sally's Age:" + sallyAge); trace("Jenny's Age:" + jennyAge); ...