Re: 128 or 96 bit integer types?

2007-07-27 Thread Marc 'BlackJack' Rintsch
bounded by available memory. In [59]: 2**128 Out[59]: 340282366920938463463374607431768211456L Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing certain tags from html files

2007-07-27 Thread Marc 'BlackJack' Rintsch
ns the text and tries to match every occurrence of a given regular > expression, would it be a good idea? No regular expressions are not a very good idea. They get very complicated very quickly while often still miss some corner cases. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Hex editor display - can this be more pythonic?

2007-07-29 Thread Marc 'BlackJack' Rintsch
, since I've often found it a chore to figure out > which hex byte to change if I wanted to edit a certain ASCII char. Thus, > I might display data something like this: > > 00(\0) 01() FF() 20( ) 34(4) 35(5) 36(6) 08(\b) 38(8) 39(9) 61(a) 62(b) > 63(c) 64(d) 65(e) 7E(~) > &

Re: making a variable available in a function from decorator

2007-07-29 Thread Marc 'BlackJack' Rintsch
kwargs): kwargs['spam'] = eggs func(*args, **kwargs) return decorated @deco def test(parrot, spam): print parrot, spam Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Hex editor display - can this be more pythonic?

2007-07-29 Thread Marc 'BlackJack' Rintsch
On Sun, 29 Jul 2007 18:27:25 -0700, CC wrote: > Marc 'BlackJack' Rintsch wrote: >> I'd use `string.printable` and remove the "invisible" characters like '\n' >> or '\t'. > > What is `string.printable` ? There is no printable met

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Marc 'BlackJack' Rintsch
work. Simple example: def do_work(arguments, callback=lambda msg: None): callback('Start processing.') for percent in xrange(0, 101): callback('finished %d%%...' % percent) callback('Done.') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why?

2007-07-30 Thread Marc 'BlackJack' Rintsch
7;Decimal' and 'Decimal' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Marc 'BlackJack' Rintsch
On Mon, 30 Jul 2007 06:32:55 -0400, Steve Holden wrote: > >>> [x for x in xrange(0, 101)] == [y for y in xrange(101)] > True First I thought: Why the unnecessary list comprehension but to my surprise: In [33]: xrange(42) == xrange(42) Out[33]: False That's strange.

Re: How to write GUI and event separately in wxPython??

2007-07-30 Thread Marc 'BlackJack' Rintsch
On Mon, 30 Jul 2007 11:16:01 -0400, Steve Holden wrote: > Marc 'BlackJack' Rintsch wrote: >> First I thought: Why the unnecessary list comprehension but to my surprise: >> >> In [33]: xrange(42) == xrange(42) >> Out[33]: False >> >> That'

Re: Reading a two-column file into an array?

2007-07-30 Thread Marc 'BlackJack' Rintsch
d the loop can be replaced by a call to `list()`: import csv def main(): data_file = open('filename', 'rb') a = list(csv.reader(data_file, delimiter='\t')) data_file.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: get directory and file names

