@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2



Comments:

<0> SgtUnix: That's me :P Unfortunately way to busy with school and social life :P IRC has a low priority now.. And with regards to pinging out and joining all the time. hehe. Sorry. I guess I should find a stable server or something. Not a NATed to death machine
<1> i have a text processing question
<1> can someone help me?
<2> I might if it doesn't involve regular expressions
<1> if I open a text file and read it how would do a word count on it? total count for the word "the" in that text file
<2> I think there's a count function
<2> "sdfdf".count("df") => 2
<2> that wouldn't account for word separators though
<1> i don't want join words, only exact word......for example.. "it" and "its" are different
<2> the hard part of that is describing the exact set of rules that tell you what the word is
<3> mornin'
<1> found some good example in google group......thanx for the help
<4> hi
<4> i'd like to: print "That is %s" % (price*1.016)
<4> but how's that done?
<5> you just did it



<4> weird...
<4> i got an error message
<5> if it doesn't seem be to working, then something else is wrong
<4> xihr: hm... how can i convert a string (through raw_input) into an integer?
<5> is that what price is?
<5> newPrice = int(price)
<5> or:: newPrice = float(price)
<4> yup (now i know why it didn't work :) )
<5> if you really want a floating point
<4> i love python :)
<5> with a dynamic language, when something doesn't work that you think should have, it usually means that the objects you're manipulating aren't what you think they are ...
<4> nod
<5> so your instinct is right
<4> xihr: newPrice = "%.2f" % (float(price)*1.016); how would you round the result?
<5> that's the best way (though you end up with as tring)
<5> a string*
<5> rounding is a concept which is problematic with floating point (not Python specific)
<4> shizzle
<5> with floating point, rounding is really a choice of representation so a string makes sense even though it doesn't seem right
<4> unfortunately i need results like "500.00" or "500.15" etc.
<4> so gotta round the float
<5> yeah, that's fine
<5> '%.2f' % ... is the right way to do that
<5> (note that floating point is still inherently inaccurate so it's conceivable, though not likely, that you may have other accuracy problems)
<4> input = 506, then i get 544.46 (should be rounded to 544.45 :( )
<5> for what
<5> 506*1.016 is 514.096...
<5> so there's extra steps you're doing you haven't mentioned
<4> xihr: woopsie, typed 1.076 not 1.016 (that's why)
<4> and round() rounds it to 544.00
<5> round is very likely not what you want
<4> yup
<5> "rounding" a floating point in this sense is really a way of displaying it, not changing a floating point value
<5> since not all floating point values can be represented, your "rounded" version will likely not be exact
<5> to specify the number of decimal places, you'd do something like round(x, 2)
<5> but that's still not what you want
<5> '%.2f' % x is right
<5> (and rounds up properly)
<4> that would be ok if people could pay something like 500.46 in my country :)
<4> but there are only xx.45 xx.50 xx.60 xx.95 1.05 etc.
<5> oh
<5> well then you're going to have to do math, there aren't any internal routines for rounding to non-decimals
<4> hm... gotta move to another country :)
<4> hehe
<5> heh
<4> xihr: how can i show the decimal place only?
<5> what do you mean?
<4> like: newPrice = 135.46, but only return 0.46
<5> x - int(x)
<4> i guess, i should sleep :)
<4> hehe
<4> and how do i get the second place after 0.x5 (it would be the 5 now) ?
<4> then i'd do some logic work: if (x < 5): x=0 elseif(x==5): x=5 elseif(x<10) x=5 or something like that...
<4> what does "ValueError: invalid literal for int(): 530.00" mean?
<6> sungsung: 530.00 is a float, not an integer.
<6> Err.
<6> You had 530 in a string?
<6> int(float("530.0")) == 530
<4> thanks hund
<4> thanks xihr :)



