Team Chat Logs

March 10, 2010

2010 2
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

[00:21:50]<puff>IO
[00:22:37]<Natalie>Does Python's re module support character classes like [[:upper:]]?
[00:23:06]<puff>I'm making a telnet client to automate data stuff from an old line-by-line mode chat system. In theory I guess I should use something like expect, but I seem to learn better when I have a good project to work on, so I'm doing it in python.
[00:23:35]<puff>I was using python's builtin telnet lib, but that seems kinda kludgy... googling around, I came across a reference to the twisted python networking stuff. Is there a preferred telnet lib?
[00:23:36]<bob2>http://docs.python.org/library/re.html#re-syntax
[00:23:37]<bob2>indeed
[00:24:36]<bob2>puff: twisted is pretty great, and it handles the event loop bit for you
[00:24:37]<Natalie>I don't see it there...
[00:26:31]<puff>bob2: Hm, reading this now: http://onlamp.com/lpt/a/6680
[00:26:48]<puff>bob2: Er, this: http://onlamp.com/pub/a/python/2006/08/10/untwisting-python-network-programming.html?page=last
[00:27:46]<Natalie>Hrmph, http://bugs.python.org/issue433029
[00:27:52]<bob2>http://twistedmatrix.com/documents/current/core/howto/ might be a better palce to start
[00:38:16]<scap>does anyone know of a good way to capture stdin of a child opened with subprocess.popen
[00:40:08]<sadata>scap: http://stackoverflow.com/questions/24931/how-to-capture-python-interpreters-and-or-cmd-exes-output-from-a-python-script
[00:41:33]<bob2>scap: stdin=PIPE
[00:41:55]<scap>bob2: I have been using that with no luck
[00:42:02]<bob2>no luck = ?
[00:42:54]<scap>how do I get to see the input that the child see from the parent it what I don't understand
[00:43:15]<scap>sys.stdin.readline doesn't give me anything
[00:43:19]<kosh>bob2: in his world he uses luck instead of skill, so stuff not working is random
[00:43:46]<bob2>scap: you are the parent
[00:45:23]<traceback1>if I have an exception object--how can i print out the full traceback from it?
[00:46:19]<scap>I think I am really not understanding something. I get the I am the parent when I run my code I get nothing from sys.stdin but the child program works fine with the input. What I want is a way to duplicate the input that is going to the child in the parent.
[00:46:40]<Snova>traceback1: the traceback module
[00:50:45]<fynn>Hello.
[00:51:10]<lasko>Hello fynn
[00:52:37]<kosh>greetings non-sentient lifeform
[01:02:34]<prefrontal>how do I convert 3.7285e-07 to .00000037285? thanks
[01:04:10]<Vornicus>You want to force decimal view? Okay, try "%f" % my_number -- this may not work though, there's a failsafe in there to prevent it from trying if it would produce too many leading or trailing zeros.
[01:06:05]<Vornicus>oh good god, it's even worse than that. Hang on...
[01:08:40]<Vornicus>"%0.11f" % 3.7285e-07 # this should do it. Note that you have to adjust the .11 appropriately.
[01:08:51]<prefrontal>yes i got that just now, thank you
[01:08:59]<prefrontal>those string formatting docs are far to obscure to have no examples!
[01:09:32]<prefrontal>i wonder why they chose to use a crazy % operator for those rather than just exposing a method-based api, which is much simpler and easier to comprehend
[01:09:45]<Vornicus>prefrontal:good news, meet string.format
[01:11:49]<prefrontal>this is what I had to use.. i couldn't figure out how to make it automatically determine the right precision so I used rstrip to remove trailing 0s. str("%.15f" % float('3.7285e-07')).rstrip('0')
[01:13:26]<Vornicus>prefrontal: unfortunately there usually isn't a sensible correct precision.
[01:13:55]<Vornicus>(because the full precision is 50 digits of non-zero values)
[01:14:03]<Vornicus>ooh ooh
[01:14:08]<prefrontal>i don't understand. i have explicitly specified the correct precision in scientific notation
[01:14:16]<prefrontal>i could write some code to figure it out, but i did ;-)
[01:15:05]<Vornicus>SOmewhere, there's a function that will get you the exponent alone from a given float.
[01:16:17]<Vornicus>math.frexp does it almost but that's binary.
[01:16:45]<Vornicus>prefrontal: floating point numbers are always the same precision: 52 bits.
[01:17:09]<Vornicus>this "scientific notation" crap, programming languages generally have no truck with it.
[01:17:24]<Acedip>how does one pass multiple command line arguments?
[01:17:34]<Vornicus>>>> "%0.30f" % 3.7285e-07 # '0.000000372850000000000006791816'
[01:18:03]<prefrontal>lol
[01:18:05]<prefrontal>oops
[01:19:38]<Vornicus>They'll "display" numbers in scientific notation, but it doesn't keep them around like that.
[01:21:04]<Vornicus>(well it does, but not the way you might hope - as mentioned, it thinks in bits, and has a constant precision.)
[01:21:47]<Vornicus>YOu might be able to get http://docs.python.org/library/decimal.html#module-decimal to do what you need but fair warning it's slow
[01:22:19]<roccity_>what would be a good project to start for a new python programmer
[01:22:38]<Vornicus>roccity_: new to Python, or new to Programming?
[01:22:42]<prefrontal>convert scientific notation to its proper fixed precision
[01:23:22]<roccity_>Vornicus: I'm new to programming comming from ruby
[01:23:26]<inkoDe>First thing I did was jump into pygame. But, I had a bit of programming experience.
[01:23:29]<bhagat>channel # what changes I have to make in this apache Vhost so I can execute .py files from the directory "modWSGI"
[01:23:30]<bhagat>http://paste.pocoo.org/show/187803/
[01:24:47]<Vornicus>roccity_: okay, build for me... hm.
[01:24:51]<inkoDe>Python is really pretty simple, most of the time (at least in my experience) has been learning to use the libs.
[01:25:32]<Vornicus>damn, man, idunno. Usually the way this is done is you have an itch that's not too hard and you decide to scratch it with a new language.
[01:25:59]<papna>Learning the libraries and codebases you're working with is the majority of time developing in any language.
[01:26:22]<timClicks>i'm having trouble with subprocess.Popen
[01:26:34]<roccity_>is it better for sy admin? then say perl?
[01:26:35]<timClicks>string = subprocess.Popen(['echo'], haystack, stdout=PIPE)
[01:26:46]<roccity_>or actually easier than perl for that
[01:26:46]<shylent>Acedip: well, you just, well pass them. And then you have them in the sys.argv list
[01:27:00]<Vornicus>roccity_: imo it's better than most languages for most things. But this is my opinion.
[01:27:00]<timClicks>results in a NameError, that PIPE is undefined
[01:27:02]<shylent>Acedip: is there something I am missing from your question
[01:27:14]<shylent>timClicks: subprocess.PIPE
[01:27:19]<papna>timClicks: from subprocess import PIPE
[01:27:26]<shylent>timClicks: its a constant in the subprocess module
[01:27:53]<roccity_>Vornicus: I know sysadmin stuff for bsd and linux but never got into scripting really so trying to see where to start
[01:29:01]<timClicks>hrm. I'm trying to replicate the example http://docs.python.org/library/subprocess.html#using-the-subprocess-module
[01:29:14]<timClicks>http://docs.python.org/library/subprocess.html#replacing-older-functions-with-the-subprocess-module
[01:29:27]<timClicks>^ is direct link to section
[01:29:32]<shylent>so, timClicks, what is the problem?
[01:29:34]<roccity_>Vornicus: I was trying to develop a way to install apps like codecs and things on linux but I don't get teh subprocess stuff or how I would use it with say apt-get or yum -i
[01:29:38]<bob2>roccity_: you ain't going to escape shell just yet, but python is handy :)
[01:29:55]<roccity_>Vornicus: I thought that there was a thing called commands
[01:30:02]<papna>timClicks: In all of those examples, PIPE refers to the constant in the subprocess module.
[01:30:03]<timClicks>shylent: think I've found the problem
[01:30:13]*timClicks!~timClicks@219-89-80-120.adsl.xtra.co.nz should RTFM
[01:30:21]<timClicks>papna: ty
[01:31:22]<Vornicus>roccity_: to be honest I've never used subprocess to its full power.
[01:32:51]<roccity_>Vornicus: do you know how I would use it for something like apt-get or yum -i?
[01:33:55]<Vornicus>No. I don't often find myself on Linux either
[01:34:46]<shylent>aww, you are a Mac guy then?
[01:35:05]<Vornicus>mac/windows. Mostly mac when I do dev.
[01:35:43]<Vornicus>(mostly windows when I want to blow shit up. Fortunately, my favorite blow shit up game is Half-Life 2, and it's coming to mac! ...or maybe this isn't so fortunate, my poor productivity...)
[01:35:57]<prefrontal>shylent, output = Popen('apt-get -y install my_package', stdout=PIPE).communicate()[0]
[01:36:06]<shylent>ah, video games, I've completly forgotten about those :P
[01:36:36]<Noxilenticus>how do I get the current path my script starts out in other than by hacking up argv[0]?
[01:37:13]<shylent>prefrontal: don't know why you are addressing this to me :P BUT try not to pass strings to Popen. I think, that passing arguments as lists is a much better idea
[01:37:28]<prefrontal>oh that was for roccity_
[01:37:59]<prefrontal>passing it as a list seems unnecessary. i've been using that exact line of code for 2 years (command notwithstanding)
[01:38:27]<shylent>prefrontal, up to you, of course :)
[01:38:39]<roccity_>prefrontal: thanks
[01:38:54]<shylent>but as a matter of public record, it is much harder to mess stuff up if you pass it as a list
[01:39:53]<Vornicus>Noxilenticus: os.getcwd() knows where you called it from. Unless you mean where the script itself lives -- this is a bit more of a challenge; I'd ask the unix util "which" at the top of the program.
[01:40:25]<bhagat>what changes I have to make in this apache Vhost so I can execute .py files from the directory "modWSGI
[01:40:27]<Noxilenticus>awesome Vornicus that is all I need thank you
[01:40:27]<prefrontal>alright well here is an example i wrote that uses a list. quite a nice command: http://pastebin.ca/1831333
[01:40:28]<infobob>http://bpaste.net/show/4026/ (repasted for prefrontal)
[01:40:55]<hachque>how can i detect if a program can be executed (e.g. if a program is available in the PATH?)
[01:41:03]<bhagat>can anyone help me to do this http://paste.pocoo.org/show/187803/ ^^^^
[01:41:22]<Vornicus>hachque: the unix util "which" does precisely this.
[01:41:27]<Acedip>shylent: i got it, i was trying to pass the argv which is a list to a function
[01:42:05]<hachque>Vornicus: yeah but i need to do it from Python and on windows
[01:43:53]<prefrontal>hachque, use sys.path and glob.glob
[01:43:53]<Vornicus>hachque: ...okay you, uh. well I can't really call that winning.
[01:44:16]<prefrontal>hachque, you can use glob.glob on every path in sys.path and then use a quick list lookup to see if the cmd is there
[01:44:34]<roccity_>thanks Vornicus and prefrontal
[01:45:09]<Vornicus>Acgtually that'd be a good one. Write which for windows.
[01:45:53]<Vornicus>and dammit you people I need to wash dishes and sleep! Stop distracting me! :P
[01:48:33]<prefrontal>hachque, here is my quick impl of 'which': if 'my_cmd' in [glob.glob(x + '/*') for x in sys.path]: print True
[01:51:21]<hachque>thanks prefrontal
[01:59:15]<ohan_magopian>completely python-unrelated question, i need to ask in an english speaking channel: could someone explain to me what a "conchord" is?
[02:00:09]<Snova>I've never heard of it... and neither has Google
[02:00:27]<ohan_magopian>wondering what "flight of the conchords" mean
[02:00:29]<ohan_magopian>maybe nothing :/
[02:00:33]<ohan_magopian>(name of a band)
[02:00:48]<prefrontal>type define:conchord into google.
[02:00:53]<kosh>concord, large bird
[02:01:06]<kosh>name of a supersonic passenger jet
[02:01:07]<Snova>Flight of the Conchords is the only thing that Google pulls up though
[02:01:30]<Snova>it could also be a play on the word "chord", though I'm not sure what "con" would mean here
[02:01:40]<confluency>ohan_magopian: I think it's a deliberate misspelling of "concord", to suggest a pun on "chord".
[02:01:46]<confluency>Snap. :)
[02:01:53]<ohan_magopian>oh ok
[02:02:13]<ohan_magopian>i thought it was something like a small fish that are usually packed in tin boxes
[02:02:16]<ohan_magopian>how are those called?
[02:02:25]<ohan_magopian>we call them "sardines" in france
[02:02:38]<Snova>I can only think of sardines.
[02:02:43]<ohan_magopian>oh
[02:02:50]<ohan_magopian>well, then it's just my brain messing up
[02:03:05]<ohan_magopian>sorry about that guys ;)
[02:03:10]<ohan_magopian>back to python then :D
[02:04:00]<ohan_magopian>i was wondering (python related this time ;) how to know when something is available in the __future__ module?
[02:04:17]<ohan_magopian>like, the "with" statement, if i'm in python 2.4, should it be importable from __future__ ?
[02:04:52]<l0nwlf>ohan_magopian: dir(__future__) ?
[02:05:11]<ohan_magopian>that works if i have a python 2.4 at hand :D
[02:08:30]<monokrome>Is it possible to use virtualenv to create an environment with Python 3 in it?
[02:08:37]<ohan_magopian>(thanks confluency for telling me about pilchards, which does, well, nearly, sound like "chords" ;)
[02:08:55]<jorrit>Hi
[02:17:32]<shahbazi>hi all
[02:17:46]<shahbazi>how can i stick two lists together?
[02:17:54]<jorrit>l1.extend(l2)
[02:18:28]<shahbazi>jorrit: i dont want use extend
[02:18:40]<jorrit>shahbazi, well...
[02:18:51]<jorrit>shahbazi, that's like saying: how can I add two numbers but I don't want to use '+'
[02:19:08]<jorrit>shahbazi, so why not?
[02:19:30]<shahbazi>coz i want to write it in one line
[02:19:38]<jorrit>shahbazi, sorry. No way.
[02:19:48]<shahbazi>let me paste the code
[02:19:51]<jorrit>shahbazi, and please avoid trying to make writing one-liners a goal.
[02:19:56]<jorrit>shahbazi, that's really not useful.
[02:20:14]<timClicks>is there any way to tell str.split to create a tuple, rather than a list?
[02:20:22]<_habnabit>l1.extend(l2) is one line.
[02:20:29]<_habnabit>timClicks, no.
[02:20:34]<timClicks>_habnabit: okay
[02:20:39]<shahbazi>[[[1+i*4,5+i*4],[2+i*4,6+i*4]] for i in range(4)]
[02:20:51]<shahbazi>it is what i wanna do
[02:20:56]<shahbazi>i want to make the lists
[02:21:04]<shahbazi>and stick them together
[02:21:08]<shahbazi>in just one line
[02:21:25]<qebab>Why does it have to be "just one line"?
[02:21:26]<_habnabit>shahbazi, I don't see what you're asking.
[02:21:46]<shahbazi>lets make it abit simpler
[02:22:05]<shahbazi>i have a list:
[02:22:39]<shahbazi>[[[1,2],[3,4]],[[5,6],[7,8]]]
[02:22:59]<shahbazi>and im looking for an statement to make the list like this:
[02:23:17]<shahbazi>[[1,2],[3,4],[5,6],[7,8]]
[02:23:27]<shahbazi>is there a way to do this?
[02:23:48]<shahbazi>i used "sum" but did not work
[02:23:49]<_habnabit>[x for x in L for x in x]
[02:24:12]<_habnabit>sum is only for numbers. Don't use it for anything else.
[02:25:31]<shahbazi>_habnabit: ok
[02:25:35]<shahbazi>im trying it
[02:25:46]<shahbazi>it shud work
[02:26:49]<snappy>1
[02:26:51]<snappy>er sorry
[02:36:20]<shahbazi>it works
[02:36:24]<shahbazi>thank you
[03:04:26]<monokrome>Hey. Does anyone here know any reason why it would be a bad idea to use a virtualenv as a user home directory?
[03:05:03]<monokrome>IE, if I had a user for each website hosted on a server and used their home directory as their virtual environment root
[03:05:58]<Khmar>I often delete virtualenv's after I'm done with my project. I can't do that with home directories.
[03:06:35]<Khmar>But I guess that wouldn't apply to 'daemon' users.
[03:06:49]<monokrome>Yea, I plan on keeping the websites running in the virtualenv so that updating modules doesn't mess up the install
[03:07:03]<monokrome>er... The project?
[03:07:12]<lvh>monokrome: sure, that sounds like a good idea, although strictly speaking you don't need the virtualenv
[03:08:53]<monokrome>Well, I plan on updating modules as time goes on and I keep writing new apps - but I don't want it to break the old ones.
[03:09:18]<bob2>right, but all virtualenv does is free you from setting PYTHONPATH and PATH
[03:09:23]<_habnabit>You can use ~/.local directories.
[03:10:02]<monokrome>~/.local?
[03:10:06]<_habnabit>Yep.
[03:10:57]<monokrome>Do you know where I could find an article describing those?
[03:11:17]<monokrome>Googling "~/.local" isn't too helpful :)
[03:11:23]<_habnabit>There's nothing special about it, and nothing to explain.
[03:11:29]<_habnabit>You use ~/.local as your prefix.
[03:11:40]<_habnabit>python setup.py install --prefix=~/.local
[03:11:47]<monokrome>ooh
[03:11:52]<bob2>well, isn't it special in the sense that 2.6 looks in there by default?
[03:11:57]<bob2>(for libs)
[03:12:02]<_habnabit>2.6+, yeah.
[03:14:36]<jita>I know basic python, i want to gain practical knowledge of it. what should i do? make program or read some open source code, i haven't made any program before
[03:15:15]<jorrit>jita, the answer to that question differs depending on the person and how you like to learn. Personally I can only learn stuff by using it. So I would select some project (not too big) and start working on it.
[03:15:16]<kkb110>jita: what kind of program do you want to make eventually
[03:15:52]<jita>kkb110: i have no particular progam in mind, i just want to learn programming
[03:18:01]<lasko>jita: Well what are you interested in? Command line application, GUI interface programming?
[03:18:37]<jita>lasko: for the time being, i will stick to command line application till i get a good grasp of things
[03:19:22]<kkb110>jita: I think the first you should do is setting a goal.. which is not too broad
[03:19:26]<lasko>jita: And what are you interested in programming?
[03:20:18]<lasko>jita: How about starting off with basic games? IE: Hangman game, or a single player MUD application. These kinds of projects can develop both basic skills and as well introduce to you advance techniques.
[03:21:15]<jita>lasko: MUD application?
[03:21:54]<lasko>jita: Well Multi User Dungeon.
[03:22:28]<jita>lasko: ok thanks, i will look into it
[03:23:00]<cnfer>morning
[03:25:56]<cnfer>is there a reference about the format of your docstrings?
[03:26:15]<bob2>cnfer: epytext is what basically everything uses
[03:26:37]<_habnabit>epytext or ReST.
[03:27:07]<cnfer>ah, not quite what i meant, but useful none the less :P
[03:27:40]<cnfer>i meant on the way it documents it's expected parameters etc
[03:27:55]<bob2>epytext or rest are two ways to do that
[03:27:58]<_habnabit>Yes, that's what we're talking about.
[03:28:17]<bob2>python itself does not care at all, doc extraction tools do, and they usually support one or both of the above
[03:28:46]<cnfer>http://epydoc.sourceforge.net/epytext.html right?
[03:28:59]<bob2>yeah
[03:29:02]<_habnabit>Sure.
[03:29:09]<bob2>is that not the sort of thing you're lookign for?
[03:29:24]<cnfer>no, that shows me the markup language
[03:29:29]<cnfer>i meant the conventions
[03:29:29]<wohnout>HI is there anybody using suds soap client? I have small problem with client.service.<Method>. One of my methods is returning type which defined in WSDL. I'm able to create object by client.factory.create but not to retrieve it by this client.service.<Method> http://pastebin.ca/1831446
[03:29:29]<_habnabit>Oh, that doesn't have tags.
[03:29:35]<infobob>http://paste.pocoo.org/show/187815/ (repasted for wohnout)
[03:29:52]<Insectoid>Just submitted my first package to PyPi but by using the correct install_requires keyword in setup.py easy_install fails with pywin32 installation. Is there anything at all I can do about this/anyone I can poke?
[03:29:57]<_habnabit>cnfer, http://epydoc.sourceforge.net/manual-fields.html
[03:30:21]<cnfer>like do i type "foo is a variable" or do i type "foo: int" or "int => foo"
[03:30:38]<_habnabit>00:29:57 < _habnabit> cnfer, http://epydoc.sourceforge.net/manual-fields.html
[03:31:01]<rioch>I've replaced string in my code with _(). What tool do I use to create the .po/.pot files?
[03:31:34]<Insectoid>rioch: PoEdit if you're on Windows.
[03:32:02]<rioch>and on Linux? :)
[03:32:09]<cnfer>hmm
[03:32:32]<TheSheep>rioch: poedit, virtaal and a couple more
[03:32:34]<bob2>rioch: pygettext and xpot apparently exist
[03:32:53]<cnfer>_habnabit: that looks like the one, mostly
[03:32:54]<cnfer>thanks
[03:33:05]<bob2>cnfer: what's the mostly bit? how to specify types?
[03:33:34]<rioch>thanks bob2
[03:35:43]<cnfer>bob2: python itself doesn't parse the epydoc tags?
[03:35:53]<cnfer>like when i do help(myfunction)
[03:36:17]<_habnabit>cnfer, help() shows exactly what you've written.
[03:36:21]<bob2>pretty sure it just displays it
[03:36:22]<_habnabit>cnfer, no parsing.
[03:36:28]<cnfer>yeah, looks like it
[03:36:43]<_habnabit>cnfer, tags and formatting are only used by documentation generators.
[03:37:04]<cnfer>i'm trying to make my packages to output help similar to that of "official" ones
[03:37:22]<_habnabit>Such as?
[03:37:25]<bob2>like docs.python.org/lib?
[03:37:32]<bob2>if so, you're not going to like the answer :)
[03:38:32]<cnfer>no, not web based, purely when i run help() on them
[03:39:00]<cnfer>i find that i use that quite a lot
[03:39:10]<bob2>which bit can't you replicate?
[03:40:52]<cnfer>atm, any of it :P
[03:41:37]<bob2>ok, so you type 'from mypackage import SomeClass ; help(SomeClass)' - what doesn't look right?
[03:46:17]<cnfer>trying to compare it, but mine doesn't have a lot atm
[03:48:47]<cnfer>ok, for example when i run help on mine, it shows me every function, and every thing DATA right?
[03:48:59]<cnfer>when i do the same on gzip, it is hiding some of that
[03:49:57]<bob2>gzip is a C module
[03:50:35]<cnfer>i got gzip.py open
[03:50:45]<bob2>ah, sorry
[03:50:48]<bob2>I was thinking of zlib
[03:51:07]<_habnabit>cnfer, it defines __all__
[03:51:39]<cnfer>it does. no idea what that does, but i'm googling :P
[03:52:26]<bob2>http://stackoverflow.com/questions/2187583/whats-the-python-all-module-level-variable-for
[03:53:55]<cnfer>oohhh
[03:53:59]<cnfer>hmm, now that is interesting
[03:55:26]<[thyko]>hi people
[03:55:57]<josvuk>Hi
[03:56:04]<cnfer>thanks! that sure explains a lot
[03:57:12]<bhagat>how can I execute .py files in a directory named modWSGI , I loaded apache with mod_wsgi , whats wrong here http://paste.pocoo.org/show/187820/ ?
[03:57:42]<bob2>that's not really how mod_wsgi works, afaik
[03:57:51]<bob2>it wants you to point it at each script individually
[03:58:16]<_habnabit>Lines 5-10 are redundant.
[03:58:19]<_habnabit>Remove 'em.
[04:00:40]<bhagat>so I need to rename each .py file to .wsgi ?
[04:00:58]<bob2>no
[04:01:12]<bob2>I'm pretty sure you need one WSGIScriptAlias line per script
[04:01:19]<bob2>or to do the dispatch in your python script
[04:03:30]<bhagat>bob2; if it so, if I have a python application y contain x number of .py files in a directory named "blah" how to deploy it ?
[04:04:00]<bhagat>in apache using mod_wsgi ?
[04:04:06]<bhagat>is it possible ?
[04:05:40]<_habnabit>bhagat, what application is this?
[04:05:44]<bob2>wsgi is for wsgi apps
[04:05:48]<ikanobori>It doesn't work like PHP.
[04:05:53]<bob2>wsgi apps aren't piiles of unrelated .py files in a directory
[04:07:11]<bhagat>http://paste.pocoo.org/show/187827/
[04:08:05]<_habnabit>bhagat, did you write this code?
[04:09:12]<bhagat>bob2: I want to execute .py files in browser, I used mod_python for this, but some of you advised me to go for mod_wsgi but I am new to mod_wsgi
[04:10:25]<bhagat>_habnabit, I saw some one trying to do similar like this with BeautifulSoup I want to know whether it works for me too..
[04:10:42]<_habnabit>bhagat, see, I don't know why you thought this code would do anything.
[04:10:56]<_habnabit>bhagat, it's not WSGI, it's not CGI, it's not a mod_python handler, ...
[04:11:02]<cnfer>aha, http://www.python.org/dev/peps/pep-0257/ is interesting
[04:13:47]<_habnabit>bhagat, have you even read a WSGI tutorial?
[04:13:47]<kosh>_habnabit: are you sure people still read? I thought everything was idiot proof and handed out in soundbytes
[04:13:47]<bhagat>_habnabit, is it on http://code.google.com/p/modwsgi/ ?
[04:13:47]<_habnabit>bhagat, no, it's not a mod_wsgi-specific thing.
[04:13:47]<_habnabit>bhagat, wsgi.org has a bunch.
[04:14:20]<bob2>bhagat: mod_wsgi is for running wsgi-compliant apps, not random python files
[04:14:31]<bob2>bhagat: you'll need to wrap all this code in a basic wsgi app to make it work with mod_wsgi
[04:14:45]<bob2>bhagat: to make it work with mod_python, I gather you'd need to do something similar
[04:14:57]<bhagat>aah okay, let me go through, but what the problem with old style mod_python ? is it due to restarting all the time the webserver ?
[04:15:08]<bhagat>bob2 ; sure I am reading the docs
[04:15:27]<_habnabit>bhagat, mod_python has a lot of problems and I don't feel like enumerating them all right now.
[04:15:36]<_habnabit>bhagat, the biggest is that it's not intended for writing web applications.
[04:15:44]<bhagat>bob2, mod_python way works for me , but wsgi totally new to me
[04:15:50]<_habnabit>bhagat, another big one is it's not actively maintained or developed anymore.
[04:17:36]<josvuk>Hm, myjob='hacker' for c in myjob: print(c, end=' ') should print me h a c k e r acording to my lecture, but it doesnt it rises an error,
[04:17:45]<josvuk>what is going wrong?
[04:18:05]<hachque>does anyone know any good benchmarking scripts that test the speed of python?
[04:18:07]<_habnabit>josvuk, you're reading a python 3.x tutorial and using python 2.x.
[04:18:12]<_habnabit>hachque, pystone.
[04:18:20]<_habnabit>josvuk, read a python 2.x tutorial.
[04:19:42]<hachque>_habnabit: actually i kinda need a script that isn't a module
[04:19:49]<hachque>just a plain old performance testing script
[04:20:10]<_habnabit>hachque, ... yes, that's what pystone is.
[04:21:50]<hachque>yeah... i kinda need something without classes or anything like that
[04:21:50]<bhagat>_habnabit, bob2 thanks a lot..
[04:21:56]<hachque>just mathematical performance
[04:22:21]<_habnabit>hachque, how about you explain what you're actually trying to do instead of retroactively adding silly constraints.
[04:22:22]<hachque>there has to be some performance-intensive math problems out there :P
[04:22:39]<hachque>i need a script that I can run in both Python and my compiled language to test performace
[04:22:48]<josvuk>argh, habnabit thats cruel :-(
[04:25:22]<bhagat>how to simulate a load test on python applications which involves login and read/write queries to databases (say Postgres ) any hints ?
[04:26:34]<ikanobori>With a script run in parallel a few times.
[04:27:47]<rioch>for i18n, I generate .h files containing the translatable strings in a .glade file. Do I need to keep these .h files after the .pot file is generated, or can I delete them?
[04:28:16]<ikanobori>Does it hurt to keep them?
[04:28:38]<kosh>might run out of space ;)
[04:28:52]<ikanobori>It's just xml :-(
[04:29:20]<kosh>ikanobori: obviously I needed sarcasm tags
[04:31:03]<scottwolchok>what's the least painful portable way to convert from uint32_t to Python integer using the C API and eventually ending up with the integer as part of a tuple? Py_BuildValue doesn't seem to support it directly
[04:31:52]<scottwolchok>and calling PyInt_FromSize_t as an argument to Py_BuildValue will leak on error (if there's more than one and only one fails)
[04:32:38]<_habnabit>PyInt_FromUnsignedLong
[04:32:50]<ikanobori>kosh: Or you.
[04:32:55]<ikanobori>kosh: I mean, me.
[04:33:14]<scottwolchok>_habnabit: no such function is documented
[04:33:29]<scottwolchok>_habnabit: at least not at http://docs.python.org/c-api/int.html
[04:34:07]<scottwolchok>_habnabit: however, the k param to Py_BuildValue & explicit cast to unsigned long in args list seems to be what I want
[04:34:21]<_habnabit>Oh, right, PyLong_FromUnsignedLong.
[04:35:06]<jseutter>Could anyone help me sort out why easy_install can't find the package I published on PyPI?
[04:35:58]<scottwolchok>_habnabit: yeah, but that's kind of a lame function because you always get a Python long when a Python int might do
[04:36:12]<_habnabit>scottwolchok, so? ints and longs are interchangable.
[04:36:19]<_habnabit>interchangeable, even.
[04:36:51]<thrashold>scottwolchok: uint32 might not fit in Python int on some platforms
[04:37:23]<bob2>what python platform has an unsigned int shorter than 32 bits?
[04:37:25]<scottwolchok>thrashold: good point. I only care about x86/x86_64 for this application, though. (while I strive to write good research code, there are limits)
[04:37:52]<thrashold>bob2: Er? Python int is signed int AFAIK.
[04:37:58]<_habnabit>bob2, python int is signed long.
[04:38:10]<thrashold>scottwolchok: uint32 doesn't fit in Python int on x86
[04:38:11]<bob2>ah, sorry
[04:39:32]<christopher22>hello I have a XML which has the following attribute: ctr="5.030641178084698E-4".. on the website however I see 0.05.. is it possible to calculate 5.030641178084698E-4 --> to 0.05 ?
[04:40:59]<jseutter>christopher22: num = float('5.030641178084698E-4')
[04:41:28]<jseutter>christopher22: It should be 0.0005, not 0.05
[04:41:34]<christopher22>ty I just saw the same output in my script.. when I did print on round(float(num))
[04:41:41]<christopher22>needs multiplying
[04:41:44]<christopher22>times 100
[04:41:47]<jseutter>nod
[04:42:13]<jseutter>looks like they're doing percent
[04:44:07]<christopher22>true
[04:44:27]<christopher22>they are doing percentage so it's 0.05%
[04:47:30]<monokrome>Nobody is speaking in #wsgi, so I hope someone in here can help. This is copied from the mod_wsgi docs: "Note that this option is ignored if Apache wasn't started as the root user". Considering Apache shouldn't be run as root, will this work if Apache is in the wheel group?
[04:47:57]<bob2>no
[04:48:03]<bob2>apache should start as root
[04:48:06]<bob2>then it chuids
[04:48:11]<bob2>er setuids
[04:48:26]<bob2>putting it in the wheel group is insane
[04:48:54]<bob2>it's opening up a local root exploit
[04:49:32]<monokrome>bob2: I thought running Apache as root would be fine, but it fails: http://dpaste.com/170331/
[04:50:08]<bob2>read the last three lines
[04:50:21]<christopher22>I was wondering is this the best way to get: 0,05% --> http://dpaste.com/170332/
[04:50:27]<kosh>running apache or any network service as root is IDIOTIC
[04:50:35]<kosh>that is why it tries to prevent that stuff
[04:50:56]<christopher22>some things might not be completely right.. since the code is actually a lot longer.. but I only took out the relevant part
[04:50:58]<bob2>(if you just use your os's packages, it'll do this for you)
[04:51:07]<kosh>I have run into many programs that flat out refuse to run if you try to run them as root
[04:51:30]<monokrome>bob2: My "User" is set to www-data
[04:51:41]<bob2>apache seems to disagree
[04:51:47]<monokrome>That ran into the error of not being able to spawn daemons ran by different users, so I changed it to "root"
[04:51:52]<monokrome>Sorry, I mean it defaults to www-data
[04:52:19]<bob2>I'd undo everything you've done
[04:52:23]<bob2>all of it
[04:52:23]<monokrome>I have
[04:52:37]<bob2>your OS has an apache package that doesn't run out of the box?
[04:52:48]<monokrome>It runs, and it's back to "default" now
[04:53:02]<monokrome>I undid setting it to "root" after it didn't work
[04:53:04]<bob2>so the pastebin'd error is fixed?
[04:53:23]<monokrome>Indeed, but my WSGI scripts are running as "www-data" instead of the user set in WSGIDaemonProcess
[04:53:54]<jseutter>christopher22: you've hit the limit of my knowledge. That looks correct to me, however. I'm not familiar with locales.
[04:54:11]<christopher22>ok well thank you for your time to look into it :-)
[04:54:12]<monokrome>I am testing the user running the script with the following wsgi file: http://dpaste.com/170333/
[04:54:17]<christopher22>aprreciate it a lot
[04:54:23]<jseutter>no prob :)
[04:55:01]<bob2>monokrome: os.getuid
[04:55:12]<bob2>I'm not sure getpass gives you useful information here
[04:55:31]<monokrome>getpass.getuser gives the username of the current user... It printed "www-data" to the file
[04:56:06]<bob2>no it doesn't
[04:56:15]<bob2>try os.getuid
[04:56:17]<monokrome>ok
[04:56:42]<bob2>well, maybe it does, but I'm more sure of what getuid gives
[04:58:03]<monokrome>It gave me 33, which is www-data
[05:02:03]<monokrome>If Apache isn't supposed to run as root, and mod_wsgi has to have Apache running as root in order to spawn daemons as other users - how is this feature usable? :/
[05:02:54]<_habnabit>I'm pretty sure that it's smarter than that.
[05:03:09]<_habnabit>apache always starts as root and then setuids.
[05:03:11]<bob_f>_habnabit: Have you fixed your bot yet ?
[05:03:19]<_habnabit>bob_f, have you read the messages I left you yet?
[05:03:27]<bob_f>Nope.
[05:03:35]<bob_f>I don't have any.
[05:03:51]<monokrome>ok that makes sense... "ps aux" shows one apache2 process as root, and 3 as www-data
[05:04:10]<shylent>monokrome: is that apache-prefork?
[05:04:15]<shylent>in that case it makes sense
[05:06:40]<bob2>ah
[05:06:47]<monokrome>shylent: Not prefork
[05:06:56]<shylent>I didn't get much of a reply in #django, maybe someone here can enlighten me? Are there any particular scenarios of using python's logging module with django? I mean, in all my django webapps I've just used the toplevel logging functions (like logging.error, logging.warn etc) to log to the root logger, but sometimes that is clearly not enough. Any tips? Please? :(
[05:07:18]<bob_f>_habnabit: How did you send them to me ?
[05:07:26]<_habnabit>bob_f, addressed you in #python.
[05:07:42]<bob2>monokrome: which mpm?
[05:07:46]<monokrome>shylent: This might be useful for you http://code.google.com/p/django-logging/
[05:07:54]<monokrome>I've seen people mention it before.
[05:08:04]<_habnabit>Anyway, I should be asleep.
[05:08:10]<monokrome>bob2: Is there a way I can check?
[05:08:12]<bob2>maybe it needs prefork/worker
[05:08:49]<bob_f>_habnabit: Hmm. Well, I didn't get anything in my away log.
[05:09:00]<bob_f>_habnabit: Can you summarise ?
[05:09:13]<bob2>monokrome: errorlog from startup?
[05:09:13]<bob_f>I don't want to keep banning him if there's a good reason you keep unbanning him. :)
[05:09:29]<monokrome>worker.c?
[05:09:48]<monokrome>Yea, it's using "Worker"
[05:10:34]<_habnabit>bob_f, pastebin.com is still cluttered and still has ads. The other motivation for repasting is making sure that the highlighting is correct; more people seem to forget/ignore to choose python as the option when pasting to pastebin.com than other sites.
[05:10:59]<_habnabit>bob_f, also infobob repastes from pastebin.org, which is still using pastebin.com's old code but with even more ads.
[05:11:13]<bob_f>_habnabit: Hmm. I think the original reason was because pastebin was horribly hard to read. Now it isn't. The ads people can block if they like, I don't think that's really a reason to avoid it.
[05:11:44]<bob_f>_habnabit: I just feel that it's a little rude to tell people they can't use pastebin.com now, since it looks fine.
[05:12:26]<ikanobori>They should all use bpaste
[05:12:31]<ikanobori>All of them.
[05:13:02]<_habnabit>bob_f, shrug. I think it looks *better*, but still not "fine".
[05:13:18]<monokrome>bob2: So, it's using Worker but only 1 of my 4 Apache processes is running as root
[05:13:29]<bob2>ok, whatever
[05:13:29]<bob_f>I can read it without any problem. It seems a little nazi-ish to repaste from it now.
[05:13:49]<bob_f>Plus it's unnecessary noise.
[05:14:30]<cheater>but if it happens always then it's easier to filter out by our brains than if it happens only sometimes
[05:14:35]<_habnabit>That seems like a bit of an exaggeration.
[05:14:58]<_habnabit>anyway, bed.
[05:15:09]<bob_f>_habnabit: Hope you choke in your sleep. <3
[05:15:12]<bob2>monokrome: apache conf file?
[05:15:36]<monokrome>bob2: The VirtualHost or the entire apache2.conf?
[05:15:55]<bob2>former
[05:16:16]<josvuk>hm, s='spam' s[::-1] yields to 'maps' but why s[0:4:-1) don't :-(
[05:16:35]<bob2>4 is an invalid index
[05:16:43]<monokrome>http://dpaste.com/170336/
[05:17:03]<bob2>hm, I'm a liar
[05:17:23]<monokrome>That's the VirtualHost
[05:17:41]<bob2>monokrome: anything in /home/bctsaltlake/logs/error.log?
[05:20:11]<josvuk>hm, bob2 s[0:4] yields to 'spam' so it can't be an invalid index :-(
[05:20:31]<monokrome>bob2: Only the expected Target WSGI script '/home/bctsaltlake/bin/bctsaltlake.wsgi' does not contain WSGI application 'application'.
[05:20:32]<bob2>indeed
[05:20:40]<bob2>...
[05:21:01]<monokrome>Did you see the placeholder wsgi script I was using?
[05:21:04]<bob2>doesn't mod_wsgi just start up python processess to run the application itself?
[05:21:21]<bob2>provide a working script and see if it works
[05:21:38]<monokrome>The script I have writes the username running the application to a file
[05:22:14]<monokrome>The "working" WSGI script throws a database error because it can't access the database unless it's running as user bctsaltlake
[05:25:28]<blackslik>Hello Any Python Programmer here with some voip knowlegde
[05:26:41]<blackslik>Hello Any Python Programmer here with some voip knowledge
[05:27:18]<ikanobori>I know what VoIP means!
[05:27:26]<ikanobori>Any specific knowledge you require?
[05:27:39]<monokrome>So, Apache is being run as root and the daemon process user=username isn't working? :/ WSGI must be messing up
[05:33:20]<blackslik>Voice over IP
[05:34:11]<christopher22>hello I have the following datetime conversion: "aangemaakt op %s" % t.strftime("%d %B %Y, %H:%M uur")
[05:34:21]<ikanobori>christopher22: It's Dutch.
[05:34:21]<christopher22>but I was wondering if the date march could be changed into a dutch month?
[05:34:50]<nandersson>Hi, I would like to retrieve my file over http instead from the local filesystem. It seems the "parse" only accepts a file-object. How is this achieved? tree = etree.parse('examples/feed.xml')
[05:35:04]<ikanobori>christopher22: With the locale module.
[05:35:12]<christopher22>ok thank you
[05:35:17]<nandersson>..I.e tree = etree.parse('http://localhost/examples/feed.xml') fails
[05:35:36]<ikanobori>blackslik: If you need help with Python code you can ask in this channel instead of PM'ing me, there are more people here to respond.
[05:35:59]<bob2>nandersson: urllib.urlopen
[05:36:19]<nandersson>bob2, Ok! It works in Python3?
[05:36:40]<bob2>nandersson: you'll need to consult the python3 documentation to find where it moved
[05:37:11]<blackslik>Hello Any Python Programmer here with some voip knowlegde, i have this python code that i want help on
[05:37:18]<bob2>blackslik: stop it
[05:37:22]<bob2>blackslik: ask your question
[05:37:24]<b00^wk>hello
[05:37:25]<nandersson>bob2, Ok, I'll do that! Thanks!
[05:38:58]<thirsteh>What is the easiest way to get e.g. every second item of a list in a list of lists?
[05:39:39]<thirsteh>e.g. I want to make a tuple with all of the dates in: ((u'patrick', datetime.date(2010, 3, 26)), (u'patrick2', datetime.date(2010, 3, 31)), (u'patrick3', datetime.date(2010, 5, 10)))
[05:39:51]<bob2>that's a tuple of tuples
[05:40:02]<bob2>but: dates = [x[1] for x in yourtuplething]
[05:40:06]<thirsteh>Sorry, I always mix them up
[05:40:10]<thirsteh>Thanks bob2
[05:41:37]<blackslik>I want to make a python code automated like bring to codes to peform on the same command line also i am not a python programmer
[05:41:58]<bob2>blackslik: this isn't really a place to get people to do your work for you
[05:42:11]<bob2>blackslik: are you looking to learn python to do this task?