2007-07-31 Thread Marc 'BlackJack' Rintsch
modules. In particular `os.listdir()`, `os.path.isfile()` and `os.path.splitext()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: encode() question

2007-07-31 Thread Marc 'BlackJack' Rintsch
d idea. It sounds like horrible idea as those are the ones that are really needed. One could argue about `str.encode` and `unicode.decode`. But there are at least uses for `str.encode` like 'sting-escape', 'hex', 'bz2', 'base64' etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Marc 'BlackJack' Rintsch
xpressed in functions and classes/methods? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Marc 'BlackJack' Rintsch
. Pyrex is then translated to C and can be compiled as Python extension module. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How does xmlrpc work ?

2007-07-31 Thread Marc 'BlackJack' Rintsch
e connection and keep it alive forever OR create a new > connection when a method is called and end it after the call is > finished? Every XMLRPC call uses its own HTTP connection that is closed after the call is finished. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python

Re: A way to re-organize a list

2007-07-31 Thread Marc 'BlackJack' Rintsch
on. And the result of that script looks strange: 1, 2, 3, 4], [1, 2, 4, 5], [1, 2, 'A', 'B']]], [[[2, 2, 'A', 'C' Aren't the two top level elements wrapped in one list too much? Furthermore the test data doesn't contain an example where the first item is the same but the second item is different. > def group_items(source_list, f_list, target=[]): Default arguments are evaluated *once* when the ``def`` is executed. So all calls to this function share the same list object bound to `target`. Call this function twice without an explicit `target` and you'll see the problem. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: access the name of my method inside it

2007-08-01 Thread Marc 'BlackJack' Rintsch
uction code. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: access the name of my method inside it

2007-08-01 Thread Marc 'BlackJack' Rintsch
On Wed, 01 Aug 2007 07:01:42 -0400, Steve Holden wrote: > Marc 'BlackJack' Rintsch wrote: >> On Wed, 01 Aug 2007 09:06:42 +, james_027 wrote: >> >>> for example I have this method >>> >>> def my_method(): >>> # do somethin

Re: Assertion in list comprehension

2007-08-01 Thread Marc 'BlackJack' Rintsch
d in case of doctests, > showing) whether a function works as expected. If it is input validation I wouldn't expect it protected by a ``if __debug__:``. That looks more like debugging/testing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is shelve/dbm supposed to be this inefficient?

2007-08-01 Thread Marc 'BlackJack' Rintsch
the underlying DB used by `shelve` works with a hash table it may be expected to see that "bloat". It's a space vs. speed trade off then. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-06 Thread Marc 'BlackJack' Rintsch
> In other words, what's going on here? How is it that y accumulates > argument values between function calls in the first function, but > doesn't in the second one? Not `y` is accumulating but the list object does. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Something in the function tutorial confused me.

2007-08-06 Thread Marc 'BlackJack' Rintsch
ime the function is called. It is always the very same list object. And if you mutate it, this will be visible to other calls to the function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use C enum in Python CTypes?

2007-08-06 Thread Marc 'BlackJack' Rintsch
sily yourself, > using c_int as the base class." I would just define constants: (OLSS_AD, OLSS_DA, OLSS_DIN, OLSS_DOUT, OLSS_SRL, OLSS_CT) = map(ctypes.c_int, xrange(6)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative-importing *

2007-08-06 Thread Marc 'BlackJack' Rintsch
forbid them in relative imports because relative imports are new and this doesn't break old programs. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression Groups - loop

2007-08-07 Thread Marc 'BlackJack' Rintsch
ups(): > but then, it's check only the first group. and i tried: There is only one group in your regular expression. I guess you are confusing groups within one match with multiples matches in the text. `re.search()` finds exactly one sentence. If you want all sentences us

Re: How to use C enum in Python CTypes?

2007-08-07 Thread Marc 'BlackJack' Rintsch
On Tue, 07 Aug 2007 02:13:38 -0700, rozniy wrote: > On Aug 7, 2:11 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Tue, 07 Aug 2007 04:57:19 +, rozniy wrote: >> > This site >> >http://python.net/crew/theller/ctypes/tutorial.html#bugs-to

Re: Adding a list of descriptors to a class

2007-08-07 Thread Marc 'BlackJack' Rintsch
> __init__ method, I get the error: "TypeError: 'dictproxy' object does > not support item assignment" Does ``setattr(self.__class__, attr, MyDesc(attr))`` work? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub does not replace all occurences

2007-08-07 Thread Marc 'BlackJack' Rintsch
NORECASE) option. Without this > option, some tags containing only capital letters (like ) were > kept in the string when doing one processing run but removed when > doing multiple runs. Can you give some example HTML where it fails? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Seek the one billionth line in a file containing 3 billion lines.

2007-08-08 Thread Marc 'BlackJack' Rintsch
e, the second start offset for the second line and so on. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to avoid reverse code engineering of a python executable

2007-08-08 Thread Marc 'BlackJack' Rintsch
sibly will be if it is worth the trouble. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: This bit of code hangs Python Indefinitely

2007-08-08 Thread Marc 'BlackJack' Rintsch
e things from that queue from another thread and then the ``for``-loop goes on. That's the typical use case for queues. Why did you put an upper bound to the queue? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: some import / namespace questions

2007-08-08 Thread Marc 'BlackJack' Rintsch
On Wed, 08 Aug 2007 17:11:19 +0200, stef mientki wrote: > Now it's not possible to import in the existing modules the main plugin, > like >from Main_User import * > because this will start the infinite loop. Which means there's code at the module level. Tell the users to put that into a fun

Re: check if regeular expression has results

2007-08-09 Thread Marc 'BlackJack' Rintsch
t; What's the way to do that simply? Simply use an ``if`` on the result of the search or match. If the regular expression doesn't match `None` is returned, which is `False` in a boolean context, otherwise a match object is returned, which is `True` in a boolean context. Ciao, Marc &

Re: Jython - variables are stored somehow

2007-08-09 Thread Marc 'BlackJack' Rintsch
_()` to: def __init__(self): self.abschnitte = list() print "Abschnitt in DatenTypen: " + str(self.abschnitte) > So, I read about deleting Instances with "del" ... but it does not > work at all. You can't delete objects with ``del``, just

