Re: the annoying, verbose self

2007-11-24 Thread Marc 'BlackJack' Rintsch
On Sat, 24 Nov 2007 14:09:04 +0100, Ton van Vliet wrote: > On 24 Nov 2007 08:48:30 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > wrote: > >>On Sat, 24 Nov 2007 09:12:34 +0100, Ton van Vliet wrote: >> >>> Just bringing up something I sometimes m

Re: the annoying, verbose self

2007-11-24 Thread Marc 'BlackJack' Rintsch
On Sat, 24 Nov 2007 08:27:56 -0800, samwyse wrote: > On Nov 24, 7:50 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote: >> > On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]&g

Re: How to display unicode with the CGI module?

2007-11-24 Thread Marc 'BlackJack' Rintsch
rings. If you don't do this explicitly Python tries to encode as ASCII and fails if there's anything non-ASCII in the string. The `encode()` method is your friend. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are class methods not classmethods?

2007-11-27 Thread Marc 'BlackJack' Rintsch
Out[83]: > In [84]: type(Parrot.cmethod) Out[84]: In [85]: Parrot.__dict__['cmethod'] Out[85]: In [86]: type(Parrot.__dict__['cmethod']) Out[86]: Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Split a String

2007-11-30 Thread Marc 'BlackJack' Rintsch
plit function, but this mini-monster wouldn't properly get > split up due to those random quotations postgresql returns to me. I hope you don't use Python to access the database, get a tuple back, convert it to a string and then try to break up that string into a list!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Oh no, my code is being published ... help!

2007-11-30 Thread Marc 'BlackJack' Rintsch
e time. If the function looking style would be adopted for 2.x, do *you* want to explain confused newbies why they can write:: print('hello!') but this acts "strange": print('hello, my name is ', name) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "Python" is not a good name, should rename to "Athon"

2007-12-04 Thread Marc 'BlackJack' Rintsch
! >> >>Wasn't Ra the Sun god? >> > > He meant quetzatcoatl. We could rename the language. That name is already taken in the programming language domain. There's a Tiny C compiler for 6510 based targets: http://www.kdef.com/geek/vic/quetz.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Newbie Question

2007-12-06 Thread Marc 'BlackJack' Rintsch
re's an alternative way with the `functools.partial()` function: from functools import partial # ... msg = Button(win, text='Write Something', command=partial(salutation, tree)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File to dict

2007-12-07 Thread Marc 'BlackJack' Rintsch
turn item... > > Yuck. I guess Duncan's point wasn't the construction of the dictionary but the throw it away part. If you don't keep it, the loop above is even more efficient than building a dictionary with *all* lines of the file, just to pick one value afterwards. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Calculate an age

2007-12-08 Thread Marc 'BlackJack' Rintsch
er it's easy but providing functions in the standard library for arbitrary date calculation involving years is not so easy. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Distinguishing attributes and methods

2007-12-08 Thread Marc 'BlackJack' Rintsch
he decision is easy -- everything on an object is an attribute. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Distinguishing attributes and methods

2007-12-08 Thread Marc 'BlackJack' Rintsch
On Sat, 08 Dec 2007 00:34:06 -0800, MonkeeSage wrote: > I think he means callable attributes (methods) and non-callable > attributes (variables). But not every callable attribute is a method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Distinguishing attributes and methods

2007-12-08 Thread Marc 'BlackJack' Rintsch
object bindings and methods are objects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: auto-increment operator - why no syntax error?

2007-12-08 Thread Marc 'BlackJack' Rintsch
>>>> n += 1 >>>> n > 2 >>>> ++n > 2 There is no syntax error. It is just some unary pluses "chained". Maybe unexpected but no syntax error. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: dictionary of dictionaries

2007-12-09 Thread Marc 'BlackJack' Rintsch
; dictionary with a tuple of both as keys: data = dict(((i, j), randint(0, 10)) for i in xrange(11) for j in xrange(11)) And just for completeness: The given data in the example can be stored in a list of lists of course: data = [[randint(0, 10) for dummy in xrange(11)] for dummy in xrange(11)]

Re: Distinguishing attributes and methods

2007-12-09 Thread Marc 'BlackJack' Rintsch
In [469]: a = collections.defaultdict(int) In [470]: callable(a.default_factory) Out[470]: True In [471]: a.default_factory(42) Out[471]: 42 `a.default_factory` is callable but hardly a method of `a` or `defaultdict` but a "data attribute" that happens to be callable. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to protect my new commercial software.

2007-12-10 Thread Marc 'BlackJack' Rintsch
ke it as ugly and unusable as you can. Spend the time you planned for writing documentation for this task. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumb newbie back in shell

2007-12-10 Thread Marc 'BlackJack' Rintsch
obal line_ptr > 69 global char_ptr > ... > 75 line_ptr = 0 > 76 char_ptr = 0 > ... > 109 def get_toks( text ): > 110 while line_ptr < last_line: > ... > So when is a global var global? When you declare it ``global`` *in the function*. ``global`` on module level ha

Re: dictionary of dictionaries

2007-12-11 Thread Marc 'BlackJack' Rintsch
ful than the real default. What is the > reasoning behind NOT using this as the default implementation for a > dict in python? How's that more useful in the general case? Maybe if you come from a language where some default value pops up if the key is not present you are used to write code in a way that exploits this fact. But in the general case!? I need `defaultdict` not very often but want to know if a key is not present in a dictionary. Because most of the time that's a special condition or error that has to be handled or signaled up the call chain. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Text widget updates only after calling method exits (threading issue?)

2007-12-12 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Dec 2007 17:58:37 -0800, mariox19 wrote: > If I am supposed to send messages to Tkinter objects only from the > main thread, how can I get the letters to appear 1 per second? Take a look at the `after()` method on widgets. Ciao, Marc 'BlackJack'

Re: Is anyone happy with csv module?

2007-12-12 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Dec 2007 20:08:21 -0300, Gabriel Genellina wrote: > data = [row for row in csv.reader(..)] A bit shorter:: data = list(csv.reader(..)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: determining bytes read from a file.

2007-12-13 Thread Marc 'BlackJack' Rintsch
rst > '\0' are counted. If you want to deal with bytes better open the file in binary mode. Windows alters line endings and stops at a specific byte (forgot the value) otherwise. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic or not?

2007-12-13 Thread Marc 'BlackJack' Rintsch
= [do_something(item) for item in old] Or: new = map(do_something, old) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: RegExp Help

2007-12-14 Thread Marc 'BlackJack' Rintsch
tarting to parse XML with regular expressions you are making the very same mistake. XML may look somewhat simple but producing correct XML and parsing it isn't. Sooner or later you stumble across something that breaks producing or parsing the "naive" way. Ciao, Marc &#x

Re: Compressing a text file using count of continous characters

2007-12-14 Thread Marc 'BlackJack' Rintsch
implement it. :-) `itertools.groupby()` might be handy. And you have to think about digits in the source if that's allowed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python really a scripting language?

2007-12-15 Thread Marc 'BlackJack' Rintsch
arBasic for the conversion. Full story: http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: checking for negative values in a list

2007-12-17 Thread Marc 'BlackJack' Rintsch
On Mon, 17 Dec 2007 06:20:23 -0800, vimal wrote: >i have a list of numbers > > say a = [1,-1,3,-2,4,-6] > > how should i check for negative values in the list In [6]: a = [1, -1, 3, -2, 4, -6] In [7]: any(n < 0 for n in a) Out[7]: True Ciao, Marc 'Blac

Re: Passing by reference

2007-12-23 Thread Marc 'BlackJack' Rintsch
e other program will say: > tok = Toker( text_array ) > tokens = tok.tokenize() > > So how does the constructor make the array of strings available to the > tokenize() method? Assuming the `__init__()` above belongs to the `Toker` class then the `tokenize()` method can access it via `self.text`

Re: difference between class and static methods?

2006-04-18 Thread Marc 'BlackJack' Rintsch
rom_file()` method inherited from class `A` is called but with `B` as the first argument so it returns an instance of `B`. A staticmethod is just a function attached to a class without any "magic". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Strategy Design Pattern

2006-04-21 Thread Marc 'BlackJack' Rintsch
on is sufficient or if the `strategy` needs some state that must be preserved between calls to the strategy object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: BIOCHIP --->>> NO GOOD !!

2006-04-21 Thread Marc 'BlackJack' Rintsch
in Australia and he told me two >> >> I'm thinking a list comprehension... > > Possibly some filter(map()) for the really orthodox believers... And ``ifilter(imap(…))`` for the reformists. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PyLint results?

2006-04-21 Thread Marc 'BlackJack' Rintsch
another `ham`. > 8) W:995:sendStringToSocket: Used builtin function 'map' >Is that a problem? `map` is "deprecated" in favor of list comprehensions. A matter of taste… Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: do while loop

2006-04-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 雷 wrote: > suggest add do while loop in later version Please also suggest a clean syntax for this. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Can you create an instance of a subclass with an existing instance of the base class?

2006-04-28 Thread Marc 'BlackJack' Rintsch
"ancestors" so you can build an object hierarchy. Missing attributes are looked up in the "ancestors" and one can explicitly look up the inheritance tree with ``super``. There are no classes, just four objects. Convention in naming and usage makes two of them something like templates or "classes" for new objects but they are in no way special. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does bufsize=1 not work in subprocess.Popen ?

2006-04-29 Thread Marc 'BlackJack' Rintsch
ch line as it is ouput, not all of the lines at termination, > which is what is happening. >From the Python side you can only control Python's input buffer but not the output buffer of the external program you are starting. I guess that programs buffers its output. Ciao, Marc &

Re: request help with Pipe class in iterwrap.py

2006-05-02 Thread Marc 'BlackJack' Rintsch
the chained iterators:: new_list = pipe(grep('larch'), grep('parrot', 'v')), list)(my_list) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: "TypeError" wrong number of args

2006-05-03 Thread Marc 'BlackJack' Rintsch
s, **t) return d class A: @b def a(x, y, z): print y, z x.e(23) def e(u, v): print u, v class B: def e(v, w): print 'spam', v, w A.e = e x = A() x.a('answer', 42

Re: scope of variables

2006-05-03 Thread Marc 'BlackJack' Rintsch
ind out yourself by just trying that code. Running this:: b = 3 def adding(a): print a + b adding(5) Puts out 8 as expected. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-04 Thread Marc 'BlackJack' Rintsch
ago. IIRC, disabling some other program or service > fixed it for one MS victem. IIRC it was something like an NTP daemon that caused the clock to "jump" a little and (Window's) sleep was confused. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-05 Thread Marc 'BlackJack' Rintsch
The "jump" of the system clock might confuse the systems `sleep` implementation. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: altering an object as you iterate over it?

2006-05-19 Thread Marc 'BlackJack' Rintsch
cing `file` as a synonym was the possibility to inherit from builtins. Inheriting from `open` looks quite strange. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about exausted iterators

2006-05-20 Thread Marc 'BlackJack' Rintsch
ybe duck typing. :-) SCNR, Marc 'BlackJack' Rintsch [1] http://www.cybersalt.org/cleanlaugh/images/03/ducktape.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: write() vs. writelines()

2006-05-26 Thread Marc 'BlackJack' Rintsch
r line in lines: file.write(line) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Modify one character in a string

2006-05-26 Thread Marc 'BlackJack' Rintsch
ause it depends on the details > of the operating system you're using. On Unix, you can seek to a specific > place in a file, write a single character, seek to EOF, and you've done an > in-place single character edit of the file. Why seeking to EOF after writing the byte?

Re: Happy Christmas Pythoneers

2007-12-28 Thread Marc 'BlackJack' Rintsch
and connected with the caller's history of `champagne.drink()` calls. The `person.is_pretty` property is most definitely linked to that call history in many instances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode(s, enc).encode(enc) == s ?

2007-12-28 Thread Marc 'BlackJack' Rintsch
ing bytes are all ASCII. And of course you can use that escape prefix as often as you want within a string of ASCII byte values. http://en.wikipedia.org/wiki/ISO-2022-JP#ISO_2022_Character_Sets > I.e. in practice (in a context limited to the encoding in question) > should this be considered as a data loss, or should these strings be > considered "equivalent"? Equivalent I would say. As Unicode they contain the same characters. Just differently encoded as bytes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange Behavior: csv module & IDLE

2007-12-28 Thread Marc 'BlackJack' Rintsch
der IDLE. Any help or explanation would be appreciated. You are not closing the file so the buffered data is not written to disk. To call a function you need the parenthesis, otherwise you are just referencing it without any effect. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: How to implement listing al 'Employees'.

2007-12-29 Thread Marc 'BlackJack' Rintsch
maybe it should not be a class. Maybe a function returning `Article`\s would be enough. This is not Java, not everything has to be stuffed into classes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Optional code segment delimiter?

2007-12-29 Thread Marc 'BlackJack' Rintsch
to yell at you. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Fate of itertools.dropwhile() and itertools.takewhile()

2007-12-30 Thread Marc 'BlackJack' Rintsch
tswith(start_marker), lines)) Maybe these functions usually don't turn up in code that can be called "recipes" so often but are useful for themselves. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: at what complexity, a comparison fails ?

2007-12-31 Thread Marc 'BlackJack' Rintsch
ngth and all elements at the corresponding indexes compare equal, the lists are considered equal. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: pdf library.

2008-01-01 Thread Marc 'BlackJack' Rintsch
nning a 500odd page ebook > through one of those scripts might not be such a good idea. Heuristics? Neither PDF nor HTML know "chapters". So it might be guesswork or just in your head. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython application ( problem ? )

2008-01-02 Thread Marc 'BlackJack' Rintsch
On Wed, 02 Jan 2008 03:24:56 -0800, vedrandekovic wrote: > Here is sample of my simple script with wxpython and modules: > subprocess,threading, directpython... Are you accessing the GUI from threads? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: Point Object

2008-01-05 Thread Marc 'BlackJack' Rintsch
into decimal and confirm that they match. The right direction would be the tutorial in the docs I guess: http://docs.python.org/tut/tut.html What do you mean by the "hexadecimal form"? `id()` returns ordinary `int`\s and not strings. Ciao, Marc 'BlackJack' Rints

Re: Pet Store

2008-01-08 Thread Marc 'BlackJack' Rintsch
looking for a Python web framework with a "Pet Store" tutorial? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: popen question

2008-01-08 Thread Marc 'BlackJack' Rintsch
do whatever is needed to output the numbers from ``slow`` unbuffered or line buffered. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python syntax:urgent

2008-01-08 Thread Marc 'BlackJack' Rintsch
are strings, adjust > accordingly): > > s = "gmmscore -i %s -l %s -t %s -m %s -d %s -v %s -n %s -r %s" % > (Input, List, modeltype, str(mixture), str(dimension), str(vfloor), > str(number), str(results)) > > subprocess.Popen([s]) Here you are trying to start

Re: problem of converting a list to dict

2008-01-09 Thread Marc 'BlackJack' Rintsch
[1] > IndexError: list index out of range > > Anyone could shed me a light on this? The real list you used had at least one string without a '=' in it. The list given above doesn't raise that exception: In [102]: mylist=['','tom=boss','mike=manager

Re: Embedding python code into text document question.

2008-01-10 Thread Marc 'BlackJack' Rintsch
a solution that works? > Any suggestions? Any help will be appreciated :) My suggestion would be: use one of the many already existing templating systems. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: adding methods at runtime

2008-01-10 Thread Marc 'BlackJack' Rintsch
ance, the method will > not get "self" as parameter. You are not adding a method but a function. Take a look at `types.MethodType()` to create a method from a function, instance, and class. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: encrypting python modules

2008-01-11 Thread Marc 'BlackJack' Rintsch
to the clients for execution. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: super, decorators and gettattribute

2008-01-13 Thread Marc 'BlackJack' Rintsch
) > and .__len__, str() and .__str__. Do you maybe know what's the > rationale behind not following that convention by getattr? I think you are confusing `__getattr__` and `__getattribute__` here! `getattr()` maps to `__getattr__()`, it's `__getattribute__` that's differen

Re: XOR encryption

2008-01-18 Thread Marc 'BlackJack' Rintsch
nd remaining part of the text is not read. You have to open the file in binary mode ('rb'/'wb') instead of text mode ('r'/'w') to stop Windows from interpreting the EOF character this way. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with 'global'

2008-01-21 Thread Marc 'BlackJack' Rintsch
or if that import is not the very first statement in a source file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: what's this instance?

2008-01-22 Thread Marc 'BlackJack' Rintsch
e works well.But what's the instance of "oops"? where is it > coming from? I'm totally confused on it.thanks. `oops` is bound to the `ValueError` or `TypError` object if `float()` raises such an exception. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on sort() key function

2008-01-22 Thread Marc 'BlackJack' Rintsch
it's all greek. I grew up with C function pointers, and they > always work. > > robert Suppose `func` is a C function pointer, then foo = func; and foo = func(); have different meanings. It's just the same in Python. First is the function itself, second *calls* the function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Module/package hierarchy and its separation from file structure

2008-01-23 Thread Marc 'BlackJack' Rintsch
x.X as X. Then you shoot down the idiomatic answer I guess. That's what most people do. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Stripping whitespace

2008-01-23 Thread Marc 'BlackJack' Rintsch
ou! You *can* just do ``lala.split()``: In [97]: lala = 'LNAME PASTA ZONE' In [98]: lala.split() Out[98]: ['LNAME', 'PASTA', 'ZONE'] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Some questions about decode/encode

2008-01-24 Thread Marc 'BlackJack' Rintsch
AX wants bytes, not a decoded string. Don't decode it yourself. > However, I use another text editor to convert the file to utf-8 and > SAX will parse the content successfully. Because now you feed SAX with bytes instead of a unicode string. Ciao, Marc 'BlackJack'

Re: piping into a python script

2008-01-24 Thread Marc 'BlackJack' Rintsch
ls that can get the data from command line or files treat a single - as file name special with the meaning of: read from stdin. So the interface if `fui.py` would be: 1. ./fui.py *.a 2. ls *.a | ./fui.py - 3. ls *.a | ./fui.py *.b - Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: When is min(a, b) != min(b, a)?

2008-01-25 Thread Marc 'BlackJack' Rintsch
mbership testing and "nested comparison" of those structures. There is no ``is`` involved. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: read and readline hanging

2008-01-25 Thread Marc 'BlackJack' Rintsch
are you sure that the > > subprocess is flushing its buffers so you can recognize it's time to > > provide more input? > > The subprocess in a purely passive position: it is an interpreter: I > send it commands and I read the answers. The python side is in charge. This

Re: is possible to get order of keyword parameters ?

2008-01-25 Thread Marc 'BlackJack' Rintsch
keyword parameters inside the > function. > any hints ? Impossible. Dictionaries are unordered. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: translating Python to Assembler

2008-01-26 Thread Marc 'BlackJack' Rintsch
you do that? > > I thought it might be compile(), but apparently not. Maybe `bytecodehacks`_ + `psyco`, or PyPy!? .. _bytecodehacks: http://sourceforge.net/projects/bytecodehacks/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to make format operator % work with unicode as expected

2008-01-27 Thread Marc 'BlackJack' Rintsch
that you confuse unicode and utf-8. Are you sure you are qualified to ask such a question in the first place!? :-þ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting Large File (Code/Performance)

2008-01-27 Thread Marc 'BlackJack' Rintsch
640k, it's >> easy to state that there is no limit. :) > > Huh? I used DOS sort to sort files much bigger than 640K. That was an allusion to a quote misattributed to Bill Gates about DOS: 640K ought to be enough for anybody. http://en.wikiquote.org/wiki/Bill_Gates#Misattributed Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Some questions about decode/encode

2008-01-27 Thread Marc 'BlackJack' Rintsch
vert the GBK string to unicode string, what > should I do to make SAX work? Decode it and then encode it to utf-8 before feeding it to the parser. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: translating Python to Assembler

2008-01-27 Thread Marc 'BlackJack' Rintsch
. The byte code is *interpreted* by Python, not compiled to assembler. If you want to know how this happens get the C source code of the interpreter and don't waste your time with disassembling `python.exe`. C is much easier to read and there are useful comments too. Ciao, Marc '

Re: translating Python to Assembler

2008-01-27 Thread Marc 'BlackJack' Rintsch
On Sun, 27 Jan 2008 11:23:20 +, over wrote: > Don't fucking tell me about assembler, you asshole. I can read > disassembled code in my sleep. Yes you can read it, but obviously you don't understand it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.o

Re: translating Python to Assembler

2008-01-27 Thread Marc 'BlackJack' Rintsch
e, there's almost always a rational explanation. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to make format operator % work with unicode as expected

2008-01-27 Thread Marc 'BlackJack' Rintsch
On Sun, 27 Jan 2008 16:00:42 +, Peter Pei wrote: > "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote: >> >>> You didn't understand my que

Re: read and readline hanging

2008-01-28 Thread Marc 'BlackJack' Rintsch
es line buffering but if it is connected to a pipe or redirected to a file it chooses block buffering instead. In such cases the `pexpect` module might be a solution. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: optional static typing for Python

2008-01-28 Thread Marc 'BlackJack' Rintsch
code. Can be used for other things as well. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A question about osyco

2008-01-28 Thread Marc 'BlackJack' Rintsch
e twice and measure the time of the second call. IIRC psyco needs at least one call to analyze the function, so the first call is not speed up. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode literals to latin-1

2008-01-30 Thread Marc 'BlackJack' Rintsch
decode('latin-1') > but to no avail. In [388]: 'Fr\u00f8ya'.decode('unicode-escape') Out[388]: u'Fr\xf8ya' In [389]: print 'Fr\u00f8ya'.decode('unicode-escape') Frøya Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing Pubic Hair Methods

2008-01-30 Thread Marc 'BlackJack' Rintsch
nt and not a function. So the way you wrote it with parentheses is a bit misleading. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing Pubic Hair Methods

2008-01-30 Thread Marc 'BlackJack' Rintsch
odd. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary Keys question

2008-01-30 Thread Marc 'BlackJack' Rintsch
Fallback is the hash of the identity of an object: In [415]: class A(object): pass .: In [416]: a = A() In [417]: hash(a) Out[417]: 161029068 In [418]: hash(id(a)) Out[418]: 161029068 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: psyco question

2008-02-03 Thread Marc 'BlackJack' Rintsch
formance? What about `psyco.unbind()`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does anyone else use this little idiom?

2008-02-03 Thread Marc 'BlackJack' Rintsch
mentation will become > 'range' at that time. The point wasn't `range` vs. `xrange` but the arguments (1,n) vs. (n). Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does anyone else use this little idiom?

2008-02-03 Thread Marc 'BlackJack' Rintsch
... del go.count > ... return False > ... go.count -= 1 > ... return True > ... >>>> while go(3): > ... print 'hello' > ... > hello > hello > hello >>>> Please try: while go(3): while go(3): print 'Think about it...' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-parsing

2008-02-04 Thread Marc 'BlackJack' Rintsch
appears to be working OK as is, but I would welcome any & > all suggestions for improving it or making it more idiomatic. As already said, that ``while`` loop should be a ``for`` loop. But if you put `m_abbrevs` into a `list` you can replace the loop with a single call to its `index()` method: ``dlist[1] = m_abbrevs.index(dlist[1]) + 1``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-parsing

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 09:43:04 +, Odysseus wrote: > In article <[EMAIL PROTECTED]>, > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> def extract_data(names, na, cells): >> found = dict() > > The problem with initializing the &#x

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
s are done at the same time. That's what I meant by people > going through the doors. Maybe it was more clear in my head. But my timing shows that method two is slower on my computer. So there is no obvious winner. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
ne explain why the code which does more work > takes less time? Can't confirm this (Linux, Python 2.5): Method 1: 15.380897998809814 Method 2: 18.085366010665894 I guess it's really all about the disk IO as my system monitor applet shows that almost all of the time is spend in the kernel and very little in user space. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Elementary string-parsing

2008-02-04 Thread Marc 'BlackJack' Rintsch
test functions or to reuse the code from other scripts. >> def extract_data(names, na, cells): >> >> and >> >> return > > What should it return? A Boolean indicating success or failure? All the > data I want should all have been stored in the &quo

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
each > time. It doesn't hold. Read the code again. The total count of "open door" and "close door" is the same in both cases. It's for every person: open his door; push him through the door; close his door vs. for every person: open his doo

Re: future multi-threading for-loops

2008-02-04 Thread Marc 'BlackJack' Rintsch
core. Clearly, not generally > applicable. -- But, from __future__ import does change syntax. Why not simply writing a function? def execute_parallel(f, A): for args in A: start_new_thread(target=f, args=args) def f(x): normal_suit(x) parallel(f, A) Ciao, Marc &#x

Re: extending python with array functions

2008-02-04 Thread Marc 'BlackJack' Rintsch
rectly access the "raw" memory. To the OP: Since Python 2.5 the `ctypes` module is another way to interface with "native" code in dynamic libraries from the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected timing results with file I/O

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 21:58:46 +, Steven D'Aprano wrote: > On Mon, 04 Feb 2008 17:08:02 +0000, Marc 'BlackJack' Rintsch wrote: > >>> Surprisingly, Method 2 is a smidgen faster, by about half a second over >>> 500,000 open-write-close cycles. It's no

<    8   9   10   11   12   13   14   15   16   17   >