In Visual Basic, there is a piece of code that can be used to see if a command starts with a certain text. For example, if I had a textbox, and I wanted to see if the user had started it with an "A" then I would use (not exactly, but):

if Text1.Text.StartsWith "A" then
MsgBox ("Your message started with A!")
MsgBox ("You message did not start with A!")
end if

Is there a way to do with with raw_input in python? Such as:

text = raw_input("Enter your text: ")
if text.StartsWith "A"

Another question is graphics. Is there a way to create GUIs in Python? I don't mean default GUIs like in Linux or UNIX or Windows, what I am asking is custom GUIs, such as if you were to create your own operating system (not that I am taking this task under my arm, but I know that UUU was created in Python). For example, in iTunes, and in the Avant browser, they both have really interesting GUIs.

How do you call functions? Do you just "print" the function and then break it?

print function(x,y,z)


And finally:
If I needed to call another Python file (another application) how would I go about doing this? If I were to make on application but have it call a bunch of different apps to help it (like having one app be the "Queen" program, and have all of the little worker programs jump up at her every will).

:cheesy: Sorry for so many questions! Thanks in advance!!!

Here's a good example of startswith:

# Declare some values (strings...)
codes = ["00123","00332","40325","00455"]

# Print out an error message if a code doesn't have the right prefix: "00"
for code in codes:  # Goes through list of codes
    if not code.startswith("00"): # Runs if code does NOT start with "00"
        print "Error with '%s'. Code not prefixed with '00.'" % (code)

You use the function as a suffix to the list, string, etc. that you're using it on by separating the function name and item with a period.
Ex: code.startswith("00") For functions in python... you have to define them like so:

# Addition function
def add(x,y):
    sum = x + y
    return sum

So you define it using the "def" thing with the function name, and then the parameters you want to pass to the function inside the parentheses and end the line with a colon. Then indent everything in the function. You don't need to have a return statement. You might be only printing in the function, like this:

def print_me(string):
    print string

s = "Hello"

But, if you do want to return something, just use the return function, and assign the function to something:

a = 5
b = 6
ab = add(a,b)
print "%d plus %d equals %d" % (a,b,ab)

For making bigger programs and using multiple files, look into the import keyword.

I hope that's helpful.

There are a number of GUI toolkits for Python, but they are all Python wrappers for other languages. Tkinter is based on tcl, wxPython is based on wxWindows (works on Unix and Windows) written in C++, there is pygtk based on the ever so popular GTK, even pygame can be looked at as a GUI based on SDL.

There is nothing that should keep you back from writing a GUI from scratch. Not having seen such an effort by anyone I know, I supect that it might be a tad time consuming. Let me know when you have a product.

So it is possible, though, to code a GUI from scratch?

Well.. if you wrote your own classes like Tkinter, I guess you could. Why would you?

You could write a GUI toolkit with Python, but you have to understand that the real low level stuff would have to written in a low level language like C or Assembly. Python is a good glue language and bringing in C modules would be hospitable.

For your last question, Python makes the use of modules very easy. Take a look at Ene Uran's explanation of how to write simple modules and use them at: