Re: Creating (rather) generic plugin framework?

2005-11-17 Thread Edvard Majakari
Thanks both to Bruno and Jean-Paul! I think I'll go the twisted way (I try to avoid re-inventing the wheel here) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! "Debugging is twice as hard as writing the code in the firstplace.

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 P

Re: Looking for info on Python's memory allocation

2005-10-31 Thread Edvard Majakari
more. But the problem is you'd waste even more memory - 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
eful in traversing the parse tree (and maybe even then). Using a SAX / full-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! $_ = '456476617264204d616

Re: time.mktime problem

2005-09-05 Thread Edvard Majakari
"", line 1, in ? OverflowError: mktime argument out of range Python 2.3 and 2.4 both give the same error. As for the python version 2.2, no datetime module was implemented. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '

Re: time.mktime problem

2005-08-30 Thread Edvard Majakari
(1900, 1, 1, 0, 0, 1, 0, 1, -1) to epoch. However, epochs start from 1970-01-01 00:00. So that at least is not right. Hint... see what var ta1 is. With python2.3 you'll get overflow error, becuase mktime argument is out of range.

Re: HTML/text formatting question

2005-08-25 Thread Edvard Majakari
>> p.add_content(HTMLFormatter('em', 'called wuff')) >>> p.contents() 'nice doggy dogcalled wuff' """ return self._content def __str__(self): open_tag = '%s' % self.t

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

2005-07-16 Thread Edvard Majakari
reatment, because it is conventionally treated as an escape 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

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 infer

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

2005-07-14 Thread Edvard Majakari
r, I guess it is not very usual you should need to import stuff from arbitrary locations. Consider publishing those modules in normal Python include path (just see what ''print sys.path'' produces) -- # Edvard Majakari Software Engineer #

Re: all possible combinations

2005-07-13 Thread Edvard Majakari
;a", "b" and "c" the > "You keep using that word. I do not think it means what you think it means." Inconceivable! -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! "Debugging is twice as hard as writ

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

2005-07-13 Thread Edvard Majakari
ile programmer, and > your code base will become a tar pit even more quickly than it would in a > traditional (non-agile) project... Yup. Too bad I've had the opportunity to work that way (pair programming) only few times, and even then it wasn't XP-style in any other way. It is

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

2005-07-13 Thread Edvard Majakari
1.0. Good component design is crucial because you eventually want to do major rewrites later. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join(''

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()

Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Edvard Majakari
9.96 usec per loop But using -m makes it much 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

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

2005-07-12 Thread Edvard Majakari
en make it fast Of course, such emphasis doesn't go well with classic idioms.. (yeah, programmer's block 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 va

Re: Favorite non-python language trick?

2005-07-07 Thread Edvard Majakari
ista(s). Spoils all 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}(s

Re: Favorite non-python language trick?

2005-07-06 Thread Edvard Majakari
#x27;t realized category parameter nor stacklevel in warnings module (just used a few times, never read the doc because I didn't need to). Neat, thanks. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616

Re: Favorite non-python language trick?

2005-07-06 Thread Edvard Majakari
uot;""docstring This method is now deprecated. Use frob() 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 K

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 availabl

Re: Escaping commas within parens in CSV parsing?

2005-07-01 Thread Edvard Majakari
raise IllegalCharException('invalid chars in field %s' % field) If you need to stick with comma as a separator and the format is relatively fixed, I'd probably use some parser module instead. Regular expressions are nice too, but it is easy to

Re: python install settings...

2005-06-30 Thread Edvard Majakari
gt; cc, opt = 'cat', None >>> cc_cmd = cc + ' ' + opt Traceback (most recent call last): File "", line 1, in ? TypeError: cannot concatenate 'str' and 'NoneType' objects So, for some reason, variable opt is None. -- # Edvard Majakari

Re: Boss wants me to program

2005-06-29 Thread Edvard Majakari
h Eclipse, I think it is a very good alternative 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

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

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

2005-06-28 Thread Edvard Majakari
ary. Hm. My experience is that people find loops easier to understand - varies somewhat, though. For some, 'more verbose' is 'more easy to understand'. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264

RRArray for Python?

2005-06-03 Thread Edvard Majakari
l). Arrays can be arbitrary length, 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 __in

Re: how to accomplish dl progress bars?

2005-05-27 Thread Edvard Majakari
are technically no different; if you can do a progress bar, you can do those others as well). -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join(&#x

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

2005-05-16 Thread Edvard Majakari
at? If you need to have persistent Python data structures, I'd suggest marshalling data and using (c)Pickle or similar. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! "Debugging is twice as hard as writing the code in the firstplace. Th

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).

Re: Unique Elements in a List

2005-05-12 Thread Edvard Majakari
;polynom'), there :) Reminding of ignoring terms with smaller exponent was good, too. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('&#

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 unawa

Re: Module on Getting the Date & Time

2005-05-12 Thread Edvard Majakari
gt;> time.time() # number of seconds (+ fract) 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

Re: Unique Elements in a List

2005-05-10 Thread Edvard Majakari
get() except it also sets the value if it didn't exist. +1 IOTW (idiom of the week). -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('&#x

Re: Unique Elements in a List

2005-05-10 Thread Edvard Majakari
h I'll admit I also thought of Sets first, because I didn't remember 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 F

Re: Design advice for unit test asserters

2005-05-02 Thread Edvard Majakari
help you there too; it is able to create 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!

Re: Design advice for unit test asserters

2005-04-21 Thread Edvard Majakari
ng how to create good unit tests myself (and I also see you're using standard unit test modules - I'm already seduced by the no-API py.test library...) -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b

Re: Creating module skeleton from unit tests

2005-03-08 Thread Edvard Majakari
, lots of work to make it happen, > right now only few things in Ctrl+1 are available like that (still, some > already are)... and that's the way things work... nothing's always perfect > (but at least they evolve). Thanks for the comments - and for your pydev plugin, too. -- # E

Re: Creating module skeleton from unit tests

2005-03-08 Thread Edvard Majakari
t wouldn't be TDD then. Of course it might work, but I'd like to to it the TDD way for now. 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 Gl

Creating module skeleton from unit tests

2005-03-04 Thread Edvard Majakari
; or maybe even "Test Driven *Design*". The problem can be solved more easily if you design the module skeleton first, then the tests and then the logic for the skeleton - you would be creating tests before the code, but many people wouldn't regard it as TDD then. -- # Edvard Majaka

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

2005-02-25 Thread Edvard Majakari
meClassC: # test cases with illegal input, eg. negative 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 PR

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

2005-02-25 Thread Edvard Majakari
;s no point testing other values; all other combinations fall to some of the categories mentioned. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print jo

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

2005-02-24 Thread Edvard Majakari
owever, this problem 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 avail

Statement coverage tools revisited

2005-02-11 Thread Edvard Majakari
dest.write('! ') +dest.write(self.unvisited_pfx) else: -dest.write('> ') +dest.write(self.visited_pfx) elif covered: -