Re: tempfile behavior

2007-08-09 Thread Marc 'BlackJack' Rintsch
Either use the low level functions in `os` or open the file with the `filename`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: High performance binary data

2007-08-09 Thread Marc 'BlackJack' Rintsch
For the "fast" part of the question you might consider actually measuring your program, as the task may be I/O bound i.e. Python may be faster than the data comes in regardless of which module, `struct` or `ctypes`, you use to tear apart and access the data. Ciao, Mar

Re: Does PyModule_GetDict return information about class method variables?

2007-08-09 Thread Marc 'BlackJack' Rintsch
exist until you call `foo()` and it disappears as soon as the function returns. It's the very same situation in Python: class A(object): def foo(self): bar = 42 The local name `bar` only exists if `foo()` is called on an instance of `A`. Ciao, Marc 'BlackJack' R

Re: Puzzled by "is"

2007-08-10 Thread Marc 'BlackJack' Rintsch
e you shouldn't rely on implementation details at all, so even the very same interpreter might cache and reuse the empty tuple in one run but not in the next. For me CPython, Iron Python and Jython are different implementations as they are all written from scratch. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does PyModule_GetDict return information about class method variables?

2007-08-10 Thread Marc 'BlackJack' Rintsch
On Fri, 10 Aug 2007 05:54:03 -0700, MD wrote: > On Aug 10, 12:43 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> class A(object): >> def foo(self): >> bar = 42 >> >> The local name `bar` only exists if `foo()` is called on an

Re: Question about properties.

2007-08-10 Thread Marc 'BlackJack' Rintsch
e an integer!"' > self.__x = ~x > > def get_x(self): > return ~self.__x > > x = property(get_x) > > > Can anyone please help me understand what the symbol "~" does here ?? This has nothing to do with properties. For in

Re: python 2.5 bug

2007-08-11 Thread Marc 'BlackJack' Rintsch
On Sat, 11 Aug 2007 02:41:26 -0700, vedrandekovic wrote: > I was install Python 2.5 and uninstall Python 2.4 now I cannot run my > scripts, only from idle > > What should I do? Install 2.4 again. Both can be installed in parallel. Ciao, Marc 'BlackJack&

Re: Destruction of generator objects

2007-08-11 Thread Marc 'BlackJack' Rintsch
somebody else still hold a reference on it? Yes, the interactive Python shell holds the last non-`None` result in `_`: >>> from forum import ListGenerator >>> a = ListGenerator() gen init >>> a >>> for i in a: print i ... gen iter gen next gen value 0 gen nex

Re: How to change a PyObject passed to the C extension

