Re: Python un-plugging the Interpreter

2007-04-20 Thread Marc 'BlackJack' Rintsch
ted as an integer, without "boxing" into a > general object. How is it clear that `i` is restricted to integers? That works only if you assume `range` refers to the built-in `range()` function. So the smart compiler has to check all possible control flows up to this point and be sure

Re: Python Feature Request: Explicit variable declarations

2007-04-20 Thread Marc 'BlackJack' Rintsch
` is 0? The increment happens after the division, right? :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling private base methods

2007-04-20 Thread Marc 'BlackJack' Rintsch
ery rare? Otherwise it would not be necessary to have and use a mechanism to declare everything private. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion: str.itersplit()

2007-04-21 Thread Marc 'BlackJack' Rintsch
I suggest an itersplit be introduced for > lazy evaluation, if you don't want to take up recourses, and it could > be used just like java's StringTokenizer. > > Comments? Does it really make such a difference? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Javascript equivalence

2007-04-23 Thread Marc 'BlackJack' Rintsch
intermediate lists. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen fails, but os.system works

2007-04-24 Thread Marc 'BlackJack' Rintsch
; syntax is incorrect > --- > > Can anyone tell me why? You are trying to execute a program named:: D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm Such a program does not exist on your computer. ;-) Give `subprocess.Popen()` a list with the program name and the individual arguments as elements instead. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding conventions for class names

2007-04-25 Thread Marc 'BlackJack' Rintsch
> My question is: does anyone actually follow guidelines here and if yes > which ones and are they resonable ( e.g. stable with regard to > refactoring etc. )? I follow PEP 8 in my (mostly unpublished) code if that does matter to you. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: If Dict Contains a particular key

2007-04-26 Thread Marc 'BlackJack' Rintsch
;): > pass > elde: > pass Additional to the speed argument, the ``in`` operator works with more types, like lists, sets and "iterables". And if someone implements a "container" class with membership testing, it is more likely he writes a `__contains__()` method than a `has_key()` method. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File not read to end

2007-04-26 Thread Marc 'BlackJack' Rintsch
as able to >> > parse the entire log without problem. Very quirky. > > […] > > I've attached the whole script. Thanks again for your help. There are ``break`` statements in the loop body!? Do you really want to leave the loop at those places? And I've seen at leas

Re: Python keywords

2007-04-26 Thread Marc 'BlackJack' Rintsch
s an index entry called `in operator` which leads to the page Comparisons_, telling how to overwrite the behaviour in your own classes. .. _Sequence Types: http://docs.python.org/lib/typesseq.html .. _Comparisons: http://docs.python.org/ref/comparisons.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: My python annoyances so far

2007-04-26 Thread Marc 'BlackJack' Rintsch
function one needs to write an anonymous class with a method. Quite convoluted. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: My python annoyances so far

2007-04-26 Thread Marc 'BlackJack' Rintsch
out classes like the Io language. Everything there is an object and the base object has a `clone()` method to make a copy. So you make copies of objects and modify them to tweak them into the way you want them. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Memory addressing

2007-04-27 Thread Marc 'BlackJack' Rintsch
you could get an object from a "raw" memory address. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Ping program

2007-04-27 Thread Marc 'BlackJack' Rintsch
8 -- Style Guide for Python Code: http://www.python.org/dev/peps/pep-0008/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: My newbie annoyances so far

2007-04-27 Thread Marc 'BlackJack' Rintsch
The HP RPL leaves even more questions. If the square brackets mean the ``else`` part is optional, what would be the result of the expression if `c` is `False`? Hypothetical HP RPL syntax construct in Python:: x = 42 if False end print x # -> ??? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Which are your favorite UML tools?

2007-04-28 Thread Marc 'BlackJack' Rintsch
functions as static methods of the module's class. Modules are objects too and can be seen as singletons. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Ping program

2007-04-28 Thread Marc 'BlackJack' Rintsch
ng function is what I'm working on first. Still doesn't explain why it is a class. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I can't inherit from "compiled" classes ?

2007-04-29 Thread Marc 'BlackJack' Rintsch
king wrong? You are trying to subclass a module here, just like the error message says. The module contains a `socket` type: In [3]: import socket In [4]: type(socket) Out[4]: In [5]: type(socket.socket) Out[5]: `select.select()` is a function: In [6]: import select In [7]: type(select.select) Out[7]: Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I/O Operations .....

2007-04-30 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, saif.shakeel wrote: > File writing can be done in that way,but my query is > something different.I have to rename the output file by default with > input file name(only changing the extension. Take a look at the functions in `os.path`. Cia

Re: regexp match string with word1 and not word2

2007-04-30 Thread Marc 'BlackJack' Rintsch
p_list: if re.search(regexp, line): skip = True break And if you don't intent to count the `skip`\s a `True` seems to be more readable. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling Exe from Python

2007-05-02 Thread Marc 'BlackJack' Rintsch
able and never returns > to the calling python script. > I tried "os.fork" it will start an independent process, > since logic of my program depends on the results of executable. Take a look at `os.system()` or the `subprocess` module. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I need help speeding up an app that reads football scores and generates rankings

2007-05-02 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, jocknerd wrote: > The biggest difference in my two apps is the C app uses linked lists. > I feel my Python app is doing too many lookups which is causing the > bottleneck. Then replace those linear searches you wrote in Python with a dictionary. Cia

Re: Time functions

2007-05-02 Thread Marc 'BlackJack' Rintsch
ere any formatting functions available or do I need > to make my own? Perhaps there is something similar to C's printf > formatting. You mean like `time.strftime()`!? :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: copy base class fields

2007-05-03 Thread Marc 'BlackJack' Rintsch
nit__ of B. > > Several variants of the program produces similar results. > > Please, could someone explain which way is the correct way? Call the `__init__()` of `A`: class B(A): def __init__(self, a): A.__init__(self) self.v2 = 2 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: ascii to unicode line endings

2007-05-03 Thread Marc 'BlackJack' Rintsch
d()) >>>> testUNI.close() >>>> testUNI = file("c:\\temp\\test2.txt",'r') >>>> testUNI.read() > '\xff\xfe\n\x00' > Bit pattern on disk:\0xff\0xfe\0x0a\0x00 > Bit pattern I was expecting:\0xff\0xfe\0x0d\0x00\0x0a\0x00 >>>> testUNI.close() Files opened with `codecs.open()` are always opened in binary mode. So if you want '\n' to be translated into a platform specific character sequence you have to do it yourself. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to replace the last (and only last) character in a string?

2007-05-03 Thread Marc 'BlackJack' Rintsch
is shorter than using `replace()`: In [9]: s = '12345 4343 454' In [10]: s = s[:-1] + 'r' In [11]: s Out[11]: '12345 4343 45r' BTW most things in the `string` module are deprecate because they are available as methods on string objects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: _csv.Error: string with NUL bytes

2007-05-03 Thread Marc 'BlackJack' Rintsch
der: > _csv.Error: string with NUL bytes > Exit code: 1 , 0001h As Larry said, this most likely means there are null bytes in the CSV file. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I get type methods?

2007-05-04 Thread Marc 'BlackJack' Rintsch
; Is this not what you want? These are the only methods in the Foo > class. The OPs problem is, there is no access to the class or type because there is no name. You can get just instances from a factory function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Looping over lists

2007-05-04 Thread Marc 'BlackJack' Rintsch
e > > 1 2 > 1 3 > 1 4 > 1 5 > 2 3 > 2 4 > 2 5 > 3 4 > 3 5 > 4 5 But only if the elements in the list are unique. And the runtime is suboptimal because `index()` is doing a linear search -- the outer loop becomes slower and slower with each iteration. Ciao,

Re: Python regular expressions just ain't PCRE

2007-05-04 Thread Marc 'BlackJack' Rintsch
ts isn't as compact and readable as simple regular expressions. So both `re` and higher level parsers are useful together and don't supersede each other. The same holds for C and Python. IMHO. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie prob: How to write a file with 3 threads?

2007-05-06 Thread Marc 'BlackJack' Rintsch
to be written. > I have my code, but it makes python intepreter crash everytime on my > Vista. Show minimal (non-)working code, tell us the exception plus traceback and explain "crash". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: N00b question on Py modules

2007-05-07 Thread Marc 'BlackJack' Rintsch
turn the value(s) instead: _exitcode = 0 def set_exitcode(): return 1 if __name__ == '__main__': print _exitcode _exitcode = set_exitcode() print _exitcode Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Examples / Links needed

2007-05-07 Thread Marc 'BlackJack' Rintsch
ok at the methods it implements and do this for your "number like" class. > I'm not satisfied with Python Docs. Why? What does `Emulating numeric types`_ in the reference manual lack in your opinion? .. _Emulating numeric types: http://docs.python.org/ref/numeric-types.html Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: long lists

2007-05-07 Thread Marc 'BlackJack' Rintsch
set(local) - set(remote)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: is for reliable?

2007-05-07 Thread Marc 'BlackJack' Rintsch
some 3-4 times faster than > the for loop > > How is this possible? Good question. ``for`` loops are of course reliable. Can you give a short self contained example that shows the behavior? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Designing a graph study program

2007-05-08 Thread Marc 'BlackJack' Rintsch
ph and node classes this notification can be injected by wrapper classes to some degree. For very fine grained observation of an algorithm you might try to implement a step by step debugger. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: ipython environment question

2007-05-08 Thread Marc 'BlackJack' Rintsch
from IPython.Shell import IPShellEmbed >ipshell = IPShellEmbed() >print "Please set these variables: project_name, group_name ...and > then type create()" >### I even tried to put all my >ipshell() # this call anywhere in your program will start IPython You have to call the function with arguments. The default values are only evaluated once when the ``def`` statement is executed, not every time the function is called. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Atttribute error

2007-05-08 Thread Marc 'BlackJack' Rintsch
as a function called urlopen. Do you have a file called `urllib.py` in the current directory? Then this gets imported instead of the module in the standard library. Add this directly after the ``import`` to see what's happening: print urllib.__file__ print dir(urllib) Ciao, Marc '

Re: Towards faster Python implementations - theory

2007-05-08 Thread Marc 'BlackJack' Rintsch
mean just recommendations from the programmer. So you can say this name should be an `int` and the JIT compiler produces code in advance, but it's okay to pass another object instead. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File Name Format

2007-05-08 Thread Marc 'BlackJack' Rintsch
ames. Doesn't this depend more on the file system than the operating system? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestions for how to approach this problem?

2007-05-08 Thread Marc 'BlackJack' Rintsch
I think I have vague idea how the input looks like, but it would be helpful if you show some example input and wanted output. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Designing a graph study program

2007-05-08 Thread Marc 'BlackJack' Rintsch
es have some methods with the same names and the same semantics they share the same interface. And a class that isn't meant to be instantiated or doesn't implement all methods is an abstract class. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Minor bug in tempfile module (possibly __doc__ error)

2007-05-09 Thread Marc 'BlackJack' Rintsch
If you want to change the outcome of the functions and objects then simply give the prefix as argument. In [21]: tempfile.mktemp(prefix='eggs') Out[21]: '/tmp/eggsBqiqZD' In [22]: a = tempfile.NamedTemporaryFile(prefix='eric') In [23]: a.name Out[23]: '/tmp/eri

Re: error in the if, elif, else statement ?

2007-05-09 Thread Marc 'BlackJack' Rintsch
ne 80 lGwU does not > appear. It is not assigned, otherwise you would not get this error. The line number is also correct because it's the start of the construct or "logical line" where the name is referenced. Just look at the very next line in the source. > Another strange

Re: Getting some element from sets.Set

2007-05-09 Thread Marc 'BlackJack' Rintsch
ry readable, > and I wonder if it's efficient. Give it a name and it gets more readable: def get_name(setobj): return iter(setobj).next() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing string in xml file--revisited

2007-05-10 Thread Marc 'BlackJack' Rintsch
d of fixing the code that doesn't!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Minor bug in tempfile module (possibly __doc__ error)

2007-05-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, James T. Dennis wrote: > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, James T. Dennis wrote: > >> You can change it by simply assigning to the name: > >> In [15]: tempfile.templ

Re: trouble with generators

2007-05-10 Thread Marc 'BlackJack' Rintsch
> def __init__(self): > self.genB = GenB() > > def records(self): > for a in Gen.records(self, A()): Here you create an instance of `A` and pass that *instance* and not the *class*. If you would pass the class here, you must create objects

Re: how to refer to partial list, slice is too slow?

2007-05-11 Thread Marc 'BlackJack' Rintsch
result = data[offset:offset + chunksize] if not result: break yield result def parser1(data): chunk = data.next() # ... parser2(data) def parser2(data): chunk = data.next() # ... parser3(data) # ... def main(): # Read or create data.

Re: Finally started on python..

2007-05-12 Thread Marc 'BlackJack' Rintsch
omething` objects like this: something = Something() # Puts some entries into `something`. for entry in something: print entry Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-13 Thread Marc 'BlackJack' Rintsch
you don't know how to input them with your keymap or keyboard layout. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing part of string

