Re: Cross platform Python app deployment

2007-07-30 Thread Benjamin Niemann
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

Re: Creating a daemon process in Python

2007-02-21 Thread Benjamin Niemann
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

Re: Creating a daemon process in Python

2007-02-21 Thread Benjamin Niemann
78731> HTH -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://pink.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list

Re: calling php function from python

2007-02-14 Thread Benjamin Niemann
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

Re: distutils: renaming setup.py ok?

2007-02-07 Thread Benjamin Niemann
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

Re: Inheriting str object

2007-02-05 Thread Benjamin Niemann
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,

Re: marshal.loads ValueError

2007-01-31 Thread Benjamin Niemann
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:

Re: Is there a better way to implement this:

2007-01-22 Thread Benjamin Niemann
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

Re: html + javascript automations = [mechanize + ?? ] or something else?

2007-01-16 Thread Benjamin Niemann
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

Re: UnboundLocalError

2006-11-09 Thread Benjamin Niemann
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

Re: Deprecation in String.joinfields()

2006-09-25 Thread Benjamin Niemann
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

Re: Can I inherit member variables?

2006-09-21 Thread Benjamin Niemann
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 >

Re: Can I inherit member variables?

2006-09-21 Thread Benjamin Niemann
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

Re: why a main() function?

2006-09-18 Thread Benjamin Niemann
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

Re: time.clock()

2006-07-14 Thread Benjamin Niemann
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

Re: MySQLdb not updating rows

2006-06-28 Thread Benjamin Niemann
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

Re: urllib behaves strangely

2006-06-12 Thread Benjamin Niemann
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

Re: urllib behaves strangely

2006-06-12 Thread Benjamin Niemann
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

Re: GUI viewer for profiler output?

2006-05-23 Thread Benjamin Niemann
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

Re: Python 3.0 or Python 3000?

2006-04-10 Thread Benjamin Niemann
>> 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

Re: Why did someone write this?

2006-04-07 Thread Benjamin Niemann
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

Re: import random module

2006-03-22 Thread Benjamin Niemann
> 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

Re: Python version of XMLUnit?

2006-03-06 Thread Benjamin Niemann
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 ;) --

Re: Apparent eval() leak for python 2.3.5

2006-02-17 Thread Benjamin Niemann
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

Re: Another stupid newbie question

2006-02-17 Thread Benjamin Niemann
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 --

Re: python encoding bug?

2005-12-31 Thread Benjamin Niemann
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

Re: can modules be dynamically reloaded

2005-11-16 Thread Benjamin Niemann
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

Re: Making a persistent HTTP connection

2005-11-14 Thread Benjamin Niemann
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

Re: Python's website does a great disservice to the language

2005-11-01 Thread Benjamin Niemann
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

Re: How to translate python into C

2005-10-28 Thread Benjamin Niemann
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

Re: Pickle to source code

2005-10-26 Thread Benjamin Niemann
_ 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

Re: Question about StringIO

2005-10-10 Thread Benjamin Niemann
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

Re: how to get the return value of a thread?

2005-09-09 Thread Benjamin Niemann
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

Re: ~ after script filename?

2005-09-07 Thread Benjamin Niemann
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

Re: is there a better way to check an array?

2005-09-01 Thread Benjamin Niemann
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

Re: Is my thread safe from premature garbage collection?

2005-09-01 Thread Benjamin Niemann
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

Re: Decrypting GPG/PGP email messages

2005-09-01 Thread Benjamin Niemann
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

Re: Is my thread safe from premature garbage collection?

2005-09-01 Thread Benjamin Niemann
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

Re: time.strptime() for different languages

2005-08-31 Thread Benjamin Niemann
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

Re: Dynamic image creation for the web...

2005-08-28 Thread Benjamin Niemann
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

Re: Dynamic image creation for the web...

2005-08-28 Thread Benjamin Niemann
;) (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

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-26 Thread Benjamin Niemann
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

Re: Warning when doubly linked list is defined gloablly

2005-08-24 Thread Benjamin Niemann
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

Re: DeprecationWarning: Non-ASCII character '\xf3'

2005-08-23 Thread Benjamin Niemann
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

Re: loop in python

2005-08-22 Thread Benjamin Niemann
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. -

Re: Save Binary data.

2005-08-19 Thread Benjamin Niemann
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

Re: Adobe COM with Python

2005-08-19 Thread Benjamin Niemann
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

Re: stopping a python windows service

2005-08-16 Thread Benjamin Niemann
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

Re: "Compile time" checking?

2005-08-13 Thread Benjamin Niemann
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

Re: "Compile time" checking?

2005-08-10 Thread Benjamin Niemann
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

Re: Help with Regular Expressions

2005-08-10 Thread Benjamin Niemann
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

Re: Putting function references in a Queue

2005-08-06 Thread Benjamin Niemann
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

Re: about coding

2005-08-06 Thread Benjamin Niemann
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

Re: Making a timebomb

2005-08-05 Thread Benjamin Niemann
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

Re: minidom xml & non ascii / unicode & files

2005-08-05 Thread Benjamin Niemann
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

Re: Py: a very dangerous language

2005-08-05 Thread Benjamin Niemann
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

Re: Reliable destruction

2005-08-04 Thread Benjamin Niemann
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

Re: Reliable destruction

2005-08-04 Thread Benjamin Niemann
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

Re: Py: a very dangerous language

2005-08-03 Thread Benjamin Niemann
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

Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Benjamin Niemann
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

Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
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

Re: Art of Unit Testing

2005-08-03 Thread Benjamin Niemann
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

Re: Art of Unit Testing

2005-08-02 Thread Benjamin Niemann
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

Re: trying to parse non valid html documents with HTMLParser

2005-08-02 Thread Benjamin Niemann
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

Re: python SMTP server

2005-08-01 Thread Benjamin Niemann
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 >>

Re: python SMTP server

2005-08-01 Thread Benjamin Niemann
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

Re: python SMTP server

2005-07-31 Thread Benjamin Niemann
). 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

Re: Getting TypeError in Changing file permissions

2005-07-22 Thread Benjamin Niemann
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

Re: Stupid question: Making scripts python-scripts

2005-07-21 Thread Benjamin Niemann
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

Re: Difference between " and '

2005-07-21 Thread Benjamin Niemann
"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

Re: dictionary as property

2005-07-20 Thread Benjamin Niemann
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

Re: Lisp development with macros faster than Python development?..

2005-07-05 Thread Benjamin Niemann
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

Re: Python Regular Expressions: re.sub(regex, replacement, subject)

2005-07-05 Thread Benjamin Niemann
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

Re: Existance of of variable

2005-07-04 Thread Benjamin Niemann
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

Re: nested lists - utter newbie

2005-07-01 Thread Benjamin Niemann
] > 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

Re: Request for help on naming conventions

2005-06-13 Thread Benjamin Niemann
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

Re: Walking through a mysql db

2005-06-04 Thread Benjamin Niemann
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

Re: write html-headers (utf-8)

2005-05-30 Thread Benjamin Niemann
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

Re: Suggesting methods with similar names

2005-03-30 Thread Benjamin Niemann
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

Re: IronPython 0.7 released!

2005-03-24 Thread Benjamin Niemann
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

Re: string join() method

2005-03-23 Thread Benjamin Niemann
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

Re: IronPython 0.7 released!

2005-03-23 Thread Benjamin Niemann
; > > 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://