Re: walking a directory with very many files

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 17:53:40 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 20090618081423.2e035...@coercion, Mike Kazantsev wrote: On Thu, 18 Jun 2009 10:33:49 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message

Re: multiprocessing and process run time

2009-06-19 Thread Mike Kazantsev
: http://code.google.com/p/procpy/ -- Mike Kazantsev // fraggod.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
. If it gets the right stuff, try the same with os.environ (prehaps vlc keeps socket location there, just like ssh/gpg-agents?). -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
blocking. Try this recipe: http://code.activestate.com/recipes/576759/ -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Mike Kazantsev
(query) result = db.store_result() data = result.fetch_row(maxrows=0, how=1) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Mike Kazantsev
myself, why how is 1 and wtf is this how, anyway!? ;) I can't seem to find any mention of such methods in documentation and even python source, guess they are implemented directly in underlying C lib. Hope I learned to abstract from such syntax since then, I sure do... -- Mike Kazantsev // fraggod.net

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
the second results, from py itself. My suggestion was just to compare them - pop the py shell, eval the outputs into two sets, do the diff and you'll see it at once. If there's an empty set then I guess it's pretty safe to assume that python creates subprocess in the same way the shell does. -- Mike

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 22:00:28 +0600 Mike Kazantsev mk.frag...@gmail.com wrote: On Fri, 19 Jun 2009 08:28:17 -0700 Tyler Laing trinio...@gmail.com wrote: Thanks mike, the idea that maybe some of the info isn't being passed is certainly interesting. Here's the output of os.environ

Re: n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Mike Kazantsev
max_tries). Also, you can get rid of code duplication by catching some basic urllib2 exception, then checking if it's urllib2.HTTPError and it's code is 404, retrying (continue for the loop case) otherwise. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http

Re: walking a directory with very many files

2009-06-17 Thread Mike Kazantsev
is that a problem? So you can os.listdir them? Don't ask me what for, however, since that's the original question. Also not every fs still in use handles this situation effectively, see my original post. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http

Re: walking a directory with very many files

2009-06-17 Thread Mike Kazantsev
On Wed, 17 Jun 2009 23:04:37 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 20090617142431.2b25f...@malediction, Mike Kazantsev wrote: On Wed, 17 Jun 2009 17:53:33 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: Why not use hex

Re: walking a directory with very many files

2009-06-17 Thread Mike Kazantsev
On Thu, 18 Jun 2009 10:33:49 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 20090617214535.10866...@coercion, Mike Kazantsev wrote: On Wed, 17 Jun 2009 23:04:37 +1200 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message

Re: persistent composites

2009-06-16 Thread Mike Kazantsev
. I've read this thread from the beginning, being tempted to insert remarks about shelve module or ORMs like SQLAlchemy, but that'd be meaningless without the problem description, which I haven't seen anywhere. Is it some trick idea like let's walk on our heads? -- Mike Kazantsev // fraggod.net

Re: Newbie help for using multiprocessing and subprocess packages for creating child processes

2009-06-16 Thread Mike Kazantsev
a nail with sledgehammer - just _read_ or _write_ to pipes asynchronously. -- Mike Kazantsev // fraggod.net -- http://mail.python.org/mailman/listinfo/python-list

Re: walking a directory with very many files

2009-06-16 Thread Mike Kazantsev
or reiserfs by a small margin. Sadly, that's not the case with filesystems like FreeBSD ufs2 (at least in sixth branch), so it's better to play safe and create subdirs if the app might be run on different machines than keeping everything in one path. -- Mike Kazantsev // fraggod.net

Re: Logging multiple lines

2009-06-16 Thread Mike Kazantsev
the prefix at the beginning of every line? I'd log exception name and timestamp (or id) only, pushing the full message with the same id to another log or facility (like mail it to some dedicated bug-report box). -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http

Re: walking a directory with very many files

2009-06-16 Thread Mike Kazantsev
On Wed, 17 Jun 2009 03:42:02 GMT Lie Ryan lie.1...@gmail.com wrote: Mike Kazantsev wrote: In fact, on modern filesystems it doesn't matter whether you accessing /path/f9e95ea4926a4 with million files in /path or /path/f/9/e/95ea with only hundred of them in each path. Former case (all

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread Mike Kazantsev
On Mon, 15 Jun 2009 05:37:14 -0700 (PDT) OdarR olivier.da...@gmail.com wrote: On 13 juin, 07:25, Mike Kazantsev mk.frag...@gmail.com wrote: There was quite interesting explaination of what happens when you send ^C with threads, posted on concurrency-sig list recently:  http://blip.tv

Re: parsing json using simplejson

2009-06-15 Thread Mike Kazantsev
On Sun, 14 Jun 2009 22:45:38 -0700 (PDT) deostroll deostr...@gmail.com wrote: I need to be able to parse a json data object using the simplejson package. First of all I need to know all the task needed for this job. Note that py2.6 has a bundled json module. -- Mike Kazantsev // fraggod.net

Re: waling a directory with very many files

2009-06-15 Thread Mike Kazantsev
with map, filter, and range, but I made no effort and hence cannot complain. Why? We have itertools.imap, itertools.ifilter and xrange already. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: parsing json using simplejson

2009-06-15 Thread Mike Kazantsev
() data.see_also.new_item['z'] = 3 print data.see_also.new_item.z -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-Threading and KeyboardInterrupt