2007-05-14 Thread Marc 'BlackJack' Rintsch
You can test for the prefix with the `startswith()` method and use string slicing to create a new string without the prefix: In [3]: prefix = 'Timeout ' In [4]: longname = 'Timeout N_Bs' In [5]: longname.startswith(prefix) Out[5]: True In [6]: longname = longname[len(prefix):] In [7]: longname Out[7]: 'N_Bs' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Marc 'BlackJack' Rintsch
't supported it last time I tried. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Marc 'BlackJack' Rintsch
6) Ω, and I think some omegas in the mathematical symbols area too. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-14 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Michel Claveau wrote: > And Il1 O0 ? Hm, we should ban digits from identifier names. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to choose between python and java

2007-05-14 Thread Marc 'BlackJack' Rintsch
ackwards compatibility was such a high priority. The 2.x series will be supported for some time parallel to 3.x, so there is enough time to migrate. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Marc 'BlackJack' Rintsch
ntext, but e.g. software that should map the workflow of a local company with local laws and regulations and internal "names" for things and concepts looks strange in both, pure "english" and mixed local language and english. But the latter is easier to map to the specifications and language of the end users. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Marc 'BlackJack' Rintsch
e starts to argument like you. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing and searching nodes of a tree

2007-05-15 Thread Marc 'BlackJack' Rintsch
any thing, and afford to keep them in a particular order. Is > there any way I can speed up this as I have to do this for around 4000 > times with tree size being ~5000. What about this: def search(tree, path): while path: result = tree.get(path) if result is not None: return result path = path[:-1] raise KeyError('path not on tree') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Storing and searching nodes of a tree

