@# 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



Comments:

<0> cool
<0> i.e. http://www.hackdiary.com/archives/000055.html
<1> Hmmm, how can I compress all multiple whitespace to a single space? mystring.replace(' ',' ') doesn't work as expected. Should I use a regexp?
<2> yes ChrisH
<3> ChrisH: I'm not a experienced programmer, but I think regexp should be better.
<2> replace ' +' by ' '
<4> ChrisH, " ".join(mystring.split())
<0> if it's pure spaces, " ".join(string.split())
<0> like juhaz says :)
<4> ChrisH, that would compress _all_ whitespace, though, not just spaces
<1> Juhaz: I wonder whether that's efficient...
<5> someone loves generators :/
<1> Basically I'm trying hard to avoid regexps. Not that I'm not familiar with it but coming from a Perl background every problem can be killed by throwing regexps at it. :)
<5> regexps are inefficient
<6> The join/split is the canonical way to do it in Python.



<1> Good to know. I feared that creating a "large" list and then recreating a string would be more expensive than running a regexp replacement on it.
<6> Isn't it a bit too late to worry about micro-optimisation when you've chosen a dynamically typed language which is 10-100x faster than C already? :)
<2> you mean slower
<7> Hi all. Any Leo user here?
<2> no, my cat looks like a lion though
<7> I'm having problems with the last beta of this software on windows. It just dont write
<7> loufoque any picture?
<1> Erwin: Since it's 2000x more readable I don't care that much. Actually I'm trying to compress a mulitiline """...""" string to feed it to textwrap.fill()...
<5> I actually remember reading that for strings of a certain length, joining is faster than concatenating
<2> offray_: well it's not true actually
<8> veracon_ for strings of almost any length :-)
<8> (maybe not even "almost")
<2> depends on the regex engine
<9> veracon_: uh, the join vs. add thing is interesting. mostly it's memory overhead.
<4> veracon_, I don't know about length but after certain amount of strings, joining is _lot_ faster than concatenating
<4> it's especially noticeable in older python versions, 2.4 has some pretty heavy optimization on string concat
<7> I'm having a problem with a python application on Windows. On Linux it works without any problem but on Windows It doesnt get any keyboard ouput
<10> and how are you getting this keyboard output?
<11> lmao
<9> Alpha: AOLisms are unacceptable for communication in #python. please don't use them.
<11> yeah i realised when i sent it
<9> great. :)
<12> hi all
<13> I get : warnings.warn('wxpython/wxWidgets release number mismatch') when I run import wx how can i fix that?
<14> hey guys, i've installed debian which uses python2.3 by default ... using apt i've since installed python2.4 ... the system 'default' is still python2.3 but i need to install a few modules that python2.4 can use, any suggestions?
<15> run the python2.4 binary whenever you need to run 2.4, and place the modules in the corresponding 2.4 module directory.
<10> mattt: install them using python2.4. you can just run 'python2.4' instead of 'python'.
<14> heh, that worked a charm, and seems rather obvious now that you mention it
<14> thanks guys
<15> if you want to simply run python, recreate the symlink.
<14> yeah, i read somewhere that doing that was a 'bad' idea
<15> most distros do it by default.
<14> but i might, cuz i often just run 'python <script>'
<4> you should use alternatives for that
<10> it may be bad, if system-important scripts don't work with Python 2.4.
<10> and you better make sure you have all modules installed for 2.4 as well as 2.3
<10> but I doubt it'll cause many problems on deiban.
<15> in that case you'll revert back to the 2.3 executable, but in generality the symlink isn't a ba didea.
<14> excellent, thanks guys
<10> Juhaz: the debian python packages don't seem to participate in alternatives for that.
<4> strange. I wonder if there is a reason for that, for example if it hints that there are indeed version dependent things floating around
<10> or perhaps they're conservative in upgrading.
<4> well, that they most certainly are
<4> to the point of being ridiculous, I can at least pretend to understand stable
<4> but testing? unstable? 2.3? what the hell are those guys smoking
<6> unstable has 2.4.
<10> but not default.
<16> how do i return the sql string the cursor.execute() creates?
<17> hi any more activity here than in #pygame? having some python module compiling issues :/
<17> anyone have tips on the best way to install numeric and pyobjc on OSX 10.4.4?
<18> isn't pyobjc already installed on OSX?
<17> chmeee: not being found if it is...
<19> no, i had to install it
<17> pygame's saying "Pygame requires PyObjC version 1.1 or above." when I try to compile it
<19> there should be a link from the pygame site somewhere to another site which is mirroring all sorts of wonderful things, including PyObjC
<17> and I installed the mac version...
<17> hmmm...
<19> zratchet: http://pythonmac.org/packages/
<19> you should be able to find PyObjC from there



