Creating (rather) generic plugin framework?

2005-11-16 Thread Edvard Majakari
Hi, My idea is to create a system working as follows: each module knows path to plugin directory, and that directory contains modules which may add hooks to some points in the code. Inspired by http://www.python.org/pycon/2005/papers/7/pyconHooking.html I would create a class like this: class

Re: Looking for info on Python's memory allocation

2005-10-31 Thread Edvard Majakari
- 2/3 actually. So, doubling the size of chunks is used, and the technique is quite common. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! You shouldn't verb verbs. -- http://mail.python.org/mailman/listinfo/python-list

Re: What XML lib to use?

2005-09-14 Thread Edvard Majakari
-compliant DOM parser could be good for learning things, though. As I said, depends a lot. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2

Re: time.mktime problem

2005-09-05 Thread Edvard Majakari
2.2, no datetime module was implemented. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n

Re: time.mktime problem

2005-08-30 Thread Edvard Majakari
. Hint... see what var ta1 is. With python2.3 you'll get overflow error, becuase mktime argument is out of range. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join

Re: HTML/text formatting question

2005-08-25 Thread Edvard Majakari
strings show examples how to use it. For serious HTML building stuff it needs fiddling with, but should be handy for tiny projects. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20

Re: How can I import a py script by its absolute path name?

2005-07-16 Thread Edvard Majakari
character. Moreover, I wans't the one asking for information, I have privilidge to use real operating systems as a programming platform. Thanks for enthsiasm, though :) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! You shouldn't verb verbs

Re: all possible combinations

2005-07-14 Thread Edvard Majakari
what you think it means. Inconceivable! -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! Debugging is twice as hard as writing the code in the firstplace. Therefore, if you write the code as cleverly as possible, you are, by definition

Re: How can I import a py script by its absolute path name?

2005-07-14 Thread Edvard Majakari
Thorsten Kampe [EMAIL PROTECTED] writes: sys.path.append('c:\\xxx\\yyy') or sys.path.append('c:/xxx/yyy') Well, of course. As I said, it was untested :) I just copied the path string, and didn't remember Windows uses path names which need special treatment. One more reason to avoid inferior

Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Edvard Majakari
more convenient. Footnotes: [1] Well, not exactly equal to -M in Perl, but close enough for timing stuff -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! You shouldn't verb verbs. -- http://mail.python.org/mailman/listinfo/python-list

Reading network interface data in linux

2005-07-13 Thread Edvard Majakari
Suppose one wants to fetch the following data from given network interface, say, eth0: Ethinf('eth0').addr() '192.168.1.42/24' Ethinf('eth0').route('default') '192.168.1.1' Ethinf('eth0').duplex() 'full' Ethinf('eth0').speed() 100 Some statistics: Ethstat('eth0').rx_bytes() 14325235341223

Re: Should I use if or try (as a matter of speed)?

2005-07-13 Thread Edvard Majakari
(pair programming) only few times, and even then it wasn't XP-style in any other way. It is too often considered waste of labour, I guess. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! Debugging is twice as hard as writing the code

Re: Should I use if or try (as a matter of speed)?

2005-07-12 Thread Edvard Majakari
at the moment: I should clean up a 120+ -line if-elif-elif-elif... else -block which tests a single variable and calls different methods with variable number of parameters depending on the value of the variable - guess I should apply command pattern or similar...) -- # Edvard Majakari

Re: Favorite non-python language trick?

2005-07-07 Thread Edvard Majakari
the fun for reinventing the wheel, doesn't it. :) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n

Re: Favorite non-python language trick?

2005-07-06 Thread Edvard Majakari
() instead. sys.stderr.write('warning: method some_method_which_is_badly_named_or_just_plain_wrong is now deprecated') -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! You shouldn't verb verbs. -- http://mail.python.org/mailman/listinfo

Re: Favorite non-python language trick?

2005-07-06 Thread Edvard Majakari
read the doc because I didn't need to). Neat, thanks. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es

Re: Escaping commas within parens in CSV parsing?

2005-07-01 Thread Edvard Majakari
. Regular expressions are nice too, but it is easy to make a mistake with those, and for non-trivial stuff they tend to become write-only. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria

Re: Programmers Contest: Fit pictures on a page

2005-07-01 Thread Edvard Majakari
Dan Sommers [EMAIL PROTECTED] writes: There's some sort of irony or something in there about not writing the best genetic algorithm, but I can't quite put my finger on it. +1 QOTW :) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria

Re: ANN: PyDev 0.9.5 released

