Re: Extending Python by Adding Keywords Data types

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

Re: making a variable available in a function from decorator

2007-07-30 Thread Marc 'BlackJack' Rintsch
): 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-30 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 method to strings, though I had hoped there would be. I don't yet know how

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

2007-07-30 Thread Marc 'BlackJack' Rintsch
, 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
'exceptions.TypeError': unsupported operand type(s) for -: '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. Ciao, Marc 'BlackJack

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's strange. Not so strange really. The two xrange objects

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

2007-07-29 Thread Marc 'BlackJack' Rintsch
in parens., while non-printing chars with no escapes will be shown with nothing in parens. For escaping: In [90]: '\n'.encode('string-escape') Out[90]: '\\n' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: C API -- Two questions

2007-07-27 Thread Marc 'BlackJack' Rintsch
the argument into a tuple if you *really* need a tuple, or just use it as sequence or via iterator. And pay attention to errors of course. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Any reason why cStringIO in 2.5 behaves different from 2.4?

2007-07-27 Thread Marc 'BlackJack' Rintsch
` objects. `unicode` is already decoded. If you want to feed `unicode` objects to an XML parser, simply encode it before passing it. The question remains why you have serialized XML as `unicode` in the first place as it is about bytes not unicode characters. Ciao, Marc 'BlackJack' Rintsch

Re: Filtering content of a text file

2007-07-27 Thread Marc 'BlackJack' Rintsch
you can use `itertools.groupby()` to get the groups and write them to several files. Otherwise if the files can be read into memory completely you can sort in memory and then use `itertools.groupby()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Filtering content of a text file

2007-07-27 Thread Marc 'BlackJack' Rintsch
On Fri, 27 Jul 2007 12:15:25 +0200, Bruno Desthuilliers wrote: 4/ print //-+alibaba sinage[4:].startswith('a') print //-+alibaba sinage.startswith('a', 4) This does not create an extra string from the slicing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo

Re: 128 or 96 bit integer types?

2007-07-27 Thread Marc 'BlackJack' Rintsch
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
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: is_iterable function.

2007-07-26 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Flatten a list/tuple and Call a function with tuples

2007-07-26 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-25 Thread Marc 'BlackJack' Rintsch
actually iterate over the object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Wed, 25 Jul 2007 15:46:14 -0400, Carsten Haese wrote: On Wed, 2007-07-25 at 19:11 +, Marc 'BlackJack' Rintsch wrote: And just calling `iter()` doesn't work either: In [72]: class A: : def __getitem__(self, key): : if key == 42: : return

Re: From D

2007-07-25 Thread Marc 'BlackJack' Rintsch
On Wed, 25 Jul 2007 10:47:33 -0700, Paddy wrote: But then,what would _0 be, the number 0 or the name _0 analagous to a0 Of course the name because numbers have to start with a digit or a dot. Otherwise this would break backwards compatibility. Ciao, Marc 'BlackJack' Rintsch -- http

Re: classmethod staticmethod

2007-07-24 Thread Marc 'BlackJack' Rintsch
') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing XML with ElementTree (unicode problem?)

2007-07-24 Thread Marc 'BlackJack' Rintsch
should stop searching the explanation within Python or `ElementTree` and accept having a broken XML file on your disk. :-) Have you checked the local XML file with something like `xmllint` or another XML parser already? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: display image through cgi python html

2007-07-24 Thread Marc 'BlackJack' Rintsch
and print it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python pearls required for iteration across fields of data structure

2007-07-24 Thread Marc 'BlackJack' Rintsch
On Tue, 24 Jul 2007 02:26:15 -0700, NetHead wrote: The code below is WRONG, but hopefully illustrates what I am trying to achieve. Any suggestions how to code this is an efficient and maintainable (and correct) manner? […] for i in wildcards: for j in i: try:

Re: simpleJSON pack binary data

2007-07-22 Thread Marc 'BlackJack' Rintsch
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') Out[12]: '\x00\xff\xaa' Ciao, Marc 'BlackJack' Rintsch -- http

Re: Pythonic way for missing dict keys

2007-07-22 Thread Marc 'BlackJack' Rintsch
()) 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: Copy List

2007-07-19 Thread Marc 'BlackJack' Rintsch
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 Out[13]: [[1, 2], [3, 4]] Ciao, Marc 'BlackJack' Rintsch -- http

Re: Best method for inter process communications

2007-07-17 Thread Marc 'BlackJack' Rintsch
',)) In [10]: len(a) Out[10]: 80 In [11]: print a params param valuestringhello world/string/value /param /params 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

Re: Getting values out of a CSV

2007-07-13 Thread Marc 'BlackJack' Rintsch
'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
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
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 simple segfault or totally messed up results. Ciao, Marc 'BlackJack' Rintsch -- http

Re: storing pickles in sql data base

2007-07-12 Thread Marc 'BlackJack' Rintsch
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: Simple search and Display system, no need for db?

