Re: Automatic Generation of Python Class Files

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

Re: ignoring chinese characters parsing xml file

2007-10-22 Thread Marc 'BlackJack' Rintsch
* the file but this is an *encode* error. Parsing means *decoding*. You have to show some code and the actual traceback to get help. Crystal balls are not that reliable. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: for loop

2007-10-22 Thread Marc 'BlackJack' Rintsch
to believe there's something wrong with my loop. It should not run at all as it is indented inconsistently. If that problem is corrected it will stop with a `NameError` because you try to read `population` before anything was assigned to it. Ciao, Marc 'BlackJack' Rintsch -- http

Re: Regular Expression

2007-10-22 Thread Marc 'BlackJack' Rintsch
)+\.?([A-Z]|\d)+' Does not match your second example because there is a lower case letter in it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: General module name clash problem?

2007-10-19 Thread Marc 'BlackJack' Rintsch
opinions or do i need a gotcha? The package system is not insufficient but could solve your problem actually. Don't put all your modules simply in the same directory but in a package so that your `whatever.pickle` does not clash with the standard `pickle` anymore. Ciao, Marc 'BlackJack

Re: Problem of Readability of Python

2007-10-18 Thread Marc 'BlackJack' Rintsch
= Bunch(name='Eric', age=42) print person.name point = Bunch(x=4711, y=23) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert string to command..

2007-10-18 Thread Marc 'BlackJack' Rintsch
. If you want to put this into a database you need a BLOB column or encode it as base64 or something similar more ASCII safe. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
for the += case only? B.l.__iadd__ obviously exists. Because there is always a rebinding involved. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
` is a property that checks if the value satisfies some constraints ``x.a += b`` would trigger the set method only if there is no `__iadd__()` involved if there's no rebinding. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-17 Thread Marc 'BlackJack' Rintsch
? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Order by value in dictionary

2007-10-17 Thread Marc 'BlackJack' Rintsch
(operator.itemgetter(0), sorted_items) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Appending a list's elements to another list using a list comprehension

2007-10-17 Thread Marc 'BlackJack' Rintsch
say yes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL and getpixel()

2007-10-16 Thread Marc 'BlackJack' Rintsch
BufferedImage.getRGB(x,y) .. i am wondering if someone can advise me on how i can do this Just pack the RGB values into an `int` by shifting and or-ing. Untested: red, green, blue = img.getpixel(x, y) pixel_as_int = red 16 | green 8 | blue Ciao, Marc 'BlackJack' Rintsch -- http

Re: int to str in list elements..

2007-10-16 Thread Marc 'BlackJack' Rintsch
. I get 30,888,889 bytes... I think you have an off by one error here. (One number, not one byte) :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: confused on calculating date difference in days.

2007-10-16 Thread Marc 'BlackJack' Rintsch
= datetime.date.today() - a In [426]: b.days Out[426]: 1017 Maybe you should read the docs next time. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: confused on calculating date difference in days.

2007-10-16 Thread Marc 'BlackJack' Rintsch
On Tue, 16 Oct 2007 18:10:54 +1000, Ben Finney wrote: Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: On Tue, 16 Oct 2007 12:33:33 +0530, krishnakant Mane wrote: firstly, I can't get a way to convert a string like 1/2/2005 in a genuan date object which is needed for calculation

Re: ctypes Wrapping Complex Datatypes

2007-10-16 Thread Marc 'BlackJack' Rintsch
, DFFTSOPT_ITERATIONS, iteration, sizeof(iteration)); If this handle is always just treated as a pointer to an opaque data structure you may just use a void pointer. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does the message send only once?

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

Re: some questions about Python and tkinter

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

Re: Newbi Q: Recursively reverse lists but NOT strings?

2007-10-15 Thread Marc 'BlackJack' Rintsch
it never ends. '' != [] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory Problems in Windows 2003 Server

2007-10-15 Thread Marc 'BlackJack' Rintsch
On Mon, 15 Oct 2007 11:31:59 +0200, amdescombes wrote: Are there any classes that implement disk based dictionaries? Take a look at the `shelve` module from the standard library. Or object databases like ZODB or Durus. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: Simple Text Processing Help

2007-10-15 Thread Marc 'BlackJack' Rintsch
= codecs.open('test.txt', 'r', 'utf-8') tokens = in_file.read().split() in_file.close() for element in iter_elements(tokens): print '|'.join(element) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Text Processing Help

2007-10-14 Thread Marc 'BlackJack' Rintsch
of the source seems to indicate that you don't really want to read in the whole input file at once but process it line by line, i.e. chemical element by chemical element. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Text Processing Help

2007-10-14 Thread Marc 'BlackJack' Rintsch
to Unicode: need string or buffer, list found. `tokens` is a list but you need to write a unicode string. So you have to reassemble the parts with '|' characters in between. Also shown by Paul. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: pydev code completion problem

2007-10-14 Thread Marc 'BlackJack' Rintsch
, but it would get very quickly very complicated for an IDE to keep track of objects if not even impossible. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: raw_input() and utf-8 formatted chars

2007-10-13 Thread Marc 'BlackJack' Rintsch
On Fri, 12 Oct 2007 19:09:46 -0700, 7stud wrote: On Oct 12, 2:43 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: You mean literally!? Then of course I get A\xcc\x88 because that's what I entered. In string literals in source code the backslash has a special meaning but `raw_input