2005-06-29 Thread Edvard Majakari
Dave Cook [EMAIL PROTECTED] writes: PyDev - Python IDE (Python Development Enviroment for Eclipse) version 0.9.5 has just been released. Does it work with the newly released Eclipse 3.1? Seems to work for me (but I've only coded one smallish Python program with it) -- # Edvard Majakari

Re: Boss wants me to program

2005-06-29 Thread Edvard Majakari
to commercial Python IDEs and could mature to the Other Way(TM) for developing Python programs (the other is, of course, vi(m)/(X)Emacs) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20

Re: Which kid's beginners programming - Python or Forth?

2005-06-28 Thread Edvard Majakari
, though. For some, 'more verbose' is 'more easy to understand'. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt

RRArray for Python?

2005-06-03 Thread Edvard Majakari
, and default slot values can be defined by the user. Edvard Majakari [EMAIL PROTECTED] class RRArrayError(Exception): pass class RRArray: Simple round-robin class for arbitrary items def __init__(self, slots, default=None): Instantiate RRArray object @param default: value

Re: how to accomplish dl progress bars?

2005-05-27 Thread Edvard Majakari
as well). -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n; -- http://mail.python.org/mailman

Re: Safe eval, or how to get list from string

2005-05-16 Thread Edvard Majakari
. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! Debugging is twice as hard as writing the code in the firstplace. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W

Re: Python features

2005-05-13 Thread Edvard Majakari
Fredrik Lundh [EMAIL PROTECTED] writes: does that apply to sturgeon's law itself? (fwiw, this is of course why google displays 10 results on the first page. according to the law, one of them is always exactly what you want). + 1 QOTW :-) -- # Edvard Majakari Software

Re: Module on Getting the Date Time

2005-05-12 Thread Edvard Majakari
) elapsed after 01.01.1970 1115881981.3717401 time.ctime() # current time in string format 'Thu May 12 10:13:20 2005' time.localtime() # current time as a tuple (2005, 5, 12, 10, 13, 30, 3, 132, 1) For details, see 'pydoc time' -- # Edvard Majakari Software Engineer # PGP PUBLIC

Re: Unique Elements in a List

2005-05-12 Thread Edvard Majakari
[EMAIL PROTECTED] (Aahz) writes: [x for x in data if data.count(x) == 1] suffice? it is also stable preserving order of items. Lemme demo: Only for small datasets -- this is an O(N^2) algorithm. I realized that, but maybe I should've pointed it out too. For the OP if he/she is unaware -

Re: Unique Elements in a List

2005-05-12 Thread Edvard Majakari
with smaller exponent was good, too. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n; -- http

Re: Unique Elements in a List

2005-05-10 Thread Edvard Majakari
there was such a nice method list.count(). -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! One day, when he was naughty, Mr Bunnsy looked over the hedge into Farmer Fred's field and it was full of fresh green lettuces. Mr Bunnsy, however

Re: Unique Elements in a List

2005-05-10 Thread Edvard Majakari
IOTW (idiom of the week). -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n; -- http

Re: Design advice for unit test asserters

2005-05-02 Thread Edvard Majakari
a module skeleton out of py.test suite, though it is not very mature yet. You can grab it from http://majakari.net/dl/pytestgen/ if you wish to try it. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! One day, when he was naughty, Mr Bunnsy looked

Re: Design advice for unit test asserters

2005-04-21 Thread Edvard Majakari
modules - I'm already seduced by the no-API py.test library...) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt

Re: Creating module skeleton from unit tests

2005-03-08 Thread Edvard Majakari
. But thanks for the tip, I could see what IBM has done and then forget about doing it automatically :) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex

Creating module skeleton from unit tests

2005-03-04 Thread Edvard Majakari
before the code, but many people wouldn't regard it as TDD then. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449

Re: Unit testing - one test class/method, or test class/class

2005-02-25 Thread Edvard Majakari
mentioned. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),\n; -- http://mail.python.org/mailman

Re: Unit testing - one test class/method, or test class/class

2005-02-25 Thread Edvard Majakari
integer when only positive # inputs make sense etc. Just like you said, they tell a bit different story each, so it probably makes sense to separate those. John Roth Edvard Majakari [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I just found py.test[1] and converted

Unit testing - one test class/method, or test class/class

2005-02-24 Thread Edvard Majakari
disappears if you start with writing your tests first: with TDD, you don't have untested methods, because you start by writing the tests first, and end up with a module that passes the tests -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria

Statement coverage tools revisited

2005-02-11 Thread Edvard Majakari
(' ') +dest.write(self.visited_pfx) else: -dest.write('! ') +dest.write(self.unvisited_pfx) dest.write(line) source.close() dest.close() -- # Edvard Majakari Software