Re: Built-in functions and keyword arguments

2007-10-29 Thread Marc 'BlackJack' Rintsch
e issues aside, I > think it would be a good idea if built-in functions behaved exactly > the same as normal functions. As Steven D'Aprano showed they behave like normal functions. Even pure Python functions can have arguments without names: def spam(*args): pass Ciao, Mar

Re: A Python 3000 Question

2007-10-29 Thread Marc 'BlackJack' Rintsch
to stuff them as static methods into classes or even uglier you see code like ``Spam().spammify(eggs)`` instead of a plain function call. And functions are first class objects in Python. That sounds quite OO to me. You can think of a module with functions as a singleton. Ciao, Marc &#x

Re: statvfs

2007-10-29 Thread Marc 'BlackJack' Rintsch
blocksize * number of blocks math to get > the % of used space. Just go ahead and do it: In [185]: stat = os.statvfs('/') In [186]: stat.f_bsize Out[186]: 4096 In [187]: stat.f_blocks Out[187]: 2622526L In [188]: stat.f_bsize * stat.f_blocks Out[188]: 10741866496L Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Built-in functions and keyword arguments

2007-10-30 Thread Marc 'BlackJack' Rintsch
misunderstand his intention. He wanted to give the optional third argument of `getattr()` as keyword argument. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A Python 3000 Question

2007-10-30 Thread Marc 'BlackJack' Rintsch
(). >> >> But consider rewriting the following: >> >> def table(func, seq): >> return zip(seq, map(func,seq)) >> >> table(len, ('', (), [])) > > table(lambda x:x.__len__(), ('',[],())) > > What was the point again ? Beauti

Re: Parsing xml file in python

2007-10-30 Thread Marc 'BlackJack' Rintsch
") …this line will raise an exception. `file.write()` takes just one argument, not three as in this call. If you don't get an exception maybe you have other places with a bare ``except`` like in the snippet above. Don't do that. Catch the specific exception you want to handle with an ``except`` and not simply *all*. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: jpeg image read class

2007-10-31 Thread Marc 'BlackJack' Rintsch
te over `something` directly. That loop can be written as: for pixval in data: rgb = pixval2rgb(pixval) rgbs.append(rgb) Or even shorter in one line: rgbs = map(pixval2rgb, data) If the `numpy` array is what you want/need it might be more efficient to do the RGB to "pixval" conversion with `numpy`. It should be faster to shift and "or" a whole array instead of every pixel one by one in pure Python. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: shouldn't 'string'.find('ugh') return 0, not -1 ?

2007-10-31 Thread Marc 'BlackJack' Rintsch
> > idiom, which is a bit of a pity I think. And what should ``'string'.find('str')`` return? How do you distinguish the not found at all case from the found at the very beginning case!? The simple test you want can be written this way: if 'something' in chec

Re: Method needed for skipping lines

2007-10-31 Thread Marc 'BlackJack' Rintsch
t; return rows > > How would you modify this to exclude lines between "Begin VB.Form" and > "End" as described above? Introduce the flag and look up the docs for the `startswith()` method on strings. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: XML DOM, but in chunks

2007-10-31 Thread Marc 'BlackJack' Rintsch
ee read only one record of the data at a time? Have you tried `iterparse()`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: raw_input() and utf-8 formatted chars

2007-11-02 Thread Marc 'BlackJack' Rintsch
hat UTF-8 encoded 'Ä' and shows it. If you expected the output '\xc3\x84' then remember that you ask the soup object for its representation and not a string. The object itself decides what `repr(obj)` returns. Soup objects represent themselves as UTF-8 encoded strings. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is pyparsing really a recursive descent parser?

2007-11-02 Thread Marc 'BlackJack' Rintsch
re(Word(alphas))`` part "eats" the 'end' and when it can't get more, the parser moves to the ``Literal('end')`` part which fails because the 'end' is already gone. > Is there a way to get pyparsing to parse a grammar like this? Negative lookahead

