Search Results

Search found 12457 results on 499 pages for 'variable assignment'.

Page 16/499 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Any method to denote object assignment?

    - by Droogans
    I've been studying magic methods in Python, and have been wondering if there's a way to outline the specific action of: a = MyClass(*params).method() versus: MyClass(*params).method() In the sense that, perhaps, I may want to return a list that has been split on the '\n' character, versus dumping the raw list into the variable a that keeps the '\n' intact. Is there a way to ask Python if its next action is about to return a value to a variable, and change action, if that's the case? I was thinking: class MyClass(object): def __init__(*params): self.end = self.method(*params) def __asgn__(self): return self.method(*params).split('\n') def __str__(self): """this is the fallback if __asgn__ is not called""" return self.method(*params)

    Read the article

  • rake aborted! undefined local variable or method

    - by Subhransu
    In a fresh new Ubuntu machine, I have installed ruby with sudo apt-get install ruby1.8 and then installed rubygem1.8 with : sudo apt-get install rubygems and after that installed rails3.2.8 with : gem install rails The procedure was very simple. But here comes the problem. When I tried checking the version of rake with rake --trace -version I got the following error: rake aborted! undefined local variable or method `rsion' for #<Rake::Application:0xb72c731c> /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:316:in `standard_rake_options' /usr/lib/ruby/1.8/optparse.rb:1298:in `eval' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:316:in `standard_rake_options' /usr/lib/ruby/1.8/optparse.rb:1298:in `call' /usr/lib/ruby/1.8/optparse.rb:1298:in `parse_in_order' /usr/lib/ruby/1.8/optparse.rb:1254:in `catch' /usr/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order' /usr/lib/ruby/1.8/optparse.rb:1248:in `order!' /usr/lib/ruby/1.8/optparse.rb:1339:in `permute!' /usr/lib/ruby/1.8/optparse.rb:1360:in `parse!' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:425:in `handle_options' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:74:in `init' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:72:in `init' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:64:in `run' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' /var/lib/gems/1.8/gems/rake-0.9.2.2/bin/rake:33 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 Is it the problem due to I have installed straight from ubuntu apt-get package manager ?

    Read the article

  • C # - a variable using the Encrypt md5

    - by Guilherme Cardoso
    When we are dealing with more sensitive data and important as a keyword, it is not appropriate at all stores them in database without encrypting for security reasons.  For this we use MD5  MD5 is an algorithm that allow us to encript an string, but doesn't leave us desencrypt it (not sure if it is already possible, but at least I know there are many databases already having a record).  The method below will return us a variable encrypted with md5. For example: md5_encriptar (pontonetpt.com ");   The result will be: 34efe85d338075834ad41803eb08c0df This way we save tthese encrypted data into a database, and then to make comparisons we often use the method to compare with the records kept. public string md5_encrypt(string md5) { System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] bs = System.Text.Encoding.UTF8.GetBytes(md5); bs = x.ComputeHash(bs); System.Text.StringBuilder s = new System.Text.StringBuilder(); foreach (byte b in bs) { s.Append(b.ToString("x2").ToLower()); } string password = s.ToString(); return password; }

    Read the article

  • SQL SERVER – Storing Variable Values in Temporary Array or Temporary List

    - by pinaldave
    SQL Server does not support arrays or a dynamic length storage mechanism like list. Absolutely there are some clever workarounds and few extra-ordinary solutions but everybody can;t come up with such solution. Additionally, sometime the requirements are very simple that doing extraordinary coding is not required. Here is the simple case. Let us say here are the values: a, 10, 20, c, 30, d. Now the requirement is to store them in a array or list. It is very easy to do the same in C# or C. However, there is no quick way to do the same in SQL Server. Every single time when I get such requirement, I create a table variable and store the values in the table variables. Here is the example: For SQL Server 2012: DECLARE @ListofIDs TABLE(IDs VARCHAR(100)); INSERT INTO @ListofIDs VALUES('a'),('10'),('20'),('c'),('30'),('d'); SELECT IDs FROM @ListofIDs; GO When executed above script it will give following resultset. Above script will work in SQL Server 2012 only for SQL Server 2008 and earlier version run following code. DECLARE @ListofIDs TABLE(IDs VARCHAR(100), ID INT IDENTITY(1,1)); INSERT INTO @ListofIDs SELECT 'a' UNION ALL SELECT '10' UNION ALL SELECT '20' UNION ALL SELECT 'c' UNION ALL SELECT '30' UNION ALL SELECT 'd'; SELECT IDs FROM @ListofIDs; GO Now in this case, I have to convert numbers to varchars because I have to store mix datatypes in a single column. Additionally, this quick solution does not give any features of arrays (like inserting values in between as well accessing values using array index). Well, do you ever have to store temporary multiple values in SQL Server – if the count of values are dynamic and datatype is not specified early how will you about storing values which can be used later in the programming. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Does the order of readonly variable declarations guarantee the order in which the values are set?

    - by Jason Down
    Say I were to have a few readonly variables for filepaths, would I be able to guarantee the order in which the values are assigned based on the order of declaration? e.g. readonly string basepath = @"my\base\directory\location"; readonly string subpath1 = basepath + @"\abc\def"; readonly string subpath2 = basepath + @"\ghi\klm"; Is this a safe approach or is it possible that basepath may still be the default value for a string at the time subpath1 and subpath2 make a reference to the string? I realize I could probably guarantee the order by assigning the values in a constructor instead of at the time of declaration. However, I believe this approach wouldn't be possible if I needed to declare the variables inside of a static class (e.g. Program.cs for a console application, which has a static void Main() procedure instead of a constructor).

    Read the article

  • How to create a closure and pass in variable length argument list?

    - by Jian Lin
    We can create a closure p by capturing the arguments in the scope in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that p = console.log; works well in Firefox and IE 8 but not on Chrome.

    Read the article

  • Java / Android self naming

    - by ngreenwood6
    I am about to start developing an Android application and had a question if in Java there self naming. For instance say I had a variable named dog that held the value of scruffy. Could I then create a variable named scruffy from that variable. In PHP it would be $$dog. That would make a variable with the name scruffy. If this is possible please provide example

    Read the article

  • PHP: Over-writing session variables

    - by Tom
    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, should I be destroying a previous session variable before creating a new one of the same name? Thank you.

    Read the article

  • How to create a function and pass in variable length argument list?

    - by Jian Lin
    We can create a function p in the following code: var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = function() { console.log(arguments); }; } but the arguments are passed like an array to console.log, instead of passed one by one as in console.log(arguments[0], arguments[1], arguments[2], ... Is there a way to expand the arguments and pass to console.log like the way above? Note that if the original code were var p = function() { }; if (typeof(console) != 'undefined' && console.log) { p = console.log; } then it works well on Firefox and IE 8 but not on Chrome.

    Read the article

  • Who "invented" i,j,k as integer counter variable names? [closed]

    - by mjy
    Possible Duplicate: Why are we using i as a counter in loops I've used these myself for more than 15 years but cannot really remember how/where I picked up that habit. As it is really widespread, I'm curious to know who originally suggested / recommended using these names for integer loop counters (was it the K&R book?).

    Read the article

  • Use jQuery on a variable instead on the DOM ? [solved]

    - by Stef
    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 something like data.$("a[href$='.img']").each(function(index) { }); Is this possible ? ...UPDATE... Thanks to the answers, I was able to fix this problem. function FetchPage(href) { $.ajax({ url: href, async: false, cache: false, success: function(html){ $("#__tmp__").append("<page><name>" + href + "</name><content>" + html + "</content></page>"); } }); } See this zip file for an example how to use it.

    Read the article

  • Use jQuery on a variable instead on the DOM ?

    - by Stef
    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 something like data.$("a[href$='.img']").each(function(index) { }); Is this possible ?

    Read the article

  • Python ctypes in_dll string assignment

    - by ackdesha
    I could use some help assigning to a global C variable in DLL using ctypes. The following is an example of what I'm trying: test.c contains the following #include <stdio.h> char name[60]; void test(void) { printf("Name is %s\n", name); } On windows (cygwin) I build a DLL (Test.dll) as follows: gcc -g -c -Wall test.c gcc -Wall -mrtd -mno-cygwin -shared -W1,--add-stdcall-alias -o Test.dll test.o When trying to modify the name variable and then calling the C test function using the ctypes interface I get the following... >>> from ctypes import * >>> dll = windll.Test >>> dll <WinDLL 'Test', handle ... at ...> >>> f = c_char_p.in_dll(dll, 'name') >>> f c_char_p(None) >>> f.value = 'foo' >>> f c_char_p('foo') >>> dll.test() Name is Name is 48+? 13 Why does the test function print garbage in this case?

    Read the article

  • Static variable definition order in c++

    - by rafeeq
    Hi i have a class tools which has static variable std::vector m_tools. Can i insert the values into the static variable from Global scope of other classes defined in other files. Example: tools.h File class Tools { public: static std::vector<std::vector> m_tools; void print() { for(int i=0 i< m_tools.size() ; i++) std::cout<<"Tools initialized :"<< m_tools[i]; } } tools.cpp File std::vector<std::vector> Tools::m_tools; //Definition Using register class constructor for inserting the new string into static variable. class Register { public: Register(std::string str) { Tools::m_tools.pushback(str); } }; Different class which inserts the string to static variable in static variable first_tool.cpp //Global scope declare global register variable Register a("first_tool"); //////// second_tool.cpp //Global scope declare global register variable Register a("second_tool"); Main.cpp void main() { Tools abc; abc.print(); } Will this work? In the above example on only one string is getting inserted in to the static list. Problem look like "in Global scope it tries to insert the element before the definition is done" Please let me know is there any way to set the static definiton priority? Or is there any alternative way of doing the same.

    Read the article

  • Django/Mod_WSGI error: UnboundLocalError: local variable 'resolver' referenced before assignment

    - by ycseattle
    Hello, I've setup the Django with mod_wsgi and run into this error. I thought maybe the sys.path was not setup correctly but I tried everything I could think of with no luck. Any suggestions? The following is the apache2 log for the error: mod_wsgi (pid=2579): Exception occurred processing WSGI script '/home/myapp/myapp.wsgi'. Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 142, in get_response return self.handle_uncaught_exception(request, resolver, exc_info) UnboundLocalError: local variable 'resolver' referenced before assignment The following is the content in the myapp.wsgi: import os import sys # put the Django project on sys.path sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) os.environ["DJANGO_SETTINGS_MODULE"] = "photopier.settings" #os.environ["PYTHONPATH"]="/home" from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler()

    Read the article

  • Assignment in python for loop possible?

    - by flyingcrab
    I have a dictionary d (and a seperate sorted list of keys, keys). I wanted the loop to only process entries where the value is False - so i tried the following: for key in keys and not d[key]: #do foo I suppose my understanding of python sytax is not what i thought it was - because the assignment doesnt suppose to have happened above, and a i get an instanciation error. The below works of course, but I'd really like to be able to use something like the code above.. possible? for key in keys: if d[key]: continue #foo time! Thanks!

    Read the article

  • "The left hand side of an assignment must be a variable" due to extra parentheses

    - by polygenelubricants
    I know why the following code doesn't compile: public class Main { public static void main(String args[]) { main((null)); // this is fine! (main(null)); // this is NOT! } } What I'm wondering is why my compiler (javac 1.6.0_17, Windows version) is complaining "The left hand side of an assignment must be a variable". I'd expect something like "Don't put parentheses around a method invokation, dummy!", instead. So why is the compiler making a totally unhelpful complaint about something that is blatantly irrelevant? Is this the result of an ambiguity in the grammar? A bug in the compiler? If it's the former, could you design a language such that a compiler would never be so off-base about a syntax error like this?

    Read the article

  • Java == operator. "Invalid assignment operator"

    - by Tom
    Hi, I was trying to write a simple method boolean validate(MyObject o) { return o.getPropertyA() == null && o.getPropertyB()==null; } And got a strange error on the == null part. Maybe my Java is rusty after a season in PLSQL. Consider this: Integer i = 4; i ==null; //compile error: Syntax error on token ==. Invalid assignment operator. Integer i2 = 4; if (i==null); //No problem How can this be ? Any explanation ? Im using jdk160_05.

    Read the article

  • Assignment to None

    - by Joel
    Hello, I have a function which returns 3 numbers, e.g.: def numbers(): return 1,2,3 usually I call this function to receive all three returned numbers e.g.: a,b,c=numbers() However, I have one case in which I only need the first returned number. I tried using: a, None None = numbers() But I receive "SyntaxError: assignment to None". I know, of course, that i can use the first option I mentioned and then not use "b" and "c", but only "a". However, this seems like a "waste" of two vars and feels like wrong programming. Any ideas? Thanks, Joek

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >