Re: low level python read's

2007-01-07 Thread Marc 'BlackJack' Rintsch
or an "it"? I'd say "it". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Maybe a little bug of ipython 0.7.3 ?

2007-01-08 Thread Marc 'BlackJack' Rintsch
se note that there is an extra "0" after "**26 <...>", which > doesn't appear for the followling cases:* This 0 is the last digit of `980`. If the string form is very long the string itself is shortened by leaving out the middle part. It's irre

Re: How to write temporary data to file?

2007-01-09 Thread Marc 'BlackJack' Rintsch
'url2': {... > } > > This dictionary will get _very_ big, so I want to write it somehow to a > file after it has grown to a certain size. > > How would I achieve that? If you want easy access to single 'url' keys then `shelve` might be an alternative to pickling the whole thing as one big object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie - converting csv files to arrays in NumPy

2007-01-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, oyekomova wrote: > I would like to know how to convert a csv file with a header row into a > floating point array without the header row. Take a look at the `csv` module in the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://m

Re: Concatinating PDF files

2006-01-22 Thread Marc 'BlackJack' Rintsch
part of `libtiff`: http://www.remotesensing.org/libtiff/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython or wxWidgets

2006-01-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, py wrote: > i need to design a GUI for my python app. i heard of wxWidgets and was > going to look into that, but then I saw wxPython. Why would I use > wxPython over wxWidgets? wxPython are the Python bindings to wxWidgets which is a C++ library. Cia

Re: Possible memory leak?

