hello, i am new to python and programming in general, i would like to know how to
use the "call" command
my code is something like this - def con():
-
input = raw_input('Press y to start:')
-
if input == "y" or "Y":
-
return(menu_1())
-
else:
-
print 'OMG YA NOOB I SAID PRESS y!'
-
return
-
def menu_1():
-
print '(1) Write noob to start "Stupid Program"'
-
print '(2) Write calc to start "Talking"'
-
print '(3) This section is under construction'
-
print '(4) This section is under construction'
-
input2 = raw_input('Insert text here \n'*1)
now, how do i make it work when i activate it's .py file???
it just won't start, i think i need to make it activate automaticlly without the need to write the con() at the start, how do i do that?
do i need to use the __init__ or __call__ thingy i have no idea how to use it, yes i searched the web, but it wasnt very newby-friendly!
please help me!
4 1167 Laharl 849
Recognized Expert Contributor
You can run your files from the command line with
, where filename.py is the name of the file with your code in it and args are any command line arguments to the file. As to how you call a function, you simply use function(params ).
For example: -
def hello():
-
print "Hello, world!"
-
-
def sum(x, y):
-
return x+y
-
-
if '__name__' == '__main__': not strictly necessary, but a useful trick to know
-
hello() #calls hello
-
z = sum(3, 4) #returns 3+4=7
-
print z
-
thank you, that was very helpful, another question, how do i use py2exe on that?
what do i need to do so it will start like that automaticlly so i can make it exe?
(just wondering)
PS,
i am suppused to write "start Taco.py Base()" in the cmd????
(aftter i "cd" to the folder which the file is in)
im frustrated...
for the code - def Base():
-
input=raw_input('Enter X here to start playing X-')
-
if input=="X":
-
return(Game())
-
elif input=="q":
-
exit(0) ...
Laharl 849
Recognized Expert Contributor
No, the command is 'python Taco.py' because the name of your file is Taco.py. To make it start by running that code, remove the indentation (and take it out of that function while you're at it).
I don't know anything about py2exe, sorry. I stick to Linux for my Python work...
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: engsol |
last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss
loves the quick turn-around compared to C). Each log file may contain one or more 'sessions', and each session may contain
one or more 'nodes'.
Each session in the log has an ASCII start and stop time, as does each...
|
by: Mark Adams |
last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail
server running for several months. It took me a week or so to get it up
and running in September. Now, I did a clean upgrade to Mandrake 9.2
and am reinstalling everything. This thing is kicking my ass and I
can't seem to get past it. I could really use some help if...
|
by: Serdar Kalaycý |
last post by:
Hi everybody,
My problem seems a bit clichè but I could not work around.
Well I read lots of MSDN papers and discussions, but my problem is a bit
different from them. When I tried to run the project in debug mode (by
hitting F5) it gives an error message
"Error while trying to run project: Unable to start debugging on the web
server.
|
by: Tim D |
last post by:
Hi,
I originally posted this as a reply to a rather old thread in
dotnet.framework.general and didn't get any response. I thought it might be
more relevant here; anyone got any ideas? My questions are below...
"David Good" wrote:
> We have a network running both Win2k and Win2k3 webservers and our web sites
> reside on a UNC network...
|
by: Challenge |
last post by:
Hi,
I got error, SQL1768N Unable to start HADR. Reason code = "7", when I
tried to start hadr primary database. Here are the hadr configuration
of my primary db:
HADR database role = STANDARD
HADR local host name (HADR_LOCAL_HOST) = testserver
HADR local service name ...
| |
by: carson |
last post by:
I have written two windows services:
- service A does some crunching of local data files and uploads them to
a central processing computer via http.
- service B monitors a manifest file on a webserver to see if service A
needs to be updated.
What service B does if it sees their is an update for service A is to
download a new copy of the...
|
by: =?Utf-8?B?Vmlua2k=?= |
last post by:
Hello Everyone,
I have an exe application that I want to start remotely.Once I start the
application,
I want to press ok to that application. To start the application, I did
Process.start("C://test/app.exe"). I am writing this code in a C# web
application, famework 1.1
How can I press ok to that started application.
Any help will be...
|
by: Yue Fei |
last post by:
I have a multi thread python code, threads can start immediately if I run on command line, but I can get them started right the way if I call the same code from C/C++.
test code like this:
from threading import Thread
import thread
class testThread(Thread):
def __init__ (self, id):
Thread.__init__(self)
self.id = id
def run(self):
|
by: Vinod Sadanandan |
last post by:
Fast-Start Failover An Overview In Dataguard Environment
=============================================================================
This article describes the automatic fast start failover configuration and the conditions for trigerring a fast start failover in dataguard environment .
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |