IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1982.48 MB
Powered by
Channel Info
Network: freenodeChannel: #python |
Search in www.irclog.org
Log from #python at freenode 2006-05-31
[01:28]<zgmznacw>Hey guys
[01:28]<zgmznacw>Is it possible to expand a string value onto 2 lines?
[01:28]<zgmznacw>Like
[01:28]<zgmznacw>string = "Line 1\r\n"
[01:28]<zgmznacw> "Line 2"
[01:28]<rd2nzrj2zr>andrejkw: use triple-quotes(""") or a trailing backslash (\)
[01:29]<jnzu2>andrejkw: put brackets around it.
[01:29]<jnzu2>("foo"
[01:29]<jnzu2>"bar")
[01:29]<jnzu2>and it'll work
[01:29]<zgmznacw>Jerub: thanks
[01:29]<gjrd_>the triple quotes are more commonly used, i think
[01:29]<jnzu2>(I use that a lot for i18n'd strings.
[01:29]<jnzu2>where I want control of line endings, and have big strings.
[01:29]<rd2nzrj2zr>Jerub: but that won't add a newline inbetween
[01:29]<jnzu2>cybercobra: sure it will.
[01:29]<jnzu2>see, he's used \r\n
[01:29]<zgmznacw>SyntaxError: EOL while scanning single-quoted string
[01:30]<jnzu2>andrejkw: you need the bracket.
[01:30]<fux>if a in (str1, str2, str3) checks if it is in one or the other - how can i make it that it has to be in all of them?
[01:30]<gjrd_>it won't add a anewline between
[01:30]<zgmznacw>Jerub: I did add the bracket
[01:30]<2ggay>noam_, I don't like """ for that because of how it breaks indentation
[01:30]<jnzu2>andrejkw: well, that error indicates you didn't.
[01:30]<rd2nzrj2zr>benji: yeah, they should have made it respect indentation
[01:30]<zgmznacw>Jerub: self.label2.set_markup(("Line 1\r\n
[01:30]<zgmznacw> Line 2.")
[01:31]<cxzysljrr>luh: use sufficient == :) a==s1==s2==s3==s4
[01:31]<gjrd_>you need another )
[01:31]<jnzu2>andrejkw: need to terminate the quotes.
[01:31]<zgmznacw>Jerub: theres extra )
[01:31]<jnzu2>andrejkw: note the example I gave.
[01:31]<zgmznacw>jerub: it just didn't pase in here
[01:31]<zgmznacw>jerub: self.label2.set_markup(("Line 1\r\n
[01:31]<zgmznacw> Line 2."))
[01:31]<zgmznacw>Jerub: oh never mind
[01:31]<rmra>Yhg1s: ok I'll try to explain: I have two threads for example. every thread has to work on its own jobs. every job has a unique id (which should be the keyword for searching). when one job starts than i take the starttime and write it to the corresponding key. after some time the job finishes and I have to serch for the key with the corresponding starttime for to get the total working time of the job.
[01:31]<2ggay>andrejkw, you have to close the string on the first line
[01:31]<fux>ok - it's getting late, i should get laid, and stop asking things that i would figure out during the day
[01:31]<zgmznacw>Jerub: sorry, didn't see the "
[01:32]<zgmznacw>Jerub what does it mean if I do _(
[01:33]<rd2nzrj2zr>andrejkw: call the _ function, which is sometimes used for gettext support
[01:33]<zgmznacw>cybercobra: thanks
[01:43]<gjrd_>caching works flawlessly. i'm amazed
[01:45]<rd2nzrj2zr>noam_: of what?
[01:47]<gjrd_>committed
[01:48]<gjrd_>just some stuff i've been writing. added data caching just now
[01:49]<yxrws>adac: alright, for that, you have a central jobmanager, which records start/endtimes, and all threads send start/endtimes to that manager through a Queue.
[01:51]<wxdcyrr>someone ever used a filter in python before?
[01:52]<rd2nzrj2zr>whyking: you mean used filter() ?
[01:52]<wxdcyrr>cybercobra, no.. sth like a low-pass filter in scipy
[01:53]<jfyvnzl>whats the best way to determ the execution time of my script?
[01:53]<fjffrc>oliverp, http://docs.python.org/lib/profile.html
[01:54]<axzjgjs>ahn, match module have methods to check if number is pair or uneven, if it is prime number, perfect number, to return dividers of number, calc somatory of number algarisms, etc?
[01:55]<axzjgjs>*math
[01:55]<jfyvnzl>thanks polpak
[01:55]<rmra>Yhg1s: but how to search the queue for the keyword?
[01:56]<fjffrc>adac, use a dictionary
[01:56]<fjffrc>adac, to look up the unique id
[01:57]<rmra>polpak: yea...but I have threads and therefore would a blocking queue be nice
[01:58]<fjffrc>adac, you can use a queue to pass back the id, and end time for the job, then the main thread takes that id, and matches the end time with the start time in a dictionary
[01:59]<fjffrc>adac, the queue is just for passing the data between the threads
[02:01]<rmra>polpak: hm, but i take the starttime also in the thread...
[02:02]<fjffrc>adac, does the thread need to know the start time?
[02:02]<gjrd_>good night, now
[02:02]<gjrd_>i'll sleep happily
[02:03]<fjffrc>adac, you can do that if you like, it depends on what you're trying to do
[02:04]<rmra>polpak: ok I'll try to explain: I have two threads for example. every thread has to work on its own jobs. every job has a unique id (which should be the keyword for searching). when one job starts than i take the starttime and write it to the corresponding key. after some time the job finishes and I have to serch for the key with the corresponding starttime for to get the total working time of the job.
[02:05]<fjffrc>adac, so I'd say, your main thread has a dict keyed to this unique id, when it sends a job to a thread (via a queue) it records in the dict the start time. When it later sees an id come back through the "out" queue it can record the end time, look up the start time from the dict, and find the total time
[02:06]<fjffrc>adac, alternatively you can have the thread itself record the start & end time then just pass back the unique id, and the time it took to process
[02:10]<rmra>polpak: do I need to syncronize the access to the dictionary?
[02:10]<fjffrc>adac, not if only one thread is accessing it
[02:11]<fux>good night
[02:16]<rmra>polpak: Cause I'm really a bit afraid of syncronize that with semaphores...threfore a queue would be nice
[02:16]<jnzu2>import Queue :)
[02:17]<wxdcyrr>TypeError: 'dict' object is not callable what does that mean?
[02:18]<yxrws>whyking: it means you tried to call a dict as if it were a function.
[02:19]<yxrws>adac: you dont' search the queue for the keyword. the queue is just for passing messages to the jobmanager. if the workers need to know howlogn they spent working, the job manager should tell them -- through a queue. The jobmanager keeps all the information in a normal dict, and it's the only thread that access that dict
[02:20]<wxdcyrr>hm
[02:25]<fjffrc>whyhankee, d = {'foo':1, 'bar':2} ; d('foo') #<--- TypeError: 'dict' object is not callable
[02:26]<fjffrc>err
[02:26]<fjffrc>whyking, ^^
[02:26]<svzuav>Yhg1s: did you look at that code I pasted?
[02:27]<wxdcyrr>polpak, yeah.. i'm with you.. thx
[02:38]<rzrss>is there a way to do a non-blocing read from a file?
[02:38]<jnzu2>crass: yes.
[02:39]<azvydus>I'm working on a text based rpg (nethack like, different ruleset). The thing is, the maps aren't randomly generated. Anyone know of an easier way to make a map than typing it by hand?
[02:42]<rzrss>Jerub: I'm using popen3, and would like to do a non-blocking read on the error fileobject, can that be done that way?
[02:43]<jnzu2>crass: sure.
[02:43]<jnzu2>I'd use subprocess instead of popen3.
[02:54]<sdyvxa>i'm running into a problem where i need to try/except an IOError, but only one of a certain type; is that possible? i need to except IOErrors that do *not* say "IOError: file is not an RPM"
[02:55]<jnzu2>smithj: no, you have to catch all the io errors
[02:55]<jnzu2>but if you want to, you can take the exception that you've so gracefully caught, and release it in the wild once again, by using 'raise'
[02:56]<zgmznacw>Hmm
[02:56]<sdyvxa>Jerub: well, how can i figure out what the text is after the exception that i caught? i could do an if/else inside the except...
[02:56]<zgmznacw>How do I fetch the paramaters passed to the python script?
[02:56]<jnzu2>smithj: precisely!
[02:56]<jnzu2>andrejkw: import sys; sys.argv
[02:56]<zgmznacw>Jerub: Thanks again :)