Re: find.find

2007-01-09 Thread Marc 'BlackJack' Rintsch
It's the first argument to `findvisitor()` which is invoked for every directory level by `os.path.walk()`. `findvisitor()` adds all file names that match `pattern` to the `matches` list. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Question: Best Practice? (module 'shelve')

2007-01-09 Thread Marc 'BlackJack' Rintsch
t; self.db = shelve.open('textmatch.db', flag=modeflag) >> else: >> self.db = shelve.open(dbName, flag=modeflag) def open_db(self, db_name='textmatch.db', modeflag='c'): self.db = shelve.open(db_name, flag=modeflag) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: File Closing Problem in 2.3 and 2.4, Not in 2.5 (Final report)

2007-01-10 Thread Marc 'BlackJack' Rintsch
> when the GC finds it? Only when the GC destroys it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python nuube needs Unicode help

2007-01-11 Thread Marc 'BlackJack' Rintsch
: >> "UnicodeEncodeError: 'ascii' codec can't encode character u'\xe3' in >> position 40: >> ordinal not in range(128)" >> > > Find out what encoding the files are in and modify the script to use it. The problem is not the encoding of the files as you see they are decoded to unicode strings by the XML reading part already. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: What is a perl hash in python

2007-01-12 Thread Marc 'BlackJack' Rintsch
f`` statement. >graphAddressOut = tag1 + logUrl + fileOut[1] + extention1 + tag2 >+ > "SWITCH: " + string.swapcase(fileOut2D[0]) + "  & nbsp;PORT > ID: " + fileOut2D[1] + "" + imgTitleTag + imgTag1 + logUrl + > fileOut[1] + extention2

Re: How to determine what exceptions a method might raise?

2007-01-17 Thread Marc 'BlackJack' Rintsch
dynamic language; that's the price you have to pay for leaving the > static typing world". I don't thing that's a dynamic vs. static thing because in statically typed languages it's not that easy to find out all possible exceptions unless the language forces you to declare them. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I create a linked list in Python?

2007-01-17 Thread Marc 'BlackJack' Rintsch
ciency differences. Python has a list type without the "s, it's a real list. Don't confuse the *ADT list* with *linked lists* which are just one implementation of the ADT list. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read and write huge binary files

2007-01-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Lad wrote: > What is a good way to read binary data from HUGE file and write it > to another file? What about `shutil.copy()`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Standard streams

2007-01-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, raghu wrote: > what is standard streams in case of python? Do you mean `sys.stdin`, `sys.stdout` ans `sys.stderr`? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: instancemethod

2007-01-22 Thread Marc 'BlackJack' Rintsch
> python always seems to amaze me how other languages make a mess of > things that suppose to be simple It gets even simpler: cursor objects are iterable after the `execute()` call. So you don't need the number of rows:: gert.excecute('select * from person') for row in gert

Re: Code reformater?

2007-01-22 Thread Marc 'BlackJack' Rintsch
ng code from > either a web page or an e-mail that TABs are messed up, which is not a > problem with other languages, but is a problem with Python. Too bad. Well then don't use code from people using TABs. If it's indented by four spaces per level, like suggested by the style guide

Re: beep or sound playing under linux

2007-01-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, hg wrote: > Is there a way to do that ? Maybe this helps: http://paste.pocoo.org/show/316/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on using isinstance

2007-01-24 Thread Marc 'BlackJack' Rintsch
usually you don't expect a list or dictionary but some object that *acts* like a list or dictionary. Or you even expect just some aspects of the type's behavior. For example that it is something you can iterate over. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: raise UnicodeError, "label too long"

2007-01-24 Thread Marc 'BlackJack' Rintsch
o > have a problem with these strings. What exactly are you doing? How does a (unicode?) string look like that triggers this exception? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python+ncurses: I can't display accents

