Re: how do you get the name of a dictionary?

2006-08-22 Thread Marc 'BlackJack' Rintsch
u want to special case dictionaries? If Python is doing it for dictionaries, sooner or later someone will ask for the names of lists or any arbitrary object. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: swapping numeric items in a list

2006-08-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jiang Nutao wrote: > To convert list > aa = [0x12, 0x34, 0x56, 0x78] > into > [0x34, 0x12, 0x78, 0x56] > > How to do it fast? My real list is huge. Use the `array` module and the `array.byteswap()` method. Ciao, Marc 

Re: How to download a web page just like a web browser do ?

2006-08-23 Thread Marc 'BlackJack' Rintsch
all pages in the page , and > modify all the links to conrespond local disk links and ... Why don't you just use the `wget` program. Not written in Python but much easier to use instead of writing the functionality yourself. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do this?

2006-10-05 Thread Marc 'BlackJack' Rintsch
to strings. The equivalent to the second example without string formatting would be:: print 'There are' + str(number) + ' ways to skin a ' + str(furryanimal) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Python component model

2006-10-09 Thread Marc 'BlackJack' Rintsch
most of it. Python itself is a RAD tool. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: what is this UnicodeDecodeError:....?

2006-10-10 Thread Marc 'BlackJack' Rintsch
compare a unicode string `val` with a byte string in the list. The unicode string will be converted to a byte string for this comparison with the default encoding: ASCII. But 'ó' is not contained in ASCII. > Can any one please tell me why is this error, and how to get rid of > this error. Because I have some files which containing some more > special characters. Either use an unicode string in the list search too or explicitly encode the unicode string `val` with the appropriate encoding before using it to search the list. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: what is this UnicodeDecodeError:....?

2006-10-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, John Machin wrote: > Marc 'BlackJack' Rintsch wrote: > >> Because you are trying to compare a unicode string `val` with a byte >> string in the list. The unicode string will be converted to a byte string >> for this com

Re: dicts + amb

