Re: A request (was: how to repeat function definitions less

2009-03-17 Thread Marc 'BlackJack7; Rintsch
client for down-load -- yet have nothing worthy of 500 lines! > > Could this be the reason why I cannot see his messages on Google Groups? I don't see them either. My news server provider filters spam too. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A Dangling Tk Entry

2009-03-10 Thread Marc 'BlackJack7; Rintsch
"untrigger_threshold"] ) > > return frame_delay Then he did it consequently wrong. `frame_delay` is always `None` here so the ``return`` is useless. You asked what this code means and now you don't like the answer that it's somewhat useless code!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A Dangling Tk Entry

2009-03-09 Thread Marc 'BlackJack7; Rintsch
On Mon, 09 Mar 2009 04:22:57 -0700, W. eWatson wrote: > Marc 'BlackJack' Rintsch wrote: >> On Sun, 08 Mar 2009 22:20:09 -0700, W. eWatson wrote: >> >>> You didn't answer my question why entry is necessary at all. The >>> original author thought it

Re: A Dangling Tk Entry

2009-03-09 Thread Marc 'BlackJack7; Rintsch
ld return the widget, that should get the focus, so maybe the author really wanted to return the `Entry` instance here, instead of `None`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "/a" is not "/a" ?

2009-03-07 Thread Marc 'BlackJack7; Rintsch
a == b > True > >>> a is b > False What should this example show? And where's the singleton here? BTW: In [367]: a = 2 ^ 100 In [368]: b = 2 ^ 100 In [369]: a == b Out[369]: True In [370]: a is b Out[370]: True Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Response codes and \r\n

2009-03-05 Thread Marc 'BlackJack7; Rintsch
\n" in it, which atm I am getting rid of > with strip(), is that the best way? At which point do you get rid of it and why? BTW the last line of the code snippet needs parenthesis to actually *call* the `conn.close` method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What does self.grid() do?

2009-03-04 Thread Marc 'BlackJack7; Rintsch
On Wed, 04 Mar 2009 09:04:50 -0800, chuck wrote: > On Mar 3, 10:40 pm, Marc 'BlackJack' Rintsch wrote: >> On Tue, 03 Mar 2009 18:06:56 -0800, chuck wrote: >> > I am learning python right now.  In the lesson on tkinter I see this >> > piece of code >&g

Re: A Simple Tkinter Control Program--Slight Problem

2009-03-04 Thread Marc 'BlackJack7; Rintsch
corrects this? Learn how to copy code 1:1 from a web page or understand Python's import and namespaces. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Configuration Files and Tkinter--Possible?

2009-03-04 Thread Marc 'BlackJack7; Rintsch
d in a widget, automatically updates the display of the widget. And `Variable`\s have a method to add callbacks that get called when the content changes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What does self.grid() do?

2009-03-03 Thread Marc 'BlackJack7; Rintsch
y of the code using that widget to decide how and where it should be placed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: iterating through files

2009-02-20 Thread Marc 'BlackJack7; Rintsch
_file.writelines(islice(lines, 7, 12)) if __name__ == "__main__": main() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: memory recycling/garbage collecting problem

2009-02-16 Thread Marc 'BlackJack7; Rintsch
.2g/2048 > > Could anyone please explain why this happens? It seems some memory are > not freed. It seems the memory is not given back to the operating system. This doesn't mean that it is not freed by Python and can't be used again by Python. Create the dictionary again a

Re: Untangling pythonWin and IDLE Processes on XP Pro

2009-02-13 Thread Marc 'BlackJack7; Rintsch
ms*. A revision or version control system (VCS) lets you record the evolution of your software. You can tag versions with symbolic names like "Dev4" or "Release-1.0" and can ask the VCS for a copy of the sources with a given tag or even date. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterable Ctypes Struct

2009-02-11 Thread Marc 'BlackJack7; Rintsch
m? If not then `ctypes` might be the wrong tool. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "Super()" confusion

