ill be pulled in via a package
dependency.
distutils already allows you to create rpm packages.
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
m_a_thread)
> thread.setDaemon(True)
> thread.start()
> t2 = time.time()
> print "Time elapsed in main thread:", t2 - t1
>
>
> Of course, your mileage may vary.
That's not a daemon process (which are used to execute 'background services'
in UNIX environments).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
78731>
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
this is easier and perhaps even
faster than the RPC approach...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
l-lib' would be more
approriate (which can be done with distutils).
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ef upper(self):
return myStr(str.upper(self))
And I'm not sure, if it then works in the intended way...
What you are probably looking for, is to extend the 'str' class itself, so
every str instance has your added functionality.
Don't know, if this is possible at all,
hal and exec it misses the first two
> characters, "fr" ...any ideas?
marshal is used to (de)serialize python objects from/to strings.
marshal.loads() tries to deserialize an encoded string back into a python
object - which does not make sense here.
What you probably want is:
test():
> i = 0
> while (True):
>time.sleep(1)
>print "HELLO", i
>i+=1
>
>
> def ftimed (func, seconds):
> thread.start_new_thread (abort, (seconds,))
>
> try:
> func()
> except thread_finished:
> print &q
also FF, dunno..) using COM. This can be
done using the pywin32 module <https://sourceforge.net/projects/pywin32/>.
How this is done in detail is a windows issue. You may find help and
documentation in win specific group/mailing list, msdn, ... You can usually
translate the COM calls from VB, C#, ... qui
user_guess') - this makes the code more descriptive. Should it
really be a class, a common convention is to capitalize it 'Number()'.
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ect has no attribute 'join'
>
> Thank you for your help
joinfields is just an alias for join and only the latter is a method of the
string class (which should be used instead of the deprecated string.join
function), which means that the string "." has a method join which takes
the list as an argument.
So what you want should be written as:
newname = ".".join(li[:-1])
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
LorcanM wrote:
> Benjamin Niemann wrote:
>
>> You'll have to invoke the __init__ method of the superclass, this is not
>> done implicitly. And you probably want to add the weight and colour
>> attributes to your subclass in order to pass these to the animal
>
def __init__(self, length, weight, colour):
animal.__init__(self, weight, colour)
self.length = length
print self.weight, self.colour, self.length
HTH
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ule.
Wrapping the main code in a function allows you to call this function from
your unittests and test it like any other function.
Additionally I do usually add an 'argv' argument to main() which I use
instead of sys.argv, so I can easily test it with different arguments.
--
Benjamin N
ing your process. And unless the process uses
100% of the CPU, CPU time will appear to be 'slower' than the wall clock.
In your little program above the CPU spent about one third of the time on
this process and the rest is used for other processes (e.g. updating the
display).
What yo
ally use:
cursor.execute(
"UPDATE teachers SET password = %s WHERE teacher_code = %s",
(h, tc)
)
instead of
cursor.execute(
"UPDATE teachers SET password = '%s' WHERE teacher_code = '%s'"
% (h, tc)
)
The former form takes care of quoting and escaping, your version did not
escape potentially harmful characters in tc, resulting in a possibly opened
door for SQL injection attacks.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Benjamin Niemann wrote:
> Gabriel Zachmann wrote:
>
>> Here is a very simple Python script utilizing urllib:
>>
>> import urllib
>> url =
>> "http://commons.wikimedia.org/wiki/Commons:Featured_pictures/chronological";
>> print
mmons:Feat..' is not a legal character in this part of the
URI and has to be %-quoted as '%3a'.
Try the URI
'http://commons.wikimedia.org/wiki/Commons%3aFeatured_pictures/chronological',
perhaps urllib is stricter than your browsers (which are known to accept
every b**t
at KCachegrind can read (using a script called
hotshot2calltree, which is part of KCachegrind).
If anyone has a more direct solution, I'd be interested, too :)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
>> changed to prohibit use by people with bipolar disorder. Either that,
>> or the name will be Python 3.0.
>
> Or... just to save "3000" as a "time way down the road"... The next
> major version of Python will be: Python PI (and each build will add
> a
t this person knows that
> I don't.
You just have not found the right part of the doc:
http://docs.python.org/lib/module-sys.html#l2h-337
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
> here.
This is not specific to the random module, try:
time.py:
import time
print time.time()
Don't name your script 'random.py' (or any other name from the stdlib).
'import random' will import the script itself (not the random m
hat is usable
> from Python unit tests (using py.test, if it matters).
http://www.logilab.org/projects/xmldiff
You'd still have to integrate this into your test framework though...
And I'll have a look at XMLUnit - seem's like something I could use for my
current project ;)
--
bian/sid:
Python 2.3.5 (#2, Nov 20 2005, 16:40:39)
[GCC 4.0.3 2005 (prerelease) (Debian 4.0.2-4)] on linux2
python2.4 seems to be unaffected.
Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 2005 (prerelease) (Debian 4.0.2-4)] on linux2
--
Benjamin Niemann
Email: pink at odahoda dot de
ne, I would suggest using
def stuff(a, mx):
x = None
while x != mx:
x = random()
if x == mx: print x
else: print 'No luck,', x
Also note that random() returns a float and it is *very* unlikely that the
condition x == mx will ever come true
--
same happens if I use 'latin-1' instead of 'iso8859_1'.
>
> This caught me by surprise, since I was doing some heuristics guessing
> string encodings, and 'iso8859_1' gave no errors even if the input
> encoding was different.
>
> Is this a known behaviour, or
t;
> For example you import a module, programatically edit it, then have the
> file reload the module?
>
> Does anyone have any ideas about this?
> Steve
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
7;s called 'keep-alive'.
> And even if it works - what is the problem with connections being created?
Performance, network load...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> http://www.python.com/ perhaps?
Yep, let's make this the new official python site ;)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ow-do-i-compile-my-own-programs
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
_ method (true for built-in
stuff like list, dict, set...):
Just unpickle it and call repr() on the resulting object.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
to
> know the answer.
That's probably a deadlock as described in
<http://docs.python.org/lib/popen2-flow-control.html>
> BTW, is there an equivalent of /dev/null on MSW?
Dunno - but as a last resort, you could create a tempfile with a unique name
(to be sure, not to override an
esult = 1
elif num>50:
result = 2
fooResult.put(result)
t = thread.start_new_thread(foo,(12,))
# do other stuff, foo is running in background
r = fooResult.get() # guaranteed to block until result is available
print r
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
me you save a new file), the existing version is renamed with the ~
suffix.
After some time, you will learn to simply ignore these files ;)
Many file managers have already learnt this lesson and have options to hide
such backup files.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
se
> except ValueError:
> pass
>
> # throw expception if field is required and is empty
> if(product[k] == '' and fieldIsRequired):
> raise GMError(k + ' is required')
if product[k] == '' and k in fieldIsRequired:
raise GMError(k + ' is re
Sion Arrowsmith wrote:
> In article <[EMAIL PROTECTED]>, Benjamin Niemann <[EMAIL PROTECTED]>
> wrote:
>>[EMAIL PROTECTED] wrote:
>>> However, in my current project I'm creating a bunch of threads which
>>> are supposed to run until they've co
to a email message?
I can't help you with Thunderbird. In the worst case, you'll have to encrypt
your command file manually and attach the encrypted version to your mail.
KMail does have checkboxes for encrypt/sign every attachment separately...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
finite statement on whether threads
> are safe from unwanted garbage collection, that'd be really great.
> Thanks in advance for any helpful replies!
The threading module does already take care of keeping references to all
running threads, so there's no need to do it yourself and y
by month name, I suppose I could just substitute the month name using
> a translation table for English to Dutch month names.
Have you tested it with the proper locale setting and strptime(dateString,
"%c")? I have not ;)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odah
Tompa wrote:
> Benjamin Niemann odahoda.de> writes:
>> You are almost there.
> I don't feel so...
>
>> Your create_image.py does not return anything to the
>> browser yet.
> Yes, I am aware of that but I do not what to return.
>
>> First return pr
;)
(Your prints above are mostly equivalent, but do not output the correct \r\n
as line terminator - at least on UNIX style systems. Most webservers
tolarate this, if it's coming from a CGI - but doing it right and not
relying on a certain server behaviour is not bad anyway ;)
Then check the PIL docs to find out, how to output the image to sys.stdout
(instead of writing to a file).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
consecutive positions.
If that's the cause, then here's another reason to use long, descriptive
names instead of C64-BASIC style a, b, c, i, j... - with long names the
chances of hash collisions are pretty low.
Or everyone will start optimizing their programs by using long, *random*
names
hree lines above? (These would trigger
a SyntaxError because of the typo...)
You should provide a more complete example, so we can tell you where the
problem is. Try to build a minimal file that reproduces the problem. Often
you will find the line causing the error yourself - and the fix might be
ge of this) - if
you use anything else, then you'll have to declare it.
This will be important, if you use unicode strings:
u"stränge characters"
Python must know the encoding of the file in order to decode the string
literal into an unicode string.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
rogram would really suprising.
Python suprises me often, but in different ways ;)
Perhaps you could try to use sys.stdout.write() directly, avoiding the
overhead of 'print'. Perhaps there are differences between the (default)
output buffering settings of perl and python.
-
ges are uncompressed anyway, you could have a look at the netpbm
suite and its fileformat (which is pretty simple, but uncompressed and
would bloat JPEGs to a multiple of the original filesize) which supports
'image sequences'. Perhaps a DivX encoder could even support this
fileformat d
tributes from the JS
documentation to COM calls (the JS members start with lowercase - e.g.
'properties' -, while COM need uppercase - 'Properties').
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
er is slw, you'll still have a significant
delay... To avoid this, you would need a http client based on select() that
allows you to check shutdownEvent.isset() at certain intervals - instead of
urlopen which just blocks.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
uperset of
static code checking - all type bugs are found be the testsuite even in the
absence if static type checking.
So you won't loose anything, if you drop static typing.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Qopit wrote:
> [snip]
>
> My questions are:
> - Am I missing something with my tester example?
> - Are there other code-checking options other than PyChecker?
Try pylint
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/m
write '\\', if you need a backslash
in the string, e.g. r'\w+' == '\\w+'.
Useful for regular expression (because the re module parses the '\X'
sequences itself) or Windows pathes (e.g. r'C:\newfile.txt').
And you should append a '$' to the re
phores etc.), there should not be any greater
problems.
The function will be executed in the thread that is called it of course (and
not in the thread that sent the reference to it).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ses a format that is automatically recognized by the
emacs editor. If you are using another editor, you'll have to search its
menus for the proper way to save files as utf-8.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ag that is polled by the main
thread.
You could also try to send a signal to yourself, but I'm not sure what will
happen then...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
this module does not have that method.. i'm left no choice but to edit
> the site.py file manually to change "ascii" to "utf-8", but i won't be
> able to do that on the client computers so..
> Anyways i don't know if it would help my script at all..
There was just recently a discussing on setdefaultencoding() on various
pythonistic blogs, e.g.
http://blog.ianbicking.org/python-unicode-doesnt-really-suck.html
>
> any help will be greatly appreciated
> thx
>
> Marc
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Luis M. Gonzalez wrote:
> This is great!
> It's absolutely useless, like a real therapist, but it's free!
Never heard of Eliza? Even Emacs has it built in (Menu Help -> Emacs
Psychiatrist).
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
htt
happy that it's just a power supply that could overheat and not the core
of a nuclear power plant.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
wn() method
try:
m = measurement()
try:
m.setup()
m.run()
finally:
m.tearDown()
except KeyboardInterrupt:
# user pressed ctrl-C
print "***BREAK"
sys.exit(1)
except:
# you should at least log the exception for later debugging
traceback.print_exc()
and remove the calls to setup() and run() from the constructor.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
into
much smaller steps, each step finalized with a 'all tests passed - your
code works *exactly* as specified' (if you treat the testsuite as the
formal specification, which I do), then you are tempted to celebrate all
these small successes with a small reward. Baaad thing, if you smoke like I
do...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ne of my favourite
programming adventures, I do not have such a personal relationship with my
classes ;)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hoffman wrote:
> Benjamin Niemann wrote:
>> Christoph Zwerschke wrote:
>>
>>
>>>Benjamin Niemann wrote:
>>>
>>>>Some (many?) people don't like the unittest module, because it is not
>>>>very pythonic - nothing to won
Christoph Zwerschke wrote:
> Benjamin Niemann wrote:
>> Some (many?) people don't like the unittest module, because it is not
>> very pythonic - nothing to wonder as it has its root in the Java world.
>> That's probably one of the reasons why there are other
use unittest (because this was the API the textbook was using
that introduced me to this topic) and I also had the problem of heavy setup
costs. I deal with it by using a script around my testsuite (instead of
calling just unittest.main()) that does the setup/teardown of the
environment.
--
Benjami
tmllib and see, which parser is more forgiving.
You might pipe the document through an external tool like HTML Tidy
<http://www.w3.org/People/Raggett/tidy/> before you feed it into
HTMLParser.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Cliff Wells wrote:
> On Mon, 2005-08-01 at 12:28 +0200, Benjamin Niemann wrote:
>> Cliff Wells wrote:
>
>[snip]
>
>> > By using a local SMTP server to proxy, your app can
>> > queue up a large amount of mail in a much shorter period. It won't
>>
Cliff Wells wrote:
> On Sun, 2005-07-31 at 13:14 +0200, Benjamin Niemann wrote:
>
>> But you should be aware of the fact that (if you send mail from a dialup
>> machine without going through a relay server) your mails will quickly be
>> marked as spam - I hope you do
).
But you should be aware of the fact that (if you send mail from a dialup
machine without going through a relay server) your mails will quickly be
marked as spam - I hope you do not intend to send spam...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ject (that you got from an open() call)
as the first parameter. What you need is a string with the path to the
file.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
reate a setup.py
script for distribution. IIRC setup.py will recognize the shebang of your
scripts and replace it with the proper path to python of the target system
during installation.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
"That's my house" == 'That\'s my house'
"You say: \"Hello\"" == 'You say: "Hello"'
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
t_changed(key, value)
self.d[key] = value
def __getitem(self, key):
return self.d[key]
....
And in A.__init__
self.d = WrappedDict(self, {})
You may also subclass WrappedDict from dict...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
o learn a new programming language for every
program I'd like to apply a minor fix/customization to: not a good idea.
Probably not just for the casual hacker like me, but also for the
maintainance phase of a project, when the former lead gurus lost interest
and/or employment.
--
Benjami
nterpreted by the parser, e.g. r"\x" == "\\x". Using
r"" when working with the re module is not required but pretty useful,
because re has it's own rules for backslash handling).
For more details see the docs for re.sub():
http://docs.python.org/lib/node114.html
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
Better
use the generator syntax (requires python 2.4):
minDist, closestPlace = min(((place.pos-pos).len(), place)
for place in galaxy.places.itervalues())
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
]
> Traceback (most recent call last):
> File "", line 1, in ?
> NameError: name 'x' is not defined
Because the right hand side ('[1,2,x]') is evaluated *before* the value is
bound to the name 'x' - and at this point there is obviously no name 'x'
defined.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
at is what, or do you name objects
> whatever feels right at the time?
Naming convention are mostly a matter of personal taste (unless you are
working in a larger team, where there are some official conventions that
must be followed). So I would say the 'feels right' is the most import
to the fetchone() w/o effect.
You could either execute N-1 fetchone()s before you fetch the Nth dataset
(with N starting at 1)
or use the 'LIMIT' feature of MySQL:
cursor.execute ("SELECT * FROM dataset LIMIT %s,1", n)
where n is the index of the requested dataset (st
pecifies a charset, this will
override your . Often iso-8859-1 is the default charset
for the Content-Type header.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
ions =
raise AttributeError("'Surface' object has no attribute '%s'. Did you
mean %s?" % (name, suggestions))
I leave it to the experts to wrap this into a generic metaclass, decorator
etc. ;)
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
just go to planetpython.org
>
Or check out the Daily Python URL (http://www.pythonware.com/daily/) which
has a pretty high signal to noise ratio.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
whereas the second script outputs
-------
Content-type: text/plain\r\n
\n
Allele...
---
The (required) "\n" - that should also be an "\r\n" - seperating the headers
from the content is added by the first print.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
--
http://mail.python.org/mailman/listinfo/python-list
;
>
> I'm also a bit puzzled that www.ironpython.com has no mention of this
> release.
> Curious that J Hugunin didn't announce it himself.
Jim Hugunin announced it himself in a keynote at PyCon. You can read a lot
about it on Python centric blogs - just one example:
http://
82 matches
Mail list logo