473,563 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do i start my agrument?

58 New Member
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

Expand|Select|Wrap|Line Numbers
  1. def con():
  2.     input = raw_input('Press y to start:')
  3.     if input == "y" or "Y":
  4.         return(menu_1())
  5.     else:
  6.         print 'OMG YA NOOB I SAID PRESS y!'
  7.         return    
  8. def menu_1():
  9.     print '(1) Write noob to start "Stupid Program"' 
  10.     print '(2) Write calc to start "Talking"'
  11.     print '(3) This section is under construction'
  12.     print '(4) This section is under construction'
  13.     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!
Sep 1 '08 #1
4 1167
Laharl
849 Recognized Expert Contributor
You can run your files from the command line with
Expand|Select|Wrap|Line Numbers
  1. python filename.py args
, 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:
Expand|Select|Wrap|Line Numbers
  1. def hello():
  2.    print "Hello, world!"
  3.  
  4. def sum(x, y):
  5.    return x+y
  6.  
  7. if '__name__' == '__main__': not strictly necessary, but a useful trick to know
  8.     hello() #calls hello
  9.     z = sum(3, 4) #returns 3+4=7
  10.     print z
  11.  
Sep 1 '08 #2
Netwatcher
58 New Member
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)
Sep 2 '08 #3
Netwatcher
58 New Member
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
Expand|Select|Wrap|Line Numbers
  1. def Base():
  2.     input=raw_input('Enter X here to start playing X-')
  3.     if input=="X":
  4.         return(Game())
  5.     elif input=="q":
  6.              exit(0) ...
Sep 2 '08 #4
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...
Sep 2 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5186
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...
0
5829
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...
16
4183
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.
9
3189
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...
8
23407
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 ...
4
21695
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...
2
3874
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...
0
1518
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):
0
7997
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 . ...
0
7659
marktang
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...
0
7580
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...
0
7882
Oralloy
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. ...
1
7634
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...
0
7945
tracyyun
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...
0
6244
agi2029
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...
0
5208
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...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
916
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.