| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Comments:
<0> replace 'queue_only_override = false' '' -- /etc/exim.conf.local how can i replace that with python should i just open the file and read them and replace them .. or <1> xerophyte: you can't edit files in-place like that. the usual way is to open the file for reading, open a new (temp) file for writing, write to the outfile what you read from the first file (possibly after changing things), and when you're done, close both files and rename the tempfile to the oldfile. That way, the file is never half-written, even if your computer crashes. <2> hmm whats these odd exe files in my python lib dir? <2> e.g. os.exe, urllib.exe, including pdb's.. what are those used by/for? <1> the windows installation I can peer at doesn't have them. <0> Yhg1s, hmmm <0> Yhg1s, is there anyway i can just open a temp flie <0> or do i have to just open in the same folder <0> just wondering <1> do it in the same folder <2> Yhg1s - curious. <2> very curious <1> it doesn't have to be in the same folder, as logn as it's on the same disk, but the same folder is what's usually used. <0> for s in input: <0> output.write(s.replace(stext, rtext)) <0> Yhg1s, just wondering where do i open this new file
<3> fd = open('foo.txt', 'w') will open foo.txt which is in the same directory in write mode <1> xerophyte: before your loop <3> lol, didn't see he actually pasted some code somewhere :-/ <4> Can the Python Imaging Library read XImage data, the native format of X11? <0> TemporaryFile( <1> xerophyte: no, write a normal file. <1> xerophyte: just open a tempfile that you created out of the file you are going to replace and the PID of your process (and possibly the machine name, if you are writing to a network filesystem.) <1> aquarius: http://www.pythonware.com/library/pil/handbook/formats.htm <1> aquarius: doesn't look like it. <3> Yhg1s: how do you manage to spend so much time helping people on #python ? <4> Yhg1s: Yeah, I saw that; what I'm not sure about is whether XImages are XPMs or not :) <0> Yhg1s, how can i get the PID <0> getegid() <3> no, it gets the group id of the user thant launched python <1> xerophyte: getegid() does something entirely different. os.getpid() <1> mat_le_stagiaire: I multi-task. <3> Yhg1s: i'm curious, are you currently at work? <1> I'm currently working from home. <1> but I could just as easily be at work. <3> Yhg1s: ok <2> Yhg1s - very odd.. i did a complete reinstall of python + libs i use and they're gone.. there was about 15 of em <2> all of similar size, and each with a pdb.. cant for the life of me figure out where they came from <0> Yhg1s, http://pastebin.com/535115 i am little confused about that .. imean how can iget the filename for the output file <0> shutil.copy(os.getpid()+'.tmp',filename) <0> hmm <1> xerophyte: you must not use shutil <1> xerophyte: the whole point is that you use os.rename(), which is atomic, so the file is never 'half-written'. <1> http://pastebin.com/535118 <1> oh, I forgot something. <1> http://pastebin.com/535119 <3> does os.getpid()+'.tmp' work? (no need to do: str(os.getpid())+'.tmp' ? ) <1> mat_le_stagiaire: no, it doesn't work. <5> I thought shutils .move properly handles files on different drives, which distutils and os.rename doesn't <1> you can use str(), but a better way is to use "%s.tmp" % () <6> hi, anyone familiar with parsing MIME messages? How should I extract mail subject that looks like that?: =?utf-8?q?do_wzi=C3=84=3Fcia=3F!!!?= <1> ne1uno: correct. however, in this case, you don't *want* to handle files on different drives. <1> ne1uno: because if you do, things break. <1> Lewy: use the email module. <0> Yhg1s, i dont know if i can every become a coder ;) <7> Lewy: hm. I can't remember the name for that encoding emthod <7> Lewy: but it exists. :) <1> quoted-printable <8> xerophyte, you will... <9> Urgh, my python is definitely rusty. I can't remember how to make a duplicate of a list instead of getting a pointer to a list. <1> Mercury: 'reference', not 'pointer'. list(L) or L[:] <0> Yhg1s, why shouldn't i use shutil <8> Mercury, no pointers in python, references <1> Mercury: the former explicitly returns a list, the latter makes a copy of the same type of sequence. <0> kbrooks, thx :) but i have little hope :) <1> xerophyte: because if your machine crashes midway through shutil.copy, your file will be broken. <8> xerophyte, why? <9> Yhg1s: Thanks. <8> Yhg1s, wjhat file? <1> xerophyte: whereas os.rename() is 'atomic'. It happens instantly, there is no time inbetween where your machine can crash and the file can be gone or corrupt. <8> what* <1> kbrooks: please re-read everything xerophyte has asked in the last hour. <7> Yhg1s: I wonder. <1> Jerub: about what? <7> Yhg1s: surely you can get a signal and get an OSError. <1> Jerub: not inbetween os.rename() <7> Yhg1s: oka
<1> it either happens _right_ before the rename, or _right_ after :) <1> because it's a single kernel call, and a carefully crafted one at the filesystem layer. <5> this is why there should be less than 2 ways to do something <1> no, there's a good reason there's shutil.copy (and shutil.move) as well as os.rename(). You can do things with the one you can't do with the other :) <1> and you can't "guess" which semantic the user wants: being able to move across filesystems, or being able to do atomic moves. <5> import movewithverifyandblockalloserrors as move; move(fromfile, tofile) <1> nice description, but that's not at all what os.rename does :) <10> Hm. I have a list (say, [1, 2, 3]) and I want to do a for loop over it, but I need my values to be p***ed through a function, i.e. for i in list: ... p = f(i); # Do stuff to p. Can I write this somehow like for p in <apply f() to all elements in list>? <3> with map i think <5> maybe path module should taken a position on rename <4> for p in [f(x) for x in mylist]: <1> the map solution is 'map(f, L)' <1> like the list comp, it returns a list of results. <10> aquarius, Yhg1s: Thanks <4> true; I'm trying to wean myself off map and onto comprehensions. Next step: generator expressions! <10> Both work. <4> are map and so on likely to go away in favour of comprehensions at some point? <5> they will never go away, except maybe as builtins <1> they'll probably be hidden in a module eventually, yes. <3> Yhg1s: i thought that guido wanted to remove them (map, zip..,as well as lambda) <1> mat_le_stagiaire: as builtins, yes. <3> ok <4> People can just do "import * from useThatFunctionalStuffILearnedAtUniversity" or something :) <6> Yhg1s, Jerub: email.Header.decode_header(encoded_header) <10> Oh, and another question: Is there a good emacs mode for python? <10> I don't think the standard python-mode is very good. <1> python-mode has come with emacs and xemacs for quite a while now. <1> there isn't a better one :) <1> in fact, there isn't another one. no one else thinks it's not very good, apparently. <1> what are you missing? Or hating? <3> emacs sux ;-) <3> one has to be an octopus to manage to use quickly all the functionalities :-/ <1> mat_le_stagiaire: no, _you_ have to be that :) I am not, and I use it fine. <0> Yhg1s, the search text could be this "queue_only_override = false" or this "queue_only_override = false" ..do i have use the re for to match that <0> any other simple way <1> xerophyte: I'd say you want to split on whitespace and see if the first thing is '"queue_only_override'. <1> xerophyte: if it isn't, write the original line. if it is, write a new line. <0> for s in input: <0> output.write(s.replace(stext, rtext)) <0> then i have to modify that to readline or <1> no, you can do whatever you need to do inside the while loop. <0> Yhg1s, little confused can you rewrite this for me pelase if the stext has spaces http://pastebin.com/535119 <1> xerophyte: only by hardcoding "queue_only_override", but it should be enough of an example to show you. <1> http://pastebin.com/535158 <0> Yhg1s, i am trying to conver a perl script to python just to learn python ) <0> Yhg1s, the perls script author just used replace system ("replace 'queue_only_override = false' '' -- /etc/exim.conf.local"); <0> hmmm <11> is it me or does python guis seem a little slow to resize? <11> there is no way around this or could it be based on the type of gui used such as wxpython, etc? <1> there's nothing particular about Python GUI's that make them slow in resizing. All of them just wrap C or C++ libraries, and most of the resizing code is in there. <10> Yhg1s: I think it's annoying that M-q doesn't work in comments, and I'd like to have some way of accessing documentation directly from emacs. <10> Those are my primary concerns, anyway. <1> well, python-mode is an opensource project, patches are welcome, I'm sure. <12> EMACS Makes A Computer Slow ;) <13> what is func-caller version of thread.start_new_thread() ? <1> 'func-caller'? <13> hmm... i mean <13> if use_thread: thread.start_new_thread(func, args) <13> else: thefunction(func, args) <1> func(*args) <13> oh... <13> thanks, Yhg1s <14> hello <13> hi <14> i would like to recompile my python on os x 10.3.9 with ncurses and compilation, how do o do that <15> It looks like the argument is going to be purely Java vs python here. The main argument the PM has is that getting python people is hard, and that on Java a lot of existing technology is there. <15> To the hiring issue I'd like to respond that altough he might get easier hand on a java developer it's going to be exactly as hard to get a good Java developer as it is to get somebody who is devoted to python. <15> Of course my PM has the advantage that he manages 2 Java developers, is one himself (sort of) and that I'm the only Python guy. <15> His disadvantage is that he tries to unload his java envangelism on my shoulders, because I'm going to be the one who has to do it. <16> khinester: fink would be the obvious way <16> you could also try darwinports <15> any advice? <16> __doc__: telling him that he's trapped in a mental prison and has no choice but to do what you say would be a bad idea
Return to
#python or Go to some related
logs:
DbDriver config locked by another process nvidia GLXBadDrawable #debian ubuntu ur012i Can't locate strftime.pm dell m50 xorg.conf var/lib/bin/mysqld
#web uninstall cedega #linuxhelp
|
|