Jump to content

  • Log In with Google      Sign In   
  • Create Account


Prompting and Passing

  • You cannot reply to this topic
10 replies to this topic

#1 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 10:42 AM

i was learning from learnpythonthehardway.org
 
Exercise 14: Prompting and Passing
 
when i do like the exercise 
 
first:
VbjyAvFd.png
 
so i did that :
V0JOC5hI.png
 
 
What should i do !? sad.png
and if can put screen pls put :)

Edited by koka282, 13 August 2014 - 10:43 AM.


Sponsor:

#2 BeerNutts   Crossbones+   -  Reputation: 2779

Like
2Likes
Like

Posted 13 August 2014 - 11:33 AM

It should be:

script, user = argv[0], argv[1]

 

argv is a list, and argv[0] is the name of the script, while argv[1] (and [2], [3], etc.) are the parameters given to the script


My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#3 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 12:07 PM

ty :)

but :(

V0OIpNpB.png



#4 Strewya   Members   -  Reputation: 1350

Like
0Likes
Like

Posted 13 August 2014 - 12:17 PM

How are you invoking the script?


devstropo.blogspot.com - Random stuff about my gamedev hobby


#5 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 12:50 PM

i don't know what do u mean ! :( 



#6 Strewya   Members   -  Reputation: 1350

Like
2Likes
Like

Posted 13 August 2014 - 12:58 PM

You should call the script through a terminal somewhat like this:

python "new 1.txt" your_name_here

 

Also, it might be easier if the name of the script doesn't contain any spaces, something like new_1.txt, then you could call it without the quotes:

python new_1.txt your_name_here

 

In both cases, the your_name_here argument will be in the argv[1].


devstropo.blogspot.com - Random stuff about my gamedev hobby


#7 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 01:49 PM

like that ?

V1tqkl23.png

ty for helping me :)



#8 Andy Gainey   Members   -  Reputation: 1992

Like
1Likes
Like

Posted 13 August 2014 - 02:36 PM

Your first line to invoke the script from the terminal window was almost correct.  You were just in the wrong directory (hence the error that python gave you "No such file or directory"; it couldn't find "new 1.txt" from its current location).  It looks like your file "new 1.txt" is in the folder C:\Users\ahmed\Desktop\, so you'll need to navigate to that directory before you run python.  This can be done with the cd command (short for change directory):

 

PS C:\User\ahmed> cd Desktop

PS C:\User\ahmed\Desktop> python "new 1.txt" koka282



"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke

#9 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 03:52 PM

Ty all smile.png

 

V1TUD2lX.png


Edited by koka282, 13 August 2014 - 07:05 PM.


#10 koka282   Members   -  Reputation: 182

Like
0Likes
Like

Posted 13 August 2014 - 07:04 PM

pls why he use %r & %s

why don't use %r only ?!



#11 Dave Hunt   Crossbones+   -  Reputation: 2413

Like
0Likes
Like

Posted 14 August 2014 - 12:12 PM

pls why he use %r & %s

why don't use %r only ?!

You also asked this question here: http://www.gamedev.net/topic/659845-what-the-difference-between-r-s/







PARTNERS