Search Results

Search found 253 results on 11 pages for 'dean richardson'.

Page 7/11 | < Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >

  • .net List<string>.Remove bug Should I submit a MS Connect bug report on this?

    - by Dean Lunz
    So I was beating my head against a wall for a while before it dawned on me. I have some code that saves a list of names into a text file ala ... System.IO.File.WriteAllLines(dlg.FileName, this.characterNameMasterList.Distinct().ToArray()); The character names can contain special characters. These names come from the wow armory at www.wowarmory.com There are about 26000 names or so saved in the .txt file. The names get saved to the .txt file just fine. I wrote another application that reads these names from that .txt file using this code // download the names from the db var webNames = this.DownloadNames("character"); // filter names and get ones that need to be added to the db var localNames = new List<string>(System.IO.File.ReadAllLines(dlg.FileName)); foreach (var name in webNames) { if (localNames.Contains(name.Trim())) localNames.Remove(name); } return localNames; ... the code downloads a list of names from my website that are already in the db. Then reads the local .txt file and singles out every name that is not yet in the db so it can later add it. The names that get read from the .txt file also get read just fine with no problems. The problem comes in when removing names from the localNames list. localNames is a List type. As soon as localNames.Remove(name) gets called any names in the list that had special characters in them would get corrupted and be converted into ? characters. See for screen cap http://yfrog.com/12badcharsp So i tried doing it another way using ... // download the names from web that are already in the db var webNames = this.DownloadNames("character"); // filter names and get ones that need to be added to the db var localNames = new List<string>(System.IO.File.ReadAllLines(dlg.FileName)); int index = 0; while (index < webNames.Count) { var name = webNames[index++]; var pos = localNames.IndexOf(name.Trim()); if (pos != -1) localNames.RemoveAt(pos); } return localNames; .. But using localNames.RemoveAt also corrupts the items in the list converting special characters into ?. So is this a known bug with the List.remove methods? Does anyone know? Has anyone else had this problem? I also used .NET Reflector to disassemble/inspect the list.remove and list.RemoveAt code and it appear to be calling some external Copy function. Aside from the fact that this is prob not the best way to get a unique list of items from 2 lists am I missing something or should be aware of when using the List.Remove methods ? I am running windows 7 vs2010 and my app is set for .net 4 (no client profile )

    Read the article

  • Manipulate multiple check boxes by ID using unobtrusive java script?

    - by Dean
    I want to be able to select multiple check boxes onmouseover, but instead of applying onmouseover to every individual box, I've been trying to work out how to do so by manipulating check boxes by ID instead, although I'm not sure where to go from using getElementById,. So instead of what you see below. <html> <head> <script> var Toggle = true; var Highlight=false; function handleKeyPress(evt) { var nbr; if (window.Event) nbr = evt.which; else nbr = event.keyCode; if(nbr==16)Highlight=true; return true; } function MakeFalse(){Highlight=false;} function SelectIt(X){ if(X.checked && Toggle)X.checked=false; else X.checked=true; } function ChangeText() { var test1 = document.getElementById("1"); test1.innerHTML = "onmouseover=SelectIt(this)" } </script> </head> <body> <form name="A"> <input type="checkbox" name="C1" onmouseover="SelectIt(this)" id="1"><br> <input type="checkbox" name="C2" onmouseover="SelectIt(this)" id="2"><br> <input type="checkbox" name="C3" onmouseover="SelectIt(this)" id="3"><br> <input type="checkbox" name="C4" onmouseover="SelectIt(this)" checked="" disabled="disabled" id="4"><br> <input type="checkbox" name="C5" onmouseover="SelectIt(this)" id="5"><br> <input type="checkbox" name="C6" onmouseover="SelectIt(this)" id="6"><br> <input type="checkbox" name="C7" onmouseover="SelectIt(this)" id="7"><br> <input type="checkbox" name="C8" onmouseover="SelectIt(this)" id="8"><br> </form> </body> </html> I want to be able to apply the onmousover effect to an array of check boxes like this <form name="A"> <input type="checkbox" name="C1" id="1"><br> <input type="checkbox" name="C2" id="2"><br> <input type="checkbox" name="C3" id="3"><br> <input type="checkbox" name="C4" checked="" disabled="disabled" id="4"><br> <input type="checkbox" name="C5" id="5"><br> <input type="checkbox" name="C6" id="6"><br> <input type="checkbox" name="C7" id="7"><br> <input type="checkbox" name="C8" id="8"><br> </form> After trying the search feature of stackoverflow.com and looking around on Google I haven't been able to a find a solution that makes sense to me thus far, although I'm still in the process of learning so I fear I might be trying to do something too advanced for my level of knowledge.

    Read the article

  • How are you using IronPython?

    - by Will Dean
    I'm keen to drink some modern dynamic language koolaid, so I've believed all the stuff on Michael Foord's blog and podcasts, I've bought his book (and read some of it), and I added an embedded IPy runtime to a large existing app a year or so ago (though that was for someone else and I didn't really use it myself). Now I need to do some fairly simple code generation stuff, where I'm going to call a few methods on a few .net objects (custom, C#-authored objects), create a few strings, write some files, etc. The experience of trying this leaves me feeling like the little boy who thinks he's the only one who can see that The Emperor has no clothes on. If you're using IronPython, I'd really appreciate knowing how you deal with the following aspects of it: Code editing - do you use the .NET framework without Intellisense? Refactoring - I know a load of 'refactoring' is about working around language-related busywork, so if Python is sufficiently lightweight then we won't need that, But things like renames seem to me to be essential to iteratively developing quality code regardless of language. Crippling startup time - One of the things which is supposed to be good about interpreted languages is the lack of compile time leading to fast interactive development. Unfortunately I can compile a C# application and launch it quicker than IPy can start up. Interactive hacking - the IPy console/repl is supposed to be good for this, but I haven't found a good way to take the code you've interactively arrived at and persist it into a file - cut and paste from the console is fairly miserable. And the console seems to hold references to .NET assemblies you've imported, so you have to quit it and restart it if you're working on the C# stuff as well. Hacking on C# in something like LinqPad seems a much faster and easier way to try things out (and has proper Intellisense). Do you use the console? Debugging - what's the story here? I know someone on the IPy team is working on a command-line hobby-project, but let's just say I'm not immediately attracted to a command line debugger. I don't really need a debugger from little Python scripts, but I would if I were to use IPy for scripting unit tests, for example. Unit testing - I can see that dynamic languages could be great for this, but is there any IDE test-runner integration (like for Resharper, etc). The Foord book has a chapter about this, which I'll admit I have not yet read properly, but it does seem to involve driving a console-mode test-runner from the command prompt, which feels to be an enormous step back from using an integrated test runner like TestDriven.net or Resharper. I really want to believe in this stuff, so I am still working on the assumption that I've missed something. I would really like to know how other people are dealing with IPy, particularly if they're doing it in a way which doesn't feel like we've just lost 15 years'-worth of tool development.

    Read the article

  • Does the 80/20 rule of time management apply to developers?

    - by Dean
    Jeff's recent article linked to a time management example of the First Fit Decreasing algorithm, which talked about the Pareto principle (or, the 80/20 rule) of time management, that is, that 80% of the work we produce in 20% of our time. Now we've all heard the programmer quote: The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. But all jokes aside, it is often as if 20% of your code is to do what you want, and the other 80% is to handle exceptions... so does the 80/20 rule really apply to developers? Does anyone have any examples of why it does / does not apply to us?

    Read the article

  • Open Source Log Aggregators?

    - by Dean J
    I have sixteen servers using Log4J logs, accessible by ssh. I want to see the output of all logs on my desktop machine. Apache Chainsaw can presumably do this, but the documentation isn't getting me there. "Put all the jars into your ~/.chainsaw directory", got that. "Chainsaw will automatically use the functionality in those JARs"? Nope. Chainsaw isn't picking up log4j-chainsaw-vfs.jar, by the look of it, so sftp is out. Any suggestions other than Chainsaw?

    Read the article

  • using the data-custom="" to bind to events

    - by Dean Peterson
    I'm pretty sure I'm gonna get slammed on this. I love using the data-whatever attribute to bind events to. It feels very clean to me and helps reserve my class attribute for just styling. I know this selector is among the slowest, so I don't use it when there are a lot of elements. Would love to hear compelling arguments against this. $("body").delegate("[data-action]", "click", function(){ var action = $(this).attr("data-action"); //route action to appropriate function });

    Read the article

  • How to use pure in D 2.0

    - by James Dean
    While playing around with D 2.0 I found the following problem: Example 1: pure string[] run1() { string[] msg; msg ~= "Test"; msg ~= "this."; return msg; } This compiles and works as expected. When I try to wrap the string array in a class I find I can not get this to work: class TestPure { string[] msg; void addMsg( string s ) { msg ~= s; } }; pure TestPure run2() { TestPure t = new TestPure(); t.addMsg("Test"); t.addMsg("this."); return t; } This code will not compile because the addMsg function is impure. I can not make that function pure since it alters the TestPure object. Am i missing something? Or is this a limitation? The following does compile: pure TestPure run3() { TestPure t = new TestPure(); t.msg ~= "Test"; t.msg ~= "this."; return t; } Would the ~= operator not been implemented as a impure function of the msg array? How come the compiler does not complain about that in the run1 function?

    Read the article

  • Java - Console-like web applet.

    - by Dean
    Hey, I've been developing an application in the windows console with Java, and want to put it online in all of its console-graphics-glory. Is there a simple web applet API I can use to port my app over? I'm just using basic System.out and System.in functionality, but I'm happy to rebuild my I/O wrappers. I think something along these lines would be a great asset to any beginning Java developers who want to put their work online.

    Read the article

  • PHP: Writing non-english characters to XML - encoding problem

    - by Dean
    Hello, I wrote a small PHP script to edit the site news XML file. I used DOM to manipulate the XML (Loading, writing, editing). It works fine when writing English characters, but when non-English characters are written, PHP throws an error when trying to load the file. If I manually type non-English characters into the file - it's loaded perfectly fine, but if PHP writes the non-English characters the encoding goes wrong, although I specified the utf-8 encoding. Any help is appreciated. Errors: Warning: DOMDocument::load() [domdocument.load]: Entity 'times' not defined in filepath Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0x91 0x26 0x74 0x69 in filepath Here are the functions responsible for loading and saving the file (self-explanatory): function get_tags_from_xml(){ // Load news entries from XML file for display $errors = Array(); if(!$xml_file = load_news_file()){ // Load file // String indicates error presence $errors = "file not found"; return $errors; } $taglist = $xml_file->getElementsByTagName("text"); return $taglist; } function set_news_lang(){ // Sets the news language global $news_lang; if($_POST["news-lang"]){ $news_lang = htmlentities($_POST["news-lang"]); } elseif($_GET["news-lang"]){ $news_lang = htmlentities($_GET["news-lang"]); } else{ $news_lang = "he"; } } function load_news_file(){ // Load XML news file for proccessing, depending on language global $news_lang; $doc = new DOMDocument('1.0','utf-8'); // Create new XML document $doc->load("news_{$news_lang}.xml"); // Load news file by language $doc->formatOutput = true; // Nicely format the file return $doc; } function save_news_file($doc){ // Save XML news file, depending on language global $news_lang; $doc->saveXML($doc->documentElement); $doc->save("news_{$news_lang}.xml"); } Here is the code for writing to XML (add news): <?php ob_start()?> <?php include("include/xml_functions.php")?> <?php include("../include/functions.php")?> <?php get_lang();?> <?php //TODO: ADD USER AUTHENTICATION! if(isset($_POST["news"]) && isset($_POST["news-lang"])){ set_news_lang(); $news = htmlentities($_POST["news"]); $xml_doc = load_news_file(); $news_list = $xml_doc->getElementsByTagName("text"); // Get all existing news from file $doc_root_element = $xml_doc->getElementsByTagName("news")->item(0); // Get the root element of the new XML document $new_news_entry = $xml_doc->createElement("text",$news); // Create the submited news entry $doc_root_element->appendChild($new_news_entry); // Append submited news entry $xml_doc->appendChild($doc_root_element); save_news_file($xml_doc); header("Location: /cpanel/index.php?lang={$lang}&news-lang={$news_lang}"); } else{ header("Location: /cpanel/index.php?lang={$lang}&news-lang={$news_lang}"); } ?> <?php ob_end_flush()?>

    Read the article

  • Custom Java events with listeners vs. a JMS based implementation?

    - by Joe Dean
    My application requires events to be fired based on some specific activities that happen. I'm trying to determine if I should create my own event handling system using the Java EventObject with custom listeners similar to Java AWT Or should I use a JMS implementation? I was considering either apache's Qpid or ActiveMQ solution. I'm exploring these options at the moment and was wondering if anyone has experience with Qpid or ActiveMQ and can offer some advise (e.g., pros, cons to consider, etc) Also, if anyone has any suggestions for building a simple event handling system... if it's even worth while to consider this over a JMS based solution.

    Read the article

  • USB windows xp final USB access issues

    - by Lex Dean
    I basically understand you C++ people, Please do not get distracted because I'm writing in Delphi. I have a stable USB Listing method that accesses all my USB devices I get the devicepath, and this structure: TSPDevInfoData = packed record Size: DWORD; ClassGuid: TGUID; DevInst: DWORD; // DEVINST handle Reserved: DWord; end; I get my ProductID and VenderID successfully from my DevicePath Lists all USB devices connected to the computer at the time That enables me to access the registry data to each device in a stable way. What I'm lacking is a little direction Is friendly name able to be written inside the connected USB Micro chips by the firmware programmer? (I'm thinking of this to identify the device even further, or is this to help identify Bulk data transfer devices like memory sticks and camera's) Can I use SPDRP_REMOVAL_POLICY_OVERRIDE to some how reset these polices What else can I do with the registry details. Identifying when some one unplugs a device The program is using (in windows XP standard) I used a documented windows event that did not respond. Can I read a registry value to identify if its still connected? using CreateFileA (DevicePath) to send and receive data I have read when some one unplugs in the middle of a data transfer its difficult clearing resources. what can IoCreateDevice do for me and how does one use it for that task This two way point of connection status and system lock up situations is very concerning. Has some one read anything about this subject recently? My objectives are to 1. list connected USB devices identify a in development Micro Controller from everything else send and receive data in a stable and fast way to the limits of the controller No lock up's transferring data Note I'm not using any service packs I understand everything USB is in ANSI when windows xp is not and .Net is all about ANSI (what a waste of memory) I plan to continue this project into a .net at a later date as an addition. MSDN gives me Structures and Functions and what should link to what ok but say little to what they get used for. What is available in my language Delphi is way over priced that it needs a major price drop.

    Read the article

  • C++0x Overload on reference, versus sole pass-by-value + std::move?

    - by dean
    It seems the main advice concerning C++0x's rvalues is to add move constructors and move operators to your classes, until compilers default-implement them. But waiting is a losing strategy if you use VC10, because automatic generation probably won't be here until VC10 SP1, or in worst case, VC11. Likely, the wait for this will be measured in years. Here lies my problem. Writing all this duplicate code is not fun. And it's unpleasant to look at. But this is a burden well received, for those classes deemed slow. Not so for the hundreds, if not thousands, of smaller classes. ::sighs:: C++0x was supposed to let me write less code, not more! And then I had a thought. Shared by many, I would guess. Why not just pass everything by value? Won't std::move + copy elision make this nearly optimal? Example 1 - Typical Pre-0x constructor OurClass::OurClass(const SomeClass& obj) : obj(obj) {} SomeClass o; OurClass(o); // single copy OurClass(std::move(o)); // single copy OurClass(SomeClass()); // single copy Cons: A wasted copy for rvalues. Example 2 - Recommended C++0x? OurClass::OurClass(const SomeClass& obj) : obj(obj) {} OurClass::OurClass(SomeClass&& obj) : obj(std::move(obj)) {} SomeClass o; OurClass(o); // single copy OurClass(std::move(o)); // zero copies, one move OurClass(SomeClass()); // zero copies, one move Pros: Presumably the fastest. Cons: Lots of code! Example 3 - Pass-by-value + std::move OurClass::OurClass(SomeClass obj) : obj(std::move(obj)) {} SomeClass o; OurClass(o); // single copy, one move OurClass(std::move(o)); // zero copies, two moves OurClass(SomeClass()); // zero copies, one move Pros: No additional code. Cons: A wasted move in cases 1 & 2. Performance will suffer greatly if SomeClass has no move constructor. What do you think? Is this correct? Is the incurred move a generally acceptable loss when compared to the benefit of code reduction?

    Read the article

  • Is there really such a thing as a char or short in modern programming?

    - by Dean P
    Howdy all, I've been learning to program for a Mac over the past few months (I have experience in other languages). Obviously that has meant learning the Objective C language and thus the plainer C it is predicated on. So I have stumbles on this quote, which refers to the C/C++ language in general, not just the Mac platform. With C and C++ prefer use of int over char and short. The main reason behind this is that C and C++ perform arithmetic operations and parameter passing at integer level, If you have an integer value that can fit in a byte, you should still consider using an int to hold the number. If you use a char, the compiler will first convert the values into integer, perform the operations and then convert back the result to char. So my question, is this the case in the Mac Desktop and IPhone OS environments? I understand when talking about theses environments we're actually talking about 3-4 different architectures (PPC, i386, Arm and the A4 Arm variant) so there may not be a single answer. Nevertheless does the general principle hold that in modern 32 bit / 64 bit systems using 1-2 byte variables that don't align with the machine's natural 4 byte words doesn't provide much of the efficiency we may expect. For instance, a plain old C-Array of 100,000 chars is smaller than the same 100,000 ints by a factor of four, but if during an enumeration, reading out each index involves a cast/boxing/unboxing of sorts, will we see overall lower 'performance' despite the saved memory overhead?

    Read the article

  • How can I use a new Perl module without install permissions?

    - by James Dean
    Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the Parallel::ForkManager Perl module from CPAN How do I use this Parallel::ForkManager without doing a central install? Is there an environment variable that I can set so it is located? Thanks JD

    Read the article

  • Why can't I save CSS changes in FireBug?

    - by Dean
    FireBug is the most convenient tool I've found for editing CSS - so why isn't there a simple "Save" option? I am always finding myself making tweaks in FireBug, then going back to my original .css file and replicating the tweaks. Has anyone come up with a better solution? EDIT: I'm aware the code is stored on a server (in most cases not my own), but I use it when building my own websites. Firebug's just using the .css file FireFox downloaded from the server, it knows precisely what lines in which files its editing, I can't see why there's not an "Export" or "Save" option which allows you to store the new .css file. (Which I could then replace the remote one with). I have tried looking in temporary locations, and choosing file-save and experimenting with the output options on FireFox, but I still haven't found a way. Here's hoping someone has a nice solution... EDIT 2: The Official Group has a lot of questions, but no answers.

    Read the article

  • Display Ajax Loader while page rendering

    - by Dean
    This is probably a simple question but how can I best use an AJAX loader in ASP.NET to provide a loading dialog whilst the page is being built? I currently have an UpdatePanel with an associated UpdateProgressPanel which contains the loading message and gif in a ProgressTemplate. Currently I have a page that onLoad() goes and gets the business entities and then displays them. While it is doing this I would like to display an AJAX loader. Would it be better to have nothing in the page load and have a hidden button that is triggered onLoadComplete or unLoad() which would then wait for the button click method to complete displaying the UpdateProgressPanel?

    Read the article

  • Loop through a Map with JSTL

    - by Dean
    I'm looking to have JSTL loop through a Map and output the value of the key and it's value. For example I have a Map which can have any number of entries, i'd like to loop through this map using JSTL and output both the key and it's value. I know how to access the value using the key, ${myMap['keystring']}, but how do I access the key?

    Read the article

  • Best way to detect duplicates when using Spring Hibernate Template

    - by Dean Povey
    We have an application which needs to detect duplicates in certain fields on create. We are using Hibernate as our persistence layer and using Spring's HibernateTemplate. My question is whether it is better to do so an upfront lookup for the item before creating, or to attempt to catch the DataIntegrityViolation exception and then check if this is caused by a duplicate entry.

    Read the article

  • SOAP security in Salesforce

    - by Dean Barnes
    I am trying to change the wsdl2apex code for a web service call header that currently looks like this: <env:Header> <Security xmlns="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"> <UsernameToken Id="UsernameToken-4"> <Username>test</Username> <Password>test</Password> </UsernameToken> </Security> </env:Header> to look like this: <soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-4" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>Test</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Test</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> One problem is that I can't work out how to change the namespaces for elements (or even if it matters what name they have). A secondary problem is putting the Type attribute onto the Password element. Can any provide any information that might help? Thanks

    Read the article

  • How to generate a Makefile with source in sub-directories using just one makefile.

    - by James Dean
    I have source in a bunch of subdirectories like: src/widgets/apple.cpp src/widgets/knob.cpp src/tests/blend.cpp src/ui/flash.cpp In the root of the project I want to generate a single Makefile using a rule like: %.o: %.cpp $(CC) -c $< build/test.exe: build/widgets/apple.o build/widgets/knob.o build/tests/blend.o src/ui/flash.o $(LD) build/widgets/apple.o .... build/ui/flash.o -o build/test.exe When I try this it does not find a rule for build/widgets/apple.o. Can I change something so that the %.o: %.cpp is used when it needs to make build/widgets/apple.o ?

    Read the article

  • Best programming language for a beginner to learn?

    - by Dean
    I am teaching my friend how to program in C, he has no programming experience. He wants to learn C so that he can program different microprocessors. I have suggested he learn another language something like java or ruby so that he can learn basics before moving on to a language like C. Is this advisable or should i just teach him C?

    Read the article

  • What is the process of turning HTML into Postscript programmatically

    - by Dean
    I am trying to understand what the process is of turning HTML into a PDF/Postscript programmatically All Google searches turn up libraries to do this, but I am more interested in the actual process required. I know you could just set up a Postscript printer and print directly to that, but some of these libraries appear to create the PDF on the fly to allow previews etc. has anyone had any experience in this, or can provide any guidance?

    Read the article

  • Generic Lists copying references rather than creating a copiedList

    - by Dean
    I was developing a small function when trying to run an enumerator across a list and then carry out some action. (Below is an idea of what I was trying to do. When trying to remove I got a "Collection cannot be modified" which after I had actually woken up I realised that tempList must have just been assigned myLists reference rather than a copy of myLists. After that I tried to find a way to say tempList = myList.copy However nothing seems to exist?? I ended up writing a small for loop that then just added each item from myLsit into tempList but I would have thought there would have been another mechanism (like clone??) So my question(s): is my assumption about tempList receiving a reference to myList correct How should a list be copied to another list? private myList as List (Of something) sub new() myList.add(new Something) end sub sub myCalledFunction() dim tempList as new List (Of Something) tempList = myList Using i as IEnumerator = myList.getEnumarator while i.moveNext 'if some critria is met then tempList.remove(i.current) end end using end sub

    Read the article

  • ZendX jQuery Autocomplete not working in framework

    - by Jan-Dean Fajardo
    I added the ZendX library. Added the helper in controller: public function init() { $this->view->addHelperPath( 'ZendX/JQuery/View/Helper' ,'ZendX_JQuery_View_Helper'); } Created a form for view page: public function indexAction() { // Filter form $this->view->autocompleteElement = new ZendX_JQuery_Form_Element_AutoComplete('txtLocation'); $this->view->autocompleteElement->setAttrib('placeholder', 'Search Location'); $this->view->autocompleteElement->setJQueryParam('data', array('Manila', 'Pasay', 'Mandaluyong', 'Pasig', 'Marikina','Makati')); } Load jQuery and form in view page. <?php echo $this->jQuery(); ?> <form> <?php echo $this->autocompleteElement; ?> </form> The form is visible in the view page. But the autocomplete isn't working. I even don't see any jQuery script in the source page. Have I missed something?

    Read the article

  • What's a good way to provide additional decoration/metadata for Python function parameters?

    - by Will Dean
    We're considering using Python (IronPython, but I don't think that's relevant) to provide a sort of 'macro' support for another application, which controls a piece of equipment. We'd like to write fairly simple functions in Python, which take a few arguments - these would be things like times and temperatures and positions. Different functions would take different arguments, and the main application would contain user interface (something like a property grid) which allows the users to provide values for the Python function arguments. So, for example function1 might take a time and a temperature, and function2 might take a position and a couple of times. We'd like to be able to dynamically build the user interface from the Python code. Things which are easy to do are to find a list of functions in a module, and (using inspect.getargspec) to get a list of arguments to each function. However, just a list of argument names is not really enough - ideally we'd like to be able to include some more information about each argument - for instance, it's 'type' (high-level type - time, temperature, etc, not language-level type), and perhaps a 'friendly name' or description. So, the question is, what are good 'pythonic' ways of adding this sort of information to a function. The two possibilities I have thought of are: Use a strict naming convention for arguments, and then infer stuff about them from their names (fetched using getargspec) Invent our own docstring meta-language (could be little more than CSV) and use the docstring for our metadata. Because Python seems pretty popular for building scripting into large apps, I imagine this is a solved problem with some common conventions, but I haven't been able to find them.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >