473,499 Members | 1,655 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 1164
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
5182
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...
0
5823
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...
16
4169
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...
9
3183
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...
8
23367
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 ...
4
21681
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...
2
3865
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...
0
1515
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...
0
7991
by: Vinod Sadanandan | last post by:
Fast-Start Failover An Overview In Dataguard Environment ============================================================================= This article describes the automatic fast start failover...
0
7134
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,...
0
7014
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...
0
7180
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,...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
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...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.