2006-01-26 Thread Marc 'BlackJack' Rintsch
t_array[index] - filter_value) if num < 0: num = 0 if num > 255 * 64: num = 255 * 64 data.append(num // 64) return data.tostring() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about isinstance()

2006-01-27 Thread Marc 'BlackJack' Rintsch
ld return NotImplemented. After > all, the things you didn't think of are not (yet) implemented. I think Steven thinks that it is possible that you compare to an object of a different type which has the same attributes as expected by the `__eq__()` method. If the first test is `isinstance()` for the "correct" type you rule out those cases and give a false `False`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Are there memory limits for external C modules?

2006-01-28 Thread Marc 'BlackJack' Rintsch
Mybe you can build your C code as shared library and use `ctypes` to call the functions from Python: http://starship.python.net/crew/theller/ctypes/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Which is faster? (if not b in m) or (if m.count(b) > 0)

2006-02-14 Thread Marc 'BlackJack' Rintsch
hrough all elements of `m` in the `count()` method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic gui format?

2006-02-15 Thread Marc 'BlackJack' Rintsch
is forbidden in strings and it's not allowed to leave out a leading zero in numbers, nor is it allowed to start a number with a unary `+`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run shell commands within python

2006-02-17 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Donn Cave wrote: > You can replace "mv" with os.rename() if you don't > care that it will fail when the destination is on a different > filesystem. Etc. If you care than use `shutil.move()` instead. Ciao, Marc 'BlackJack&

Re: Quesion about the proper use of __slots__

2006-02-20 Thread Marc 'BlackJack' Rintsch
s, and 3 to 5 carriers for each of the two teams, which comes > out to be quite large. That's 750 fighter objects. This is not a "large" amount of objects. So I think it's premature optmization. Especially because you think of using __slots__ without actually trying if the

Re: python and glut

2005-05-07 Thread Marc 'BlackJack' Rintsch
this in my XF86Config and I'm in the `video` group:: Section "DRI" Group "video" Mode 0660 EndSection Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble with copy/deepcopy

2005-05-16 Thread Marc 'BlackJack' Rintsch
nstances. class Distribution: def __init__(self): self.__gr_on_transp = dict() self.__ostatok_m = dict() ... This creates *instance variables* which should be deepcopied without problems. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: convert a string to tuple

2005-05-31 Thread Marc 'BlackJack' Rintsch
#x27;, '4'] In [4]: tuple(b[1:-1].split(',')) Out[4]: ('1', '2', '3', '4') Ooops, you wanted ints in there: In [5]: tuple(map(int, b[1:-1].split(','))) Out[5]: (1, 2, 3, 4) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Tiff Image Reader/writer

2005-06-15 Thread Marc 'BlackJack' Rintsch
#x27;t fast enough? > > In [8]: %time img2 = Image.open('foo.tiff') > CPU times: user 0.00 s, sys: 0.01 s, total: 0.01 s > Wall time: 0.03 > > In [9]: img2.size > Out[9]: (2400, 4800) It's fast enough to open the file and read the meta-data. The OP want

Re: strange PyLint configuration

2007-06-01 Thread Marc 'BlackJack' Rintsch
f mapping.has_key(ham): pass # -> if ham in mapping: pass Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

RE: c[:]()

2007-06-01 Thread Marc 'BlackJack' Rintsch
le: func(item) do(orchestra(score), pickle) do(orchestra(conductor), sequence) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

RE: c[:]()

2007-06-01 Thread Marc 'BlackJack' Rintsch
t; code? I don't see how writing other languages and Python parsers and translators into other representations tells you much about the spirit and idiomatic *usage* of a language. Your proposal is not about syntax, it's about semantics. ``obj[:]()`` is basically syntactic sugar for: ``ob

Re: Python Pop Quiz

2007-06-01 Thread Marc 'BlackJack' Rintsch
tp://en.wikipedia.org/wiki/Zilog_Z80 >> Essay: "C++ is better than C", agree or disagree? (four word maximum) > > STL compile error diagnostics. So do you agree or disagree!? ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-03 Thread Marc 'BlackJack' Rintsch
e "map()" function for doing > somethimg with each element of a sequence, if the order of a actions > not important. > > it is easy to read and understandable. And has the same issue as a list comprehension if all you want is the side effect of the calls: a useless temporary list full of `None`\s is build. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-03 Thread Marc 'BlackJack' Rintsch
quot;. No, the side effect is the printing of 'From Russia with love.' IMHO there's a difference between this single `None` that can't be prevented and abusing a list comprehension or `map()` just for side effects and not for building a list with meaningful content. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: *Naming Conventions*

2007-06-03 Thread Marc 'BlackJack' Rintsch
; ... Makes sense, too, but aren't all functions getting something? So you may reduce this to just `values()`. On the other hand there is the convention to name functions and methods as verbs that are "doing" something. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: magic names in python

2007-06-04 Thread Marc 'BlackJack' Rintsch
> * is the use of magic names encouraged and/or part of good coding > practice. What do you mean by "use"? Implement them to override behavior? Yes, that's their purpose. Invent new magic names? No of course not, they are special for a reason: preventing name clas

Re: Dict naming, global vs local imports, etc. [was Re: *Naming Conventions*]

2007-06-04 Thread Marc 'BlackJack' Rintsch
g. `pylint` reports unused imported names. I don't follow PEP8 only if it's not possible otherwise. But cyclic imports are bad anyway. :-) And if the import is *really* expensive and only needed in some special circumstances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
;>> from sys import maxint >>> c = count(maxint) >>> c.next() 2147483647 >>> c.next() -2147483648 What I find most disturbing here, is that it happens silently. I would have expected an exception instead of the surprise. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: magic names in python

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, per9000 wrote: > On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, per9000 wrote: >> > >> > [...] >> > >> > So another question emerges: >> >

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Peter Otten wrote: > Marc 'BlackJack' Rintsch wrote: > >>>>> from itertools import count >>>>> from sys import maxint >>>>> c = count(maxint) >>>>> c.next() >> 2147483647 >>&g

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
By the way, here's what I get if I force the wrong library upon python2.5: > > /usr/local/lib/python2.4/lib-dynload $ python2.5 > Python 2.5 (r25:51908, Oct 3 2006, 08:48:09) > [GCC 3.3.3 (SuSE Linux)] on linux2 Seems to be the same Python version, just build three days earlier and with a different GCC version. Weird. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, Dutch, English, Chinese, Japanese, etc.

2007-06-04 Thread Marc 'BlackJack' Rintsch
pedia.org/wiki/Lojban Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: magic names in python

2007-06-05 Thread Marc 'BlackJack' Rintsch
Except documenting what's going on and not over(ab)using the reflective and dynamic nature of Python to the point where the source starts to get unreadable and too magic, AFAIK there's no special "pythonic" recommendation. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-06 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > Is there a general Pythonic idiom for efficiently walking over part of a > sequence without copying it first? Should there be? What about using `itertools.islice()`: for e in islice(a, 4): pass Ciao, Marc &#

Re: overriding setting