Re: remove header line when reading/writing files

2007-10-12 Thread Marc 'BlackJack' Rintsch
'): in_file = gzip.GzipFile(zip_name, 'r') out_file.writelines(islice(in_file, 1, None)) in_file.close() os.chdir(os.pardir) out_file.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: raw_input() and utf-8 formatted chars

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

Re: gdbm troubles.

2007-10-11 Thread Marc 'BlackJack' Rintsch
not exist. That `gdbm` object doesn't have a `get()` method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Declarative properties

2007-10-11 Thread Marc 'BlackJack' Rintsch
and setters. But why? Default getters and setters are unnecessary and if you need something other than the default you need to write it anyway more explicitly. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Declarative properties

2007-10-11 Thread Marc 'BlackJack' Rintsch
On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote: On Oct 11, 2:27 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: But why? Default getters and setters are unnecessary and if you need something other than the default you need to write it anyway more explicitly. I see some

Re: Declarative properties

2007-10-11 Thread Marc 'BlackJack' Rintsch
`pylint` check for attributes that are introduced in other methods than `__init__()` and give a warning. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Declarative properties

2007-10-11 Thread Marc 'BlackJack' Rintsch
On Thu, 11 Oct 2007 09:58:48 -0700, Dan Stromberg wrote: On Thu, 11 Oct 2007 13:46:12 +, Marc 'BlackJack' Rintsch wrote: On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote: 1. If I use instance field 'name' which is accessed directly by other classes, and later I decide

Re: determining fully qualified package class name

2007-10-11 Thread Marc 'BlackJack' Rintsch
.__name__ The value for name will be MyClass Is there a comparable way to get the fully qualified name (package, module, and class name) in Python? Take a look at the `__module__` attribute of the class. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python

Re: .join(string_generator()) fails to be magic

2007-10-11 Thread Marc 'BlackJack' Rintsch
not fit into the allocated memory anymore, so there is new memory allocates that can hold both strings - double amount of memory needed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: .join(string_generator()) fails to be magic

2007-10-11 Thread Marc 'BlackJack' Rintsch
On Thu, 11 Oct 2007 07:02:10 +, thebjorn wrote: On Oct 11, 8:53 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Even if `str.join()` would not convert the generator into a list first, you would have overallocation. You don't know the final string size beforehand so intermediate

Re: unpickle from URL problem

2007-10-10 Thread Marc 'BlackJack' Rintsch
, not text files, so make sure you always treat them as binary, e.g. opening the files with mode 'rb' and 'wb' and don't transmit them in text mode over FTP etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: function wrappers

2007-10-10 Thread Marc 'BlackJack' Rintsch
`wrapper`. The name `func` in that new function object refers to the object bound to `func` in the `require_int` namespace. Then the new function is returned still carrying a reference to the `func` object that was passed into `require_int`. Ciao, Marc 'Blackjack' Rintsch -- http

Re: unpickle from URL problem

2007-10-10 Thread Marc 'BlackJack' Rintsch
On Wed, 10 Oct 2007 15:21:06 +, Alan Isaac wrote: Marc 'BlackJack' Rintsch wrote: Pickles are *binary* files, not text files Actually not: http://docs.python.org/lib/node316.html These were created with protocol 0. Actually yes, the docs are wrong. It's a binary file with bytes

Re: I'm starting to think like a Pythonista

2007-10-10 Thread Marc 'BlackJack' Rintsch
? No advantage there. What is the dis-advantage of using xrange over range in this circumstance? It's an unnecessary intermediate step. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Static variable vs Class variable

