Re: Elementary string-parsing

2008-02-05 Thread Marc 'BlackJack' Rintsch
On Tue, 05 Feb 2008 06:19:12 +, Odysseus wrote: > In article <[EMAIL PROTECTED]>, > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> Another issue is testing. If you rely on global names it's harder to test >> individual functions. [.

Re: getting all user defined attributes of a class

2008-02-06 Thread Marc 'BlackJack' Rintsch
gt; getAllUserAttributes? No and there can't be since the attributes you seem to be interested in don't exist until an instance is created. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: getting all user defined attributes of a class

2008-02-06 Thread Marc 'BlackJack' Rintsch
A)) Out[370]: [('x', 1)] > When I do help on some built-in function, it displays that function is > built_in. Can that information get accessed using a function? (now, > don't ask me to store help-output in buffer and grep for built-in). Yes but it is not built-in. Have a look at the `inspect` module. What's the use case? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner question, function returning object.

2008-02-07 Thread Marc 'BlackJack' Rintsch
s namespace. > I'm not sure enough of what I am doing to tell if I have another error in > my code causing the problem. Is either of these examples supposed to work > as shown? Is it clear that either example is obviously wrong? The second is wrong. The first should

Re: __builtins__

2008-02-08 Thread Marc 'BlackJack' Rintsch
air the > "mistake" (as I got an import error __import__ not found if I want to > import __builtins__...? Don't ``del __builtins__`` in the first place. :-) > That's may be obvious for you, but that's all strange to me and I > didn't find answers on the net... So the real question is, why you see 'math' in `__builtins__`. It should not be there. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not a Python compiler?

2008-02-08 Thread Marc 'BlackJack' Rintsch
ee of confusion among the jury when using the Chewbacca defense. :-) http://en.wikipedia.org/wiki/Chewbacca_defense Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not a Python compiler?

2008-02-08 Thread Marc 'BlackJack' Rintsch
On Fri, 08 Feb 2008 05:12:29 -0800, Ryszard Szopa wrote: > Expressing simple loops as C for loops... You mean simple loops like ``for i in xrange(1000):``? How should the compiler know what object is bound to the name `xrange` when that loop is executed? Ciao, Marc 'BlackJack&

Re: ways to declare empty set variable

2008-02-12 Thread Marc 'BlackJack' Rintsch
On Tue, 12 Feb 2008 14:45:43 +0100, Sun wrote: > then the question is how can I declare a empty set variable as a 'var= []' > do to a list variable? You don't declare variables in Python. Just create an instance of `set` and bind it to a name: var = set() Ciao,

Re: fromfunc functions

2008-02-13 Thread Marc 'BlackJack' Rintsch
lue. In [18]: def f(func, arg): : return func(arg) : In [19]: f(int, '42') Out[19]: 42 In [20]: f(str.split, 'a b c') Out[20]: ['a', 'b', 'c'] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: a question in python curses modules

2008-02-15 Thread Marc 'BlackJack' Rintsch
bject to be sure that it is still there and not already garbage collected. *But* it's not guaranteed that `__del__()` is called at all! So if you think this clean up is necessary to leave a usable console then don't put it into a `__del__()` method! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: a question in python curses modules

2008-02-15 Thread Marc 'BlackJack' Rintsch
On Fri, 15 Feb 2008 15:10:12 +, Sion Arrowsmith wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >>When the interpreter shuts down it has to remove objects. Everything you >>need in a `__del__()` method must be referenced by that object to be su

Re: Tkinter Confusion

2008-02-17 Thread Marc 'BlackJack' Rintsch
x27;t create several `Tk` instances. That usually causes very weird side effects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What's "the standard" for code docs?

2008-02-20 Thread Marc 'BlackJack' Rintsch
t is still in its early learning phase. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-22 Thread Marc 'BlackJack' Rintsch
uot;boxes", the memory location and type are attached to the name. In Python both belong to the value. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Acting like button are being pressed (BUT THEY ARE NOT) Please Help

2008-02-22 Thread Marc 'BlackJack' Rintsch
lls that it could use some loops to refactor it into a **much** shorter piece of code. Then get rid of the asterisk import, ``except``\s without a specific exception to handle, and the``global`` statement before you repost the problem. Ciao, Marc 'BlackJack' Rintsch -- http

Re: Getting python docstings

2008-02-22 Thread Marc 'BlackJack' Rintsch
t do what you want, then *what* exactly *do* you want? You know that `epydoc` supports reStructuredText as markup language!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-22 Thread Marc 'BlackJack' Rintsch
On Fri, 22 Feb 2008 12:32:10 +, Steven D'Aprano wrote: > On Fri, 22 Feb 2008 08:12:56 +0000, Marc 'BlackJack' Rintsch wrote: > >> A "variable" in programming languages is composed of a name, a memory >> location, possibly a type and a value. In C

Re: Article of interest: Python pros/cons for the enterprise

2008-02-22 Thread Marc 'BlackJack' Rintsch
end(); ++i ) > std::cout << *i << '\n'; > } > > As you can see the standard library takes care of all memory > management. Aaah, that's much nicer and easier to understand than the list comprehension. After this great example I'll switch to C++. ;-) But somehow you still manage memory by writing in a style that favors value types. SCNR, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-23 Thread Marc 'BlackJack' Rintsch
L` is a class attribute and it's rebound to the instance, or if they tried it on a list in a tuple. Extending a list that's a read only property doesn't work either. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple - looking for a way to do an element exists check..

2008-02-23 Thread Marc 'BlackJack' Rintsch
a.append(element) > > It may be more readable (although that's debatable), but it always > traverses the entire list. The ``not in`` stops if the element is found. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Return value of an assignment statement?

2008-02-24 Thread Marc 'BlackJack' Rintsch
On Sat, 23 Feb 2008 22:44:30 +, Tim Roberts wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >>On Fri, 22 Feb 2008 11:00:17 -0800, Aahz wrote: >> >>> It's just too convenient to be able to write >>> >>> L +=

Re: dict.get and str.xsplit

2008-02-26 Thread Marc 'BlackJack' Rintsch
? And if not, why? I guess it's the method lookup that's the slow part. Factor it out of the loop and measure again:: adict_get = adict.get for _ in xrange(M): for k in keys1: r = adict_get(k, None) for k in keys2: r = adict_get(k, Non

Re: Article of interest: Python pros/cons for the enterprise

2008-02-26 Thread Marc 'BlackJack' Rintsch
ompletely wrong to have to think about it and to write in that "value style", because that goes against my expectations/picture of OOP -- a graph of independent/loosely coupled objects communicating with each other. In this sense C++ looks like a quite crippled and fragile OOP language t

Re: How about adding rational fraction to Python?

2008-02-26 Thread Marc 'BlackJack' Rintsch
le > manner as seen by those general population not by people who holds a > CS degree. So why is it creepy then!? ``3 // 4`` is for the people knowing about integer division and ``3 / 4`` gives the expected result for those who don't. Those who don't know ``//`` can write ``

Re: dict.get and str.xsplit

2008-02-26 Thread Marc 'BlackJack' Rintsch
On Tue, 26 Feb 2008 06:33:01 -0800, castironpi wrote: > On Feb 26, 8:14 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Tue, 26 Feb 2008 06:02:12 -0800, bearophileHUGS wrote: >> > This is a real difference, that has real impact on the programs I

Re: How about adding rational fraction to Python?

2008-02-26 Thread Marc 'BlackJack' Rintsch
", "copyright", "credits" or "license" for more information. >>> 3 / 4 0.75 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is there enough information?

2008-02-26 Thread Marc 'BlackJack' Rintsch
On Tue, 26 Feb 2008 09:13:35 -0800, castironpi wrote: > Back home, the original post would be interesting, so I wrote it. So you think of this group as your personal notepad. That explains a lot. :-/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/li

Re: Pythons & Ladders

2008-02-27 Thread Marc 'BlackJack' Rintsch
t. I'll bite. This a bit of an overreaction unless you know what the course was about. If the goal is to learn about the computer and that basically everything is a number in the end, then C is a good choice. More portable than assembler but nearly as close to the metal. To the OP: If y

Re: XML expat error

2008-02-27 Thread Marc 'BlackJack' Rintsch
of letting it propagate to the top level and ending the program. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-27 Thread Marc 'BlackJack' Rintsch
ell works and I don't notice much complaints about it. Complain! :-) For implementing this in Python you have to carry an "is allowed to be coerced to float" flag with every integer object to decide at run time if it is an error to add it to a float or not. Or you make Python into a statically typed language like Haskell. But then it's not Python anymore IMHO. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythons & Ladders

2008-02-28 Thread Marc 'BlackJack' Rintsch
ly it's about a language called C ++ according to the OP. >> To the OP: If you try C++, don't hold that crappy language against C#, D, >> or Java. ;-) > > What's the relevance of C#, D, or Java to the OP's post? The same as C++ to the OP's post if he would have talked about C. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: XML expat error

2008-02-28 Thread Marc 'BlackJack' Rintsch
ing. Then you should work through the tutorial in the docs, at least until section 8.3 Handling Exceptions: http://docs.python.org/tut/node10.html#SECTION0010300000 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-03-01 Thread Marc 'BlackJack' Rintsch
how. `x` doesn't start as `Int` or `Integer` but the very generic and AFAIK abstract type class `Num`. After seeing the second line the compiler finds an implementation for `+` and the type class `Fractional` for both operands and now thinks `x` must be a `Fractional`, a subclass of `Num`.

Re: mod_python Unable to create file

2008-03-01 Thread Marc 'BlackJack' Rintsch
enied > > What is missing? To state the ovious: the rights to create a file at `file_path`. Remember that web servers usually have their own "user". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: First post from a Python newbiw

2008-03-02 Thread Marc 'BlackJack' Rintsch
On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote: > Apart from doing something like > a=[0,0,0] > b=[0,0,0] > c=[0,0,0] > d=[a,b,c] > > is there a better way of creating d?? a = [[0] * 3 for dummy in xrange(3)] Ciao, Marc 'BlackJack' Rintsch --

Re: First post from a Python newbiw

2008-03-02 Thread Marc 'BlackJack' Rintsch
On Sun, 02 Mar 2008 21:58:31 +0100, Christoph Zwerschke wrote: > Marc 'BlackJack' Rintsch schrieb: >> On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote: >> >>> Apart from doing something like >>> a=[0,0,0] >>> b=[0,0,0] >>> c=[0,0

Re: Is it possible to return a variable and use it...?

2008-03-02 Thread Marc 'BlackJack' Rintsch
a description of either what error message you get, with full traceback, or if it does not raise an exception but just does not what you excpect it to do, tell us what you expected and what you get instead. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Character Problem

2008-03-02 Thread Marc 'BlackJack' Rintsch
, that you have a problem with encodings but what is the *specific* problem? Where does the program fail? With what exception(s)? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Can one get "for x in y" to work for non builtin classes?

2008-03-03 Thread Marc 'BlackJack' Rintsch
getitem__()` is enough. The end will be signaled by an `IndexError`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: help needed with regex and unicode