2009-02-10 Thread Marc 'BlackJack7; Rintsch
perative way (this is not polite). So I'm impolite. :-) I'm using multiple inheritance only for mixin classes and even that quite seldom. No `super()` in my code. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "Super()" confusion

2009-02-10 Thread Marc 'BlackJack7; Rintsch
inteheritance > situations. For the simple case, though, like that presented by the OP, > I believe super() is perfect. But for the simple cases it is unnecessary because it was invented to deal with multiple inheritance problems. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is python Object oriented??

2009-02-01 Thread Marc 'BlackJack7; Rintsch
rting Java Access Protection for Unit Testing`_ for examples. .. _Subverting Java Access Protection for Unit Testing: http://www.onjava.com/pub/a/onjava/2003/11/12/reflection.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is python Object oriented??

2009-01-31 Thread Marc 'BlackJack7; Rintsch
a class > definition and see the declaration of a veryInterestingMember and forget > that you're not supposed to access it. If you try to access it, the > compiler will give you a diagnostic message at compile time. I can't forget that because if I'm not supposed to acce

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-31 Thread Marc 'BlackJack7; Rintsch
On Fri, 30 Jan 2009 21:59:34 +0100, Stef Mientki wrote: > Marc 'BlackJack' Rintsch wrote: >> On Fri, 30 Jan 2009 00:25:03 +0100, Stef Mientki wrote: >> >> >>> try this: >>> >>> class MyRegClass ( int ) : >>> def __init__ ( s

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Marc 'BlackJack7; Rintsch
t; return line def __repr__(self): return '0x%X' % self.value > __str__ = __repr__ This is unnecessary, the fallback of `__str__` is `__repr__` already. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newby: how to transform text into lines of text

2009-01-26 Thread Marc 'BlackJack7; Rintsch
On Mon, 26 Jan 2009 16:10:11 +0100, Andreas Waldenburger wrote: > On 26 Jan 2009 14:51:33 GMT Marc 'BlackJack' Rintsch > wrote: > >> On Mon, 26 Jan 2009 12:22:18 +, Sion Arrowsmith wrote: >> >> > content = a.readlines() >> > >> >

Re: Newby: how to transform text into lines of text

2009-01-26 Thread Marc 'BlackJack7; Rintsch
On Mon, 26 Jan 2009 12:22:18 +, Sion Arrowsmith wrote: > content = a.readlines() > > (Just because we can now write "for line in file" doesn't mean that > readlines() is *totally* redundant.) But ``content = list(a)`` is shorter. :-) Ciao, Marc

Re: Reading the first MB of a binary file

2009-01-25 Thread Marc 'BlackJack7; Rintsch
gt;open("Chuck.S01E01.HDTV.XViD-YesTV.avi", "rb").read(1024) > b'\x00\x00\x00\x00\x00\x00\x00' As MRAB says, maybe the first 1024 actually *are* all zero bytes. Wild guess: That's a file created by a bittorrent client which preallocates the files

Re: A different kind of interface

2009-01-25 Thread Marc 'BlackJack7; Rintsch
ee IBQ too ... also weird is that he has Content-Type: text/plain; > charset=utf-7 Why weird? Makes perfect sense: In [98]: print '+IBQ-'.decode('utf-7') — In [99]: unicodedata.name('+IBQ-'.decode('utf-7')) Out[99]: 'EM DASH' So there are newsrea

Re: A different kind of interface

2009-01-22 Thread Marc 'BlackJack7; Rintsch
rom within the editor. > > I don't know what an IBQ is. +IBQ- seems to be the way your newsreader displays the dashes that where in Ben's posting. I see "em dash" characters there: In [84]: unicodedata.name(u'—') Out[84]: 'EM DASH' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Style Guide Questions - Contd.

2009-01-19 Thread Marc 'BlackJack7; Rintsch
" by default and of course define your own set of "value doesn't matter" names. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Marc 'BlackJack7; Rintsch
__`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner: Data type conversion question

