@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> right....
<1> *logre*
<2> Man, I actually whistled IRL too.
<2> And this guy outside the window turned around.
<3> you hounddog!
<1> Crow!
<1> cra cra cra.
<3> :D
<1> I don't get it.
<1> 539?
<4> convert it to decimal :D
<4> (from hex)



<1> D'oh.
<4> :p
<4> I was just following Two9A
<1> You're sooo sju over halv to.
<4> I felt inspired :D
<1> Oh.
<1> Maybe I should be Zero75151, then.
<4> 479569?
<4> octal?
<1> No, integers starting with 0 are octal literals.
<1> Python to the rescue!
<1> >>> int("075151",8)
<1> 31337
<4> yes, I figured as much :D
<4> hex > octal :p
<1> (OK, just 075151 would do)
<5> How do we shuffle an array?
<5> ( Change indexes at random )
<5> ok, found it
<4> try, fail, then ask
<4> ask, try, succeed = bad
<6> anyone can tell me how to unwrap this
<6> [('pcode', 'I.DEMO')] [('pcode', 'I.DEMO'), ('creatives', 'tadd and popunder')] [('pcode', 'I.DEMO'), ('pport', '2323'), ('creatives', 'tadd and popunder')]
<6> i'm not even sure what it is
<6> but i just need the last list
<6> or convert it into a hash
<7> aList[-1]
<5> :)
<5> indeed
<6> wow my brain is small
<6> another question
<6> ('pcode', 'I.DEMO') ('creatives', 'tadd and popunder') ('creatives', 'tadd and popunder')
<6> how can conver that into a hash
<7> a dictionary?
<6> right now it looks like I have 3 arrays
<6> x1hr yeah dictionary
<7> they're tuples
<7> dict(aListOfTuples)
<5> or, from hash to tuple
<5> tuple( aDict )
<5> or to a list
<5> list( aDictOrAtuple )
<7> no, that will iterate over the dictionary's keys
<7> you want aDict.items()
<5> right
<6> p = (data.items()[-1]
<6> print dict(p)
<6> returns null
<5> phusniken: What the variable data exactly conains?
<5> *contains
<6> [('pcode', 'I.DEMO')] [('pcode', 'I.DEMO'), ('creatives', 'tadd and popunder')] [('pcode', 'I.DEMO'), ('pport', '2323'), ('creatives', 'tadd and popunder')]
<5> data is a list, not a dictionary
<6> i'm trying to convert it into a dictionary
<7> there's no such thing as "null" in Python so you're going to have to be more clear
<5> so you can't say data.items()
<7> Indy: you're confusing him by talking about converting FROM dictionaries
<7> yourDict = dict(data[-1])



<7> that's what you want
<6> xihr that's what I had before and it returns nothing
<6> empty data set
<7> that's a statement, statements don't return anything
<6> print yourDict
<6> returns nothing
<7> print is also a statement and doesn't return anything
<5> phusniken: What do you mean "return" ?
<5> only functions return things
<7> if you mean it PRINTS nothing, then something is seriously wrong
<7> you're going to have to show us exact code if you want more help, since you didn't follow the instructions properly so we can't tell what's wrong
<6> Keyerror: -1
<6> is what i'm gettng
<7> that's not returning nothing, is it?
<7> that's an exception
<7> exceptions are how you tell what's wrong
<7> that key means that data is empty
<7> or that data is something other than a list and doesn't like your subscritpion
<7> you showed us a list of lists of tuples, and said you wanted the last one turned into a dictionary
<7> that's dict(a[-1])
<5> phusniken: Paste your code in http://www.pastebin.com/
<6> http://www.rafb.net/paste/results/Tn568J82.html
<7> if that's not what you have, or you meant something else, then that won't work, but we can't tell you what's wrong
<7> data is already a dictionary
<7> so what you asked for has nothing to do with the code you wanted to write
<6> ok i see where I got confused
<6> {'pcode': 'I.DEMO'} {'pcode': 'I.DEMO', 'creatives': 'tadd and popunder'} {'pcode': 'I.DEMO', 'pport': '2323', 'creatives': 'tadd and popunder'}
<6> i just need the last dict in that dict
<7> dicts don't have an ordering
<6> data[-1]
<7> do you mean a list of dicts?
<7> you have to be more careful with your words
<6> blame Guido
<7> you're the one making errors, not Gudo
<7> Guido*
<6> he should have just called it hashes, arrays like everyone else
<7> hash is a misnomer, and arrays exist in Python as something else, as do other sequences like lists and tuples
<7> that you don't understand what you're doing is not really anybody's fault but your own
<7> that the terminology is different (but not different from languages other than Perl) doesn't change the fact that you still don't know what the types do or how they work
<7> so terminology changes won't help you there
<6> i got a bit confused I knw exactly what most types do, i'm just getting confused working with lists of lists, and dicts within dicts
<6> so data is a dict that contains the followin
<6> {'pcode': 'I.DEMO'} {'pcode': 'I.DEMO', 'creatives': 'tadd and popunder'} {'pcode': 'I.DEMO', 'pport': '2323', 'creatives': 'tadd and popunder'}
<7> that's more than one dict
<7> so I repeat the question: do you mean a dict of dicts or a list of dicts?
<6> corrected its a list of dicts
<6> I just need the dict with the longest len
<6> i tried using (max) but it did not produce what I expected
<8> what do you mean by, longest len?
<7> the most elements?
<6> the dict that has the most elements
<8> most elements?
<7> len(aDict) tells you how many elements it has
<7> aDict < anotherDict is nonsensical, which is why max doesn't work
<6> xihr i got that but how would I referense the largest one
<7> you want to iterate over the list of dictionaries and get the one with the most elements
<7> iterate
<7> there are more compact ways of doing it but they will introduce forms you are not familiar with
<6> i just wish this thing cgi form method would reutrn 1 dict with all my elements instead of 3 different dicts
<7> so rewrite it
<8> phusniken, how did you get the data? FieldStorage() returns a single dict
<8> cgi.FieldStorage()*
<7> I like blaming other people for my own lack of understanding
<7> pretty sure that gets you real far in life
<8> heh
<8> and whats worse, if he read the docs, he would have pulled the data into a single dict like he wants
<7> he actually pasted the code he was working with earlier
<7> he was manually pulling that stuff out of the FieldStorage and then putting it back in some dictionary form
<7> i.e., nothing that made sense


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #python
or
Go to some related logs:

beats fleshlight
cghjfghj
#politics
Sweden.vs.Finland.Olympic.Hockey.Final.2006.SWEDiSH.PDTV.XviD-TS
SQL join from tables in two different servers
xls to cvs
#freebsd
#politics
#heroin
flash2004mx



Home  |  disclaimer  |  contact  |  submit quotes