2008-03-03 Thread Marc 'BlackJack' Rintsch
] = 'æ­ï½ æ½å¤此åï«åéé§ç²è'; > $errorMessage = 'æ­ï½ æ½å¤此åï«åéé§ç²è'; > } Looks like an UTF-8 encoded file viewed as ISO-8859-1. Sou you should decode `content` to unicode before searching the chinese characters. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Classes and modules are singletons?

2008-03-06 Thread Marc 'BlackJack' Rintsch
>>>reload(module) >> >>>c2 = module.Someclass >> >>>c1 is c2 > > What about > >>>> o= object() >>>> b1= o.someattr >>>> reload( o ) >>>> b2= o.someattr >>>> b1 is b2 > > ? You are really a bit thick, a troll, or a bot. *plonk* Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: gc question

2008-03-09 Thread Marc 'BlackJack' Rintsch
Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: SV: Changing the size of a Button

2008-03-09 Thread Marc 'BlackJack' Rintsch
occurs and to > print the sizes. However, i'd like to > assign these values to the button so it > always stays the same width as the frame. Don't do it yourself, pack with the `fill` argument set to `Tkinter.X`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Inheritance

2008-03-13 Thread Marc 'BlackJack' Rintsch
he same `CSS` instance. Ciao, Marc 'BlackJack' -- http://mail.python.org/mailman/listinfo/python-list