2007-01-27 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Fabrice DELENTE wrote: > As support for 8-bit (and even unicode) is important for my script, is there > any hope? Should I switch to slang instead of curses? Take a look at urwid: http://excess.org/urwid/ Ciao, Marc 'BlackJack&

Re: import from future

2007-01-27 Thread Marc 'BlackJack' Rintsch
rs', 'nested_scopes'] In [4]: __future__.all_feature_names Out[4]: ['nested_scopes', 'generators', 'division'] In [5]: __future__.division Out[5]: _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192) In [6]: help(__future__) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: decode overwrite variable?

2007-01-28 Thread Marc 'BlackJack' Rintsch
= u'\u2022' In [3]: a = a.decode('iso-8859-1') --- exceptions.UnicodeEncodeError Traceback (most recent call last) /home/marc/ UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022'

Re: import from future

2007-01-28 Thread Marc 'BlackJack' Rintsch
gt;From 2.5 on we have `with_statement`:: >>> __future__.with_statement _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha', 0), 32768) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Help me understand this

2007-01-30 Thread Marc 'BlackJack' Rintsch
lowed by a ".". A space between the integer literal and the dot operator works too: In [1]: 2 .__add__(1) Out[1]: 3 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Random passwords generation (Python vs Perl) =)

2007-01-31 Thread Marc 'BlackJack' Rintsch
ne 1, in > File "", line 0 > > ^ > SyntaxError: unexpected EOF while parsing It's `input()` that expects a valid Python expression. An empty one doesn't work, it has to evaluate to something. In [2]: input() ---

Re: another newbie question: why should you use "*args" ?

2007-01-31 Thread Marc 'BlackJack' Rintsch
;] > plot ( list[0], color[0]) > hold (True) > for i in range ( 1, len(list) ): > plot ( list[i], color[i] ) No need for the counter here. for args in zip(list[1:], color[1:]): plot(*args) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: division by 7 efficiently ???

2007-02-01 Thread Marc 'BlackJack' Rintsch
s the OP trying to divide by 7 or 2? I read it as divide by 7. And the `int.__div__()` Method limits this somehow -- a more polymorphic approach would be:: import operator operator.div(14, 7) :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: division by 7 efficiently ???

2007-02-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Krypto wrote: > The correct answer as told to me by a person is > > (N>>3) + ((N-7*(N>>3))>>3) How could it be correct if it uses `-`? You ruled out `-` and `/` in your first post. Ciao, Marc 'BlackJack' Rintsch

Re: Where Does One Begin?

2007-02-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > pygame is probily a good program to start with as long as you keep in > mind that it is possible that up to 50% of the p.c. laptops may not be > able to run it. Huh? Care to explain this? Ciao, Marc 'BlackJa

Re: HELP NEEDED ... Regd. Regular expressions PyQt

2007-02-03 Thread Marc 'BlackJack' Rintsch
ranges isn't that hard without a regular expression. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Determining encoding of a file

2007-02-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Tony Houghton wrote: > In Linux it's possible for filesystems to have a different encoding from > the system's setting. Given a filename, is there a (preferably) portable > way to determine its encoding? No. Ciao, Marc 

Re: confused about resizing array in Python

2007-02-04 Thread Marc 'BlackJack' Rintsch
res or objects then you have something like Python's list type. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Where Does One Begin?

2007-02-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > On Feb 3, 2:16 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, >> >> [EMAIL PROTECTED] wrote: >> > pygame is probily a good program to start with as lo

Re: Inheriting str object

2007-02-05 Thread Marc 'BlackJack' Rintsch
prints 'hello world' > s=s.upper() > print s.hello() # expected to print 'hello WORLD', but s is no longer > myStr, it's a regular str! > > What can I do? Return a `myStr` instance instead of a regular `str`: def hello(self): return myStr('hell

Re: C parsing fun

