# Need more than 1 value to unpack?

## Recommended Posts

i everyone i just learning execise13 from learnpythonthehardway.org and i got syntax error time & need 1 value to unpack time :( help me pls

...........................

.......................

##### Share on other sites

I'm familiar with the book but have never gone through it. I read that chapter that you are on and on the line that follows "What You Should See" he wants you to navigate, in Unix or a Windows prompt, to the directory where test11.py is and type in the command:

python test11.py first 2nd 3rd

This will run the file in the python interpreter and pass it first, 2nd, and 3rd as arguments.

Edited by tp9

##### Share on other sites

Bro :)

Thanks for helping me & pls send me screen in python :)

##### Share on other sites

Bro

Thanks for helping me & pls send me screen in python

Sup...

You know you keep posting a screenshot of your editor right? You can't execute the python interpreter from within your script. You need to run it from the command line, outside of your script, in the same location that your script is located.

If you don't know how to use the command line you'll have to learn that first. Command lines are OS dependent too so keep that in mind.

##### Share on other sites

Yes i don't know how to use command line but i will see any video to help me ,,i will search  & sry about Difficulty understanding & thanks for helping me&Thanks for this useful information :) & pls if u have skype i want to add u

I hope i will be Professional Programmer

Edited by koka282

##### Share on other sites

Yes i don't know how to use command line but i will see any video to help me ,,i will search  & sry about Difficulty understanding & thanks for helping me&Thanks for this useful information & pls if u have skype i want to add u

I hope i will be Professional Programmer

NP. Don't worry, you'll get there. Just takes a bit of time and patience. Good luck.

##### Share on other sites

Pls if u know Program to program python with it like Notpad++ pls tell me

Edited by koka282

##### Share on other sites

Pls if u know Program to program python with it like Notpad++ pls tell me

To execute Python programs from Notepadd++ you need the plugin PyNPP. Just put the DLL in your Plugins folder and a new option will show up under Plugins. The only option you have to set is the location of your root Python folder (mine is C:\Python34). To execute your Python script hit Ctrl + Alt + F5.

Edited by tp9

##### Share on other sites

Pls if u know Program to program python with it like Notpad++ pls tell me

To execute Python programs from Notepadd++ you need the plugin PyNPP. Just put the DLL in your Plugins folder and a new option will show up under Plugins. The only option you have to set is the location of your root Python folder (mine is C:\Python34). To execute your Python script hit Ctrl + Alt + F5.

i put  the Dll (PyNPP)

but pls see

what should i do ??

I've used the command line  right???

Edited by koka282

##### Share on other sites

You are confused about the line "test11.py first 2nd 3rd" Your code should match exactly to what he lists in the text:

from sys import argv

script, first, second, third = argv

print "The script is called:", script

print "Your first variable is:", first

print "Your second variable is:", second

print "Your third variable is:", third


Notice that you have an extra line that you should remove?

What you may not understand is what a program is and how they are executed? In mouse environments, you don't realize what is happening when you click a button to start up a program it just happens. But in the old days and for people who enjoy text interaction (very powerful once you learn to use it, look into linux and unix environments for more examples), many programs are started by typing their name! Where do you type their name? Well, in a terminal in linux or the command prompt in windows. Then, you can add different parameters and mix programs to do very interesting things. I haven't used windows for a long time, but I believe the following directions will get you on the right track.

1. Remove the line you shouldn't have in your Python script and save.

2. Open a command prompt. Try the start button and typing in cmd or Google the answer.

3. Navigate to where you want to run the program you wrote. Try typing the following: cd "E:\f\mohamed\New folder (5)"

I got that directory from your screenshot by the way.

4. Execute your program, but with extra parameters (these allow the program to adapt to do different things). Type the following: python test11.py first 2nd 3rd

5. Your program should output this:

The script is called: test11.py



Interesting tidbit: You are actually running the program called "python" and "test11.py" tells the program to run the code you wrote! Python then passes the rest of the arguments (first, 2nd, 3rd) to the code you wrote.