2007-06-06 Thread Marc 'BlackJack' Rintsch
mes don't have types in Python, objects do. `list()` takes an optional argument. Just make sure your derived type does to and passes this to the base class `__init__()`. Then you can create an instance like this: a = MyList([[1, 2, 3], [4, 5, 6, 7]]) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: running a random function

2007-06-07 Thread Marc 'BlackJack' Rintsch
a > way of actually running the function. If you have a function or callable you call it with the "call operator", which are parenthesis: In [8]: int Out[8]: In [9]: int() Out[9]: 0 For a random selection of an element from a list look at the `random.choice()` function. Ciao,

Re: Integer division

2007-06-07 Thread Marc 'BlackJack' Rintsch
anguage for a reason. I'm surprised > at how few Pythonistas are using it six years later. It would just document intent here because it still gives `float` results if used with at least one `float` as operands: In [1]: 10.0 // 2 Out[1]: 5.0 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to do reading of binary files?

2007-06-08 Thread Marc 'BlackJack' Rintsch
depending of the size of the files and memory of course. One problem I see is that '\x0c' may not always be the page end. It may occur in "rastered image" data too I guess. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: interating over single element array

2007-06-08 Thread Marc 'BlackJack' Rintsch
--- exceptions.TypeError Traceback (most recent call last) /home/new/ TypeError: len() of unsized object > any suggestions are appreciated, Yes, don't try iterating over objects that are not iterable. ;-) What you *can* do is iterating over lists, tuples or ot

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Marc 'BlackJack' Rintsch
it with a named function of course. > mylist = ['Fred','bill','PAUL','albert'] > > mylist.sort(key=lambda el: el.lower()) So this becomes: def keyfunc(el): return el.lower() mylist.sort(key=keyfunc) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Working with fixed format text db's

2007-06-08 Thread Marc 'BlackJack' Rintsch
e objects should *always* be "true". An error is handled via exceptions. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: interating over single element array

2007-06-09 Thread Marc 'BlackJack' Rintsch
trings that produce the data themselves, for example by attaching a counter to a basename, or extracting the names from XML files, fetching them from a database etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Third-party libs in version control

2007-06-09 Thread Marc 'BlackJack' Rintsch
ode might be okay but if there are external dependencies one can't checkout on another computer and expect everything to work there. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Postpone creation of attributes until needed

2007-06-11 Thread Marc 'BlackJack' Rintsch
> self.__dict__['z'] = self.x * self.y > return self.__dict__[name] > > I tried that, but I get AttributeError: 'A' object has no attribute > '__dict__'. That's because you used `__slots__`. One of the drawbacks of `__slots__`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newsgroup query

2007-06-12 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jeff Rollin wrote: > Why do I not see my messages with attached files in the newsgroup, and is > there any way to configure this? No, most news servers strip attachments from postings in non-binary groups. It's a plain text medium. Ciao, Marc &#

Re: Accessing attributes?

2007-06-12 Thread Marc 'BlackJack' Rintsch
ere am I going wrong? Looking at the indention of the code I would say you just have an `__init__()` and all other ``def``\s are local functions to that method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A gotcha: Python pain point?

2007-06-12 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Terry Reedy wrote: > | Should I import this to see how > | many principles this behavior violates? > > ??? > > If you meant 'report' (on SF), please do not. I think he meant ``import this`` at the Python interpreter. Ciao,

Re: a question about unicode in python

2007-06-12 Thread Marc 'BlackJack' Rintsch
n't decode bytes in position 0-1: > invalid data > > by in python interactive, it is right > >>>> s = u'张三' > > why? Does the "coding comment" match the actual encoding of the source file? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Threading Example Doesn't Work (2.5.1)

2007-06-12 Thread Marc 'BlackJack' Rintsch
think is happening? Any chance that you have a module called `threading` that is not the one in the standard library? Perhaps you named the script above `threading.py`!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > No need to create the intermediate list, a generator expression works just > fine: > > a = tuple(i for i in range(10)) But `range()` creates the intermediate list anyway. ;-) a = tuple(xrange(10)) Ciao, Marc &

Re: problem on waiting exit thread and write on file

2007-06-13 Thread Marc 'BlackJack' Rintsch
ead in threads: thread.join() Much shorter, isn't it!? :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: huge dictionary -> bsddb/pickle question

2007-06-15 Thread Marc 'BlackJack' Rintsch
han bsddb might be useful here. An SQL one like SQLite or maybe an object DB like zodb or Durus. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Should: "for k,v in **dictionary_instance" work?

