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.
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
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
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
"", 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!
$_ = '
(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.
>> p.add_content(HTMLFormatter('em', 'called wuff'))
>>> p.contents()
'nice doggy dogcalled wuff'
"""
return self._content
def __str__(self):
open_tag = '%s' % self.t
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
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
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
#
;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
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
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(''
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()
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
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
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
#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
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
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
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
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
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
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
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
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
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(
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
"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).
;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('
[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
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
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('
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
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!
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
, 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
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
; 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
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
;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
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
dest.write('! ')
+dest.write(self.unvisited_pfx)
else:
-dest.write('> ')
+dest.write(self.visited_pfx)
elif covered:
-
43 matches
Mail list logo