2007-05-15 Thread Marc 'BlackJack' Rintsch
and a bit faster too as a method lookup is spared. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-15 Thread Marc 'BlackJack' Rintsch
en end users with transliterated identifiers. If the OpenOffice API wouldn't be so "javaesque" this would be a good use case for code with non-ASCII identifiers. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Marc 'BlackJack' Rintsch
rogramming professional it may be mandatory to be able to write english identifiers, comments and documentation, but there are not just programming professionals out there. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Execute commands from file

2007-05-16 Thread Marc 'BlackJack' Rintsch
at the `code` module in the standard library: In [31]: code? Type: module Base Class: String Form: Namespace: Interactive File: /usr/lib/python2.4/code.py Docstring: Utilities needed to emulate Python's interactive interpreter. Ciao, Marc &#

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Stefan Behnel wrote: > René Fleschenberg wrote: >> Marc 'BlackJack' Rintsch schrieb: >>> There are potential users of Python who don't know much english or no >>> english at all. This includes kids, old people, people fro

Re: cPickle.dumps differs from Pickle.dumps; looks like a bug.

2007-05-16 Thread Marc 'BlackJack' Rintsch
: In [75]: a = 5 In [76]: b = 5.0 In [77]: a == b Out[77]: True In [78]: f(a) == f(b) Out[78]: False And `f()` doesn't even use something like `random()` or `time()` here. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Joining Lists