2007-08-11 Thread Marc 'BlackJack' Rintsch
``struct`` this would have severe consequences for cached/shared objects. Just imagine: from your_module import bzzzt def f(): print 2 + 2 bzzzt(2) # This changes the value of 2 to 3. f()# This prints '6'! Ciao, Marc 'BlackJack' Rintsch -- http://mai

Re: Who told str() to round my int()'s!!!

2007-08-11 Thread Marc 'BlackJack' Rintsch
point values. I know Python is lying when 0.1 prints as 0.1, but do you really want to see 0.1555111512312578270211815834045410156250 instead? Use string formatting to tell the number of digits you want to see: In [16]: '%.56f' % 0.1 Out[16]: '0.15

Re: decorators - more than just syntactic sugar

2007-08-11 Thread Marc 'BlackJack' Rintsch
d out the predefined decorators? *The* predefined decorators? Decorators are just functions after all. There are some meant to be used as decorators but there are also "ordinary" functions that may make sense as decorators. Ciao, Marc 'BlackJack' Rintsch -- http://mail.pytho

Re: Who told str() to round my int()'s!!!

2007-08-11 Thread Marc 'BlackJack' Rintsch
On Sat, 11 Aug 2007 17:10:05 +, Adam W. wrote: > On Aug 11, 12:53 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> If `str()` would not round you would get very long numbers because of the >> inaccuracies of floating point values. I know Python is

Re: What order does info get returned in by os.listdir()

2007-08-15 Thread Marc 'BlackJack' Rintsch
n implicit loop over the list. if 'readme.txt' in leafnames: print 'Hurray!' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: replacement for string.printable