<19> does that help?
<17> I got that...
<17> maybe I need to update my python though. I thought I had 2.4 but it says 2.3.5... is there something I need to do to get it to recognize 2.4 as the default when you type "python" ?
<17> (I got Macpython 2.4... )
<18> zratchet: OSX's python is 2.3.x I believe, even with 10.4
<17> yeah, have 2.3.5
<17> brb
<20> the Python it ships with is 2.3.5
<20> probably won't get upgraded until 10.5
<10> zratchet: start 'python2.4' instead of 'python'.
<17> ah, ok
<17> problems fixed, thanks all!
<21> anyone here?
<15> hi
<21> hi, can I have a function within a function? if yes, how do I call it from the outer function?
<6> Yes. And just like you'd expect.
<15> any processing you do with the inner function has to be within foo(), it can be called or defined within foo, but nothing more. If you want bar() to be accessible in a diff block/namespace you'll have to declare it global.
<22> can't load gtk module if don't have X perms?
<23> can't bothered all words in sentence?
<22> import gtk <---- needs perms to run X ?
<22> >>> import gtk
<22> Traceback (most recent call last):
<22> File "<stdin>", line 1, in ?
<22> File "/usr/lib/python2.3/site-packages/gtk-2.0/gtk/__init__.py", line 37, in ? from _gtk import *
<22> RuntimeError: could not open display
<10> seb-: yes, if you want to import gtk, you need a working X display.
<24> I'm looking to translate a floating point number to a binary representation. IE: .375 = 0.011. Any hints/
<4> seb-, you could use Xvfb or some other fake display
<10> vanweric: there isn't a builtin way, although I'm sure you can find some pure-python implementations through google or by browsing the cookbook.
<22> Juhaz: thanks, is it normal not to be able to import gtk w/o such fancy things?
<24> Thanks Yhg1s, I was hoping for built-in, I'll code a dirty one myself.
<10> seb-: well, you won't be able to *use* gtk without an X display
<10> so it's not too odd that it doesn't allow you to import.
<22> Yhg1s: i just want to use an app that makes a PNG
<10> so use PIL.
<22> Yhg1s: become a user that doesn't have DISPLAY variable set then enter python interpreter and you'll get same error
<10> anything that makes it through gtk probably needs a GUI to do it anyway.
<10> seb-: yes. And it makes sense. Where should it send the GUI if DISPLAY isn't set?
<22> Yhg1s: i wrote a lot of plotting code in matplotlib CGI script...how salvage the script?
<10> no idea, I don't know matplotlib.
<22> Yhg1s: k,
<25> anyone running 2.4.1 that could give me a sanity check on the following code?
<25> http://rafb.net/paste/results/y8Jufs42.html (3 lines of Python)
<26> I have 2.4.2
<25> it raises an exception on my mac with 2.4.1 but works on a gentoo w/ 2.4.2
<25> the exception:
<25> http://rafb.net/paste/results/yqTVNg85.html (14 lines)
<4> chmod007, http://sourceforge.net/tracker/index.php?func=detail&aid=1170331&group_id=5470&atid=105470
<25> Juhaz: thanks a lot!
<27> notelist = []
<27> for line in thefile.xreadlines():
<27> notelist = notelist.extend(line.split()) notelist = []
<27> for line in thefile.xreadlines():
<27> notelist = notelist.extend(line.split())
<27> **** there was only supposed to be one of those
<27> anyway
<27> notelist = notelist.extend(line.split())
<27> AttributeError: 'NoneType' object has no attribute 'extend'
<27> ..??
<27> notelist = [] sets notelist to the empty list, so it has that function?
<4> extend is in-place, it doesn't return the list
<27> oh
<27> ok
<27> gaah i trip over sort() all the time
<27> Juhaz: thanks!!
<21> i hate the "all data is a string" Web :@
<28> Q. using glob.glob() how do i ask for multiple matching patterns? like *.bmp|*.jpg|*.png ?
<29> man 7 glob
<28> error: no such command, this is windows dude
<29> ****s to be you.
<29> Use Google.
<23> Or Linux.
<30> ignacio: Is it possible at all?
<29> Nope.


Name:

Comments:

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






Return to #python
or
Go to some related logs:

inherit SimpleXMLRPCRequestHandler
#fedora
#math
jeeva freebsd
#bind
Debian Gnome Gtk-WARNING **: cannot open display:
yast kbfx
Xlib: Maximum number of clients reached Vnc
dl blackdown 1.5 gentoo
libjack.so ubuntu



Home  |  disclaimer  |  contact  |  submit quotes