2007-06-15 Thread Marc 'BlackJack' Rintsch
t k,v Why should it be? Why adding something that unreadable and magic instead of the perfect readable ``for k, v in some_dict.iteritems():``? And I don't see why it should be ``**``!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: BeautifulSoup - extract the

2007-06-18 Thread Marc 'BlackJack' Rintsch
All('object') Out[17]: [http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=7,0,19,0" width="640" height="400"> http://www.macromedia.com/go/"; getflashplayer="getflashplayer" type="application/x-shockwave-flash" width="640" height="400" bgcolor="#00" scale="showall"> ] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: suggestion: recursive collections.defaultdict

2007-06-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > It seems like > > x = defaultdict(defaultdict(list)) > > should do the obvious, but it doesn't. It *does* the obvious. Parenthesis after a name means: call this object *now*. Any other behavior wouldn't

Re: Rotating a picture

2007-06-19 Thread Marc 'BlackJack' Rintsch
quality and detail. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: HTMLParser.HTMLParseError: EOF in middle of construct

2007-06-19 Thread Marc 'BlackJack' Rintsch
ser may be confused at this point and be already in an internal state that sees that line in a completely different light than you do. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Packing a simple dictionary into a string - extending struct?

2007-06-20 Thread Marc 'BlackJack' Rintsch
d in your post is `ASN.1`_. And there's a secure alternative to `pickle` called cerealizer_. .. _`ASN.1`: http://pyasn1.sourceforge.net/ .. _cerealizer: http://home.gna.org/oomadness/en/cerealizer/ .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html .. _JSON: http://www.json.or

Re: configparser shuffles all sections ?

2007-06-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, stef wrote: > I just used configparser for the first time and discovered that it > shuffled all my sections, and the contents of the sections too. The data is stored in dictionaries. > This makes human manipulation of the file impossible. Why so? Cia

Re: comparing two lists and returning "position"

2007-06-22 Thread Marc 'BlackJack' Rintsch
list!? Somehow hard to believe. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: SIMD powered Python

2007-06-23 Thread Marc 'BlackJack' Rintsch
l" data types, Python is about objects. `map()`, `reduce()`, list comprehension work on arbitrary iterables so how do you expect SIMD instructions handle this? Even simple lists contain objects and those don't have to be of the same type. Ciao, Marc 'BlackJack' Rintsch

Re: SIMD powered Python

2007-06-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Bytter wrote: > Marc 'BlackJack' Rintsch escreveu: >> In <[EMAIL PROTECTED]>, Bytter wrote: >> >> > Is there any I&D ongoing about using SIMD [1] instructions, like SSE >> > [2], to speed up Python, especially

Re: Collections of non-arbitrary objects ?

2007-06-23 Thread Marc 'BlackJack' Rintsch
with a "typed list". It's easy to take an object and completely replace all its attributes so it behaves very different. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is this a valid import sequence ?

2007-06-24 Thread Marc 'BlackJack' Rintsch
d at module level. It seems a common error from people used to declare variables at that level in other languages. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: listing all property variables of a class instance

2007-06-25 Thread Marc 'BlackJack' Rintsch
; properties were defined/initalized: That's because you iterate over the instance's `__dict__` and not over the *class* `__dict__` like Neil does. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Marc 'BlackJack' Rintsch
string``. The definition of ``string / float`` is neat too. Something I really miss in everyday programming in Python, not. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Set builtin lookups

2007-06-26 Thread Marc 'BlackJack' Rintsch
ents in the list. Is this also true if I am using a set or are > sets represented by a hash table? Sets are implemented as hash tables. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: XML from SQL result

2007-06-27 Thread Marc 'BlackJack' Rintsch
in groupby(rows, second): writer.start('tag2', col2=value) for value in imap(third, rows): writer.element('tag3', col3=value) writer.end('tag2') writer.end('tag1') writer.end('document') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Marc 'BlackJack' Rintsch
ut must be read and understood a couple of times, so it's more important to have clear than short code. With `self` in place you always know which names are local and which are attributes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: restructuredtext latin1 encoding (FAQ?)

2007-07-03 Thread Marc 'BlackJack' Rintsch
efault encoding used by your operating system. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: 15 Exercises to Know A Programming Language