2007-10-09 Thread Marc 'BlackJack' Rintsch
` and then bind the result to `Child1`. `Child1` doesn't have an attribute `a`, so it is looked up in the parent class. But the result is then bound to `Child1`. So you are reading from `Foo` and writing to `Child1`. That's it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: Static variable vs Class variable

2007-10-09 Thread Marc 'BlackJack' Rintsch
() .: In [108]: class B(A): .: pass .: In [109]: B.a += [42] In [110]: A.a Out[110]: [42] In [111]: B.a Out[111]: [42] If it was just mutation then `B.a` would have triggered an `AttributeError`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman

Re: Static variable vs Class variable

2007-10-09 Thread Marc 'BlackJack' Rintsch
On Tue, 09 Oct 2007 22:43:16 +, Steven D'Aprano wrote: On Tue, 09 Oct 2007 19:46:35 +, Marc 'BlackJack' Rintsch wrote: On Tue, 09 Oct 2007 18:08:34 +, Steven D'Aprano wrote: L = [] id(L) 3083496716L L += [1] id(L) 3083496716L It's the same L, not rebound at all

Re: weakrefs and bound methods

2007-10-07 Thread Marc 'BlackJack' Rintsch
bound to the last non-`None` result in the interpreter. Drop all those `__del__()` methods as they prevent the garbage collector from collecting cycles. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: module confusion

2007-10-06 Thread Marc 'BlackJack' Rintsch
On Sat, 06 Oct 2007 19:16:47 +1300, Lawrence D'Oliveiro wrote: In message [EMAIL PROTECTED], Marc 'BlackJack' Rintsch wrote: To me a `variable` is made of a name, a memory address, a data type, and a value. In languages like C the address and type are attached to the name while in Python

Re: module confusion

2007-10-05 Thread Marc 'BlackJack' Rintsch
your definition of `variable` above. To me a `variable` is made of a name, a memory address, a data type, and a value. In languages like C the address and type are attached to the name while in Python both are attached to the value. Ciao, Marc 'BlackJack' Rintsch -- http

Re: remove list elements..

2007-10-05 Thread Marc 'BlackJack' Rintsch
important. A `set()` can be part of such a solution. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: toprettyxml messes up with whitespaces

2007-10-03 Thread Marc 'BlackJack' Rintsch
be included. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: module confusion

2007-10-02 Thread Marc 'BlackJack' Rintsch
. Importing the module `__init__` from a package using the name of the package is close enough to justify the phrase I import the package IMHO. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: C Source Code Generator For Test Cases

2007-09-29 Thread Marc 'BlackJack' Rintsch
the lib from python or from C, there still needs to be a way to generate 100+ test routines. ;-) Instead of reading the testcase tables and generating source for test routines you simply can do the tests right away. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo

Re: Python 3.0 migration plans?

2007-09-28 Thread Marc 'BlackJack' Rintsch
. Don't know if C#'s delegates qualify. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: ValueError: too many values to unpack,

2007-09-27 Thread Marc 'BlackJack' Rintsch
is to find out which of the two lines triggers the exception. This information is part of the full traceback. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: True of False

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

Re: comparing elements of a list with a string

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

Re: True of False

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 17:06:30 +, Duncan Booth wrote: Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: In [268]: 'c' in a == True Out[268]: False In [269]: ('c' in a) == True Out[269]: True In [270]: 'c' in (a == True

Re: Inserting an element into existing xml file

2007-09-25 Thread Marc 'BlackJack' Rintsch
On Tue, 25 Sep 2007 03:30:05 -0700, Anand wrote: I'm Afraid to say, I can't use lxml or elementTree as it requires many legal approvals and there is high chances of not getting it through. In what environment is it hard to get something BSD licensed through!? Ciao, Marc 'BlackJack

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Marc 'BlackJack' Rintsch
initializations and the presumed class definition boilerplate comes at the price of introducing them on your own. The mechanism is already there in Io, no need to invent, just use it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing parameters at the command line (New Python User)

2007-09-24 Thread Marc 'BlackJack' Rintsch
*and* an index: for i, arg in enumarate(args): # ... Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-24 Thread Marc 'BlackJack' Rintsch
from? Neither Python 2.5.1 nor the 3.0alpha has this in `__builtin__`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: rules from an xml file

2007-09-24 Thread Marc 'BlackJack' Rintsch
the rules better use an attribute for the numbers. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Can a base class know if a method has been overridden?

2007-09-24 Thread Marc 'BlackJack' Rintsch
on_whatever = _dummy_handler class MyHandler(EvtHandler): def on_key(self): print 'Do something...' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: puzzled about floats

2007-09-24 Thread Marc 'BlackJack' Rintsch
: In [144]: str(0.1) Out[144]: '0.1' In [145]: repr(0.1) Out[145]: '0.10001' In [146]: '%.12f' % 0.1 Out[146]: '0.1000' In [147]: '%.50f' % 0.1 Out[147]: '0.1555111512312578270211815834045410' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
, and can be done without. ``for`` loops are just a convenience, you can do without. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Who can develop the following Python script into working application ?

2007-09-22 Thread Marc 'BlackJack' Rintsch
guru.com or rentacoder.com for such assignments. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I could use some help making this Python code run faster using only Python code.

2007-09-22 Thread Marc 'BlackJack' Rintsch
a VM. About which D are we talking here? Not digital mars' successor to C++, right!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
functions and statements like while, for, with etc. become anonymous closures. Before someone starts to create such a thing he should take a look at Io which has just objects and methods. http://www.iolanguage.com/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
to override `Object clone` in Io, so all slots of the ancestor are shallow copied to the clone, but I guess this might break existing code. At least for your own code you could introduce a `realClone` slot. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing Object Data to Disk

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 17:13:14 +0530, Amit Kumar Saha wrote: BTW, do we have something like array of objects here? Like someone already said: lists. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Would Anonymous Functions Help in Learning Programming/Python?

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 06:58:57 -0700, Kay Schluehr wrote: On Sep 22, 1:15 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Sat, 22 Sep 2007 02:44:35 -0700, Kay Schluehr wrote: I checked out Io once and I disliked it. I expected Io's prototype OO being just a more flexible variant

Re: too many values with string.split

2007-09-22 Thread Marc 'BlackJack' Rintsch
that list to a string, split that string at commas, concatenate the *strings* between commas and then try to convert it to a `float`!? This is likely not what you want and should fail in most cases anyway. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I could use some help making this Python code run faster using only Python code.

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 13:00:27 -0700, Python Maniac wrote: On Sep 21, 11:39 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Fri, 21 Sep 2007 16:25:20 -0700, Python Maniac wrote: Well D code is compiled into machine code that runs via a VM. About which D are we talking here

Re: Getting rid of bitwise operators in Python 3?

2007-09-22 Thread Marc 'BlackJack' Rintsch
On Sat, 22 Sep 2007 21:17:38 +, Bryan Olson wrote: The operator module offers pow(). Is there any good reason for pow() as a built-in? The `operator.pow()` is just the function for ``**``, it lacks the optional third argument of the built in `pow()`. Ciao, Marc 'BlackJack

Re: Drawing a 640x480 Raw Image

2007-09-21 Thread Marc 'BlackJack' Rintsch
)] image.putdata(data) image.save('test.png') `data` can be any iterable with byte values. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Sets in Python

2007-09-20 Thread Marc 'BlackJack' Rintsch
in maintained internally in the dict. A copy!? That has to be a deep copy. Which would make `dict`\s alot slower and use more memory. Plus you can't store objects that can't be copied anymore. That doesn't sound like a good trade off to me. Ciao, Marc 'BlackJack' Rintsch -- http

Re: os.popen and lengthy operations

2007-09-20 Thread Marc 'BlackJack' Rintsch
` → deadlock. You have to use threads to read both `o` and `e` or the `select` module to look which file has something to read. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Deserializing specific objects from a file