2007-02-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, karoly.kiripolszky wrote: > and the great thing is that the algorithm can be used with any > language that structures the code with brackets, like PHP and many > others. But it fails if brackets appear in comments or literal strings. Ciao,

Re: Getting a class name from within main

2007-02-07 Thread Marc 'BlackJack' Rintsch
m within the class scope as seen > above in the init, but is there any way of printing it from within the > main without creating an object of the MyClass type. I need to assign > the name of the class within my script, to a variable in main. Yes:: print MyClass.__name__ Ciao,

Re: Calling J from Python

2007-02-07 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gosi wrote: > I like to use J for many things and I think that combining Python and > J is a hell of a good mixture. I was able to follow this sentence up to and including the word "hell"… :-) Ciao, Marc 'BlackJack' Rintsch --

Re: Is Python for me?

2007-02-08 Thread Marc 'BlackJack' Rintsch
tp://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415504 And a library called `poker-eval` with Python bindings: http://pokersource.org/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Regexp not performing the same in FTP versus Python

2007-02-08 Thread Marc 'BlackJack' Rintsch
function to translate a glob pattern to a `re` pattern: In [8]: fnmatch.translate('.??[oOdDnNmM]*') Out[8]: '\\...[oOdDnNmM].*$' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Glob returning an empty list when passed a variable

2007-02-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > With some number: > > In [2]: "% 3s" % 'a' > Out[2]: ' a' The space still doesn't have any effect here: In [66]: "%3s" % 'a' Out[66]: ' a' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to access an absolute address through Python?

2007-02-11 Thread Marc 'BlackJack' Rintsch
; be more specific. In pure Python it's not possible and even in C it might be difficult to get an absolute *physical* memory address unless you run DOS. Modern operating systems tend to use some virtualisation of memory. :-) What's your goal? What do you expect at the memory address y

Re: reference data in a dictionary

2007-02-14 Thread Marc 'BlackJack' Rintsch
']]. Not by directly referencing them, but with a list comprehension:: result = [the_dict[key] for key in ('row1', 'row2', 'row3')] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why I don't like range/xrange

2007-02-16 Thread Marc 'BlackJack' Rintsch
ple should demonstrate that assigning to the loop variable has no effect on the "loop test". Which IMHO is a good thing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WHAT IS THIS?

2007-02-16 Thread Marc 'BlackJack' Rintsch
python.org/doc/faq/installed/ http://effbot.org/pyfaq/installed-why-is-python-installed-on-my-machine.htm Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WHAT IS THIS?

2007-02-17 Thread Marc 'BlackJack' Rintsch
preinstalled by the vendor of that machine. A good advice about installing an uninstalling software is: If you don't know what it does and… 1. …it is not installed then don't install it. 2. …it is installed then don't uninstall it. Or things may break. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WHAT IS THIS?

2007-02-17 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, James Stroud wrote: > Better would be to remove windows xp and get another operating system. Yeah XP is sooo ooold, the OP should install Vista. Or did you mean a real OS instead of just another one? ;-) SCNR, Marc 'BlackJack' Rintsch -- htt

Re: Rational numbers

2007-02-23 Thread Marc 'BlackJack' Rintsch
ng library I would not expect changes to that package. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding non ascii characters in a set of files

2007-02-23 Thread Marc 'BlackJack' Rintsch
es `i` come from? And there's no need to read the file twice. Untested: import os, sys, codecs def checkfile(filename): f = codecs.open(filename,encoding='ascii') try: for num, line in enumerate(f): pass except UnicodeError: print &#

Re: select which lib for iNet?

2007-02-25 Thread Marc 'BlackJack' Rintsch
e Qt APIs. As Python also has APIs for such things that work cross platform it might be better to use those, because you can separate GUI and logic better. It's hard to replace the Qt libraries with a Gtk, wxPython or web GUI if you still need Qt for networking or database access. Ciao,

Re: RegExp performance?