2007-08-15 Thread Marc 'BlackJack' Rintsch
str` are deprecated. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "Variable variable name" or "variable lvalue"

2007-08-15 Thread Marc 'BlackJack' Rintsch
python class > done You want a dictionary. M = dict() for x in xrange(1, 4): M[x] = Material(x) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: replacement for string.printable

2007-08-15 Thread Marc 'BlackJack' Rintsch
Python 2.4: http://docs.python.org/lib/node40.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: to property or function in class object

2007-08-16 Thread Marc 'BlackJack' Rintsch
from some different attributes or doing a conversion before returning something is okay, but a calculation that lasts an hour or so would surprise many. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming dictionaries recursively

2007-08-17 Thread Marc 'BlackJack' Rintsch
hat dictionary into a string > pulled from another source. So the tougher problem seems to be parsing those lines. That is not a valid Python dictionary unless the names `Bob`, `Humboldt`, `red`, and `predatory` are not already defined. So you can't just ``eval`` it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File Read Cache - How to purge?

2007-08-21 Thread Marc 'BlackJack' Rintsch
ot;cache" in order to get a more accurate result in my routine? That is > without having to read another large file first? AFAIK no. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File Read Cache - How to purge?

2007-08-21 Thread Marc 'BlackJack' Rintsch
x27;t the whole file itself), why not possibly take > advantage of it? How? Your speedup comes from data in caches, but the time putting it there was spend in the previous run. So you only gain something on subsequent reads on the file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: creating a dictionary from a dictionary with regex

2007-08-22 Thread Marc 'BlackJack' Rintsch
ults you can iterate over `d` only once: from collections import defaultdict def main(): d= {'line2.qty':2, 'line3.qty':1, 'line5.qty':12, 'line2.item':'5c-BL Battery', 'line3.item':'N73', 'line5.item

Re: File Read Cache - How to purge?

2007-08-22 Thread Marc 'BlackJack' Rintsch
eally want to invalidate as much cache memory as possible you have to ``sync`` before. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: way to define static method

2007-08-22 Thread Marc 'BlackJack' Rintsch
function which can be used as decorator: class MyClass(object): @staticmethod def my_real_static_method(): # Look ma, no `self`. :-) Static methods are just functions, on classes `classmethod`\s are often more useful. They get the class as first argument. Ciao, Marc 'B

Re: Raw strings to normal strings conversion?

2007-08-23 Thread Marc 'BlackJack' Rintsch
Python source code. When the program is running there is no such distinction between "raw" and "normal" strings. Here's a solution: In [87]: print r'a\nb' a\nb In [88]: print r'a\nb'.decode('string-escape') a b Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Redo: Problem with dynamic creation of classes.

2007-08-23 Thread Marc 'BlackJack' Rintsch
terpreter doing something wrong? Hard to tell without seeing where `IFRAMED2` is bound and without knowing what you actually want to do. Can you provide a self contained example that people here can actually try!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: any problem with py's RC?

2007-08-24 Thread Marc 'BlackJack' Rintsch
e to avoid the cycles. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Joining Big Files

2007-08-25 Thread Marc 'BlackJack' Rintsch
mind filesize and memory useage, would I be better reading > every line in every file and writing each line to the output file or > is there someway I could execute some shell command. There are some copy functions that work with file like objects in the `shutil` module. Ciao, Mar

Re: How can I use python for file processing

2007-08-25 Thread Marc 'BlackJack' Rintsch
me to start processing lines, and then `str.split()` the lines and put them into a `dict()`. This is a neat little project to start learning the language. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to free memory ( ie garbage collect) at run time with Python 2.5.1(windows)

2007-08-27 Thread Marc 'BlackJack' Rintsch
ndard library is. And even a `free()` in the C standard library doesn't guarantee that memory is given back to the OS and reported as free memory again. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: XML File -- dictionary edit/search

2007-08-27 Thread Marc 'BlackJack' Rintsch
support for SQLite in the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Error handling in file generation (Pythonic way: with / decorators?)

2007-08-29 Thread Marc 'BlackJack' Rintsch
= open(dictpath, 'w') try: with dictfile: dictgen(dictfile, sources) except error, e: os.remove(dictpath) sys.exit(str(e)) except: os.remove(dictpath) raise Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the difference ?

2007-08-29 Thread Marc 'BlackJack' Rintsch
hat ``in`` works on other types too that implement `__contains__()`, like lists or sets for example, and that it is a bit faster as the second example has to look up the `has_key()` method on the object first. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: general function for sorting a matrix

2007-08-29 Thread Marc 'BlackJack' Rintsch
ue as your reference implementation sorts in place too. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: re compiled object result caching?

2007-08-29 Thread Marc 'BlackJack' Rintsch
methods > (say, it started out life as a unidimensional thing, but later needs to > be a flattening of 3 dimensions or something), you won't necessarily need > to change depenent code. Maybe you should read about the `property()` function. Ciao, Marc 'BlackJack&#x

Re: list index()

2007-08-30 Thread Marc 'BlackJack' Rintsch
s for those situations!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: We need PIGs :)

2007-08-30 Thread Marc 'BlackJack' Rintsch
ion v2.0`_ or `API for Block Encryption Algorithms v1.0`_ what you are looking for? .. _API for Block Encryption Algorithms v1.0: http://www.python.org/dev/peps/pep-0272/ .. _Python Database API Specification v2.0: http://www.python.org/dev/peps/pep-0249/ Ciao, Marc 'B

Re: list index()

2007-08-30 Thread Marc 'BlackJack' Rintsch
e return value from an "index" function in that condition. What about -1? C programmers do this all the time. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python doesn't see the directories I create

2007-08-30 Thread Marc 'BlackJack' Rintsch
y be prefixed by an 'r' to tell the compiler that backslashes have no special meaning in that raw string literal. In [23]: len('\r') Out[23]: 1 In [24]: len('\\') Out[24]: 1 In [25]: len(r'\r') Out[25]: 2 In [26]: len(r'\\') Out[26]: 2 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: SAXParseException: not well-formed (invalid token)

2007-08-30 Thread Marc 'BlackJack' Rintsch
oesn't work for me in a browser. (Could not connect…) Maybe you can download that XML file and use `xmllint` to check if it is well formed XML!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python doesn't see the directories I create