2007-07-03 Thread Marc 'BlackJack' Rintsch
o improve are also very welcome. Don't use `eval()` if it is not absolutely necessary. Especially if the input comes from a user it's a security hole. `float()` is the function to use here. `mean()` does not work as you try to divide a list by a number. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3.0 or 3000 ....is it worth waiting??? Newbie Question

2007-07-03 Thread Marc 'BlackJack' Rintsch
CII sources still work in Python 3000. And this change may be already in a Python 2.x before P3K. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with that r"\"

2007-07-04 Thread Marc 'BlackJack' Rintsch
t;) Where's the problem!? :: re.compile(r''''"''') Ah, I see -- readability is the problem. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: ignoring a part of returned tuples

2007-07-04 Thread Marc 'BlackJack' Rintsch
x27;s possible to configure many checks in Pylint. For this check it's possible to give a regular expression for names you don't care if they are unused. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: s1.intersects(s2)

2007-07-04 Thread Marc 'BlackJack' Rintsch
& s2 > set([3, 4]) >>>> > > It's all in python already. And documented on the web too. The OP already knows that but does not want to build a new `set`. He just wants to know efficiently if the sets intersect without actually *doing* the intersection. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: s1.intersects(s2)

2007-07-04 Thread Marc 'BlackJack' Rintsch
set_b = set_b, set_a return any(item in set_a for item in set_b) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Find This Module

2007-07-04 Thread Marc 'BlackJack' Rintsch
ne find the location of a built in module? It's built into the interpreter executable. In [85]: import _sre In [86]: _sre Out[86]: Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Callback scoping