2007-02-25 Thread Marc 'BlackJack' Rintsch
racters that you are not interested in anyway. Then leave off the '*' after '\D'. It doesn't matter if there are multiple non-digits before or after the ISBN, there just have to be at least one. BTW with the star it even matches *no* non-digit too! So the re looks like this: '\D(\d{10}|\d{9}X)\D' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use cmp() function to compare 2 files?

2007-02-26 Thread Marc 'BlackJack' Rintsch
d the docs about the `shallow` argument of that function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: classobj?

2007-02-26 Thread Marc 'BlackJack' Rintsch
als()` is a dictionary too, but it is more work to get an object by name from it (globals()['SomeClass'] vs. some_dict['SomeClass']) and you don't risk that some of your dynamically created classes overwrites an existing one with the same name. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: class declaration shortcut

2007-03-01 Thread Marc 'BlackJack' Rintsch
? As objects don't know to which name they are bound, that's a good way to give some information in stack traces or when doing introspection. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: class declaration shortcut

2007-03-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Bjoern Schliessmann wrote: > Michele Simionato wrote: >> On Mar 1, 9:40 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> >>> In <[EMAIL PROTECTED]>, Bjoern Schliessmann > >>>> But what's it (__name__) go

Re: xml minidom redundant children??

2007-03-01 Thread Marc 'BlackJack' Rintsch
*** > > My question is why this or #text has been > created and how to get rid of them by changing python code? (here I'm > not interested to change xml file.) They have been created because the text is in the XML source. Line breaks are valid text. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Unpacking problem

2007-03-01 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Chris Garland wrote: > But an unsigned char & a short give me this unpack('Bh','\x90\x06\x00') > Traceback (most recent call last): > File "", line 1, in ? > struct.error: unpack str size does not match format Let's pack this: In [90]: pack('Bh', 0x90, 0x6) Out[90]

Re: html sql client

2007-03-01 Thread Marc 'BlackJack' Rintsch
Are you searching for the `description` attribute of cursors? Section `Cursor Objects`: http://www.python.org/dev/peps/pep-0249/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: modify a file

2007-11-04 Thread Marc 'BlackJack' Rintsch
a 3.5G file that may be broken. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to filter files by creation date

2007-11-06 Thread Marc 'BlackJack' Rintsch
one that I receive from the 'datetime.date.today()'. Build a `datetime.date` object from the timestamp you get from the stat call: In [438]: !touch test.py In [439]: datetime.date.fromtimestamp(os.stat('/home/bj/test.py').st_ctime) Out[439]: datetime.date(2007, 11, 6)

Re: how to filter files by creation date

2007-11-06 Thread Marc 'BlackJack' Rintsch
On Tue, 06 Nov 2007 01:45:02 -0800, awel wrote: > On 6 nov, 09:00, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Mon, 05 Nov 2007 23:33:16 -0800, awel wrote: >> > I am trying to to make a script to move all the files that has been >> >

Re: how to filter files by creation date

2007-11-06 Thread Marc 'BlackJack' Rintsch
; > Could you explain a little more because I am new in scripting? >> >> Not really. I showed you the call I made and the result I got. How can I >> be more clear and precise!? > > Ok but I run in Windows and I cannot understand your '!touch test.py' Ah, sorry t

Re: Insane crazy question - printing commands

2007-11-06 Thread Marc 'BlackJack' Rintsch
in a module named `inspect.py` that is definitely not the one from the standard libarary. If that module has an ``import inspect`` it imports *itself*! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Deep comparison of sets?

2007-11-07 Thread Marc 'BlackJack' Rintsch
return cmp(self.value, other.value) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: os.popen does not seem to catch stdout

2007-11-07 Thread Marc 'BlackJack' Rintsch
On Wed, 07 Nov 2007 18:35:51 +, kyosohma wrote: > I've never had to put the command into a list or tuple...but you're > welcome to try it that way. You don't *have* to but if you do the module takes care of quoting the arguments if necessary. Ciao, Marc 'B

Re: operator overloading on built-ins

2007-11-08 Thread Marc 'BlackJack' Rintsch
On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote: >>>> (1).__cmp__(10) > -1 As the dot is an operator like ``+`` or ``/`` you can also add spaces to avoid the ambiguity: In [493]: 1 . __cmp__(10) Out[493]: -1 In [494]: 1 .__cmp__(10) Out[494]: -1 Ciao, Marc 

Re: parallel csv-file processing

2007-11-09 Thread Marc 'BlackJack' Rintsch
On Fri, 09 Nov 2007 02:51:10 -0800, Michel Albert wrote: > Obviously this won't work as you cannot access a slice of a csv-file. > Would it be possible to subclass the csv.reader class in a way that > you can somewhat efficiently access a slice? An arbitrary slice? I guess not as all records bef

Re: [OT] Stupid email disclaimers

2007-11-09 Thread Marc 'BlackJack' Rintsch
der ? And if so, how could > I *then* notify her ?-) Ask a medium? Use a crystal ball for the very long distance call? Call Dr. Frankenstein for help? =:o) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Marc 'BlackJack' Rintsch
. > Specifically, the language in which I am most productive. They are not thought out. You just ripped an aspect from that other language and threw it into a Python environment. This doesn't mean it will fit into the language or scales beyond the small toy examples. What about functi

Re: Global variables within classes.

2007-11-10 Thread Marc 'BlackJack' Rintsch
nd setBlah for every little thing? Good $GOD no! He's talking about the `__get__` method on properties. Read the docs for the built in `property()` function. It's a nice mechanism to actually avoid all those getters and setters because you can turn "simple" attributes into "computed" attributes without changing the API of the objects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: String/Decimal issues

2007-11-10 Thread Marc 'BlackJack' Rintsch
mbers that you are adding and not strings or something!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Global variables within classes.

2007-11-10 Thread Marc 'BlackJack' Rintsch
s namespace and on the right are the objects in memory. From the `Test` objects there's also a reference to the `class` that's bound to the name `Test` in the Module that is not shown in the "drawing" but necessary to look up attributes in the class of the instances. > T

Re: Coding Help

2007-11-10 Thread Marc 'BlackJack' Rintsch
] ││ >│ │ [S2] [S3] └┬┘│ >│ │││┌─< C4 >─┐│ >│ │││ [S4] ││ >│ │││└───┬┘│ >│ └───┬┴┴┘ │ >│ [S5] │ >│ └───

Re: Global variables within classes.

2007-11-10 Thread Marc 'BlackJack' Rintsch
On Sat, 10 Nov 2007 17:39:04 +, Marc 'BlackJack' Rintsch wrote: > On Sat, 10 Nov 2007 18:53:08 +0200, Donn Ingle wrote: >>>> print b.ref.attribute # print "haschanged" >>>> >>>> print j.ref.attribute #prints "original

Re: Populating a dictionary, fast

2007-11-11 Thread Marc 'BlackJack' Rintsch
{} > for line in open('keys.txt'): > v[long(line.strip())] = True Takes about 40 seconds here. [EMAIL PROTECTED]:~$ time python test.py real0m38.758s user0m25.290s sys 0m1.580s Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: how to know if folder contents have changed

2007-11-11 Thread Marc 'BlackJack' Rintsch
erations to easily find out the differences between two set of names and the `pickle` module to store Python objects in files. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python as primary language

2007-11-12 Thread Marc 'BlackJack' Rintsch
tion between processes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: regex that is equivalent to perl's syntax

2007-11-12 Thread Marc 'BlackJack' Rintsch
#x27;s > equivalent to the following perl's search string? > m/^\S{1,8}\.\S{0,3}/ It is ``re.match(r'\S{1,8}\.\S{0,3}', string)``. There's something called "documentation"… Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: reading file objects in chunks

2007-11-12 Thread Marc 'BlackJack' Rintsch
f.read(chunksize) > > I just don't feel comfortable with it for some reason I can't explain... chunksize = 26 f = open('datafile.dat', 'rb') for chunk in iter(lambda: f.read(chunksize), ''): compute_data(chunk) f.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: referencing a subhash for generalized ngram counting

2007-11-13 Thread Marc 'BlackJack' Rintsch
ct. Changing the dictionary bound to `h` changes it:: h = orig['ca'] h['adanac'] = 69 > Yet since names are not exactly references, something else is needed > for generalized ngram multi-level counting hash -- what? Names *are* implemented as references to objects, but binding the name to a different object has no effect on the object bound to that name before. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Python To Change The World :)

2007-11-14 Thread Marc 'BlackJack' Rintsch
gt; Of course if you want to have more or less realistic imaging for whatever > purpose, 3D is the way to go. If you are after traffic-simulations, it's > unneeded complexity. Not if their solution includes flying buses and taxis. Or this pneumatic delivery system for people from `Fut