2007-08-30 Thread Marc 'BlackJack' Rintsch
ven on Unix it shouldn't be a problem on most file systems to create a directory named 'C:' [EMAIL PROTECTED]:~$ mkdir C: [EMAIL PROTECTED]:~$ touch C:/test.txt [EMAIL PROTECTED]:~$ ls -l C: total 0 -rw-r--r-- 1 bj bj 0 2007-08-30 14:38 test.txt :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: SAXParseException: not well-formed (invalid token)

2007-08-30 Thread Marc 'BlackJack' Rintsch
On Thu, 30 Aug 2007 15:31:58 +0200, Pablo Rey wrote: > On 30/08/2007 14:35, Marc 'BlackJack' Rintsch wrote: > >> Maybe you can download that XML file and use `xmllint` to check if it >> is well formed XML!? > > This is the output of the xmllint command:

Re: list index()

2007-08-30 Thread Marc 'BlackJack' Rintsch
e > `list` type to provide both as well, but it provides only `index()`. > > Anyone know the reason for this lack of parallelism? Historical reasons and IIRC the `find()` method on strings will go away in Python 3.0. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python

Re: Pivy problem and some other stuff

2007-08-30 Thread Marc 'BlackJack' Rintsch
functions but a list of results of function calls. If you want the functions in that list then leave off the parentheses, because those are the "call operator". In [55]: def a(): : return 1 : In [56]: def b(): : return 2 : In [57]: funcs = [a, b]

Re: list index()

2007-08-30 Thread Marc 'BlackJack' Rintsch
t; found, such that sub is contained in the range [start, end]. Optional > arguments start and end are interpreted as in slice notation. Return > -1 if sub is not found. But that is a valid index into a string! So this may go unnoticed if one doesn't check after every cal

Re: reload(sys)

2007-08-31 Thread Marc 'BlackJack' Rintsch
r.write('Decoding Error: You must configure > default encoding\n') > sys.exit() So there is an attribute `self.encoding` on that object. Is it set? What encoding is it? And do you put byte strings with values outside ASCII into your XML or unicode strings? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: status of Programming by Contract (PEP 316)?

2007-09-01 Thread Marc 'BlackJack' Rintsch
ow do you program a dam? - and why is it > critical? > > Most dams just hold water back. And some produce electricity. And most if not all can regulate how many water is let through. If something goes wrong the valley behind the dam gets flooded. If this is controlled by a computer

Re: list index()

2007-09-01 Thread Marc 'BlackJack' Rintsch
ership in a list of N items is O(N)...). > > Depending on a how a set is stored, I'd estimate any membership check in > a set to be O(log N). Sets are stored as hash tables so membership check is O(1) just like Alex said. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: list index()

2007-09-01 Thread Marc 'BlackJack' Rintsch
askell I would expect such a function to return the `Maybe` type. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pivy problem and some other stuff

2007-09-02 Thread Marc 'BlackJack' Rintsch
e it gives a meaningless error message that the > calling line didn't work. What meaningless error message are you talking about!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'module object is not callable'

2007-09-03 Thread Marc 'BlackJack' Rintsch
n the function and then in the module. But it is defined in the class. So you have to access `Main.stepStore`. Unless you are modifying `stepStore.stepList` while iterating over it, you don't need to make a copy by the way. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Noob: What is a slot? Me trying to understand another's code

2007-09-05 Thread Marc 'BlackJack' Rintsch
on't do it with that book because the authors seem to write another programming language using Python syntax. I guess there's an older issue of that book that used the SmallTalk programming language and they switched to Python syntactically but not mentally and not the vocabulary. A &qu

Re: Using wild character

2007-09-06 Thread Marc 'BlackJack' Rintsch
;*string*' type. `str.find()` will go away in the future. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: concise code (beginner)

2007-09-06 Thread Marc 'BlackJack' Rintsch
def a0040(): global self; self.disablePLmessages([self.dev]); > def a0050(): global self; self.dev.testH.writePLram((PL.BCAL12<<8)); What is this ``global self`` meant to do? And the first line is missing a colon at the end. Ciao, Marc 'BlackJack' Rintsch -- ht

Re: We need PIGs :)