2007-05-17 Thread Marc 'BlackJack' Rintsch
if pattern_re.match(path)] This lacks `glob.glob()`\s special handling of patterns containing directory names though. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: regex matching question

2007-05-19 Thread Marc 'BlackJack' Rintsch
pairs different" constraint is something I would not even attempt to put in a regex. For searching candidates this should be good enough:: r'(\d+,\d+/){5}\d+,\d+' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: TIFF to PDF

2007-05-20 Thread Marc 'BlackJack' Rintsch
py several tiffs into one multipage tiff and `tiff2pdf` to convert it into PDF. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: re.compile for names

2007-05-21 Thread Marc 'BlackJack' Rintsch
ly. What about names with letters not in the ASCII range? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python compared to other language

2007-05-21 Thread Marc 'BlackJack' Rintsch
anguage with implicit declaration. " > > Is Python strongly typed or untyped? Strongly typed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: too much memory use

2007-05-22 Thread Marc 'BlackJack' Rintsch
ects? Anyway… If the data doesn't fit into memory anymore it's time to put them into a database. Either a `shelve`, an SQL database like SQLite or maybe an object database like zodb or Durus. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to use imaageop.scale

2007-05-23 Thread Marc 'BlackJack' Rintsch
talking about the Python Imaging Library (PIL) here? What have you tried and in which way did it fail? What about the `resize()` method on image objects? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: of destructors, open files and garbage collection

