Search Results

Search found 20383 results on 816 pages for 'hello'.

Page 26/816 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Python sys.argv lists and indexes

    - by Fred Gerbig
    In the below code I understand that sys.argv uses lists, however I am not clear on how the index's are used here. def main(): if len(sys.argv) >= 2: name = sys.argv[1] else: name = 'World' print 'Hello', name if __name__ == '__main__': main() If I change name = sys.argv[1] to name = sys.argv[0] and type something for an argument it returns: Hello C:\Documents and Settings\fred\My Documents\Downloads\google-python-exercises \google-python-exercises\hello.py Which kind of make sense. Can someone explain how the 2 is used here: if len(sys.argv) >= 2: And how the 1 is used here: name = sys.argv[1]

    Read the article

  • Executing a dynamically bound function in Clojure

    - by Carl Smotricz
    I'd like to pre-store a bunch of function calls in a data structure and later evaluate/execute them from within another function. This works as planned for functions defined at namespace level with defn (even though the function definition comes after my creation of the data structure) but will not work with functions defined by let [name (fn or letfn inside the function. Here's my small self-contained example: (def todoA '(funcA)) (def todoB '(funcB)) (def todoC '(funcC)) (def todoD '(funcD)) ; unused (defn funcA [] (println "hello funcA!")) (declare funcB funcC) (defn runit [] (let [funcB (fn [] (println "hello funcB"))] (letfn [(funcC [] (println "hello funcC!"))] (funcA) (eval todoA) ; OK (funcB) ; OK (eval todoB) ; "Unable to resolve symbol: funcB in this context" at line 2 (funcC) ; OK (eval todoC) ; "Unable to resolve symbol: funcC in this context" at line 3 ))) Is there a simple fix I could undertake to get eval'd quoted calls to functions to work for functions defined inside another function?

    Read the article

  • Log the method name in objective-C?

    - by vodkhang
    Currently, we are defining ourselves an extended log mechanism to print out the class name and the source line number of the log. #define NCLog(s, ...) NSLog(@"<%@:%d> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) For example, when I call NCLog(@"Hello world"); The output will be: Hello world Now I also want to log out the method name like: Hello world So, this would make our debugging become easier when we can know which method is getting called. I know that we also have XCode debugger but sometimes, I also want to do debugging by logging out.

    Read the article

  • Blackberry,php webservice

    - by kashif-pucitian
    Hi, i am new to blackberry and webservices concept. My client side code will be on Blackberry and server cide code will be on php. 1) i want to send simple string "hello world" from blackberry mobile (client side code) to php page (server side code) which will display me "hello world". 2) then i will retreive that "hello world" from php page (server side code) and display it on my blackberry application (client side code). Pleease give me source code help of this so by following that example i will implement complex web services.

    Read the article

  • Socket.recv works but not gets or read?

    - by Earlz
    Hello I've been messing around with Sockets in Ruby some and came across some example code that I tried modifying and broke. I want to know why it's broken. Server: require "socket" dts = TCPServer.new('127.0.0.1', 20000) loop do Thread.start(dts.accept) do |s| print(s, " is accepted\n") s.write(Time.now) print(s, " is gone\n") s.close end end Client that works: require 'socket' streamSock = TCPSocket.new( "127.0.0.1", 20000 ) streamSock.print( "Hello\n" ) str = streamSock.recv( 100 ) print str streamSock.close Client that is broken require 'socket' streamSock = TCPSocket.new( "127.0.0.1", 20000 ) streamSock.print( "Hello\n" ) str=streamSock.read #this line modified print str streamSock.close I know that the streamSock.print is unnecessary (as well as the naming scheme being non-ruby) but I don't understand why read doesn't work while recv does, Why is this?

    Read the article

  • How does dereferencing of a function pointer happen?

    - by eSKay
    Why and how does dereferencing a function pointer just "do nothing"? This is what I am talking about: #include<stdio.h> void hello() { printf("hello"); } int main(void) { (*****hello)(); } From a comment over here: function pointers dereference just fine, but the resulting function designator will be immediately converted back to a function pointer And from an answer here: Dereferencing (in way you think) a function's pointer means: accessing a CODE memory as it would be a DATA memory. Function pointer isn't suppose to be dereferenced in that way. Instead, it is called. I would use a name "dereference" side by side with "call". It's OK. Anyway: C is designed in such a way that both function name identifier as well as variable holding function's pointer mean the same: address to CODE memory. And it allows to jump to that memory by using call () syntax either on an identifier or variable. How exactly does dereferencing of a function pointer work?

    Read the article

  • Noob Droid Question regarding random number

    - by Pete Herbert Penito
    Brand new to droid programming, but would love to learn as much as possible, so I finally got my emulator working correctly, I even got a hello world button to work, I'm attempting to make this button display a random number, I've googled this and came up with this code: Random generator = new Random(); int n = generator.nextInt(n); I fixed the Random function by including some Random java utility. I'm assuming this code above goes in the .java file of the project, so my button code looks as follows (tested and works): PopUpText.makeText(v.getContext(), "Hello World", PopUpText.LENGTH_LONG).show(); I figured I could replace "Hello World" with n to display the number in the box, however the following error is stopping the compile: The local variable n may not have been initialized Any ideas why this is happening? Any advice would be hugely appreciated.

    Read the article

  • Using Timer only once

    - by zaidwaqi
    Hi, I want to use a timer only once, at 1 second after the initialization of my main form. I thought the following would have a message box saying "Hello World" just once, but actually a new message box says "Hello World" every one second. Why so? I had put t.Stop() in the tick event. Also, do I need to dispose the timer somehow to avoid memory leakage? Timer t = new Timer(); t.Interval = 1000; t.Tick += delegate(System.Object o, System.EventArgs e) { MessageBox.Show("Hello World"); t.Stop(); }; t.Start(); Please help and show if there is a better way of doing this? Thanks.

    Read the article

  • How to handle right to left languages in Flash (pre version 10)?

    - by Maan Ashgar
    Hello, We are currently working with Flex creating a web application. We are having trouble taking Arabic text from the user and displaying correctly (like in a chat feature). While presumably Flash 10 will solve this problem, we don't want to force our users to upgrade. Flash flips the order of the sentence's words. so if I wrote something like "Hello World" in the text field, it will appear as "World Hello" in the chat area. Is there a standard way to work with Right to Left languages in Flash? *We currently flip the order of the words with a function, but it things get messed up when using English or special characters in the chat like :) or :D *

    Read the article

  • Updating label using jquery and code behind

    - by Zaps
    Hi, I have a label on a page and I'm updating the text property of the label when text is changed in a textbox. I'm updating the label like so: $myLabel.text("hello"); The text is being displayed correctly on the screen butwhen I try to save the text value to an object in the code behind (When I press a button) the text property of the label is "" and not "hello". var myLabel = myLabel.Text; //the var myLabel is "" when it should be "hello" Any ideas as to why this would be? Thanks in advance, Zaps

    Read the article

  • Raw SQL sent to SQL Server from .NET on stored procedure call

    - by Jeff Meatball Yang
    Is there a way to get the raw text that is sent to SQL Server, as seen in SQL Profiler, from the ADO.NET call? using(SqlConnection conn = new SqlConnection(connString)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "GetSomeData"; cmd.Parameters.Add("@id").Value = someId; cmd.Parameters.Add("@someOtherParam").Value = "hello"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); // this sends up the call: exec GetSomeData @id=24, @someOtherParam='hello' // how can I capture that and write it to debug? Debug.Write("exec GetSomeData @id=24, @someOtherParam='hello'"); }

    Read the article

  • C++ String manipulation isn't making sense to me...

    - by Andrew Bolster
    I am trying some of the Stanford SEE courses online to learn some new languages; this particular assignment has to do with removing substrings from strings. What I've got so far is below, but if text = "hello hello" and remove ="el", it gets stuck in a loop, but if i change text to text = "hello hllo", it works, making me think I'm doing something obviously stupid. There is a stipulation in the assignment not to modify the incoming strings, and instead to return a new string. string CensorString1(string text, string remove){ string returned; size_t found=0, lastfound=0; found = (text.substr(lastfound,text.size())).find(remove); while (string::npos != found ){ returned += text.substr(lastfound,found); lastfound = found + remove.size(); found = (text.substr(lastfound,text.size())).find(remove); } returned += text.substr(lastfound,found); return returned; } Guidance would be appreciated :-) Thanks

    Read the article

  • regex preg_match|preg_match_all in php

    - by Josh
    I'm trying to come up with a regex that constructs an array that looks like the one below, from the following string $str = 'Hello world [something here]{optional}{optional}{optional}{n possibilities of this}'; So far I have /^(\*{0,3})(.+)\[(.*)\]((?:{[a-z ]+})?)$/ Array ( [0] => Array ( [0] => Hello world [something here]{optional}{optional}{optional}{n possibilities of this} [1] => [2] => Hello world [3] => something here [4] => {optional} [5] => {optional} [6] => {optional} [7] => ... [8] => ... [9] => {n of this} ) ) What would be a good approach for this? Thanks

    Read the article

  • Wrap words in tags, keep markup

    - by spacevillain
    For example I have a string with markup (from html node): hello, this is dog "h<em>e<strong>llo, thi</strong>s i</em><strong>s d</strong>og" What is the most correct way to find some words in it (let's say "hello" and "dog"), wrap them in a span (make a highlight) and save all the markup? Desired output is something like this (notice properly closed tags) <span class="highlight">h<em>e<strong>llo</strong></em></span><strong>,</strong> <em><strong>thi</strong>s<em> i</em><strong>s <span class="highlight"><strong>d</strong>og</span> Looks the same as it should: hello, this is dog

    Read the article

  • Can you use zero-width matching regex in String split?

    - by polygenelubricants
    System.out.println( Arrays.deepToString( "abc<def>ghi".split("(?:<)|(?:>)") ) ); This prints [abc, def, ghi], as if I had split on "<|>". I want it to print [abc, <def>, ghi]. Is there a way to work some regex magic to accomplish what I want here? Perhaps a simpler example: System.out.println( Arrays.deepToString( "Hello! Oh my!! Good bye!!".split("(?:!+)") ) ); This prints [Hello, Oh my, Good bye]. I want it to print [Hello!, Oh my!!, Good bye!!]. `.

    Read the article

  • python: strange behavior about exec statement

    - by ifocus
    exec statement: exec code [ in globals[, locals]] When I execute the following code in python, the result really confused me. Some of the variables were setup into the globals, some were setup into the locals. s = """ # test var define int_v1 = 1 list_v1 = [1, 2, 3] dict_v1 = {1: 'hello', 2:'world', 3:'!'} # test built-in function list_v2 = [float(x) for x in list_v1] len_list_v1 = len(list_v1) # test function define def func(): global g_var, list_v1, dict_v1 print 'access var in globals:' print g_var print 'access var in locals:' for x in list_v1: print dict_v1[x] """ g = {'__builtins__': __builtins__, 'g_var': 'global'} l = {} exec s in g, l print 'globals:', g print 'locals:', l exec 'func()' in g, l the result in python2.6.5: globals: {'__builtins__': <module '__builtin__' (built-in)>, 'dict_v1': {1: 'hello', 2: 'world', 3: '!'}, 'g_var': 'global', 'list_v1': [1, 2, 3]} locals: {'int_v1': 1, 'func': <function func at 0x00ACA270>, 'x': 3, 'len_list_v1': 3, 'list_v2': [1.0, 2.0, 3.0]} access var in globals: global access var in locals: hello world ! And if I want to setup all variables and functions into the locals, and keep the rights of accessing the globals. How to do ?

    Read the article

  • Decorators vs. classes in python web development.

    - by Tristan
    I've noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods for GET/POST. I'm curious about the virtues of these three approaches. Are there major advantages or disadvantages to any of these approaches? To fix ideas, here are three examples. Bottle uses decorators: @route('/') def index(): return 'Hello World!' Pylons uses controller classes: class HelloController(BaseController): def index(self): return 'Hello World' Tornado uses request handler classes with methods for types: class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") Which style is the best practice?

    Read the article

  • what's wrong with concatenation in blackberry application?

    - by sexitrainer
    For the life of me, I can't understand why adding a concatenated string to the MainScreen is causing the BB simulator to throw an exception. If I run a VERY simple hello program with the following control, all is well: RichTextField rtfHello = new RichTextField("Hello There !!!"); add(rtfItemDescription); But if I add a concatenated string, the entire app breaks: String MyName = "John Doe"; RichTextField rtfHello = new RichTextField("Hello There !!!" + MyName); add(rtfItemDescription); So what am I doing wrong? Why would the simulator throw an exception for the second example?

    Read the article

  • How do I create a MessageBox in C# ?

    - by Nick Stinemates
    I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition. I started in the Form Designer and made a button named "Click Me!" proceeded to double-click it and typed in MessageBox("Hello, World!"); I received the following error: MessageBox is a 'type' but used as a 'variable' Fair enough, it seems in C# MessageBox is an Object. I tried the following MessageBox a = new MessageBox("Hello, World!"); I received the following error: MessageBox does not contain a constructor that takes '1' arguments Now I am stumped. Please help.

    Read the article

  • python: multiline regular expression

    - by facha
    Hi, everyone I have a piece of text and I've got to parse usernames and hashes out of it. Right now I'm doing it with two regular expressions. Could I do it with just one multiline regular expression? #!/usr/bin/env python import re test_str = """ Hello, UserName. Please read this looooooooooooooooong text. hash Now, write down this hash: fdaf9399jef9qw0j. Then keep reading this loooooooooong text. Hello, UserName2. Please read this looooooooooooooooong text. hash Now, write down this hash: gtwnhton340gjr2g. Then keep reading this loooooooooong text. """ logins = re.findall('Hello, (?P<login>.+).',test_str) hashes = re.findall('hash: (?P<hash>.+).',test_str)

    Read the article

  • Ruby on Rails: how to render a string as HTML?

    - by Tim
    I have @str = "<b>Hi</b>" and in my erb view: <%= @str > What will display on the page is: <b>Hi</b> when what I really want is Hi. What's the ruby way to "interpret" a string as HTML markup? Edit: the case where @str = "<span class=\"classname\">hello</span>" If in my view I do <%raw @str %> The HTML source code is <span class=\"classname\">hello</span where what I really want is <span class="classname">hello</span> (without the backslashes that were escaping the double quotes). What's the best way to "unescape" those double quotes?

    Read the article

  • debugfs_create_file doesn't create file

    - by bala1486
    Hello, I am trying to create a debugfs file using the debugfs_create_file(...). I have written a sample code for this. static int __init mmapexample_module_init(void) { file1 = debugfs_create_file("mmap_example", 0644, NULL, NULL, &my_fops)\ ; printk(KERN_ALERT "Hello, World\n"); if(file1==NULL) { printk(KERN_ALERT "Error occured\n"); } if(file1==-ENODEV) { printk(KERN_ALERT "ENODEV occured\n"); } return 0; } When i ran insmod i could get the Hello, World message but no the error message. So i think the debugfs_create_file worked fine. However i couldn't find any file in /sys/kernel/debug. The folder is there but it is empty. Can anyone help me with this? Thank you... Thanks, Bala

    Read the article

  • Ruby function similar to parse_str in php?

    - by jolierouge
    Hi, I need to parse a string like this: a[metadata][][name]=dont|do|this&a[name]=Hello World&a[metadata][][value]=i|really|mean it CGI::parse gives me this: {"a[name]"=["Hello World"], "a[metadata][][name]"=["dont|do|this"], "a[metadata][][value]"=["i|really|mean it"]} I would like something like what PHP does with parse_str, which when given the same string does this: Array ( [a] => Array ( [metadata] => Array ( [0] => Array ( [name] => dont|do|this ) [1] => Array ( [value] => i|really|mean it ) ) [name] => Hello World )) Any help would be awesome. Thanks!

    Read the article

  • Javascript .match plus jQuery keyup(), double match and strange behaviour

    - by Gremo
    Not really good in regular expression, but why when a match is found console.log fires two times? $('#name').keyup(function() { var regex = /[\€]/g; var count = (m = $(this).val().match(regex)) ? m.length : 0; // Num matches console.log(count); }); Output with 'hello': 0 0 0 0 0 After adding '€' symbol to 'hello' we have: 0 0 0 0 0 1 1 After adding 'h' symbol to 'hello€' we have: 0 0 0 0 0 1 1 1 Shouldn't be just one 1 after adding '€' to 'hello'?

    Read the article

  • printing menu in terminal and choosing an option, how to?

    - by carlos
    I'm a haskell beginner. I'm trying to make a program that shows a menu through terminal and ask user to introduce an option. Here is the code: main :: IO () main = do putStrLn "0 <- quit" putStrLn "1 <- Hello" putStr "Choose an option: " c <- getChar case c of '0' -> return () '1' -> putChar '\n' >> putStrLn "Hello World" >> main When I use this module in the ghci interpreter everything works like it's suposed to do. But if i compile this with: ghc hello.hs and run it in the terminal, it doesn't display the line "Choose an option:" before ask for a char to be introduced. I think this may be caused because of haskell lazy nature and I don't know how to fix it. Any ideas?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >