On 04/17/2013 08:12 PM, Alan Gauld wrote:
On 17/04/13 20:27, Danilo Chilene wrote:
import sys
a = 'This is A'
b = 'This is B'
c = 'This is C'
for i in sys.argv[1]:
if sys.argv[1] == 'a':
print a
if sys.argv[1] == 'b':
print b
if sys.argv[1] == 'c':
pr
On 17/04/13 20:27, Danilo Chilene wrote:
import sys
a = 'This is A'
b = 'This is B'
c = 'This is C'
for i in sys.argv[1]:
if sys.argv[1] == 'a':
print a
if sys.argv[1] == 'b':
print b
if sys.argv[1] == 'c':
print c
I run python file.py a and returns t
On 17/04/2013 20:27, Danilo Chilene wrote:
Dear Python Tutor,
I have the code below(file.py):
import sys
a = 'This is A'
b = 'This is B'
c = 'This is C'
for i in sys.argv[1]:
if sys.argv[1] == 'a':
print a
if sys.argv[1] == 'b':
print b
if sys.argv[1] == 'c':
On 04/17/2013 05:15 PM, Danny Yoo wrote:
Yup! Sorry about my tone for its stridency. But I just got concerned
that the original poster seemed content about turning the chain of if
statements into a table definition. To my mind, they're very closely
related, data and control. I'm trying to pus
Yup! Sorry about my tone for its stridency. But I just got concerned
that the original poster seemed content about turning the chain of if
statements into a table definition. To my mind, they're very closely
related, data and control. I'm trying to push the OP to realizing
that if they are doin
On 04/17/2013 04:49 PM, Danny Yoo wrote:
Wait. If the solution that we're stopping at to use a hashtable here,
that's not quite right.
Nothing wrong with a dict, if a proper specification of the problem were
available. Notice that in my solution, the messages were not all
trivially related
Wait. If the solution that we're stopping at to use a hashtable here,
that's not quite right. A good solution to this should be _much_
shorter, on the order of a one-liner. Hashtables are great, but
they're not the answer to everything.
If we're doing something like:
a -> "This is A"
b
Hello Dave,
1) I'm using Python 2.7
2) The program wasn't suppose to really work, was just a example.
3) You assumed correct.
That's was what I looking for, worked like charm.
Thanks!
On Wed, Apr 17, 2013 at 5:18 PM, Dave Angel wrote:
> On 04/17/2013 03:27 PM, Danilo Chilene wrote:
>
>> Dear
On Wed, Apr 17, 2013 at 1:03 PM, Danny Yoo wrote:
> ##
> ## double: string -> string
> def double(x):
> return x + x
>
>
> ## For example, a blast from the past:
> print "The Noid says: " + double("pizza")
> ##
>
I'm sorry, but this is a bug.
On 04/17/2013 03:27 PM, Danilo Chilene wrote:
Dear Python Tutor,
I have the code below(file.py):
import sys
a = 'This is A'
b = 'This is B'
c = 'This is C'
for i in sys.argv[1]:
if sys.argv[1] == 'a':
print a
if sys.argv[1] == 'b':
print b
if sys.argv[1] == 'c
What's the part that's "changing"? What's the part that stays the same?
I would recommend thinking of this in terms of a function.
Can you write a function that consumes a letter l and returns the
string "This is ..." where "..." is the uppercased l?
As an example of a simple function on string
My memory is fine, as is my grip on reality as well as courtesy to my
fellow pythonistas.
Good day to you sir.
Rikard Bosnjakovic wrote:
> On 4/18/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
>
>> I never talk to mailboxes, nor to other inanimate objects; I was talking
>> to you.
>
> I'm not int
As long as the PROBLEM lives, the THREAD will rise from the dead over
and over. Kill the problem, you kill the thread.
Kent Johnson wrote:
> Rikard Bosnjakovic wrote:
>> On 4/17/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
>>
>>> I really wish this list would start mungin' some headers alread
On 4/18/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
> I never talk to mailboxes, nor to other inanimate objects; I was talking
> to you.
I'm not interested in listening to your ifs about your memory.
--
- Rikard - http://bos.hack.org/cv/
___
Tutor mail
use a replyto header, or swap around things so the FROM is the list
address, not the submitter, or kill me, or give me food, or something.
Luke Paireepinart wrote:
> Rikard Bosnjakovic wrote:
>> On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
>>
>>
>>> IF my memory serves well, argument 0 i
I never talk to mailboxes, nor to other inanimate objects; I was talking
to you.
Rikard Bosnjakovic wrote:
> On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
>
>> IF my memory serves well, argument 0 in that list is the name of the
>> program itself, as well as the path to it if any was provid
On 4/18/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Please don't start this thread again.
We didn't start it, rather it just never ends.
--
- Rikard - http://bos.hack.org/cv/
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/li
Rikard Bosnjakovic wrote:
> On 4/17/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
>
>> I really wish this list would start mungin' some headers already.
>
> I second that.
>
> Not using a reply-to-tag is braindead.
Please don't start this thread again.
Kent
_
On 4/17/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> I really wish this list would start mungin' some headers already.
I second that.
Not using a reply-to-tag is braindead.
--
- Rikard - http://bos.hack.org/cv/
___
Tutor maillist - Tutor@pyt
Rikard Bosnjakovic wrote:
> On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
>
>
>> IF my memory serves well, argument 0 in that list is the name of the
>> program itself, as well as the path to it if any was provided.
>>
>
> Stop replying to my mailbox.
>
I really wish this list would
On 4/17/07, Kirk Bailey <[EMAIL PROTECTED]> wrote:
> IF my memory serves well, argument 0 in that list is the name of the
> program itself, as well as the path to it if any was provided.
Stop replying to my mailbox.
--
- Rikard - http://bos.hack.org/cv/
On 4/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I've been reading the python tutorial trying to get used to the style
> tryna understand it. So I come across this: "sys.argv[0]" in the tutorial
> on python.org. What is "sys.argv"? How does it work? Can someone give me
> a simple exam
Reply to [EMAIL PROTECTED] 07-04-17 07:26:
>I've been reading the python tutorial trying to get used to the style
>tryna understand it. So I come across this: "sys.argv[0]" in the tutorial
>on python.org. What is "sys.argv"? How does it work? Can someone give me
>a simple example on how to use
On Mon, 13 Feb 2006, [ISO-8859-1] J?nos Juh?sz wrote:
> Is it any way to translate the sort DOS filename to the long NTSF one with
> python ?
You'll have to expand on this to handle files other than current
directory, but basically:
>>> win32api.FindFiles("FILEWI~1.TXT")[0][8]
'FileWithALongFil
Thanks Andre,
The problem came from my wrong script calling.
Python is just fine :)
I corrected it, and I can call it now with
"""
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\Shell\Flat2Xls\Command]
@="python \"D:\\devel\\xlsxml.py\" \"%1\""
"""
In this case there is a new menu
János Juhász wrote:
> Hi,
>
> I want to pass args to my python script on XP.
> This code
> print 'argv[0] %s' % sys.argv[0]
> print 'argv[1] %s' % sys.argv[1]
> print 'argv[2] %s' % sys.argv[2]
>
> shows this:
> argv[0] D:\devel\home\devel\python\db\xlsxml.py
> argv[1] "K:\IT\admin\test\Flat
> ar
On 2/13/06, János Juhász <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to pass args to my python script on XP.
> This code
> print 'argv[0] %s' % sys.argv[0]
> print 'argv[1] %s' % sys.argv[1]
> print 'argv[2] %s' % sys.argv[2]
>
> shows this:
> argv[0] D:\devel\home\devel\python\db\xlsxml.py
> argv[
> As an added bonus, you can also create a system environment variable
> called PATHEXT and set it to .py and you won't even have to type the
.py
Well, well, well, you live and learn! :-)
Thanks for that neat tip.
Alan G.
___
Tutor maillist - Tutor@
pyc
While you're at it, you should also check the assoc/ftype for .pyw as
.pyw=Python.NoConFile
Python.NoConFile="C:\Python24\pythonw.exe" "%1" %*
Good luck,
Jeff
-Original Message-
From: Richard gelling [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005
oConFile
Python.NoConFile="C:\Python24\pythonw.exe" "%1" %*
Good luck,
Jeff
-Original Message-
From: Richard gelling [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 1:41 PM
To: tutor@python.org
Subject: Re: [Tutor] sys.argv[1: ] help
Hi,
It is actually as
On Sun, 27 Feb 2005 17:55:54 +, Richard gelling
<[EMAIL PROTECTED]> wrote:
>
> No What I get if I was to type in
> ./arg1.py a b c
>
> All I get is
> []
It sounds as though the command shell is not passing along the
additional parameters. Try opening Windows Explorer, and go to the
Folder
> Add a file called 'test.cmd' in the same directory as your 'test.py'
> program with the following content:
>
> ###
> python test.cmd %*
> ###
Scratch that! *grin* Sorry, meant to write that the test.cmd should
contain:
###
python test.py %*
###
Darn it, but I don't have a Windows box handy
> >(I know I'm being a bit silly about asking about what looks like a
> >simple email typo, but computer programming bugs are all-too-often
> >about typos. *grin*
>
> Sorry for the late response, I tried all of the the suggestions,
> including correcting my typo of print sys[1:] and tried print
>
Yeah, python.exe is the right one... bizarre... I'll have a poke at it
when I get home from work.
Sorry I haven't been more helpful.
Cheers,
Liam Clarke
On Sun, 27 Feb 2005 18:57:30 +, Richard gelling
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> It is actually associated with just 'python', ch
Hi,
It is actually associated with just 'python', changed it to associate
with 'pythonw' and I got nothing on the same example not even the [], so
I am assuming that 'python' is the correct one?
Liam Clarke wrote:
Yeah, right click on a .py and check if it's associated with pythonw
or python.
Hi,
It is actually associated with just 'python', changed it to associate
with 'pythonw' and I got nothing on the same example not even the [], so
I am assuming that 'python' is the correct one?
Liam Clarke wrote:
Yeah, right click on a .py and check if it's associated with pythonw
or pyth
Yeah, right click on a .py and check if it's associated with pythonw
or python.exe
GL,
Liam Clarke
On Sun, 27 Feb 2005 18:28:18 +, Richard gelling
<[EMAIL PROTECTED]> wrote:
> Hi,
> Yes, I use both Wndows XP and Linux( at work ) . I left that in by
> mistake I am actually just typing in
>
Hi,
Yes, I use both Wndows XP and Linux( at work ) . I left that in by
mistake I am actually just typing in
arg1,py a b c
at the windows XP command prompt
Sorry for the confusion.
Liam Clarke wrote:
Are you using XP still? I've never seen this before -
./arg1.py a b c
But anyhoo, I tri
Are you using XP still? I've never seen this before -
> ./arg1.py a b c
But anyhoo, I tried out just
'c:\python23\foo.py'
as opposed to
'c:\python23\python foo.py' and
while foo.py will run, it doesn't echo to the console, as on my
machine running a .py file runs it through pythonw.exe - I'd
Hi,
No What I get if I was to type in
./arg1.py a b c
All I get is
[]
If i type at the command prompt
python arg1.py a b c
I get ['a','b','c'] as expected
All the other programs and examples I have typed in work fine just by
typing in the file name, I don't have to preced the file name with
pyt
Richard,
if you try to print sys.argv[1:] when sys.argv only contain sys.argv[0]
then you are bound to get an empty list returned, [] .
Im not sure I understand the problem you think you've got but here's
what happens with sys.argv for me, and it's correct.
[argl.py]
$ cat argl.py
#!/usr/bin/py
Danny Yoo wrote:
I am reading ' Learning Python second edition' by Mark Lutz and David
Ascher, and I trying the code examples as I go along. However I am
having a problem with the following, which I don't seem to be able to
resolve :-
# test.py
import sys
print sys[ 1: ]
This I believe
> > I am reading ' Learning Python second edition' by Mark Lutz and David
> > Ascher, and I trying the code examples as I go along. However I am
> > having a problem with the following, which I don't seem to be able to
> > resolve :-
> > # test.py
> > import sys
> >
> > print sys[ 1: ]
> >
> > T
Remember computers count from 0, so sys[1] is the 2nd argument, sys[0]
is always the filename.
On Fri, 25 Feb 2005 22:33:50 -0500, Jay Loden <[EMAIL PROTECTED]> wrote:
> Should be:
>
> import sys
>
> def main():
> '''prints out the first command line argument'''
> print sys.argv[1]
>
> main
Should be:
import sys
def main():
'''prints out the first command line argument'''
print sys.argv[1]
main()
On Friday 25 February 2005 04:35 pm, Richard gelling wrote:
> Hi,
>
> I am reading ' Learning Python second edition' by Mark Lutz and David
> Ascher, and I trying the code examples
45 matches
Mail list logo