2009-01-15 Thread Marc 'BlackJack7; Rintsch
inc += 1 elif date < currentDate: inc = 1 else: assert False # Should never happen. return "%s%02d" % (date, inc) That's it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Marc &#x27;BlackJack7; Rintsch
gt; Why not? Just saying it isn't doesn't make it not. Because "developer" means people who don't mess with implementation details. So they respect the leading underscore convention. No use case for enforced access restriction. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementing file reading in C/Python

2009-01-13 Thread Marc &#x27;BlackJack7; Rintsch
es" seems to be asking for trouble to me. That's why those regions are usually "write protected" and "no execution allowed" from the code in the user area of the virtual address space. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-12 Thread Marc &#x27;BlackJack7; Rintsch
vent adding attributes dynamically. And it has some drawbacks when you inherit from such classes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Encoding Title mail

2009-01-12 Thread Marc &#x27;BlackJack7; Rintsch
w I could solve > this problem, as with a google search i didn't find the solution. Look into the `email` package in the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python strings and coding conventions

2009-01-11 Thread Marc &#x27;BlackJack7; Rintsch
hat are all those line continuation characters ('\') for? You are aware that they are unnecessary here? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: are there some special about '\x1a' symbol

2009-01-10 Thread Marc &#x27;BlackJack7; Rintsch
7;before' > > Here I can write all symbols, but not read. I've tested it with python > 2.6, 2.5 and 2.2 and WinXP SP2. > > Why is it so and is it possible to fix it? \x1a is treated as "end of text" character in text files by Windows. So if you want all, unaltered data, open the file in binary mode ('rb' and 'wb'). Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 09 Jan 2009 15:34:17 +, MRAB wrote: > Marc 'BlackJack' Rintsch wrote: > >> def iter_max_values(blocks, block_count): >> for i, block in enumerate(blocks): >> histogram = defaultdict(int) >> for byte in bl

Re: Where's Psyco now?

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
d directly to machine code. And for some very generic functions that are called with lots of different types, the memory consumption is high because of all the specialized code that will be compiled. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: string split

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 09 Jan 2009 12:39:22 -0800, Leland wrote: > It seems work this way, but is there more elegant way to do this? Yes, the `csv` module in the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
dx%d' % (width, height) print 'Bytes per Pixel: %d' % blocksize with open(filename, 'rb') as data_file: blocks = iter(partial(data_file.read, blocksize), '') pixel_values = imap(ord, iter_max_values(blocks, pixels)) write_pgm(

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
ictionary are mapped to ones after the loop which gives a pretty boring PGM. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 09 Jan 2009 19:33:53 +1000, James Mills wrote: > On Fri, Jan 9, 2009 at 7:15 PM, Marc 'BlackJack' Rintsch > wrote: >> Why parentheses around ``print``\s "argument"? In Python <3 ``print`` >> is a statement and not a function. > > N

Re: Implementing file reading in C/Python

2009-01-09 Thread Marc &#x27;BlackJack7; Rintsch
pixels += 1 > if (havepixels % 1024) == 0: > print("Progresss %s: %.1f%%" % (sys.argv[1], 100.0 * havepixels / > pixels)) > > picture[(posx, posy)] = most Why are you using a dictionary as "2d array"? In the C code you simply write the values sequentially, why can't you just use a flat list and append here? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: "python -3" not working as expected

2009-01-08 Thread Marc &#x27;BlackJack7; Rintsch
t;. > > Unfortunately I saw no warnings about print becoming a function in > Python 3 ("print()"). Where is the problem? There is no problem. ``print``\s are handled fine by the 2to3.py script. The option warns about stuff that is not easily automatically converted. C

Re: An idea of how to identify Israeli owned software companies

2009-01-07 Thread Marc &#x27;BlackJack7; Rintsch
o those who >> want to support Israeli companies. > > Something like that web-service that publishes the names and addresses > of doctors who perform abortions so that they can be assassinated? Hey, it's about boycott, not killing them. Applied to the doctors example:

Re: del behavior 2

2009-01-07 Thread Marc &#x27;BlackJack7; Rintsch
which I have had happen. So if python does not get a chance to take > care of those, what is a good way to do so? Does a try/finally or a > with statement address that? Thanks! If you clean up the mess in the ``finally`` branch: yes. + raises a `KeyboardInterrupt`. Ciao, Marc

Re: why cannot assign to function call

2009-01-07 Thread Marc &#x27;BlackJack7; Rintsch
Using reference counting for memory management is an implementation detail. It's possible to use other garbage collectors without the need of reference counting. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter - problem closing window

2009-01-06 Thread Marc &#x27;BlackJack7; Rintsch
ngs can happen. Additional windows have to be created as `Toplevel` instances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-05 Thread Marc &#x27;BlackJack7; Rintsch
let`` is optional in Commodore BASIC. But where is the difference to x = 10 print x ? Wouldn't you have guessed what this Python program will do just the same? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-05 Thread Marc &#x27;BlackJack7; Rintsch
On Sun, 04 Jan 2009 20:03:11 -0600, Derek Martin wrote: > On Sat, Jan 03, 2009 at 10:15:51AM +0000, Marc 'BlackJack' Rintsch > wrote: >> On Fri, 02 Jan 2009 04:39:15 -0600, Derek Martin wrote: >> >> What's the difference between Python and Java or

Re: Take the first n items of an iterator

2009-01-04 Thread Marc &#x27;BlackJack7; Rintsch
On Sun, 04 Jan 2009 10:55:17 +, Steven D'Aprano wrote: > I thought there was an iterator in itertools for taking the first n > items of an iterator, then halting, but I can't find it. Did I imagine > such a tool, or am I missing something? `itertools.islice()` Ciao,

Re: Returning a string

2009-01-03 Thread Marc &#x27;BlackJack7; Rintsch
004 >> > Out[19]: u'004' >> >> What? > > That's the output got from ipython. As you can see, it prints > 'Afghanistan' but it can not returns it. In change, the another strings > are returned. Maybe you should show the *input* too… Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-03 Thread Marc &#x27;BlackJack7; Rintsch
are likely to have been exposed to is simple > and sensible. I think the "bin model" is more complex because you don't just have a name and an object but always that indirection of the "bin". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not Ruby?

2009-01-03 Thread Marc &#x27;BlackJack7; Rintsch
cff5937?hl=en&q=recycle+bin#97254d877903bbd No you didn't "got" Steven, as unnecessary cross posting is something different than answering a question that should have been a new thread start. Oh, and: *plonk* for your childish annoying behaviour… Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Videocapture in python

2009-01-01 Thread Marc &#x27;BlackJack7; Rintsch
On Thu, 01 Jan 2009 04:28:21 -0800, koranthala wrote: > Please let me know if you need any more information. Where does `videocapture.py` coming from? It's not part of the standard library. And which operating system are we talking about? Ciao, Marc 'BlackJack

Re: Memory leak problem (while using tkinter)

2008-12-31 Thread Marc &#x27;BlackJack7; Rintsch
lest possible program that still has the problem. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Strategy for determing difference between 2 very large dictionaries

2008-12-24 Thread Marc &#x27;BlackJack7; Rintsch
btle point here :) `keys()` creates a list in memory, `iterkeys()` does not. With ``set(dict.keys())`` there is a point in time where the dictionary, the list, and the set co-exist in memory. With ``set(dict.iterkeys())`` only the set and the dictionary exist in memory. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread Marc &#x27;BlackJack7; Rintsch
On Sun, 21 Dec 2008 15:30:34 +, Duncan Booth wrote: > Marc 'BlackJack' Rintsch wrote: > >>> a+b+c+d might execute a.__add__(b,c,d) allowing more efficient string >>> concatenations or matrix operations, and a%b%c%d might execute as >>> a.__mod__(b

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread Marc &#x27;BlackJack7; Rintsch
mpile time and ``a % b`` returns an object of ``type(a)``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-12-21 Thread Marc &#x27;BlackJack7; Rintsch
ou are not fast enough to elaborate on Python's slowness!? :-) cm_gui is slow! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread Marc &#x27;BlackJack7; Rintsch
lems. And even if nobody has problems with the limitations of ``%`` string formatting why shouldn't they add a more flexible and powerful way!? Python 3.0 is not a bug fix release. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python 3.0 string formatting - really necessary?

2008-12-21 Thread Marc &#x27;BlackJack7; Rintsch
the language whereas my ideas for "fixes" of the quirks wouldn't. "joe-python" most often doesn't see the whole picture and demands changes that look easy at first sight, but are hard to implement right and efficient or just shifts the problem somewhere else where

Re: encoding problem

2008-12-20 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 19 Dec 2008 16:50:39 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > >>>> And does REALbasic really use byte strings plus an encoding!? >>> You betcha! Works like a dream. >> >> IMHO a strange design decision. > > I

Re: New Python 3.0 string formatting - really necessary?

2008-12-20 Thread Marc &#x27;BlackJack7; Rintsch
all you need to remember. If people can't understand that, > i fear for the future of Humans as a species! Yeah, doomsday is near. Curly brackets and a number instead of a percent sign followed by an 's' is a sure sign of the end… You're a funny little troll, Sir.

Re: encoding problem

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 19 Dec 2008 15:20:08 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > >>> And because strings in Python, unlike in (say) REALbasic, do not know >>> their encoding -- they're just a string of bytes. If they were a >>> string of

Re: encoding problem

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 19 Dec 2008 08:20:07 -0700, Joe Strout wrote: > Marc 'BlackJack' Rintsch wrote: > >>> The question is why the Python interpreter use the default encoding >>> instead of "utf-8", which I explicitly declared in the source. >> >&

Re: New Python 3.0 string formatting - really necessary?

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
ogramming for this > student. Lets not forget how important C is! To a Python "n00b"? Not important at all. Beside the point that '%s' is still possible -- someone who knows C but struggles with replacing '%s' by '{0}' has far greater problems. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension in if clause of another list comprehension

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
On Fri, 19 Dec 2008 04:26:16 -0800, bearophileHUGS wrote: > Peter Otten: >> The problem is that list comprehensions do not introduce a new >> namespace. > > I think Python3 fixes this bug. Or removes that feature. ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding problem

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
ode literals in that very source file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to parsing a sequence of integers

2008-12-19 Thread Marc &#x27;BlackJack7; Rintsch
max/min, is there something like average()? No, but it's easy to implement with `sum()`, `len()` and ``/``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread Marc &#x27;BlackJack7; Rintsch
ent. No the program flow there is just some linear calls to methods. It's the XML structure that is not reflected by the indentation, the program flow is represented just fine here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I return a non-zero status result from a python script?

2008-12-15 Thread Marc &#x27;BlackJack7; Rintsch
On Mon, 15 Dec 2008 13:12:08 -0800, silverburgh.me...@gmail.com wrote: > How can I return a non-zero status result from the script? Just do a > return 1? at the end? ``sys.exit(42)`` Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: the official way of printing unicode strings

2008-12-14 Thread Marc &#x27;BlackJack7; Rintsch
t is the official, recommended Python way? I'd make that first line: sys.stdout = codecs.getwriter('utf-8')(sys.stdout) Why is it even more cumbersome to execute that line *once* instead encoding at every ``print`` statement? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimizing methods away or not?

2008-12-14 Thread Marc &#x27;BlackJack7; Rintsch
On Sun, 14 Dec 2008 09:19:45 +, Marc 'BlackJack' Rintsch wrote: > class Parrot: > def __init__(self, *args): > print "Initialising instance..." > assert self.verify() Here I meant ``assert self._verify()`` of course. > def _verif

Re: Optimizing methods away or not?

2008-12-14 Thread Marc &#x27;BlackJack7; Rintsch
t do others think? > Which do you consider better design? None of it. Why not simply: class Parrot: def __init__(self, *args): print "Initialising instance..." assert self.verify() def _verify(self): print "Verifying..." return None If you compile with -O the ``assert`` is optimized away. But you still can call `_verify()` at specific points even in optimized code if you want or need. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Umlauts in idle

2008-12-13 Thread Marc &#x27;BlackJack7; Rintsch
but let the interpreter show the result you get the `repr()` form of that character displayed, which always uses escapes for bytes that are non-printable or not within the ASCII range for strings. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: var or inout parm?

2008-12-13 Thread Marc &#x27;BlackJack7; Rintsch
cts? I use it very often with number types and sometimes with tuples, and there rebinding is necessary. If I couldn't use it in this way: ``x = 0; x += z``, I'd call that a bad design decision. It would be a quite useless operator then. Ciao, Marc 'BlackJack' Rintsc

Re: var or inout parm?

2008-12-12 Thread Marc &#x27;BlackJack7; Rintsch
e that may or may not raise that exception, depending on implementation details: t = (1, 2) t[0] = 1 # Maybe okay -- maybe not. t[1] += 0 # Same here. I'd find that quite odd. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing None objects from a sequence

2008-12-12 Thread Marc &#x27;BlackJack7; Rintsch
uch an error in a post, I suggest to practice some time > writing correct code before having one-liner contests with your > perl-loving friends :) If you call something an error, make sure it really is one. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: var or inout parm?