2007-07-11 Thread Marc 'BlackJack' Rintsch
, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-11 Thread Marc 'BlackJack' Rintsch
: data = self.current_file.read(size) result += data if len(data) != size: self.current_file = self.files.pop() size = size - len(data) return result Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python

Re: bool behavior in Python 3000?

2007-07-11 Thread Marc 'BlackJack' Rintsch
``==`` 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
]: gmpy.digits(a, 2).zfill(16) Out[16]: '000101100100' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help

2007-07-10 Thread Marc 'BlackJack' Rintsch
' 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: Empty text

2007-07-08 Thread Marc 'BlackJack' Rintsch
ElementTree to output the 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: Where is the syntax for the dict() constructor ?!

2007-07-07 Thread Marc 'BlackJack' Rintsch
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
is a right single quotation mark and not an apostrophe. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-06 Thread Marc 'BlackJack' Rintsch
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
. 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
but unless we know what you are going to do with these data structures it's hard to tell if it is really the best 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

Re: Repeating Thread Error

2007-07-06 Thread Marc 'BlackJack' Rintsch
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: Callback scoping

2007-07-05 Thread Marc 'BlackJack' Rintsch
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]: 0 In [17]: x[5]() Out[17]: 5 Ciao, Marc 'BlackJack

Re: what is wrong with that r\

2007-07-04 Thread Marc 'BlackJack' Rintsch
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
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
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
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
in module? It's built into the interpreter executable. In [85]: import _sre In [86]: _sre Out[86]: module '_sre' (built-in) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: restructuredtext latin1 encoding (FAQ?)

2007-07-03 Thread Marc 'BlackJack' Rintsch
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
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
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: Set builtin lookups

2007-06-27 Thread Marc 'BlackJack' Rintsch
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
('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
names are local and which are attributes. 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
* `__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
`` 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: is this a valid import sequence ?

2007-06-24 Thread Marc 'BlackJack' Rintsch
. 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: SIMD powered Python

2007-06-23 Thread Marc 'BlackJack' Rintsch
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 -- http://mail.python.org/mailman/listinfo/python

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 ID ongoing about using SIMD [1] instructions, like SSE [2], to speed up Python, especially regarding functional features, like list comprehension, map and reduce, etc

Re: Collections of non-arbitrary objects ?

2007-06-23 Thread Marc 'BlackJack' Rintsch
, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: configparser shuffles all sections ?

2007-06-22 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing two lists and returning position

2007-06-22 Thread Marc 'BlackJack' Rintsch
'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
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Rotating a picture

2007-06-19 Thread Marc 'BlackJack' Rintsch
, 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
at that line and ignore the rest. There are 604 (!) errors, some about table rows, before this line. So the parser 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

Re: BeautifulSoup - extract the object tag

2007-06-18 Thread Marc 'BlackJack' Rintsch
embed src=url quality=highpluginspage=http://www.macromedia.com/go/; getflashplayer=getflashplayer type=application/x-shockwave-flash width=640 height=400 bgcolor=#00 scale=showall /embed /param/object] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python

Re: suggestion: recursive collections.defaultdict

2007-06-18 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: huge dictionary - bsddb/pickle question

2007-06-15 Thread Marc 'BlackJack' Rintsch
'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
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: 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 'BlackJack' Rintsch -- http

Re: problem on waiting exit thread and write on file

2007-06-13 Thread Marc 'BlackJack' Rintsch
it!? :-) 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 'BlackJack' Rintsch

Re: Accessing attributes?

2007-06-12 Thread Marc 'BlackJack' Rintsch
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, Marc 'BlackJack' Rintsch -- http

Re: a question about unicode in python

2007-06-12 Thread Marc 'BlackJack' Rintsch
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
`!? 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
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: Third-party libs in version control

2007-06-10 Thread Marc 'BlackJack' Rintsch
to work there. 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
them from a database etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer division

2007-06-08 Thread Marc 'BlackJack' Rintsch
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
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
() 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 other iterables with just one element in them. Try ``a = [1]``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

Re: Case-Insensitive Sorting of Multi-Dimensional Lists

2007-06-08 Thread Marc 'BlackJack' Rintsch
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
, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: running a random function

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

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 'BlackJack' Rintsch -- http

Re: overriding setting

2007-06-06 Thread Marc 'BlackJack' Rintsch
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: magic names in python

2007-06-05 Thread Marc 'BlackJack' Rintsch
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: magic names in python

2007-06-04 Thread Marc 'BlackJack' Rintsch
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 clashes with the user's names. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

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

2007-06-04 Thread Marc 'BlackJack' Rintsch
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
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: * is the use of magic names encouraged and/or part of good coding practice. What do you mean by use

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 c.next() -2147483648 What I find most disturbing here, is that it happens silently. I would have expected an exception

Re: int vs long

2007-06-04 Thread Marc 'BlackJack' Rintsch
: /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

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

2007-06-04 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-03 Thread Marc 'BlackJack' Rintsch
'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: c[:]()

2007-06-03 Thread Marc 'BlackJack' Rintsch
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
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

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