When you use and IDE to run stuff it runs the python program in the background and outputs the results to you.

##### Share on other sites

Thanks for helping me &  ?Sry about Difficulty understanding

now what ?!

##### Share on other sites

You first need to type cd /D "E:\f\mohamed\New folder (5)\" to change to the correct folder.

The /D let's the 'cd' command know that it has permission to switch drives to the 'E:' drive.

You'll know if it works, because the C:\Users\________ > at the front of each line would turn into the path you typed in.

Then, since you are at the current folder of your .py script, you can execute your script by typing: python test11.py

However, you want to also pass in parameters, so instead of just typing "python test11.py", type python test11.py aarvark purple mongoose instead. The last three words can be anything you want (because they'll be passed to your script, and your script will have to handle them), as long as there is just a single space between each one and as long as you keep to letters and numbers, and avoid fancy symbols (some symbols have special meanings).

:)

thanks bro

now what ?!

##### Share on other sites

Type: python test11.py aarvark purple mongoose

The last three words can be anything you want (because they'll be passed to your script, and your script will have to handle them), as long as there is just a single space between each one and as long as you keep to letters and numbers, and avoid fancy symbols (some symbols have special meanings).

Edited by Servant of the Lord

##### Share on other sites

Where I should type python test11.py aarvark purple mongoose

##### Share on other sites

The black window with the white text is called the 'DOS Prompt' the 'DOS Window' or the 'Command Prompt' or 'Command Window'. You use it alot in programming.

In the Command Prompt window (the black window with the white text), make sure you are executing within the correct folder. You can see what folder you are 'in' (i.e executing within), because the command prompt tells you what folder it is running inside.

It shows it right here, where the > arrow is. I highlighted the text in yellow here: (normally it is just white text)

The command prompt executes (i.e. 'runs') programs. You type in the name of the program, followed by a space, followed by zero or more 'arguments'.

CD is one such program. It stands for 'change directory'. 'directory' is another word for 'folder'. The 'cd' program changes what folder the command prompt is currently executing within. This is called the 'current working directory'.

To use CD, you must type in its name, followed by the arguments you want to give it. In your current situation, you want to use CD to change your directory to the directory that your python script is in.

So, in the command prompt, type: cd /D "E:\f\mohamed\New folder (5)\"

That'll execute the 'cd' program, and give it the /D argument and the folderpath argument you want to move to.

You'll know if it worked, because it'd change the 'current working directory' to the path you specified.

Once your current working directory is the same directory (i.e. 'folder') that has your python script in it, you can tell the 'python' program to run your .py script.

Do this by typing, in the command prompt, the name of the python program (called 'python') and passing it several arguments. The first argument would be the name of your script. The other arguments will be passed into your script so your script can handle it.

The command you type is:

python test11.py argument1 argTwo arg3

You type it into the command prompt, just like you do with the 'CD' program.

##### Share on other sites

Now what !?

Edited by koka282

##### Share on other sites

You need to delete the "python test11.py etc.." line from your script, since it doesn't belong there.

##### Share on other sites

Thanks all

Good now in cmd

but i can't make From Notpad++ ,,from Cmd only

right ?

Thanks all :)

##### Share on other sites

That's because when you run it in Notepad++, you aren't passing any arguments.

Your script expects 3 arguments. When you run it from the command line, you are passing it three arguments.

When you run it from Notepad++, you haven't passed in any arguments. I don't currently have Notepad++ installed, but I'd guess under the "Run" filemenu there'd be an option to specific command-line arguments.

##### Share on other sites

When you run it from Notepad++, you haven't passed in any arguments. I don't currently have Notepad++ installed, but I'd guess under the "Run" filemenu there'd be an option to specific command-line arguments.

I may be remembering incorrectly, but I believe Notepad++'s run option just makes you type in the arguments after the (filepath +) filename. Just like the command line.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627689
• Total Posts
2978648

• 13
• 14
• 12
• 10
• 12