2008-12-12 Thread Marc &#x27;BlackJack7; Rintsch
def f(a, x): .: a += x .: In [253]: dis.dis(f) 2 0 LOAD_FAST0 (a) 3 LOAD_FAST 1 (x) 6 INPLACE_ADD 7 STORE_FAST 0 (a) 10 LOAD_CONST 0 (None) 13 RETURN_VALUE Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Marc &#x27;BlackJack7; Rintsch
you use to look at the text how many spaces will be displayed. Better use four real spaces to indent one level so it looks the same everywhere. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File names, character sets and Unicode

2008-12-12 Thread Marc &#x27;BlackJack7; Rintsch
#x27;m usually using UTF-8 as default but offer the user ways, e.g. command line switches, to change that. If I have to display file names in a GUI I use a decoded version of the byte string file name, but keep the byte string for operations on the file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Announcement: MindTree for Python beta -- feedback appreciated

2008-12-10 Thread Marc &#x27;BlackJack7; Rintsch
module named future_builtins > > Hmmm... does this mean that Python3 has no future? :-) It is just not built in. So it is easier to change the future by replacing the module. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is 3.0 worth breaking backward compatibility?

2008-12-09 Thread Marc &#x27;BlackJack7; Rintsch
are year and month of release. So this year's releases have "version" 8 and the latest is from october so it is 8.10. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get a beep, OS independent ?

