473,395 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Parameter Passing - String Variable Truncated ?

Hi,

I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
....snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK

arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed

os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
....
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re

in_featclass = sys.argv[1]
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------

Thanks, for help.

Aug 31 '07 #1
5 3295
On Sep 1, 9:54 am, goldtech <goldt...@worldpost.comwrote:
Hi,

I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
...snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK

arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed

os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
...
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re

in_featclass = sys.argv[1]
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------
Try handle.write(repr(sys.argv[1:]) + "\n")
and come back with your conclusions ... unless of course someone has
spoonfed you in the meantime.

Another clue: write yourself a little arg-dumper script and try
running it in a Command Prompt window.
8<---
import sys
for x, arg in enumerate(sys.argv):
print x, repr(arg)
8<---
HTH,
John

Sep 1 '07 #2
goldtech wrote:
Hi,

I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the echo print to
the output window shows the whole string with the fc part. Better
explained below I hope, there's the calling .py and the spawn
script .py:
...snip...
while fc:
counter = counter + 1
fc_cntr = str(counter) + ' : ' + fc
print fc_cntr + '\n' # Print to Pythonwin interactive window -
eg. "1 : New York" - all is printed OK

arglist = []
arglist.append(pythonPath)
arglist.append(spawn_script)
arglist.append(fc_cntr) # This gets sent to the spawn_script but
only "1" gets printed

os.spawnv(os.P_WAIT, pythonPath, arglist)
fc = fcs.next()
...
--------------------------
## the spawn_script
import win32com.client, sys, os, time, re

in_featclass = sys.argv[1]
Try

in_featclass = sys.argv[1:]

to collect all the arguments. At the moment I suspect some shell
argument processing is intervening, splitting your "N : something" into
multiple arguments.
handle = open('C:\\log_file.txt', 'a')
handle.write(in_featclass + "\n") # ONLY the counter part gets printed
to the log file! Why?
--------------------------

Thanks, for help.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Sep 1 '07 #3
Steve Holden wrote:
[...]
>in_featclass = sys.argv[1]

Try

in_featclass = sys.argv[1:]
Sorry, that should have been

in_featclass = " ".join(sys.argv[1:])+"\n"

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Sep 1 '07 #4
Steve Holden wrote:
[...]
>in_featclass = sys.argv[1]

Try

in_featclass = sys.argv[1:]
Sorry, that should have been

in_featclass = " ".join(sys.argv[1:])+"\n"

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Sep 1 '07 #5
snip...
--------------------------

Try handle.write(repr(sys.argv[1:]) + "\n")
and come back with your conclusions ... unless of course someone has
spoonfed you in the meantime.

Another clue: write yourself a little arg-dumper script and try
running it in a Command Prompt window.
8<---
import sys
for x, arg in enumerate(sys.argv):
print x, repr(arg)
8<---
HTH,
John
It's a list.

....
['5', ':', 'Alaska.shp']
['6', ':', 'Arizona.shp']
['7', ':', 'Arkansas.shp']
['8', ':', 'California.shp']
['9', ':', 'Colorado.shp']
['10', ':', 'Connecticut.shp']
['11', ':', 'Delaware.shp']
['12', ':', 'District', 'of', 'Columbia.shp']
['13', ':', 'Florida.shp']
['14', ':', 'West', 'Virginia.shp']
['15', ':', 'Wisconsin.shp']
['16', ':', 'Wyoming.shp']

Thanks,
Lee G.

Sep 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Belinda | last post by:
Hello All I have the following test.asp page which needs one parameter querystr but my querystr is a very long string value. When I send a long value the query string is getting truncated after...
3
by: whatduck | last post by:
I'm having trouble passing a variable that contains spaces. If the variable contains a space I get the following error: "Application uses a value of the wrong type for the current operation." ...
2
by: Chris | last post by:
I have two forms. From form one I have a listbox that when double clicked I get the selected value (string) and store in a variable. I parse the string to get the first 12 characters and store it...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
2
by: Cole Shelton | last post by:
Hi all, I am trying to upload roughly 20-30k of binary data up to my webservice. At first, I just took my byte array and encoded it as a base64 string and passed it into my webservice. ...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
4
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am...
14
by: bill | last post by:
Can someone please show me an example of passing a string value into an sql statement in vb 2005? Something like this is what I'm after: Dim sqlButton1 As String = "Select * from tblAssets where...
13
by: masso600 | last post by:
char word; in = fopen("test.txt", "r"); while(fscanf(in,"%s",&word)!=EOF) { /* Print all words */ /* printf("%s\n",&word); */
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
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...
0
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...

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.