473,326 Members | 2,128 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,326 software developers and data experts.

dictionary

what the wrong with the following code ????
>>d={"server":"mpilgrim","database":"master",
.... "uid":"sa",
.... "pwd":"secret"}
>>d
{'pwd': 'secret', 'database': 'master', 'uid': 'sa', 'server':
'mpilgrim'}
>>["%s="%s" % (k,v) for k,v in d.items()]
File "<stdin>", line 1
["%s="%s" % (k,v) for k,v in d.items()]
^
SyntaxError: EOL while scanning single-quoted string
Oct 24 '08 #1
10 1136
asit <li*****@gmail.comwrote:
["%s="%s" % (k,v) for k,v in d.items()]
The first " opens a string, the second " terminates it, the third " opens
it again, and you don't have a fourth " in your line to close it.

Try using an editor which supports syntax colouring (even Idle does this)
and the problem will be instantly apparent.

--
Duncan Booth http://kupuguy.blogspot.com
Oct 24 '08 #2
>>>["%s="%s" % (k,v) for k,v in d.items()]
File "<stdin>", line 1
["%s="%s" % (k,v) for k,v in d.items()]
^
SyntaxError: EOL while scanning single-quoted string
You have three quotation marks... you want

"%s=%s"

not

"%s="%s"

-tkc

Oct 24 '08 #3
On Oct 24, 3:06 pm, Tim Chase <python.l...@tim.thechases.comwrote:
>>["%s="%s" % (k,v) for k,v in d.items()]
File "<stdin>", line 1
["%s="%s" % (k,v) for k,v in d.items()]
^
SyntaxError: EOL while scanning single-quoted string

You have three quotation marks... you want

"%s=%s"

not

"%s="%s"

-tkc
Thanx
Oct 24 '08 #4
On Fri, 24 Oct 2008 10:04:32 +0000, Duncan Booth wrote:
asit <li*****@gmail.comwrote:
> ["%s="%s" % (k,v) for k,v in d.items()]

The first " opens a string, the second " terminates it, the third "
opens it again, and you don't have a fourth " in your line to close it.

Try using an editor which supports syntax colouring (even Idle does
this) and the problem will be instantly apparent.
Or just read the exception, which explained exactly what's wrong:

"EOL while scanning single-quoted string"
What are programmers coming to these days? When I was their age, we were
expected to *read* the error messages our compilers gave us, not turn to
the Interwebs for help as soon there was the tiniest problem.
--
Steven
who is having a "you damn kids get off my lawn" moment...
Oct 24 '08 #5
On 24 Oct 2008 13:17:45 GMT, Steven D'Aprano wrote:
>
What are programmers coming to these days? When I was their age, we were
expected to *read* the error messages our compilers gave us, not turn to
the Interwebs for help as soon there was the tiniest problem.
Yes, and what's more, the text of the error message was
"IEH208". After reading it several times, one looked it up
in a big fat set of books, where one found the explanation:

IEH208: Your program contains an error.
Correct the error and resubmit your job.

An excellent system for purging the world of the weak and
timid.

--
To email me, substitute nowhere->spamcop, invalid->net.
Oct 24 '08 #6
On Fri, 24 Oct 2008 14:53:19 +0000, Peter Pearson wrote:
On 24 Oct 2008 13:17:45 GMT, Steven D'Aprano wrote:
>>
What are programmers coming to these days? When I was their age, we
were expected to *read* the error messages our compilers gave us, not
turn to the Interwebs for help as soon there was the tiniest problem.

Yes, and what's more, the text of the error message was "IEH208". After
reading it several times, one looked it up in a big fat set of books,
where one found the explanation:

IEH208: Your program contains an error. Correct the error and resubmit
your job.

An excellent system for purging the world of the weak and timid.
You had reference books? You were lucky! When I was lad, we couldn't
afford reference books. If we wanted to know what an error code meant, we
had to rummage through the bins outside of compiler vendors' offices
looking for discarded documentation.

--
Steven
Oct 24 '08 #7
On Oct 24, 8:01 pm, Steven D'Aprano <st...@REMOVE-THIS-
cybersource.com.auwrote:
On Fri, 24 Oct 2008 14:53:19 +0000, Peter Pearson wrote:
On 24 Oct 2008 13:17:45 GMT, Steven D'Aprano wrote:
What are programmers coming to these days? When I was their age, we
were expected to *read* the error messages our compilers gave us, not
turn to the Interwebs for help as soon there was the tiniest problem.
Yes, and what's more, the text of the error message was "IEH208". After
reading it several times, one looked it up in a big fat set of books,
where one found the explanation:
IEH208: Your program contains an error. Correct the error and resubmit
your job.
An excellent system for purging the world of the weak and timid.

You had reference books? You were lucky! When I was lad, we couldn't
afford reference books. If we wanted to know what an error code meant, we
had to rummage through the bins outside of compiler vendors' offices
looking for discarded documentation.

--
Steven
I don't have a reference book. I read from e-buks and some print outs
of Reference Card. Again, I had this error becoz my console has no
colour highlighting feature.
Oct 24 '08 #8
asit wrote:
what the wrong with the following code ????
>>>d={"server":"mpilgrim","database":"master",
... "uid":"sa",
... "pwd":"secret"}
>>>d
{'pwd': 'secret', 'database': 'master', 'uid': 'sa', 'server':
'mpilgrim'}
>>>["%s="%s" % (k,v) for k,v in d.items()]
File "<stdin>", line 1
["%s="%s" % (k,v) for k,v in d.items()]
^
SyntaxError: EOL while scanning single-quoted string
By single-quoted, the message mean quoted by ' or " rather than
triple-quoted with ''' or """.

Oct 24 '08 #9
Am Fri, 24 Oct 2008 05:06:23 -0500 schrieb Tim Chase:
>>>>["%s="%s" % (k,v) for k,v in d.items()]
File "<stdin>", line 1
["%s="%s" % (k,v) for k,v in d.items()]
^
SyntaxError: EOL while scanning single-quoted string

You have three quotation marks... you want

"%s=%s"

not

"%s="%s"

-tkc
Or he may have wanted
"%s = '%s'"
Another neat python feature.
HTH
Martin
Oct 24 '08 #10
when I was a baby programmer even vendors didn't have documentation to
throw out... we just viewed the dissassembeled opcodes to find out how
things worked... we never did find out much but I could make the speak
click, and we were happy with it.
Oct 24 '08 #11

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

Similar topics

1
by: none | last post by:
or is it just me? I am having a problem with using a dictionary as an attribute of a class. This happens in python 1.5.2 and 2.2.2 which I am accessing through pythonwin builds 150 and 148...
4
by: brianobush | last post by:
# # My problem is that I want to create a # class, but the variables aren't known # all at once. So, I use a dictionary to # store the values in temporarily. # Then when I have a complete set, I...
1
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex...
8
by: akameswaran | last post by:
I wrote up a quick little set of tests, I was acutally comparing ways of doing "case" behavior just to get some performance information. Now two of my test cases had almost identical results which...
8
by: Brian L. Troutwine | last post by:
I've got a problem that I can't seem to get my head around and hoped somebody might help me out a bit: I've got a dictionary, A, that is arbitarily large and may contains ints, None and more...
3
by: JamesB | last post by:
I have a config screen in my app that updates a dictionary<key,value>. I want to store a copy of this before going into the config screen so if the user wants to cancel all their changes I can...
3
by: wildThought | last post by:
If I have an object that contains a generic dictionary inside of it, how do I get access to its properties such as count?
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
8
by: Bob Altman | last post by:
Hi all, I'm trying to do something that should be really easy, but I can't think of an obvious way to do it. I have a dictionary whose value is a "value type" (as opposed to a reference type --...
1
by: sachin2 | last post by:
I am using 3 types of dictionaries. 1) Dictionary<string, string > d = new Dictionary<string, string>(); 2) Dictionary<string, List<string>> d = new Dictionary<string, List<string>>(); 3)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.