2008-12-07 Thread Marc &#x27;BlackJack7; Rintsch
beep in X-Windows so every desktop environment implements something like audio notifications. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-06 Thread Marc &#x27;BlackJack7; Rintsch
t; I agree that for newcomers to Python, the class method definition might > seem strange. And after the change it continues to because they will run into *both* variants in tutorials, code, and books, so it might be even more confusing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: pydoc enforcement.

2008-12-01 Thread Marc &#x27;BlackJack7; Rintsch
undocumented parts of the code anymore, because now every "docable" object has "documentation" like this just to make the compiler happy: def spam(foo, bar): """ :param foo: a foo object. :param bar: a bar object. """ Which basically

Re: unicode and hashlib

2008-11-29 Thread Marc &#x27;BlackJack7; Rintsch
your `unicode` object so you get bytes to feed to the MD5 algorithm. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Instance attributes vs method arguments

2008-11-25 Thread Marc &#x27;BlackJack7; Rintsch
On Tue, 25 Nov 2008 10:48:01 +, John O'Hagan wrote: > On Tue, 25 Nov 2008, Marc 'BlackJack' Rintsch wrote: >> On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: >> > Is it better to do this: >> > >> > class Class_a(): >>

Re: Instance attributes vs method arguments

2008-11-25 Thread Marc &#x27;BlackJack7; Rintsch
lf if those methods are really methods, because they don't use `self` so they could be as well be functions or at least `staticmethod`\s. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Using dictionary to hold regex patterns?