2007-09-19 Thread Marc 'BlackJack' Rintsch
to individual files and store them in a ZIP archive. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: lambda-funcs problem

2007-09-19 Thread Marc 'BlackJack' Rintsch
of functions:: F.append(lambda x, i=i: x + i) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory Problem

2007-09-18 Thread Marc 'BlackJack' Rintsch
). And you also left out some information like the number of rows/columns and the size of the data. Have you already thought about using a database? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you limit the # of lines Read?

2007-09-18 Thread Marc 'BlackJack' Rintsch
of the readline() function? t = string.readline() # Limit this somehow? Do you want to limit how much of *one* line is read or the number of lines!? The latter can be done with `itertools.islice()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: where are the .pyc files?

2007-09-17 Thread Marc 'BlackJack' Rintsch
On Mon, 17 Sep 2007 01:23:20 +, Summercool wrote: On Sep 16, 10:36 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: The `*.pyc` files are usually only created when you import a module, not when a module is run directly. how come a program that runs directly doesn't need

Re: Needless copying in iterations?

2007-09-16 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 00:40:13 +, Steven D'Aprano wrote: On Sun, 16 Sep 2007 00:05:58 +, Marc 'BlackJack' Rintsch wrote: In *general* the compiler can't tell, but in specific cases it could. A (hypothetical) optimizing compiler would tell the difference between: for item in alist

