@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20



Comments:

<0> just out of interest, is there a concise way to write "if <any keys of x> in y" for a large if/elif block?
<1> set intersection
<0> I... see!
<2> hmmh. what is a "proper" way to install wsgiref? it seems to be documented on http://docs.python.org/dev/lib but I don't see it in my 2.5beta system...
<3> I have some old code that I write for python2.2. the xreadlines module has changed. what is the module to use with python2.4?
<4> bb3: for line in file("myfile"):
<4> bb3: the file object itself is an iterator
<2> 2.5alpha even
<3> Jerub, thanks
<5> I'm looking for a property implementation with python 2.3 without using the new object style cl***
<4> Bader: ... you have to use new style.
<4> what's wrong with using newstyle cl***es?
<1> The getter works without new-style.
<5> Jerub: I can't use it
<5> Pythy: I want the property object
<4> Bader: that's not a sufficient answer.



<5> it's because zope 2.7 doesn't work with property and I don't want to be stuck with ComputedAttribute
<6> Bader: then you need to make a setattribute that checks for attribute-instances
<5> so I need a property implementation without using the new style cl***
<7> does anyone know a python module for taking screenshots?
<7> (in linux)
<8> moberg_ , didn't you ask exactly the same yesterday??
<5> moberg_: PyXPCom and good luck
<8> :)
<7> ocr`: yes I did, but no one answered :)
<8> hehe
<7> Bader: thanks!
<9> Bader: as Pythy pointed out, property() fulfils those requirements, for read-only properties
<5> joedj: property doesn't exist with python 2.2
<9> Bader: you said 2.3
<5> does it exist with 2.3 without new-style cl*** ?
<9> yes, for read-only properties
<5> joedj: thanks
<6> and you can make a __setattr__ that handles properties
<6> for write access
<10> hello
<10> IF I had line 'question 12. text'. How to get into two variables '12' and 'text' ?
<11> why is mechanize so slow
<11> -why- is it so -slow-
<9> squ: parts = 'question 12. text'.split(None, 2); number, question = parts[1][:-1], parts[2]
<12> squ: you mean from "token_1 token_2. the_rest" you want token_2 and the_rest?
<10> Leeds, i need '2' and 'the_rest'
<12> squ: doesn't joedj's answer work?
<10> testing:)
<9> alternatively, something like dot = s.index('.'); number, question = s[9:dot], s[dot+2:]
<10> honestly I were hoping you will reply with some regexp examples:)
<10> to remind myself how thats were handled in python
<9> in python, we tend to do without if possible :)
<13> Is there a way to sort a slice of a list?
<13> foo = list[1:] ; foo.sort(); list[1:] = foo?
<14> l[i:j] = sorted(l[i:j]) ?
<1> l=[9,3,1,2,9]; l[1:-1] = sorted(l[1:-1]); print l #==> [9, 1, 2, 3, 9]
<13> volvox: Yea, that seems a good way.
<10> Is here any bot searching for docs?:)
<9> ?.os.listdir
<1> ?listdir squ
<10> ?.split
<15> ?.getp***
<1> ?"".split squ
<16> Is there an iterator version of os.listdir?
<9> intgr: there's os.walk
<16> Since I'm trying to iterate through a directory over a network share with hundreds of thousands of files.
<16> And it's not exactly efficient to load them into a list first.
<10> prepare text file with list on local machine:)
<16> So you're telling me there is no way to do this the Right Way?
<16> s/there is no way/it's not possible/
<10> If you are asking me about iterability of os.listdir - I dont know
<10> but you can look in the cl*** source file and check for __iter__
<16> os.listdir returns a list created in memory.
<10> or use the answer you got from joedj
<9> nah, my answer doesn't help
<10> anyway, I find prechaching once-a-day list of files/dirs into one local text file be good way
<16> And no low-level opendir/readdir either.
<16> Oh well
<10> what is the way to make an If line[:6] == 'question' but 'question' with not english letters?
<1> .startswith()
<1> and Unicode



<10> ?.startswith()
<1> ?"".startswith squ
<16> 'asdasd'.startswith('asd') => True
<10> hm
<10> why that is working?
<10> I remember myself adding # -*- coding: .. and translating chars with .unicode and etc
<10> to make python understand it:)
<16> squ: That only applies to Unicode literals in your source files.
<17> Hello. Where is the mistake here? http://pastebin.com/710296
<17> An error occurs. Why?
<18> what was the error ?
<19> which error _Indy_ ?
<10> ?.write
<10> ?"".write
<17> david`bgk: An IOError
<1> you must do a .seek() when switching between reading & writing.
<17> squ: Sorry?
<17> Pythy: Why? Isn't 'r+' a read & write mode?
<1> It is.
<17> Pythy: Ok. Could you rewrite the script correctly and paste it somewhere, please?
<16> _Indy_: Since when you read the entire file, the write position will be at the end of the file
<16> So you have to seek between reading and writing.
<17> intgr: The fact that the write position is at the end of the file, affects the program badly? Why?
<16> If you initially had a file with 'xxx' in it, your program will turn it into 'xxxXXX' which is probably not what you want.
<17> ok
<17> I see
<1> Just do a fo.seek() when switching between .read()-operations & .write()-operations. (And, contrary to what intgr just said, this have nothing to do with positioning: you must do this, even when you think you're at the point where you wish to be -- in that case, seek to where you are.)
<10> intgr, it doesnt turn into that, it errors as he says:)
<16> Then there's probably some other problem.
<17> Pythy: So, the correct is here? http://pastebin.com/710307
<16> Pythy: Might be according to POSIX, but I don't think any libc's actually require you to do that.
<4> intgr: would you like to find out that that's not true?
<4> intgr: frankly, I'd prefer to never find out that it's not true.
<16> _Indy_: Tell us the error description you get, a lot of different stuff can trigger IOException.
<17> intgr: IOError (0 , Error)
<17> something like that
<1> fo.seek(0, 1) # to where I am.
<16> Ack, s/IOException/IOError/
<17> Pythy: So, this? http://pastebin.com/710311
<16> Jerub: No, but I've never even heard about it.
<4> intgr: I have. gstreamer had this problem.
<16> Oh.
<4> intgr: ona 64-bit platform somewhere
<16> _Indy_: Yes.
<17> ok
<17> thx
<16> Jerub: Perhaps Python should automatically wrap this?
<4> http://piman.livejournal.com/367657.html
<10> _Indy_, you could do just write-only reopen of file:)
<4> I don't see why :p
<16> Since it's unintuitive and will lead to obscure errors.
<17> squ: Yes, but this would be slower.
<16> (Especially on obscure platforms)
<1> >>> if __import__('sys').version_info < (2, 5): os.SEEK_CUR = 1 # or use fou.tell()
<1> >>> fou = open(fn, "r+b"); print fou.read(); fou.seek(0, os.SEEK_CUR); fou.write("EOF"); fou.close()
<1> (There's also an append "a"-mode.)
<17> Pythy: This http://pastebin.com/710311 didn't work. It just appended the capitals at the end of the file. I wnat the words to be replaces by the capitals.
<1> then seek to the start
<17> How?
<17> fou.seek( 0 )
<16> seek(0, 0)
<17> ?
<17> a, ok
<17> th
<17> x
<1> fou = open(fn, 'r+b'); fou.read(); fou.seek(0); fou.write('Hi, this is the replacement text.'); fou.truncate(); fou.close()
<20> c' qualche italiano?
<17> Pythy: Ok. This http://pastebin.com/710316 worked. But Is it faster or slower than opening the file in 'r' mode, reading the contents and then opening the file in 'w' mode and writing them in capitals?
<21> hi, quick question: can I have multiple in a try: except: block, can I have multiple except statments ?
<17> KoRnouille: Yes you can.
<21> _Indy_: thanks
<17> KoRnouille: np
<1> (And a single except can catch different types of errors, too.)


Name:

Comments:

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






Return to #python
or
Go to some related logs:

#php
#css
#ubuntu
Trying to execute code outside RAM or ROM linuxbios
uninstall pamie
#perl
#css
#perl
#php
suse_update_desktop



Home  |  disclaimer  |  contact  |  submit quotes