2006-10-11 Thread Marc 'BlackJack' Rintsch
d__()` method that returns an iterator. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: A friendlier, sugarier lambda -- a proposal for Ruby-like blocks in python

2006-10-14 Thread Marc 'BlackJack' Rintsch
ancy formatting %s" \ > ... )) > > This works syntactically. It works just fine without the trailing backslash. A "logical line" does not end until all opened parenthesis and brackets are matched by their closing counterpart. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Making a shorter shebang

2006-10-14 Thread Marc 'BlackJack' Rintsch
g into your account. CGI scripts are executed by the web server which usually has its own user and group, `wwwrun` or something like that, and does not read the `.profile` in your home directory. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to find pydoc?

2006-10-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Wijaya Edward wrote: > > I tried to call pydoc from my Linux box. > To my realization that it doesn't contain > pydoc. > > I thought this module should be a default module. Yes it is part of the standard library. What distribution are y

Re: loop iterators?

2006-10-17 Thread Marc 'BlackJack' Rintsch
t; Is there a way to get rid of the i processing in this script? for i, e in enumerate(l): print i, e Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Faulty encoding settings

2006-10-17 Thread Marc 'BlackJack' Rintsch
is quite fragile. If you redirect stdin or stdout the encoding is set to None for example because the interpreter can't tell what encoding the "other side" of the redirection produces or expects. BTW the US-ASCII isn't wrong but just limiting as everything in the ASCII range is the same in ISO-8859-1. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: I would like write some data recovery software

2006-10-17 Thread Marc 'BlackJack' Rintsch
> Yes, OK I guess NTFS would be of most interest to me. Then you'll have a hard time because NTFS specs are not available for free. Just reverse engineered stuff. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: creating many similar properties

2006-10-17 Thread Marc 'BlackJack' Rintsch
ary of names mapped to values and another that maps the names to default values for the modulo operation. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: characters in python

2006-10-18 Thread Marc 'BlackJack' Rintsch
252/Untitled-1_copy.png.html Do you want to change the characters in a picture!? Your question still is *very* vague. Please provide a more detailed description of the problem at hand. What do you have? A text file? In which encoding? And what do you want to achieve? Ciao, Marc &#

Re: Getting method name from within the class method

2006-10-18 Thread Marc 'BlackJack' Rintsch
complain that you have to type and probably change 'a_method' twice instead of once. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: UTF-8 to unicode or latin-1 (and yes, I read the FAQ)

2006-10-19 Thread Marc 'BlackJack' Rintsch
onsole encoding (sys.stdout.encoding) is > ignored. Nope, it is not ignored. This would not work then:: In [2]: print 'K\xc3\xb6nig'.decode('utf-8') König In [3]: import sys In [4]: sys.getdefaultencoding() Out[4]: 'ascii' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: BeautifulSoup problem

2006-10-20 Thread Marc 'BlackJack' Rintsch
27;span', {'class': 'nametext'}).contents Out[12]: [u'Hello'] Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: why does this unpacking work

2006-10-20 Thread Marc 'BlackJack' Rintsch
#x27;San Francisco' >> print state >> # 'California' > > Yes, I understand that. What confused me was if it had been written like > this: > > pair = (("California","San Francisco")) Uhm, you mean:: pair = (("California",&qu

Re: How to print a file in binary mode

2006-10-22 Thread Marc 'BlackJack' Rintsch
? If you use ``print repr(bytes)`` everything outside ASCII will be printed as escape sequence. But why do you want to "print" JPEG images anyway? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print a file in binary mode

2006-10-22 Thread Marc 'BlackJack' Rintsch
ile is not too big it's better to load it into memory completely. And if you need the byte value of every single byte you should read the file into an `array.array()` of type 'B'. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: implementation of "in" that returns the object.

2006-10-22 Thread Marc 'BlackJack' Rintsch
t; ... for i in listObj: > ... if i is value: > ... return value > ... return False > ... def my_in(value, sequence): if value in sequence: return value else: return False Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing Unicode and string

2006-10-23 Thread Marc 'BlackJack' Rintsch
e strings* and bytes have values in the range 0..255. Why would you restrict them to ASCII only? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: encoding of sys.argv ?

2006-10-23 Thread Marc 'BlackJack' Rintsch
nd there's no standard way to find out which it was. The `sys.stdin.encoding` approach isn't very robust because this will only be set if the interpreter can find out what encoding is used on `stdin`. That's impossible if the `stdin` is the input from another file. Make it explici

Re: forcing a definition to be called on attribute change

2006-10-24 Thread Marc 'BlackJack' Rintsch
ame here but prefixing names with "type information" is "unpythonic" too, again IMHO, because this can get very misleading if you change the type. Then you have to change all occurrences of the name or end up with names like `lstObj` bound to a set object or something similar. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem Commenting within Filehandle Iteration

2006-10-26 Thread Marc 'BlackJack' Rintsch
myfile.close(), with identation error. > This error doesn't occur when commenting (#) is not in use. > > Why so? Is there away to do the commenting in correct way > under this circumstances? There has to be code in the ``else`` block. So either comment out the ``else`` line too,

Re: python html 2 image (png)

2006-10-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote: > Whatever lunix is, […] An operating system for the Commodore 64. `LUnix NG` Website: http://lng.sourceforge.net/ :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Search & Replace

2006-10-26 Thread Marc 'BlackJack' Rintsch
w") text = text.replace("Left_RefAddr", "FromLeft") text = text.replace("Left_NonRefAddr", "ToLeft") # ... file.write(text) file.close() Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: importing class

2006-10-27 Thread Marc 'BlackJack' Rintsch
ement to your file: from Tkinter import Frame, Button You use `Button` too and this also lives in the `Tkinter` module. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Telnetlib to twisted

2006-10-27 Thread Marc 'BlackJack' Rintsch
;m not listed in the headers. This is irrelevant because the whole paragraph is about emails and not about newsgroup postings. ;-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: question about True values

2006-10-28 Thread Marc 'BlackJack' Rintsch
iterators. > >>>> it = iter([0]) >>>> bool(it) > True >>>> it.next() > 0 >>>> bool(it) > False It works for *this* iterator. By accident. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Where do nested functions live?

2006-10-28 Thread Marc 'BlackJack' Rintsch
the outer one and on those objects it is possible to inspect and read the docs. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: scared about refrences...

2006-10-30 Thread Marc 'BlackJack' Rintsch
ontain other object that may contain other > objects See the `copy` module especially `copy.deepcopy()`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: string formatter for tuple

2006-11-02 Thread Marc 'BlackJack' Rintsch
ppens, a is actually 3 elements when the print > statement is only expecting to print one value. I tried > > print "a = %s" %(a) > > but I got the same error. > > How can I print a tuple with a single string format? Put the tuple in a tuple: print 'a = %s" % (a

Re: creating new objects with references to them

2006-11-02 Thread Marc 'BlackJack' Rintsch
third instance has been created? Put your objects into a list. Each time the user presses the `New` Button append a new researcher object to it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WSDL?

2006-11-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, tobiah wrote: > What else is available for sharing complex structures > with processes running programs that were written in > other languages? Corba? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WSDL?

2006-11-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jorge Vargas wrote: > and please please don't go to corba we need to kill that. Have you real reasons or is this a religious thing? As I see it Corba is much better supported by Python libs than SOAP is. Ciao, Marc 'BlackJack' Rintsch --

Re: py2exe questions

2006-11-04 Thread Marc 'BlackJack' Rintsch
d to run from memory without a real file backing it on some platforms. A pure Python program/package should be possible without temporary files. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: elementtree terminology + tangential questions

2006-11-04 Thread Marc 'BlackJack' Rintsch
. :: This is an example of "tail text" in XHTML. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: WSDL?

2006-11-05 Thread Marc 'BlackJack' Rintsch
rd "webservice" was yet to be invented. A huge part of the SOAP popularity comes from marketing and shoving down the buzzwords "webservices" and "XML" down everyone's throat and has nothing to do with technical advantages or disadvantages. Well, IMHO at least.

Re: Python Distilled

2006-11-06 Thread Marc 'BlackJack' Rintsch
E Traceback (most recent call last): File "", line 1, in TypeError: exceptions must be classes, instances, or strings (deprecated), not type Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: please help with optimisation of this code - update of given table according to another table

2006-11-08 Thread Marc 'BlackJack' Rintsch
get_key(row)) if row_to_be_updated is not None: for column in columns_to_be_updated: row_to_be_updated[column] = row[column] def main(): table_a = [[1, 4, 5, 7, 7], [3, 4, 0, 0, 0]] table_b = [[2, 2, 8, 8, 8], [1, 4, 9, 9, 9]] update_table(table_a, table_b, (0, 1), (2, 4)) for row in table_a: print row Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, skip wrote: > > Irmen> So there. Finally back on the original subject ;-) > > And without satisfying Godwin's Law. Pretty good. Which was very hard with all those language nazis out there. Ooops… SCNR, Marc 'BlackJack'

Re: Sorted list - how to change it

2006-11-09 Thread Marc 'BlackJack' Rintsch
uffle(lst) If you *really* want to be sure it's not sorted after shuffling. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorted list - how to change it

2006-11-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch wrote: > lst = [1, 2, 3, 4, 5] > tmp = list(lst) > while lst == tmp: > random.shuffle(lst) Argh, that fails if the list is empty or contains just one item. lst = [1, 2, 3, 4, 5] if len(lst) > 1: tmp =

Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Marc 'BlackJack' Rintsch
t() > I think the colon could be omitted from every type of compound > statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything? I would miss auto-indenting in my editor to which the colon at the line end is an important clue. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Having problems with urlparser concatenation

2006-11-09 Thread Marc 'BlackJack' Rintsch
you'll see there's a function `open_local_file()` involved. This function is chosen by `urllib` because your path looks like a local file, i.e. it lacks the protocol information. You don't want 'en.wikipedia.org/robots.txt', you want 'http://en.wikipedia.org/robots.txt'! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: SyntaxError: Invalid Syntax.

2006-11-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, ronrsr wrote: > def connect(): > > >return = MySQLdb.connect (host = "db91x..com", ^ You can't assign to a keyword. Just leave this ``=`` out. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: newbee I have an object how to check what's his class?

2006-11-10 Thread Marc 'BlackJack' Rintsch
lt: > isinstance(x,X) > False > type(x) is X > False > > list Define "doesn't work". Obviously lists are not instances of your `X` class. So where's the problem? What did you expect and why? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Marc 'BlackJack' Rintsch
language supports the serial 'or' (and >> 'and') and looks just like that. > > Python also supports it. No it doesn't -- look again at the example given above. It's legal syntax in Python but doesn't have the semantics implied by the example. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing database output in tabular form

2006-11-13 Thread Marc 'BlackJack' Rintsch
TML control chars. Look up the `tostring()` method on `array.array` objects and `str.replace()` for replacing the line ends by ''. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: to setattr or def setProp()

2006-11-13 Thread Marc 'BlackJack' Rintsch
roperties directly from the instances. I can either def > __setattr__ , __getattr__ or I can define function for each property > like setWidth(), setHeight() . Or you can use `property()` to create "computed attributes". Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Heap Memory

2006-11-16 Thread Marc 'BlackJack' Rintsch
u have. And with 2 GiB and 40 objects you have about 5 KiB per object. If you pickle that huge list there has to be enough memory to hold the pickled data in memory before it is written to disk. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: C extensions and memory leakage

2006-11-17 Thread Marc 'BlackJack' Rintsch
rom another person. What do you mean by "C wrapper"? You know that Python uses reference counters to manage memory and that you are responsible for these counters if you are dealing with Python objects in your C extension? Ciao, Marc 'BlackJack' Rintsch -- http://m

Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

2006-11-17 Thread Marc 'BlackJack' Rintsch
r(path) except UnicodeError, e: files = os.listdir(path.encode(sys.getfilesystemencoding())) # Decode and filter the list "manually" here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Need C# Coding for MD5 Algorithm...

2006-05-29 Thread Marc 'BlackJack' Rintsch
ed to implement your own. You can get an MD5 `HashAlgorithm` object this way:: HashAlgorithm algorithm = HashAlgorithm.Create("MD5"); Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: About Threading - implementation

2006-06-14 Thread Marc 'BlackJack' Rintsch
.e. many threads waiting for blocking IO then just use Python threads. If your task is computational intensive then it may be better to use processes and some form of inter process communication. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: determining file type

2006-06-14 Thread Marc 'BlackJack' Rintsch
]: In [6]:file = 'foo.txt' In [7]:file Out[7]:'foo.txt' In [8]:file('x') --- exceptions.TypeError Traceback (most recent call last) /home/bj/ TypeError: 'str' obje

Re: python and HDF

2006-06-15 Thread Marc 'BlackJack' Rintsch
Python? Which C library/wrapper do you use? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: list of polynomial functions

2006-06-15 Thread Marc 'BlackJack' Rintsch
olys.append(lambda x: polys[i](x)*x) The `i` is the problem. It's not evaluated when the lambda *definition* is executed but when the lambda function is called. And then `i` is always == `n`. You have to explicitly bind it as default value in the lambda definition: polys.append(

Re: list of polynomial functions

2006-06-16 Thread Marc 'BlackJack' Rintsch
f` is called. That's a problem if you create more than one function in `outer` and use a name from outer's locals that changes: In [7]:def pitfall(): .7.:functions = list() .7.:for i in range(3): .7.:functions.append(lambda: i) .7.:print 'pitfall: i=%d' % i .7.:return functions .7.: In [8]:for function in pitfall(): .8.:print function() .8.: pitfall: i=2 2 2 2 At the time the list with the functions is returned `i` is 2. So if you call any of the functions it looks up this `i`. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Pycrypto