Re: list of class initiations ?

2007-11-16 Thread Marc 'BlackJack' Rintsch
o build something with those functions. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding lowest value in dictionary of objects, how?

2007-11-19 Thread Marc 'BlackJack' Rintsch
gt; > This one returns the lowest value Object, but not the lowest value of > age in all the Objects of the table. In the example `min()` finds the object with the lowest `id()`. To change that you can implement the `__cmp__()` method on your `Block` objects. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: pydoc - how to generate documentation for an entire package?

2007-11-19 Thread Marc 'BlackJack' Rintsch
On Mon, 19 Nov 2007 10:50:28 -0800, Jens wrote: > Generating documentation form code is a nice thing, but this pydoc.py > is driving me insane - isn't there are better way? Epydoc!? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Problem?

2007-11-19 Thread Marc 'BlackJack' Rintsch
UpKey(self,event): > self.canv.move(tagOrId,xAmount=0,yAmount=10) Where's `tagOrId` coming from? That's a `NameError` here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add a Decorator to a Class Method

2007-11-19 Thread Marc 'BlackJack' Rintsch
rgs) return new_func class A(object): @pre def func(self, a, b): print a + b a = A() a.func(3, 5) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why it is invalid syntax?

2007-11-21 Thread Marc 'BlackJack' Rintsch
which ``if`` does the ``else`` belong to here? :: if 1: print 1 if: 1 print 1 else: print 1 Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: foldr function in Python