Re: How to port Python code into C++ code automatically?

2008-03-13 Thread Marc 'BlackJack' Rintsch
n_ or Pyrex_ do. Both compile a subset of Python with optional static typing to C extension modules. .. _Cython: http://www.cython.org/ .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: List mutation method gotcha - How well known?

2008-03-14 Thread Marc 'BlackJack' Rintsch
ays an implicit ``return None`` at the end of every function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling global variables (Newbie)

2008-03-14 Thread Marc 'BlackJack' Rintsch
tates 'NameError: global name '__file__' is not defined' >> >> In Python 2.5 I ran my script as a module in IDLE gui. How does _file_ get >> defined? >> > Do you perhaps mean '__name__'? I guess not. It makes more sense to apply path functi

Re: request for Details about Dictionaries in Python

2008-03-14 Thread Marc 'BlackJack' Rintsch
On Fri, 14 Mar 2008 17:06:00 +, Matt Nordhoff wrote: > Hmm, if Perl's on-disk hash tables are good, maybe someone should port > them to Python, or maybe someone already has. I don't know Perl's on-disk hash tables but there is a `shelve` module in the standard library

Re: Unicode/UTF-8 confusion

2008-03-15 Thread Marc 'BlackJack' Rintsch
eedup routine now > offered by simplejson -- yet the need to do this apostrophe escaping seems > to negate this advantage! Is there perhaps some combination of dumps keyword > arguments, python encode()/str() magic, or something similar that > accomplishes this same result? > > What is the highest-performance way to get simplejson to emit the desired > serialization of the given test string? Somehow I don't get what you are after. The ' doesn't have to be escaped at all if " are used to delimit the string. If ' are used as delimiters then \' is a correct escaping. What is the problem with that!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode/UTF-8 confusion