2007-09-06 Thread Marc 'BlackJack' Rintsch
You don't have the choice between `.foo` and `.get_foo()` in Java because Java has no properties and people are trained to write getters and setters for everything. I like that choice in Python because I can write shorter code that is not cluttered with very simple getters and setters. Ciao

Re: Using wild character

2007-09-06 Thread Marc 'BlackJack' Rintsch
On Thu, 06 Sep 2007 16:48:31 -0700, Zentrader wrote: > On Sep 6, 12:47 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Wed, 05 Sep 2007 22:54:55 -0700, TheFlyingDutchman wrote: >> > To do a "*string" wildcard filter use the endswith() fun

Re: unexpected behavior: did i create a pointer?

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 10:40:47 +, Steven D'Aprano wrote: > Nor does it include "peek" and "poke" commands for reading and writing > into random memory locations. I guess `ctypes` offers tools to write `peek()` and `poke()`. :-) Ciao, Ma

Re: Using s.sort([cmp[, key[, reverse]]]) to sort a list of objects based on a attribute

2007-09-07 Thread Marc 'BlackJack' Rintsch
onvert them to a number first. If the "natural" sort criterion for `Step` objects is the start time you might override `__cmp__()` of `Step`\s instead:: def __cmp__(self, other): return cmp(self.startTime, other.startTime) Now you can just sort the list with ``steps.sort()`

Re: Class design (information hiding)

2007-09-07 Thread Marc 'BlackJack' Rintsch
plementation and that this all might change without notice in the next release. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: exponential float formmating

2007-09-07 Thread Marc 'BlackJack' Rintsch
uld be alway the sing and 2 number for the exponent. > > for example 13 shoud be 0.13000E+02 > I always get 1.3E001 I don't know if this is platform dependent but this works for me: In [41]: '%e' % 1.3 Out[41]: '1.30e+00' In [42]: ('%e' % 1.

Re: Generating a unique identifier

2007-09-07 Thread Marc 'BlackJack' Rintsch
enough, but I thought I'd check if there was an existing > solution in the standard library that I missed. For that easy solution you can use `itertools.count()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Marc 'BlackJack' Rintsch
]: map(int, [1, 0, True, False]) Out[52]: [1, 0, 1, 0] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to determine the bool between the strings and ints?

2007-09-07 Thread Marc 'BlackJack' Rintsch
very `bool` instance is also an instance of `int`. There's nothing special about it. In [57]: issubclass(bool, int) Out[57]: True In [58]: bool.__base__ Out[58]: Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Speed of Python

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 22:59:26 +, wang frank wrote: > I also have tried to use numpy to speed it up. However, surprisingly, it is > slower than the pure python code. > > Here is the code: > import numpy > arange=numpy.arange > nlog=numpy.log > def bench6(n): > for i in xrange(n): >

Re: Speed of Python

2007-09-07 Thread Marc 'BlackJack' Rintsch
On Fri, 07 Sep 2007 23:53:48 +, wang frank wrote: >>From: "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> >>To: python-list@python.org >>Subject: Re: Speed of Python >>Date: 7 Sep 2007 23:17:55 GMT >> >>On Fri, 07 Sep 2007 22:5

Re: python sqlite THREADSAFE?

2007-09-08 Thread Marc 'BlackJack' Rintsch
On Sat, 08 Sep 2007 10:37:51 +0200, EuGeNe Van den Bulke wrote: > Is the sqlite distributed with Python 2.5 compiled with the > -DTHREADSAFE=1 flag? My gutt feeling is Windows (yes) MacOS/Linux (no) > but ... Take a look at the `threadsafety` attribute of the module. Ciao,

Re: /dev/null as a file-like object, or logging to nothing

2007-09-08 Thread Marc 'BlackJack' Rintsch
On Sat, 08 Sep 2007 18:52:57 +0200, Torsten Bronger wrote: > Is there a portable and simply way to direct file-like IO to simply > nothing? I try to implement some sort of NullLogging by saying `os.devnull`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/

<    4   5   6   7   8   9   10   11   12   13   >