Search Results

Search found 7418 results on 297 pages for 'argument passing'.

Page 161/297 | < Previous Page | 157 158 159 160 161 162 163 164 165 166 167 168  | Next Page >

  • Using __str__ representation for printing objects in containers in Python

    - by BobDobbs
    I've noticed that when an instance with an overloaded str method is passed to the print() function as an argument, it prints as intended. However, when passing a container that contains one of those instances to print(), it uses the repr method instead. That is to say, print(x) displays the correct string representation of x, and print(x, y) works correctly, but print([x]) or print((x, y)) prints the repr representation instead. First off, why does this happen? Secondly, is there a way to correct that behavior of print() in this circumstance?

    Read the article

  • A c# Generics question involving Controllers and Repositories

    - by UpTheCreek
    I have a base repository class which contains all the common repository methods (as generic): public abstract class BaseRepository<T, IdType> : IBaseRepository<T, IdType> My repositories from this base e.g.: public class UserRepository : BaseRepository<User, int>, IUserRepository I also have a base controller class containing common actions, and inherit from this in controllers. The repository is injected into this by DI. E.g. public class UserController : BaseController<User> { private readonly IUserRepository userRepository; public UserController (IUserRepository userRepository) { this.userRepository= userRepository; } My question is this: The base controller needs to be able to access the repository methods that are defined in the base repository. However I'm passing in via DI a different repository type for each controller (even though they all inherrit from the base repository). How can the base controller somehow access the repository that is passed in (regardless of what type it is), so that it can access the common base methods?

    Read the article

  • Creating a custom widget using django for use on external sites

    - by ajt
    I have a new site that I am putting together and part of it has statistics for the site's users. I would like to create a widget that others can use on another website by invoking javascript that reads data from my server and shows that statistics for a given user, but I am having a hard time finding specific tutorials that covers this in django. I have seen the link at Alex Maradon's site [0], but it looks to me like that is passing html back to the widget and I am having a hard time figuring out how to do this using something like xml. Are there any django apps for doing this or does anyone know of good how-tos? [0] http://alexmarandon.com/articles/web_widget_jquery/

    Read the article

  • Using a locale-dependent sorting function in Ruby/Rails

    - by knuton
    What is a good approach to sorting an array of strings in accordance with the current locale? For example the standard Array#sort puts "Ä" after "Z", which is not correct in German. I would have expected the gem I18n to offer a hook for defining my own sorting algorithms or providing collation strings or objects. In my imagination, passing this proc or string to the sort function, would make it behave as necessary. I know that this is possible in Python, for example. Google has not helped me this time. Can you? Any advice appreciated!

    Read the article

  • OAuth 2.0: Can a user-agent client avoid forwarding fragments?

    - by Bosh
    In the OAuth 2.0 draft specification, user-agent clients receive authorization in the form of a bearer token via redirection (from an authentication server) to a URL such as HTTP/1.1 302 Found Location: http://example.com/rd#access_token=FJQbwq9&expires_in=3600 According to Section 3.5.2 it is then the user-agent's job to GET the URL in question, but "The user-agent SHALL NOT include the fragment component with the request." In other words, as a result of the example redirection above, the user-agent should GET /rd HTTP/1.1 Host: example.com without passing #access_token to the server. My question: what user agents behave this way? I thought redirection in Firefox, for example, would (logically) include the fragment in the GET request. Am I just wrong about this, or does the OAuth 2.0 specification rely on non-standard user-agent behavior?

    Read the article

  • AS3: creating a class with multiple and optional parameters?

    - by redconservatory
    I'm creating a slideshow where each slide can have: - a video or a still - 1 audio track or many (up to 3) - 1 button or many (up to 3) I was thinking that each slide can be it's own object, and then I would pass the video, audio, buttons, etc., into it as parameters: package { import flash.media.Video; public class Section { public function Section (video:Video, still:myPhotoClass, audiotrack:Sound, button:myButtonClass) { // can have video OR a still // can have 1 audio track or several // can have 1 button or more } } I'm not sure how to go about approaching this since there can be multiples of certain items (audio, buttons) and also two items are sort-of-optional in the sense that there can be ONE or the OTHER (video/still). For example, is this something that I should just avoid passing as parameters altogether, using a different approach (getters/setters, maybe)?

    Read the article

  • Is the a pattern for iterating over lists held by a class (dynamicly typed OO languages)

    - by Roman A. Taycher
    If I have a class that holds one or several lists is it better to allow other classes to fetch those lists(with a getter) or to implement a doXList/eachXList type method for that list that take a function and call that function on each element of the list contained by that object. I wrote a program that did a ton of this and I hated passing around all these lists sometimes with method in class a calling method in class B to return lists contained in class C, B contains a C or multiple C's (note question is about dynamically typed OO languages languages like ruby or smalltalk) ex. (that came up in my program) on a Person class containing scheduling preferences and a scheduler class needing to access them.

    Read the article

  • Coldfusion CFC creation taking a variable amout of time to execute.

    - by Bazza
    I've been doing some logging of object creation times in our open account process in production. Periodically, initializing an object would take way longer than expected. By initializing I mean calling it's init() and passing a couple of arguments that may be simple variables or objects. e.g. <cfset validateObj = createObject("component", "compExample").init( productionMode = VARIABLES.productionMode, ipWhiteListed = isWhiteListed, ipLocatorObj = VARIABLES.ipLocatorObj ) /> Thats all that happens in init() methods. Generally the execution time would be 0ms, but at random times I might get 3 or 3.5 seconds. This is not specific to one particular server or to our generally busy period. It appears to be quite random. One thought was that these templates were being evicted from our template cache as they are not especially frequently used, although I checked cfstat on a number of servers and the max CP/Sec is -1. Running CF 8,0,1 Has anybody else ever come across this?

    Read the article

  • Filtering results and pagination

    - by alj
    I have a template that shows a filter form and below it a list of the result records. I bind the form to the request so that the filter form sets itself to the options the user submitted when the results are returned. I also use pagination. Using the code in the pagination documentation means that when the user clicks for the next page, the form data is lost. What is the best way of dealing with pagination and filtering in this way? Passing the querystring to the paginiation links. Change the pagination links to form buttons and therefore submit the filter form at the same time, but this assumes that the user hasn't messed about with the filter options. As above but with the original data as hidden fields. ALJ

    Read the article

  • Matlab: Randomize and Split

    - by Null-Hypothesis
    I have following data matrix in Matlab, I am trying to actually split this into multiple segments by passing a variable to a matlab function. But before splitting I would like to shuffle the matrix. The size of my matrix is 150X4 s.data 5.1000 3.5000 1.4000 0.2000 4.9000 3.0000 1.4000 0.2000 4.7000 3.2000 1.3000 0.2000 4.6000 3.1000 1.5000 0.2000 5.0000 3.6000 1.4000 0.2000 .. s = data: [150x4 double] labels: [150x1 double] Coming from R environment I find MatLab is very strange. Initially I thought the columns in matrix has a relationshop like in a R dataframe but thats wrong in my assumption.

    Read the article

  • What is the best way to detect Copy (Ctrl+C) event in an IWpfTextView?

    - by Nick U
    I am trying to detect a copy event in the text view and I have been researching the best way to do this. Is it to possibly hook into the StandardCommand Copy event somehow and detect it that way? Or is it possible to use the KeyProcessor(and simply detect Ctrl+C keypresses)? My extension is currently implementing the IWpfTextViewCreationListener; is there a way to somehow get access to the KeyProcessor or StandardCommand from the IWpfTextView that the listener is passing to me? If so, can you post a code sample that demonstrates this? Thanks, Nick

    Read the article

  • Javascript function as a parameter to another function?

    - by Alex
    Hello there, I'm learning lots of javascript these days, and one of the things I'm not quite understanding is passing functions as parameters to other functions. I get the concept of doing such things, but I myself can't come up with any situations where this would be ideal? My question is: When do you want to have your javascript functions take another function as a parameter? Why not just assign a variable to that functions return value and pass that variable to the function like so: // Why not do this var foo = doStuff(params); callerFunction(foo); //instead of this callerFunction(doStuff); I'm confused as to why I would ever choose to do things as in my second example. Why would you do this? What are the use cases? Thanks!!

    Read the article

  • orbean forms bulder + custom persistance api: Why does it call /crud/.../data/data.xml?

    - by yankee
    I am currently implementing my own persistence layer for orbeon forms. As far as I have understood the virtual hierachy of data, creating a form with form builder in the application "myapp" with the name "myform" should cause the form builder to call /crud/myapp/myform/form/form.xhtml, passing the newly created form as HTTP-PUT data. Thus I created a spring method annotated with: @RequestMapping(method = RequestMethod.PUT, value = "/crud/{applicationName}/{formName}/form/form.xhtml") public void saveForm(@PathVariable String formName, @RequestBody String putData) I expected this method to be called with my form. But this method does not get called. Instead the method @RequestMapping(method = RequestMethod.PUT, value = "/crud/{applicationName}/{formName}/data/{uuid}/data.xml") public void saveInstance(@PathVariable String uuid, @RequestBody String putData) gets called. Put data contains the full xhtml form. Why is this happening? I thought that the second URL would only be called for saving an instance, more specifically the <xforms:instance id="fr-form-instance"> part of a form, once I fill in values for a form.

    Read the article

  • How do set default values in django for an HttpRequest.GET?

    - by Mike
    I have a webpage that displays data based on a default date. The user can then change their view of the data by slecting a date with a date picker and clicking a submit button. I already have a variable set so that if no date is chosen, a default date is used.... so what's the problem? The problem comes if the user trys to type in the url page without a parameter... like so: http://mywebpage/viewdata (example A) instead of http://mywebpage/viewdata?date= (example B) I tried using: if request.method == 'GET': but apparently, even example A still returns true. I'm sure I'm doing some obvious beginner's mistake but I'll ask anyway... Is there a simpler way to handle example A other than passing the url to a string and checking the string for "?date="?

    Read the article

  • Question regarding two dimensional array

    - by Sherwood Hu
    I have some problems using two dimensional array in the code and need some help. static const int PATTERNS[20][4]; static void init_PATTERN() { // problem #1 int (&patterns)[20][4] = const_cast<int[20][4]>(PATTERNS); ... } extern void UsePattern(int a, const int** patterns, int patterns_size); // problem #2 UsePattern(10, PATTERNS, sizeof(PATTERNS)/sizeof(PATTERNS[0])); in the first statement, I need to cast the const off the two dimensional array PATTERNS. The reason for this is that the init function is called only once, and in the remaining code, PATTERNS is strictly read-only. In the second statement, I need to pass PATTERNS array to the int** argument. Direct passing resulted a compile error. Thanks!

    Read the article

  • better way of handling nested list

    - by laspal
    Hi, I have list my_list = [ [1,2,3,4,5,6], [1,3,4],[34,56,56,56]] for item in my_list: var1,var2,var3,var4,var5,var6 = None if len(item) ==1: var1 = item[0] if len(item) == 2: var1 = item[0] var2 = item[1] if len(item) == 3: var1 = item[0] var2 = item[1] var3 = item[2] if len(item) == 4: var1 = item[0] var2 = item[1] var3 = item[2] var4 = item[3] fun(var1,var2,var3,var4,var5,var6) I have a function def fun(var1, var2 = None, var3 = None, var4 = None, var5=None, var6= None) Depending upon the values in my inner list. I am passing it to function. I hope I made it clear. Thanks

    Read the article

  • Struct size containing vector<T> different sizes between DLL and EXE..

    - by Michael Peddicord
    I have this situation where an EXE program imports a DLL for a single function call. It works by passing in a custom structure and returning a different custom structure. Up till now it's worked fine until I wanted one of the structs data members to be a vector < MyStruct When I do a sizeof(vector< MyStruct ) in my program I get a size of 20 but when I do it from inside the DLL I get a size of 24. This size inconsistency is causing a ESP pointer error. Can anyone tell me why a Vector < MyStruct would be a different size in the DLL than in the program? I have reverified that my structs in both the DLL and the Program are identical. I would appreciate any help on the subject. Thank you.

    Read the article

  • How do I pass a function to NUnit Throws.Constraints?

    - by Serge Belov
    I'm trying to write some NUnit tests in F# and having trouble passing a function to the ThrowsConstraint. A distilled (non)working sample is below. open System.IO open NUnit.Framework [<TestFixture>] module Example = [<Test>] let foo() = let f = fun () -> File.GetAttributes("non-existing.file") Assert.That(f, Throws.TypeOf<FileNotFoundException>()) This compiles just fine but I get the following from the NUnit test runner: FsTest.Tests.Example.foo: System.ArgumentException : The actual value must be a TestDelegate but was f@11 Parameter name: actual While I'm able to work around the problem using ExpectedException attribute, my question is what is the correct way of using an F# function in this situation?

    Read the article

  • IE7 Times Out Debugging ASP.Net Page

    - by Eric J.
    My issue is similar to ASP.NET Debugging Timing out with IIS except that I'm using the built-in ASP.Net Development Server with VS 2010. If I pause for more than about 10 seconds in the debugger, IE7 "disconnects" from the web server with the error message Internet Explorer cannot display the webpage However, unlike in the similar question, the debugger is still running. If I refresh the browser it will post that refresh to the server and I can debug the page from the top again. Is it possible to configure things so that IE7 waits (much) longer before giving up? If it makes a difference, I'm launching IE using the "Start external program" option and passing a localhost URL as the command line argument (since Chrome is my default browser). I also specify a specific port.

    Read the article

  • NTLM Authentication fails ONLY with IE against 2k8 App server behind 2k8 IIS7 Reverse Proxy

    - by CptSkippy
    I'm developing an ASP.NET application for an intranet site that is using Windows/NTLM/WIA/whatever authentication. The application is hosted on a Windows 2k8 server but is accessed through a Reverse Proxy using IIs7 on another 2k8 machine. Authentication works fine in FireFox, Chrome and Safari but fails in IE8. If I circumvent the Proxy and access the application server directly then it works fine so it has something to do with proxy. There's nothing in the Event Viewer on any of the 3 machines to indicate what might be happening. If you connect using IE8 it prompts for your credentials instead of automatically passing them, yes I've setup an explicit trust over an above the domain trust, but it still errors out with a 401 error returned from the proxy. Any ideas where to start troubleshooting this?

    Read the article

  • Catching the redirected address from NSURLConnection

    - by Vic
    I'm working on a software which follows the HTTP redirection which is dynamically calculated by the server depending on a pparameter. I don't want to show the primary server in Mobile Safari but rather the redirected address only. The following code workks: request = [NSMutableURLRequest requestWithURL:originalUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; // Extract the redirected URL target = [response URL]; The problem is that the server requires several seconds to answer. The sendSynchronousRequest blocks the app for this time completely which is messy, I can't even display the "Busy" animation. Does anyone know how I can retrieve the redirected address asynchronously without safari appearance in the meanwhile with the redirecting server URL or display some sort of the "Be patient" animation during the sendSynchronousRequest? What disadvantages would have the passing of sendSynchronousRequest in another thread?

    Read the article

  • Storing datetime in database?

    - by Curtis White
    I'm working on a blog and want to show my posts in eastern time zone. i figured that storing everything UTC would be the proper way. This creates a few challenges though: I have to convert all times from UTC to Eastern. This is not a biggie but adds a lot of code. And the "biggie" is that I use a short-date time to reference the posts by passing in a query, ala blogger. The problem is that there is no way to convert the short date time to the proper UTC date because I'm lacking the posted time info. Hmm, any problem to just storing all dates in eastern time? This would certainly make it easier for the rest of the application but if I needed to change time zones everything would be stored wrong.

    Read the article

  • Cuda program results are always zero in HW, correct in EMU??

    - by Orion Nebula
    Hi all! I am having a weird problem .. I have written a CUDA code which executes correctly in emulation and all results show up.. however, when executed on hardware "G210" .. the results in the result memory are always 0 I am passing two vectors to the kernel, one with random variables the other is initialized to zero, the code copies the first vector to shared memory, does some swapping and other operations and then writes back the results on the second vector (the one with the initial 0's) I am using double precision, the -arch sm13 flag is used, all memory allocation also use sizeof(double) .. I have checked if the kernel is invoked, it does .. so no problems here .. the cudaMemCpy has no problems .. what could be the problem .. :( why would it work in emulation but not on HW I am quite confused .. any ideas?

    Read the article

  • Need to pass the registry path along with launch parameter ...

    - by velusbits
    I have a situation that demands, passing the registry path as a parameter for application launch, say I have IE as default launcher for http types HKEY_CLASSES_ROOT\http\shell\open\command\ Default = iexplore %1 Any shell launch of a URL would invoke iexplore <<"URL String". My requirement is additionally pass the registry path as parameter, so when a launch happens (note no change in the launch) iexplore <<"URL String" should translate into something like iexplore <<"URL String" "HKEY_CLASSES_ROOT\http\shell\open\command\" How should my registry key HKEY_CLASSES_ROOT\http\shell\open\command\ modified so as to get the extra registry path appended for all shell launches ? Any idea is appreciated, Thanks !

    Read the article

  • Is converting this ArrayList to a Generic List efficient?

    - by Greg
    The code I'm writing receives an ArrayList from unmanaged code, and this ArrayList will always contain one or more objects of type Grid_Heading_Blk. I've considered changing this ArrayList to a generic List, but I'm unsure if the conversion operation will be so expensive as to nullify the benefits of working with the generic list. Currently, I'm just running a foreach (Grid_Heading_Blk in myArrayList) operation to work with the ArrayList contents after passing the ArrayList to the class that will use it. Should I convert the ArrayList to a generic typed list? And if so, what is the most efficient way of doing so?

    Read the article

< Previous Page | 157 158 159 160 161 162 163 164 165 166 167 168  | Next Page >