2006-06-16 Thread Marc 'BlackJack' Rintsch
int('76',16))+chr(int('d3',16))+chr(int('12',16))+chr(int('26',16))+chr(int('a1',16))+chr(int('e3',16))+chr(int('ba',16))+chr(int('b0',16))) > testo = str(testo) > c = crypt.encrypt(testo) > > I don't know if this is the best way , but anyway it work In [26]:import binascii In [27]:binascii.unhexlify('ea523a664dabaa4476d31226a1e3bab0') Out[27]:'\xeaR:fM\xab\xaaDv\xd3\x12&\xa1\xe3\xba\xb0' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Date Subtraction

2006-06-16 Thread Marc 'BlackJack' Rintsch
e2 datatype is > string which need to be conerted into date fromat which i am not able > to do so please help me. from datetime import date date_str_1 = '2006-01-10' date_str_2 = '2005-12-15' date_1 = date(*map(int, date_str_1.split('-'))) date_2 = date(

Re: add elements to indexed list locations

2006-06-17 Thread Marc 'BlackJack' Rintsch
#x27;peter', 'parker'], ['bruce', 'wayne']] for name, surname in fullnames: name2hero[name].append(surname) for hero in heroes: print 'Hello %s a.k.a %s %s' % tuple(hero) IMHO you shouldn't try to program C++ in Python. Take a step back and describe *what* you want to achieve and not *how* you do it in another language. And then implement it in Python. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Date Subtraction

2006-06-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >>In <[EMAIL PROTECTED]>, >>rsutradhar_python wrote: >>> date1="2006-01-10" >>>

Re: Extracting values from text file

2006-06-18 Thread Marc 'BlackJack' Rintsch
Explicit is better than implicit. In the face of ambiguity, refuse the temptation to guess. And don't mix up weakly and dynamically typed. Python is dynamically and strictly typed. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: crawlers in python with graphing?

2006-06-19 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bryan rasmussen wrote: > It should hopefully be as high level as Wget, not download the pages > but just follow the links, and output graphs. How do you get at the links without downloading the page!? Ciao, Marc 'BlackJack' Rintsch --

Re: memory-leak in pysqlite 2.3.0 ?

2006-06-19 Thread Marc 'BlackJack' Rintsch
gt; import os > from pysqlite2 import dbapi2 > print dbapi2.version > > db = dbapi2.connect("bla.db") > c = db.cursor() > > c.execute("create table b (c integer)") > > for i in xrange(1000): > c.execute("insert into b values (%d)"

Re: pyfcp

2006-06-19 Thread Marc 'BlackJack' Rintsch
.nz/pyfcp I get: Unknown host www.python.org.nz Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding a function...

2006-06-19 Thread Marc 'BlackJack' Rintsch
t `fix` it. Importing an already imported module doesn't reload the module. > 2) Once I assign mymodule.test with override, will modules that > imported my module *PRIOR* to the assignment get override, or will they > keep the original function test()? They see the `override()` f

Re: help() on stdout.closed

2006-06-21 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Pekka Karjalainen wrote: > Suppose I had no idea what sys.stdout.closed was and wanted to find out. > Where would I look it up? `sys.stdout` is a file (like) object: http://docs.python.org/lib/bltin-file-objects.html Ciao, Marc 'BlackJack&

Re: Program slowing down with greater memory use

2006-06-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Dan Stromberg wrote: > What's the deal here? Very hard to tell without more details. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: re question

2006-06-23 Thread Marc 'BlackJack' Rintsch
t at 0x405b15f8> I have copy and pasted you code. For debugging re's in Python you might take a look at http://kodos.sourceforge.net/ Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Opening a file with system default application

2006-06-23 Thread Marc 'BlackJack' Rintsch
OS thing but a a GUI thing. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: handling unicode data

2006-06-28 Thread Marc 'BlackJack' Rintsch
ut the ``print`` because printing unicode strings means they have to be encoded into a byte string again. And whatever encoding the target of the print (your console) uses, it does not contain the unicode character u'\xd8'. From the traceback it seems your terminal uses `cp4

Re: how do i make an array global

2006-06-29 Thread Marc 'BlackJack' Rintsch
ot exist:: In [1]: a = [1, 2, 3] In [2]: a[0] Out[2]: 1 In [3]: a[1] Out[3]: 2 In [4]: a[2] Out[4]: 3 In [5]: a[3] - exceptions.IndexErrorTraceback (most recent call last) /home/marc/ IndexError: list index out of range So from the

Re: problems with mimify.mime_encode_header

2006-06-29 Thread Marc 'BlackJack' Rintsch
D1=82=D0=B5=D1=81=D1=82?= а. > > Please note that the last character (before dot) is not quoted, and > resulting string is not 8bit clean. Why should a simple ASCII 'a' be quoted? And what do you mean by "not 8bit clean"? The string is even 7-bit clean! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: inline metaclasses

2006-07-03 Thread Marc 'BlackJack' Rintsch
return type(name, bases, dict) > ... > hello >>>> > > instead of defining a separate metaclass function/class, you can do > it inline. isn't that cool? But why use a metaclass? If the meta class is only applied to *one* class, can't you do at class level

Re: How can I access the 'Entry' string in another function?

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, arvind wrote: > i've created the myclass instance and calles the "function second()". > i want to access the text entered in 'w' through Entry widget in > "function third()" > i am getting the 'fuction not having 'w' attribute error. > how to overcome it? Make `w` an attri

RE: ascii character - removing chars from string update

2006-07-03 Thread Marc 'BlackJack' Rintsch
uot; with a ''. in html, the > ' ' char is not a valid ascii char... > > in perl, i'd do 's / //' and be done with it!!! And in Python I'd use the `replace()` method on strings and be done with it!!! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: converting file formats to txt

2006-07-03 Thread Marc 'BlackJack' Rintsch
eformats'? A script that automagically converts *anything* to text? What about pictures? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, K.S.Sreeram wrote: > Marc 'BlackJack' Rintsch wrote: >> But why use a metaclass? If the meta class is only applied to *one* >> class, can't you do at class level whatever the metaclass is doing!? > > The very fact that you

Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
and 'b'. > > btw, the example seems to work even with old-style classes. Yes, but setting properties works only with new-style classes. So I use them whenever I use properties. In my mind properties and new-style classes are linked together. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: regex module, or don't work as expected

2006-07-04 Thread Marc 'BlackJack' Rintsch
iface lo[\w\t\n\s]+?(?=(iface)|$) Now only "iface lox " is matched in the example above. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: python - regex handling

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bruce wrote: > does python provide regex handling similar to perl. can't find anything in > the docs i've seen to indicate it does... The `re` module handles Perl compatible regexes. Ciao, Marc 'BlackJack' Rintsch -- http://

Re: compressed file ended before the logical end-of-stream was detected

2006-07-05 Thread Marc 'BlackJack' Rintsch
nt to catch the `ImportError`\s. If you stop the program anyway this leads to much less cluttered source code. And it maybe would make sense to print the actual catched `IOError`\s too because it may be a valueable information for the user *why* it failed. For example because he has no rights or the file system is full. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Very practical question

2006-07-05 Thread Marc 'BlackJack' Rintsch
C(object): def __init__(self): self.a=A() self.b=B() def c(self): self.b.interClassCall(self) Much less magic involved this way. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter and dialogs

2006-07-06 Thread Marc 'BlackJack' Rintsch
to do? The main loop isn't running yet. If you just call `show_ui()` you should get some windows. The ``global`` is unnecessary by the way. It even generates a warning: test.py:0: SyntaxWarning: name 'root' is assigned to before global declaration Ciao, Marc &#x

Re: Perl Dictionary Convert

2006-07-06 Thread Marc 'BlackJack' Rintsch
ary << Dict(OPEN_BRACE + OneOrMore(item) + CLOSE_BRACE) result = dictionary.parseString(source) print result['Contacts']['Class'] Output is: IPF.Contact Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: use var to form name of object

2006-07-06 Thread Marc 'BlackJack' Rintsch
def wow(self, n): return k + n f = Foo() k = f.wow(55) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Countdown timer for different timezones

2006-07-06 Thread Marc 'BlackJack' Rintsch
able way to get the time zone information from the viewer of the website with just HTTP. So you need a JavaScript solution I guess. Send the end time as UTC time to the browser an use JavaScript's `Date` object to display the countdown in local time. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: setting variables from a tuple NEWB

2006-07-06 Thread Marc 'BlackJack' Rintsch
ONS > 'bcdfgh' >>>> Little warning: It works only on module level as assigning to `locals()` return value in functions and methods has no effect on the "real" locals. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: looping question 4 NEWB

2006-07-06 Thread Marc 'BlackJack' Rintsch
nto data until there's a match and the the `replace()` starts again from the start and searches/replaces through the whole data. You can get rid of the indexes and make the code a bit clearer by the way: for old, new in find: data = data.replace(old, new) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: some questions on how to study the bittorent.

2006-07-08 Thread Marc 'BlackJack' Rintsch
www.bittorrent.org/protocol.html .. _BitTorrent Economics Paper: http://www.bittorrent.com/bittorrentecon.pdf Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: multithreading and shared dictionary

2006-07-08 Thread Marc 'BlackJack' Rintsch
nt the GIL be locked when the rehash occurs? If there is a GIL then maybe yes. But the GIL is an implementation detail. It's not in Jython nor IronPython and maybe not forever in CPython. Don't know about PyPy. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good idea or a waste of time?

2006-08-24 Thread Marc 'BlackJack' Rintsch
ally the Python way I'd say. What if `c` is of type `long` for instance? Your code would stop with an assertion error for a value that should work. Strict type checking prevents "duck typing" which is a quite fundamental concept in Python. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: get a line of text from a socket...

2006-08-25 Thread Marc 'BlackJack' Rintsch
m a bit complicated for a simple line oriented input... This is already done in the `asyncore` and `asynchat` modules of the standard library. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Open Office and Python

2006-08-26 Thread Marc 'BlackJack' Rintsch
module from the standard library? Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Marc 'BlackJack' Rintsch
gt; IOError: [Errno 2] No such file or directory: 'veryBigFile.dat' > > Is it a BUG or a FEATURE? It's the error number Windows returns for that operation. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

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