2008-03-15 Thread Marc 'BlackJack' Rintsch
Script embeddable escaped literal string. That's simply not the job of a JSON encoder. That's another level of encoding/escaping producing something that is not JSON anymore, so why do you want to ask a JSON encoder to deliver it? This is a feature/function you should find in a HTML templating library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange problem with structs Linux vs. Mac

2008-03-17 Thread Marc 'BlackJack' Rintsch
unpack(">I", s)[0] Maybe a little more compact and readable: In [92]: sys.byteorder Out[92]: 'little' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't xmlrpclib.dumps just dump an empty value instead of ?

2008-03-17 Thread Marc 'BlackJack' Rintsch
t; > Those are valid XML and valid XML-RPC, but isn't. In XML-RPC there is no `None`, so there's the non standard `allow_none` Option to allow `None` to be represented as . And is an empty or really valid XML-RPC? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't xmlrpclib.dumps just dump an empty value instead of ?

2008-03-18 Thread Marc 'BlackJack' Rintsch
x27; > > There's a difference between those two. The first one has an empty > string value ('') while the second one pretty clearly says that > there is a parameter but has no value. > > Why ? Because there is a difference between no value and the NULL value!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Regarding coding style

2008-03-18 Thread Marc 'BlackJack' Rintsch
oring only binary "tokenized" files instead of plain text or even one big binary file that contains all sources and resources of the project. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 and PEP238 division

2008-03-18 Thread Marc 'BlackJack' Rintsch
ny particular division > operator? Can work out whether the result should be integer or float, > independent of any particular set of arguments? Seems unlikely. The interpreter can at least print out warnings when a "normal" division operator is called with two `int`\s at runtime. Ci

Re: Prototype OO

2008-03-19 Thread Marc 'BlackJack' Rintsch
On Wed, 19 Mar 2008 17:59:40 +0100, sam wrote: > Can someone tell me why class-based OO is better that Prototype based, > especially in scripting langage with dynamic types as Python is? Is it better!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: Problem with PARAGRAPH SEPARATOR

2008-03-20 Thread Marc 'BlackJack' Rintsch
object then I get a > "UnicodeError" saying that the unicode 2029 can't be encoded... > > Can anyone please tell me how I should handle that paragraph seperator? You have to encode the unicode object in an encoding that know this character. UTF-8 might be a candidate encoding for th

Re: backslash in reading bytes

2008-03-20 Thread Marc 'BlackJack' Rintsch
call are just *two* characters with a byte value of zero: In [116]: len('\x00\x00') Out[116]: 2 In [117]: print '\x00\x00' In [118]: len('\\x00\\x00') Out[118]: 8 In [119]: print '\\x00\\x00' \x00\x00 The backslash has a special meaning in string literals. If you don't want this meaning, you have to escape it with another backslash. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search (works)|(doesn't work) depending on for loop order

2008-03-22 Thread Marc 'BlackJack' Rintsch
t with the `seek()` method. That only works on "seekable" files and it's not a good idea anyway because usually the files and the overhead of reading is greater than the time to iterate over in memory data like the patterns. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiline CSV export to Excel produces unrecognized characters?

2008-03-24 Thread Marc 'BlackJack' Rintsch
nebreak. > > Any idea why these are there or how to get rid of them? Any chance you are doing this on Windows and Excel doesn't like the return+linefeed line endings that Windows produces when writing files in text mode? Try 'wb' as mode for the output file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Does python hate cathy?