2009-06-15 Thread Mike Kazantsev
. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-14 Thread Mike Kazantsev
contextmanager decorator: from contextlib import contextmanager @contextmanager def get_cursor(): try: cursor = conn.cursor() yield cursor except Exception as ex: raise ex finally: cursor.close() with get_cursor() as cursor: # whatever ;) -- Mike Kazantsev

Re: Make upof Computer

2009-06-14 Thread Mike Kazantsev
On Sun, 14 Jun 2009 00:46:16 -0700 (PDT) Mr . Waqar Akbar wqr.ak...@gmail.com wrote: ... Judging by the typo in the last subject, someone indeed types all this crap in manually! Oh my god... -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org

Re: Different types of dicts with letter before the curly braces.

2009-06-14 Thread Mike Kazantsev
dict() to declare a dict, not some mix of letters and incomprehensible symbols, thank you. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Different types of dicts with letter before the curly braces.

2009-06-14 Thread Mike Kazantsev
so much sugar to add before it'll transform into salt and you'll start seeing lines like these: s**'@z!~;()=~$x;%xl;$(,x'*e;y*%z),$;@=x!;h(l~;*punch jokers;halt;*;print; I'm happy to use python because it discourages such syntax, among other things. /flame_war_alert -- Mike Kazantsev

Re: moving Connection/PipeConnection between processes

2009-06-13 Thread Mike Kazantsev
for py implementation of this call, which I haven't stumbled upon, but, admittely, never looked for. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-Threading and KeyboardInterrupt

2009-06-13 Thread Mike Kazantsev
links? Thanks for sharing this link, although I prefer such information in written form - it's easier/faster to work with and much more accessible. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] Multi-Threading and KeyboardInterrupt

2009-06-12 Thread Mike Kazantsev
explaination of what happens when you send ^C with threads, posted on concurrency-sig list recently: http://blip.tv/file/2232410 http://www.dabeaz.com/python/GIL.pdf Can be quite shocking, but my experience w/ threads only confirms that. -- Mike Kazantsev // fraggod.net signature.asc

Re: Lexical scope: converting Perl to Python

2009-06-12 Thread Mike Kazantsev
the private values, so I'd suggest getting some fresh air when you start to feel like doing that. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Specify the sorting direction for the various columns/

2009-06-11 Thread Mike Kazantsev
'].timetuple( Here time is inversed, yielding reverse sort order by that column. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: do replacement evenly

2009-06-02 Thread Mike Kazantsev
]) for word in words[1:]: if count_span_max: count_span_max -= 1 line += span_min + ' ' else: line += span_min line += word print '%d chars: %r'%(len(line), line) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org

Re: extract to dictionaries

2009-05-29 Thread Mike Kazantsev
( (lines.next(), dict(it.imap(str.split, lines))) for sep,lines in it.groupby(it.ifilter(bool, it.imap(lambda x: x.strip(spaces), src)), key=lambda x: x == 'end') if not sep ) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org

Re: Set a variable as in setter

2009-05-24 Thread Mike Kazantsev
) # !!! as in init def _change(self, text): return text + 'any change' --- -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get rid of pyc files ?

2009-05-24 Thread Mike Kazantsev
be amazed how much insight man python and python -h can yield ;) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Set a variable as in setter

2009-05-24 Thread Mike Kazantsev
On Sun, 24 May 2009 19:03:26 +0600 Mike Kazantsev mk.frag...@gmail.com wrote: On Sun, 24 May 2009 05:06:13 -0700 (PDT) Kless jonas@googlemail.com wrote: Is there any way to simplify the next code? Because I'm setting a variable by default of the same way than it's set in the setter

Re: While Statement

2009-05-22 Thread Mike Kazantsev
sense to me than an explicit conversion. There's also op.itruediv for number /= float(total) * 100 case. http://docs.python.org/dev/library/operator.html -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: optparse options

2009-05-20 Thread Mike Kazantsev
- it should make CLI more consistent and save some typing by omitting otherwise always-required option argument (--part). -- Mike Kazantsev // fraggod.net signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another question about class property.

2009-05-20 Thread Mike Kazantsev
Jim Qiu wrote: Hi everyone, Following is the code i am reading, i don't see anywhere the declaration of Message.root object, Where is it from? ... Prehaps it gets assigned by the parent itself? Like this: def spawn_child(self): child = Message() child.root = self -- Mike

Re: SpellChecker

2009-05-20 Thread Mike Kazantsev
. text = 'some text to correct (anything, really)' result = buffer('') word, c = buffer(''), '' for c in text: if c.isalpha(): word += c else: if word: result += correct(word) word = buffer('') result += c -- Mike Kazantsev // fraggod.net

Re: Import and absolute file names, sys.path including ''... or not

2009-05-20 Thread Mike Kazantsev
? Looks like a solid way to construct relative imports to me. -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get Form values in Python code and Send Email

2009-05-20 Thread Mike Kazantsev
) smtp = smtplib.SMTP(relay) smtp.sendmail(from, to, msg.as_string() ) smtp.close() -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert a list of strings to a tuple of floats?

2009-05-18 Thread Mike Kazantsev
as it ftuple = tuple(it.imap( float, line.split('; ') )) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: pushback iterator

2009-05-17 Thread Mike Kazantsev
the cache, or just get on with that iterable until it depletes. What real-world scenario am I missing here? -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Re: pushback iterator

2009-05-17 Thread Mike Kazantsev
managed to avoid such re-iteration scenarios, but of course, it could be just my luck ;) -- Mike Kazantsev // fraggod.net signature.asc Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list