<6> *logre*
<7> Bit kimmoa!
<6> Glem n den gjken. :)
<7> Er du som til stadig prater om'n ;)
<6> Ser dt.
<6> SgtUnix: Happy leet. :)
<7> ditto
<7> og da var det slutt.
<6> 13:37:59 <@SgtUnix> og da var det slutt.
<7> I'm not 100% up to date with NTP
<7> 13:37:59.99
<7> Godt nok!
<6> There are two important things about time. The first is NTP, the second is RFC 3339.
<7> spoken like a true computer scientist
<7> i'm sure my brother, who's a physicist, would have a different opinion.
<6> I thought time is a common variable in physics.
<6> What does he do when he receives a date "06/04/07"?
<4> hm... how can i exit a loop? (e.g. after i found the first match (e.g. x < list[i]) in a loop?)
<6> sungsung: break
<4> shizzle... doesn't work :)
<4> hehe
<4> hund: break also works for a "for"-loop, right?
<6> Yes.
<4> hund: may i pm you? (two sentences)
<6> No, just go to http://rafb.net/paste/ and show us your code.
<4> hund: no code to show
<4> actually no code at all
<6> Then I'm sure you can write to sentences here.
<4> hehe ok
<6> +w
<4> shizzle, how can i print a %? print "\%" doesn't work
<6> print "%"
<8> sungsung: or within a "%d hello %%" string.. use %%
<4> thanks folks
<4> ok, i wrote a little but stupid "algorithm" (at least it does its work) for rounding up or down to 5 hundredth. e.g. 0.14 to 0.15, 0.12 to 0.10, and so on
<4> and it works like this: say x=0.37 it checks (a loop) if e.g. ..., 0.3, 0.35,0.4 is bigger than x, and it holds by 0.4
<4> then it checks the differences between rest1 = |x-0.4| and rest2= |x-0.35| and sets the value to 0.35 (in this case, since rest1 < rest2)
<4> now the quesiton: how bad is the "algorithm" and what would you do?
<6> Use the decimal module.
<6> Floating point numbers can't really be rounded as such.
<6> sungsung: Take your time and read http://docs.sun.com/source/806-3568/ncg_goldberg.html
<4> thanks a lot hund
<4> hund, structures and algorithm cl*** starts next monday, you know ;)
<6> It's not really related to that. This is fairly low-level.
<4> yup, i know
<7> w
<7> oops
<7> wrong tty
<4> hm... i wrote a little pythonscript to write standard bills. right now it stores everything in a MySQL DB and/or XML-file. how would you do the formatting? i mean, would you work with a html+css template to get a letter, or would you use LaTeX (PDF as a result), or... ?
<9> What is it you wish to accomplish?
<9> If I understand you correctly you could always generate XML and have it transformed using XSLT into either html + css or PDF (directly)
<4> Cra_: usually i write them in m$ word or in openoffice. now i'd like to enter it in a bash window and let the program do the formatting. the result should be a A4-letter.
<4> Cra_: XSLT into PDF sounds great. have you ever worked with that?
<9> can't say I have, but presumably it is no worse then defining the output of the transformation to be PDF and use correct formating
<9> you could have a problem finding a free transformer though
<4> well... that sounds bad
<4> hm.. or i could transform it into an XML file and use a WORD template.
<4> but that'd ****
<9> http://www.biglist.com/lists/xsl-list/archives/200108/msg00282.html
<4> http://www.onjava.com/pub/a/onjava/2002/10/16/fop.html <-- but it's from 2002 so...
<9> that is the same as I found
<4> heheh
<9> that is what you want though
<4> Cra_: yeah, except it doesn't seem to be easy to do the formatting by hand
<4> Cra_: what about convert the properties into LaTeX syntax and then do a tex to pdf conversion?
<4> converting
<10> hello
<10> can anyone help me with a programming languages ***ignment?
<10> pleaseeee?
<4> akane: what do you wanna know?
<10> ok, I am working with drscheme
<10> i want to know how to write a grammar, including concrete syntax and the abstract syntax for a ADTS
<10> can anyone help?
<7> drscheme?


Name:

Comments:

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






Return to #python
or
Go to some related logs:

Eromaxx.com pass
toshiba 6100 pro problem can't find files on boot
#qmail
#nhl
#computers
#nhl
#goal
weneenA
t
#computers



Home  |  disclaimer  |  contact  |  submit quotes