2008-03-25 Thread Marc 'BlackJack' Rintsch
del__()` the elements would get garbage collected just fine. If you don't want to wait until the garbage collector in CPython detects the cycle, you can use `weakref`\s for one of the two "pointers" in each element. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Circular references not being cleaned up by Py_Finalize()

2008-03-25 Thread Marc 'BlackJack' Rintsch
On Tue, 25 Mar 2008 12:32:17 -0700, blackpawn wrote: > So what's the deal here? :) I want all objects to be freed when I > shut down and their destruction functions to be properly called. Then you want something that's not guaranteed by the language. Ciao, Marc &#x

Re: Pickle: several class instance objects in one file?

2008-03-27 Thread Marc 'BlackJack' Rintsch
function? I didn't really get the meaning of > those while reading the python user manual... Usually `pickle` just works. Those methods can be used if you want to customize the process, for example if you don't want to pickle the entire object but just parts of it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with format string and unicode

2008-03-28 Thread Marc 'BlackJack' Rintsch
value contains UTF-8 > stuff (differing number of bytes per character), the length of the > resulting string (in characters) varies. How can I fix this? Use unicode strings instead. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: case insensitive lstrip function?

2008-03-28 Thread Marc 'BlackJack' Rintsch
= s.upper().lstrip(chars.upper()) > return s[len(s)-len(s2):] > else: > return s.lstrip(chars) What about this: def lstrip2(string, chars, ignore_case=True): if ignore_case: chars = chars.lower() + chars.upper() return string.lstrip(chars) Ciao,

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

2009-01-10 Thread Marc 'BlackJack' 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: Python strings and coding conventions

2009-01-11 Thread Marc 'BlackJack' 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: Encoding Title mail

2009-01-12 Thread Marc 'BlackJack' 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: Does Python really follow its philosophy of "Readability counts"?

2009-01-12 Thread Marc 'BlackJack' 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: Implementing file reading in C/Python

2009-01-13 Thread Marc 'BlackJack' 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-14 Thread Marc 'BlackJack' 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: Beginner: Data type conversion question

2009-01-15 Thread Marc 'BlackJack' Rintsch
t; currentDate: > newInc = "01".zfill(2) > serial = currentDate + newInc > print "date is different" > return serial Both branches do almost the same. You should try to avoid such code duplication. if date == currentDate:

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Marc 'BlackJack' Rintsch
u mean by "suggests … extreme semantics"? Most natural thing is to use numbers and there you *have* to be able to return something different than `self` to get anything useful. For instance: n *= 3 with `n` bound to a number different from zero can't return `self` from `__imul

Re: Python Style Guide Questions - Contd.

2009-01-19 Thread Marc 'BlackJack' 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: A different kind of interface

2009-01-22 Thread Marc 'BlackJack' 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: A different kind of interface

2009-01-25 Thread Marc 'BlackJack' 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: Reading the first MB of a binary file

2009-01-25 Thread Marc 'BlackJack' 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: Newby: how to transform text into lines of text

2009-01-26 Thread Marc 'BlackJack' 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: Newby: how to transform text into lines of text

2009-01-26 Thread Marc 'BlackJack' 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: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread Marc 'BlackJack' 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: verilog like class w/ bitslicing & int/long classtype

2009-01-31 Thread Marc 'BlackJack' 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: is python Object oriented??

2009-01-31 Thread Marc 'BlackJack' 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: is python Object oriented??

2009-02-01 Thread Marc 'BlackJack' 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: "Super()" confusion

2009-02-10 Thread Marc 'BlackJack' 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: "Super()" confusion

2009-02-10 Thread Marc 'BlackJack' 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: Iterable Ctypes Struct

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

Re: Untangling pythonWin and IDLE Processes on XP Pro

2009-02-13 Thread Marc 'BlackJack' 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: memory recycling/garbage collecting problem

2009-02-16 Thread Marc 'BlackJack' 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: iterating through files

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

Re: initialization in argument definitions

2008-11-22 Thread Marc 'BlackJack' 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: Using dictionary to hold regex patterns?

2008-11-23 Thread Marc 'BlackJack' 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: Instance attributes vs method arguments

2008-11-25 Thread Marc 'BlackJack' 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: Instance attributes vs method arguments

2008-11-25 Thread Marc 'BlackJack' 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: unicode and hashlib

2008-11-29 Thread Marc 'BlackJack' 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: pydoc enforcement.

2008-12-01 Thread Marc 'BlackJack' 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: Guido's new method definition idea

2008-12-06 Thread Marc 'BlackJack' 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: how to get a beep, OS independent ?

2008-12-07 Thread Marc 'BlackJack' 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: Is 3.0 worth breaking backward compatibility?

2008-12-09 Thread Marc 'BlackJack' 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: Announcement: MindTree for Python beta -- feedback appreciated

2008-12-10 Thread Marc 'BlackJack' 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: File names, character sets and Unicode

2008-12-12 Thread Marc 'BlackJack' 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

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