2007-11-23 Thread Marc 'BlackJack' Rintsch
ic" way to define `comma_separate()` is:: comma_separate = ','.join Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I convert escaped HTML into a string?

2007-11-23 Thread Marc 'BlackJack' Rintsch
ook like if whitespace is preserved. What matters is the actual text in the source, not the formatting. That's left to the browser. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-23 Thread Marc 'BlackJack' Rintsch
> expands to > > def abs(self): > x, y, z = self.__unpack__("x","y","z") > return math.sqrt(x**2 + y**2 + z**2) What about ``from`` instead of ``by``? That's already a keyword so we don't have to add a new one. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-24 Thread Marc 'BlackJack' Rintsch
a record definition to make that decision. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-24 Thread Marc 'BlackJack' Rintsch
> dog = 'rover' > def example(): > global cat, dog # not always required, but frequently needed > return ', '.join((cat, dog)) Ouch that's bad design IMHO. The need to use ``global`` is a design smell, if needed *frequently* it starts to stink. Ciao, M

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-24 Thread Marc 'BlackJack' Rintsch
erhaps there is a Python > Elder here that knows? AFAIK strings of length 1 and strings that would be valid Python identifiers are treated this way. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: the annoying, verbose self

2007-11-24 Thread Marc 'BlackJack' Rintsch
On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote: > On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote: >> > I've had the same thought, along with another. You see, on of my pet

<    7   8   9   10   11   12   13   14   15   16   >