2008-11-23 Thread Marc &#x27;BlackJack7; Rintsch
p, learned something new today. Naively, I though a list was > index=value, where value=a single piece of data. Your thought was correct, each value is a single piece of data: *one* tuple. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: initialization in argument definitions

2008-11-22 Thread Marc &#x27;BlackJack7; Rintsch
; guessed the wrong way. We have no way of knowing how many people guessed > the right way. Or how many worked through the tutorial, stumbled across the warning about that behavior and got that question answered before they have even known there's something to guess. Ciao, Marc &#x

Re: Avoiding local variable declarations?

2008-11-17 Thread Marc &#x27;BlackJack7; Rintsch
On Tue, 18 Nov 2008 00:18:51 +, Steven D'Aprano wrote: > On Mon, 17 Nov 2008 12:32:35 +0000, Marc 'BlackJack' Rintsch wrote: > >> Not such illogical crap like >> ``a = a + 1`` which must be obviously false unless 1 is defined as the >> neutral element f

Re: Avoiding local variable declarations?

2008-11-17 Thread Marc &#x27;BlackJack7; Rintsch
think it's called variable and works like variables work in mathematics, i.e. you can assign only once. Not such illogical crap like ``a = a + 1`` which must be obviously false unless 1 is defined as the neutral element for the definition of ``+`` here. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-15 Thread Marc &#x27;BlackJack7; Rintsch
you can't decode properly with one encoding anymore. A clean solution would be just one ``print`` with a call of `encode()` and an explicit encoding. I'd use 'utf-8' as default but give the user of the program a possibility to make another choice. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: [UnicodeEncodeError] Don't know what else to try