2007-05-24 Thread Marc 'BlackJack' Rintsch
good idea because there are no really hard guaranties by the language if and when it will be called. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: just a bug (was: xml.dom.minidom: how to preserve CRLF's inside CDATA?)

2007-05-25 Thread Marc 'BlackJack' Rintsch
ontain valid characters of this type http://www.w3.org/TR/REC-xml/#NT-Char (linked from the grammar of CDATA in your link above). Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading a file and resuming reading.

2007-05-25 Thread Marc 'BlackJack' Rintsch
mplemented I can do > this simply by counting the lines! for line_nr, line in enumerate(f): # Do something with `line_nr` and `line`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Amount of Data

2007-05-25 Thread Marc 'BlackJack' Rintsch
ll Python use swap memory or will it fail? What about putting the data into a database? If the keys are strings the `shelve` module might be a solution. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Amount of Data

2007-05-26 Thread Marc 'BlackJack' Rintsch
;t have to be an SQL database. The `shelve` module or an object DB like zodb or Durus are databases too. Maybe you should try it and measure before claiming it's going to be too slow and spend time to implement something like a database yourself. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Struggling again 'map'

2007-05-26 Thread Marc 'BlackJack' Rintsch
t;>", y `map()` expects a function as first argument that will be applied to the elements in the other the arguments which have to be iterable. That you can give `None` as a function and the resulting behavior is IMHO a very ugly thing and has not much to to with the semantics exp

Re: totally lost newbie

2007-05-27 Thread Marc 'BlackJack' Rintsch
gt; return cmp( a[0], b[0] ) > > cards.sort( mycmp ) > #print cards Maybe it's easier to use a key function instead of a compare function. A key function receives an element and must return something that is then sorted and the element ends up where the computed key is in t

Re: totally lost newbie

2007-05-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steve Howell wrote: >> def key_func(item): >> return (len(item), item) >> >> data = ['viking', 'spam', 'parrot', 'ham', 'eric'] >> data.sort(key=key_func) >> print data >&g

Re: Error in optparse documentation

2007-05-28 Thread Marc 'BlackJack' Rintsch
n error in the docs. You are reading documentation for Python 2.5 and expect everything in it to work in older versions too? Pick the right documentation from http://www.python.org/doc/versions/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Can python create a dictionary from a list comprehension?

2007-05-28 Thread Marc 'BlackJack' Rintsch
build when stumbling over a list comp and it's wasteful because an unnecessary list of `None`\s is build and thrown away for no reason other than to have a one liner. This is not Perl! ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

RE: c[:]()

2007-05-31 Thread Marc 'BlackJack' Rintsch
ing code for the first > time? for func in funcs: func() Because it is explicit and readable and matches the english description "for every function in functions: call that function" very closely while a list comprehension or your "perlish" line noise is much more magic to explain and harder to remember. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python memory handling

2007-05-31 Thread Marc 'BlackJack' Rintsch
is there a way to force python to release this memory ?! AFAIK not. But why is this important as long as the memory consumption doesn't grow constantly? The virtual memory management of the operating system usually takes care that only actually used memory is in physical RAM. Ciao,

Re: Is PEP-8 a Code or More of a Guideline?

2007-05-31 Thread Marc 'BlackJack' Rintsch
do the > math. (Too lazy to explain further...) Let's leave 'foo' and 'ar': 1. B = + = 2 key strokes. 2. _b = + <-> and = 3 key strokes. At least on my keyboard + layout. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: file reading by record separator (not line by line)

2007-05-31 Thread Marc 'BlackJack' Rintsch
ummy, record_lines in groupby(mark_records(lines), fst): yield imap(snd, record_lines) def main(): source = """\ > name1 line_11 line_12 line_13 ... > name2 ... line_21 line_22 ...""".splitlines() for record in iter_records(source)

Re: WEATHER PROGRAMMING IN PYTHON

2007-05-31 Thread Marc 'BlackJack' Rintsch
Find some page with actual weather reports or forecasts and use the BeautifulSoup module to scrape the information you need. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethod & staticmethod

2007-07-24 Thread Marc 'BlackJack' Rintsch
A.__init__(self, x, y) def main(): B.from_str('42,23') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing XML with ElementTree (unicode problem?)

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

Re: display image through cgi python html

2007-07-24 Thread Marc 'BlackJack' Rintsch
t the image, not the name. Read the binary file and print it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

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

2007-07-24 Thread Marc 'BlackJack' Rintsch
ence all exceptions with a bare except here. This swallows any errors in `replaceFieldsAndIndices()`. Maybe some of them are not the exception you expect, but real errors in your program!? Ciao, Marc 'BlackJack' Rintscj -- http://mail.python.org/mailman/listinfo/python-list

Re: is_iterable function.

2007-07-25 Thread Marc 'BlackJack' Rintsch
[74]: a = iter(A()) In [75]: a.next() --- Traceback (most recent call last) /home/bj/ in () /home/bj/ in __getitem__(self, key) : So there's no reliable way to test for "iterables" other than actually iterate over the object. Ciao, Marc &#x

Re: is_iterable function.

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

Re: is_iterable function.

2007-07-26 Thread Marc 'BlackJack' Rintsch
ext()` consumes an element if `obj` is not "re-iterable". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: From D

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

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

2007-07-25 Thread Marc 'BlackJack' Rintsch
tedious and error prone. If you are the designer of `f` then just receive the whole `x` as *one* argument. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: C API -- Two questions

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

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

2007-07-27 Thread Marc 'BlackJack' Rintsch
serialized form, is about bytes in some encoding. So this can only be stored in `str` objects. `unicode` is already decoded. If you want to feed `unicode` objects to an XML parser, simply encode it before passing it. The question remains why you have "serialized XML" as `unicode` in

Re: Filtering content of a text file

2007-07-27 Thread Marc 'BlackJack' Rintsch
inefficient because the file gets read 36 times. If the data is already sorted you can use `itertools.groupby()` to get the groups and write them to several files. Otherwise if the files can be read into memory completely you can sort in memory and then use `itertools.groupby()`. Ciao,

Re: Filtering content of a text file

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

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