Re: Needless copying in iterations?

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

Re: Needless copying in iterations?

2007-09-16 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 13:31:57 +, Steven D'Aprano wrote: On Sun, 16 Sep 2007 10:58:07 +, Marc 'BlackJack' Rintsch wrote: On Sun, 16 Sep 2007 09:50:39 +, Steven D'Aprano wrote: The point is rather moot, since CPython (and probably other Pythons) do almost no optimizations

Re: We need PIGs :)

2007-09-16 Thread Marc 'BlackJack' Rintsch
On Sun, 16 Sep 2007 10:17:18 -0400, Colin J. Williams wrote: Marc 'BlackJack' Rintsch wrote: `getFoo()` is discouraged by PEP 8. […] Perhaps PEP 8 needs rethinking. I prefer getFoo(). Yeah, *your* preference is a very good reason to rethink PEP 8… ;-) Ciao, Marc 'BlackJack

Re: where are the .pyc files?

2007-09-16 Thread Marc 'BlackJack' Rintsch
turn the show hidden file to on. The `*.pyc` files are usually only created when you import a module, not when a module is run directly. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)

2007-09-15 Thread Marc 'BlackJack' Rintsch
in the standard library instead of doing this yourself. :-) If you insist on doing it yourself take a look at the built-in `ord()` function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to join array of integers?

2007-09-15 Thread Marc 'BlackJack' Rintsch
... not integers... any fast method? Convert them to strings before joining: In [145]: foo = [1, 2, 3] In [146]: ','.join(map(str, foo)) Out[146]: '1,2,3' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: string questions

2007-09-15 Thread Marc 'BlackJack' Rintsch
, it doesn't work...I just get spam back when I print s1. Any ideas? Yes, read the documentation to find out that `replace()` does not alter the string -- strings in Python are immutable -- but returns a new, changed string. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

Re: Needless copying in iterations?

2007-09-15 Thread Marc 'BlackJack' Rintsch
]` where `i` is in `x:y` and this may lead to different results wether it iterates over a copy or the original. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
[] else: return f(l[1:]) + l[:1] f([1,2,3]) [] [3, 2, 1] # how this come here? how python save variables from each recursion? There is not just one `l` but one distinct `l` in each call. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo

Re: recursion

2007-09-14 Thread Marc 'BlackJack' Rintsch
caller: r2 f(2): return 2 * 1 Again this is evaluated and returned to its caller: r1 f(3): return 3 * 2 And here we have the final result that is returned from the first call to `f()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python osgi

2007-09-13 Thread Marc 'BlackJack' Rintsch
. But is code really a memory problem? I've never thought OMG memory is getting low, I wish I could unload a module to get some space. In my experience it's always data that eats my RAM. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3K or Python 2.9?

2007-09-13 Thread Marc 'BlackJack' Rintsch
at function definitions. You don't have to work to find out what type of variables it takes. This should either be obvious or in the docstring. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Problem

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

Re: Implementing a fixed size stack for an RPN Calculator

2007-09-12 Thread Marc 'BlackJack' Rintsch
expression to computable one. My RPN only implements: + - x % Why does this homework assignment limit the stack so severely!? ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: printing list containing unicode string

2007-09-11 Thread Marc 'BlackJack' Rintsch
several convenient properties: 1. It can handle any Unicode code point. ... As mentioned before, by definition, any Unicode encoding encodes all unicode char set. The mentioning of above as a convenient property is inane. You are being silly here. Ciao, Marc 'BlackJack' Rintsch

Re: IOError - list of all Errno numbers and their meanings?

2007-09-11 Thread Marc 'BlackJack' Rintsch
and the `os.strerror()` function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: memcpy

2007-09-11 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Sep 2007 05:09:58 -0700, Tim wrote: On Sep 10, 3:31 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Mon, 10 Sep 2007 11:38:50 -0700, Tim wrote: How do I memcpy from a pointer to an array of floats in python? I get errors: NameError: global name 'row' is not defined

Re: memcpy

2007-09-11 Thread Marc 'BlackJack' Rintsch
`shared_memory_pointer`. shared_memory_pointer = windll.kernel32.MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, 0, 0, TABLE_SHMEMSIZE) And here you bind a different object to that name, so the first binding has no effect. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org

Re: Car-ac-systems

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

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