2007-07-05 Thread Marc 'BlackJack' Rintsch
c) way to > get the behavior I want? (If you haven't guessed, I want a list of (no > parameter) functions, each of which returns its index in the list.) Default arguments are evaluated when the function is defined: In [15]: x = [lambda x=i: x for i in xrange(10)] In [16]: x[0]() Out[16]

Re: Where is the syntax for the dict() constructor ?!

2007-07-06 Thread Marc 'BlackJack' Rintsch
les, no switch statements... > > Is this the method that you would call "Mickey Mouse"? Maybe, because you've left out all handling of quoting and escape characters here. Consider this: erik,viking,"ham, spam and eggs","He said ""Ni!""","line one line two" That's 5 elements: 1: eric 2: viking 3: ham, spam and eggs 4: He said "Ni!" 5: line one line two Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Expandable 2D Dictionaries?

2007-07-06 Thread Marc 'BlackJack' Rintsch
ch for to research this concept? Thanks. It's mapping the tuple ('cat', 'paw') to 'some string'. Commas make tuples. The parenthesis are just necessary for the literal empty tuple and if the syntax would be ambiguous otherwise. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How would I write this C code in Python?

2007-07-06 Thread Marc 'BlackJack' Rintsch
"translation". `PF.buffer` might be better a string or an `array.array`. And is `BLOCK` really just a structure with *one* member? Looks a bit odd IMHO. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Repeating Thread Error

2007-07-06 Thread Marc 'BlackJack' Rintsch
rue: function_name(*arguments) just with a five second delay. > Also, do background processes run inside while loops? This question doesn't make much sense to me. Do ``while`` loops block other threads? No of course not. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Where is the syntax for the dict() constructor ?!

2007-07-07 Thread Marc 'BlackJack' Rintsch
> What would the following parse to?: > > erik,viking,ham, spam and eggs,He said "Ni!",line one > line two Why don't you try yourself? The `csv` module returns two records, the first has six items: 1: erik 2: viking 3: ham 4: spam and eggs 5: He said "Ni!" 6: line one 'line two' is the only item in the next record then. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode problem

2007-07-07 Thread Marc 'BlackJack' Rintsch
should convert \x2019 to \x27 ( as > defined in iso-8859-15 ) No it shouldn't because \x2019 is a "right single quotation mark" and not an apostrophe. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "Empty" text

2007-07-08 Thread Marc 'BlackJack' Rintsch
XHTML code I need it to? > Then either Firefox is broken or you don't declare your XHTML properly and Firefox thinks it's HTML. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help

2007-07-10 Thread Marc 'BlackJack' Rintsch
zero bytes: In [10]: a = '\000' In [11]: a Out[11]: '\x00' In [12]: ord(a) Out[12]: 0 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple search and Display system, no need for db?

2007-07-10 Thread Marc 'BlackJack' Rintsch
Then you can slap the Web 2.0 buzz label onto the system. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: concatenate file-like objects -> file-like object

2007-07-10 Thread Marc 'BlackJack' Rintsch
def read(size): result = '' while self.files: data = self.current_file.read(size) result += data if len(data) != size: self.current_file = self.files.pop() size = size - len(data) return resu

Re: bool behavior in Python 3000?

2007-07-11 Thread Marc 'BlackJack' Rintsch
gt; -1 > > At first look you can see that `cmp` does not return boolean value > what not for all newbies is so obvious. Sorry I fail to see your point!? What has ``==`` to do with `cmp()` here? The return of `cmp()` is an integer that cannot and should not be seen as boolean value. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple search and Display system, no need for db?

2007-07-11 Thread Marc 'BlackJack' Rintsch
On Wed, 11 Jul 2007 16:52:32 +, flit wrote: > That seems to be a good idea, but I am afraid the web hosting does not > have the csv modules.. The `csv` module is part of the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread Marc 'BlackJack' Rintsch
t; y > '000101100100' For the padding I'd use the `zfill()` method. In [15]: a = 0x0164 In [16]: gmpy.digits(a, 2).zfill(16) Out[16]: '000101100100' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: storing pickles in sql data base

2007-07-11 Thread Marc 'BlackJack' Rintsch
e of byte values. You have to write and read the "text" files in binary mode or they break if taken across platform boundaries because of the different line endings in Linux and Windows for instance. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting values out of a CSV

2007-07-13 Thread Marc 'BlackJack' Rintsch
ad on the processor? Do both tests read the data always from cache or has the very first loop had to fetch the CSV file from disk? $ python -m timeit -n 1000 -c 'import csv; data = [row for row in csv.reader(open("test.csv", "rb"))]' 1000 loops, best of 3: 1.27 msec per loop $ python -m timeit -n 1000 -c 'import csv; data = list(csv.reader(open("test.csv", "rb")))' 1000 loops, best of 3: 1.25 msec per loop Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-13 Thread Marc 'BlackJack' Rintsch
e you have to keep in mind that it uses lazy evaluation and that the compiler knows very much about the program structure and data types and flow to do optimizations. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Marc 'BlackJack' Rintsch
te the code". Easier than C because I don't have to deal with so much machine details, don't have to manage memory, don't need extra indexes for looping over lists and so on. And the "crashes" are much gentler, telling me what the error is and where instead of a simpl

Re: Best method for inter process communications

2007-07-17 Thread Marc 'BlackJack' Rintsch
ps(('hello world',)) In [10]: len(a) Out[10]: 80 In [11]: print a hello world Even with some additional boilerplate like XML declaration etc. there is still a little bit room until 10 kB are reached. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: merge two ranges

2007-07-17 Thread Marc 'BlackJack' Rintsch
ap(a, b) # output:None > print getOverlap(b, a) # output: None > > any easy way of doing this? Yes. That's quite an easy homework you really should do yourself. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Copy List

2007-07-19 Thread Marc 'BlackJack' Rintsch
ou that using the slice > notation will not? Well, a deep copy of course. ;-) In [6]: import copy In [7]: a = [[1, 2], [3, 4]] In [8]: b = a[:] In [9]: c = copy.deepcopy(a) In [10]: a[0][1] = 42 In [11]: a Out[11]: [[1, 42], [3, 4]] In [12]: b Out[12]: [[1, 42], [3, 4]] In [13]: c

Re: simpleJSON pack binary data

2007-07-22 Thread Marc 'BlackJack' Rintsch
nary data somehow. I'd use base64. It's available as codec for `str.encode()`/`str.decode()`. In [10]: '\x00\xff\xaa' Out[10]: '\x00\xff\xaa' In [11]: '\x00\xff\xaa'.encode('base64') Out[11]: 'AP+q\n' In [12]: _.decode('base64&

Re: Pythonic way for missing dict keys

2007-07-22 Thread Marc 'BlackJack' Rintsch
y_obj = my_dict.get(key) or my_dict.setdefault(key,myobject()) Reduces the unnecessary instantiation of `myobject` to "false" objects. May be not good enough. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-18 Thread Marc 'BlackJack' Rintsch
)) In [49]: years Out[49]: ['1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

<    2   3   4   5   6   7   8   9   10   11   >