2008-11-14 Thread Marc &#x27;BlackJack7; Rintsch
the data again because sooner or later you will come across a `stdout` where Python can't determine what the process at the other end expects, for example if output is redirected to a file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple breaks

2008-11-13 Thread Marc &#x27;BlackJack7; Rintsch
uot;break 2" in shell bash # In C, I would set j=i-1 >and i=4 ># In Python, is this possible to affect the two iterators? > > Or the only means is to use exception? You could put the code into its own, maybe local, function and use ``return``. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.stdout, urllib and unicode... I don't understand.

2008-11-12 Thread Marc &#x27;BlackJack7; Rintsch
bytes to a bunch of (unicode)characters before you concatenate the strings. BTW: ``line.strip()`` removes all whitespace at both ends *including newlines*, so there are no '\n' to replace anymore. And functions in the `string` module that are also implemented as method on `str` or `unicode` are deprecated. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple question about Python lists

2008-11-11 Thread Marc &#x27;BlackJack7; Rintsch
h element I might do something like this: > > b = a([1 5 8]); > > I can't seem to figure out a similar Python construct for selecting > specific indices. Any suggestions? b = [a[i] for i in [1, 5, 8]] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 - is this true?

2008-11-10 Thread Marc &#x27;BlackJack7; Rintsch
On Mon, 10 Nov 2008 16:32:47 +, Robin Becker wrote: > on the other hand I find it odd that > > cmp(None,None) fails in Python 3 when None==None returns True. That's because there is no order defined for `NoneType` but equality is. Ciao, Marc 'BlackJa

Re: C Module question

2008-11-10 Thread Marc &#x27;BlackJack7; Rintsch
less straightforward C manner. Then you might considering the `ctypes` module to call your C stuff. This way it is easier to build the extension and it is also independent from the Python version. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: C Module question

2008-11-10 Thread Marc &#x27;BlackJack7; Rintsch
On Mon, 10 Nov 2008 05:36:58 -0800, [EMAIL PROTECTED] wrote: > On Nov 10, 1:16 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Mon, 10 Nov 2008 03:11:06 -0800, [EMAIL PROTECTED] wrote: >> > 1. How can I pass a file-like object into the C part? The

  1   2   3   4   5   6   7   8   9   10   >