Hello ppl,
I have created a small code that i need it as an exe so i could distribute it over to other users, i used the py2exe, worked fine and gave me the exe, this is when i have all the code lying there (no defined functions)
So when i try to define it as a function, so that i could pass arguments to, it would run with no errors, but does nothing!
in other words, how do i pass arguments to this exe properly?
Thanks a lot
8 1476
Hello ppl,
I have created a small code that i need it as an exe so i could distribute it over to other users, i used the py2exe, worked fine and gave me the exe, this is when i have all the code lying there (no defined functions)
So when i try to define it as a function, so that i could pass arguments to, it would run with no errors, but does nothing!
in other words, how do i pass arguments to this exe properly?
Thanks a lot
Since the format for a script is "python test.py function arg1 arg2 .. .argx"(without quotes) an exe would probably be somthing like "test[.exe] function arg1 arg2 .. .argx"(also without quotes)
i just tried to run the python code, through python through the command line:
python c:\mycommand.exe function arg1
and it does absolutely nothing,
within the code, i have one function defined as "function" and it takes one parameter called arg1
before so, i had it without the function, just code lying there, and it was working perfectly, so could someone plz tell me what am i missin???
i guess what i want to say is, how do i pass parameters properly to a python code,
thanks a lot in advance
to be more precise, i have read the documentation, done my homework right, but it talks about inner functions and how to call them internally, but to call the finction with arguments from the command line, or even through python from outside the editor, i could not find anything,
bvdet 2,851
Expert Mod 2GB
I have never compiled a Python script, so I don't know if this will work, but have you tried accessing the argument(s) from the sys.argv variable list?
askalottaqs:
I am having the exact same problem currently. Please let me know if you've found a solution.
Thanks,
Django seems to accomplish this although it may do it this way. -
import sys
-
-
def sayHello(name):
-
print "Hello, %s!"%name
-
-
def main():
-
if len(sys.argv) >= 2:
-
if sys.argv[1] == "sayHello" and len(sys.argv) == 3:
-
sayHello(sys.argv[2])
-
-
main()
-
-
# output in command prompt
-
python test.py sayHello elcron
-
Hello, elcron!
-
Django seems to accomplish this although it may do it this way. -
import sys
-
-
def sayHello(name):
-
print "Hello, %s!"%name
-
-
def main():
-
if len(sys.argv) >= 2:
-
if sys.argv[1] == "sayHello" and len(sys.argv) == 3:
-
sayHello(sys.argv[2])
-
-
main()
-
-
# output in command prompt
-
python test.py sayHello elcron
-
Hello, elcron!
-
thank you just so much! you saved me mate :) cheers
thank you just so much! you saved me mate :) cheers
np always glad to help :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andrew Chalk |
last post by:
I am a raw beginner to Python. I just read in "Learning Python" that
assigning to a string argument inside a function does not change the string
in the caller. I want an assignment in the function...
|
by: U-CDK_CHARLES\\Charles |
last post by:
List:
I've a Python COM server that keeps an event logs.
I've been using it from VB6:
logEvent "Message"
The Python side of things looks like:
|
by: Alex Vinokur |
last post by:
Various forms of argument passing
=================================
C/C++ Performance Tests
=======================
Using C/C++ Program Perfometer...
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: eight02645999 |
last post by:
hi
if i have a string like this
"ABCE-123456 ABC_DEF_Suggest(abc def ghi).txt"
that needs to be passed to a python script
and i wanted to get the words inside the brackets after i passed...
|
by: Jack |
last post by:
I like Python but I don't really like Python's installation.
With PHP, I only need one file (on Linux) and maybe two files
on Windows then I can run my PHP script. This means no installation
is...
|
by: m2i3k |
last post by:
Hi
I have C code with requires me to register a python callback. I am
able to get the callback working well using ctypes if I use global
functions without any context argument for the callback.
...
|
by: kyosohma |
last post by:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when...
|
by: Gabriel Genellina |
last post by:
En Wed, 22 Oct 2008 19:10:27 -0200, Philip Semanchuk
<philip@semanchuk.comescribió:
Are you *really* sure you want to supply a specific address argument? Most
of the time (if not always,...
|
by: Fizzics |
last post by:
This is my first post here at Bytes. I have been trolling it, mostly with the help of Google searches, for some time now. I have done about all of the searching and reading that I really know how to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
| |