[ANN] PyGtkImageView 1.1.0 -- Image viewer widget for PyGTK

2008-03-13 Thread BJörn Lindqvist
I'm pleased to finally announce PyGtkImageView 1.1.0! Description --- GtkImageView is a simple image viewer widget for GTK+. Similar to the image viewer panes in gThumb or Eye of Gnome. It makes writing image viewing and editing applications easy. Among its features are: * Mouse and

[ANN] PyGtkImageView 1.2.0 -- Image viewer widget for PyGTK

2009-04-05 Thread BJörn Lindqvist
I'm pleased to finally announce PyGtkImageView 1.2.0! Description --- GtkImageView is a simple image viewer widget for GTK+. Similar to the image viewer panes in gThumb or Eye of Gnome. It makes writing image viewing and editing applications easy. Among its features are: * Mouse and

Re: Refactoring; arbitrary expression in lists

2005-01-13 Thread BJörn Lindqvist
# do other non-extension-related tests here if basename.find( Makefile ) != -1: return text/x-makefile I believe this can be nicelier written as: if Makefile in basename: -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: search engine

2005-01-30 Thread BJörn Lindqvist
hi all, i´m doing a search engine using python for the spider and php to make a web for the search. The Database i have choosen is postgreSQL. Do you think it is a good choosen? Any suggestion? Databases are implementation details! Considering the database should be deferred as long as

Re: About standard library improvement

2005-02-03 Thread BJörn Lindqvist
The process seem slow. I've submitted two patches and haven't gotten any response so far, but it has only been three weeks. Other patches seem to be idling for months. I'm not complaining, just want to know why the process is so slow and what you can do when you submit patches/bug reports to speed

Re: Alternative to standard C for

2005-02-05 Thread BJörn Lindqvist
I am quite new to Python, and have a straight simple question. In C, there is for (init; cond; advance). We all know that. In Python there are two ways to loop over i=A..B (numerical.): 1) i = A while iB: ...do something... i+=STEP This is indeed quite ugly. You rarely need

Re: namespaces module (a.k.a. bunch, struct, generic object, etc.) PEP

2005-02-10 Thread BJörn Lindqvist
I like it alot! My only minor complaint is that the name is to long. Also I *really wish* the Namespace could do this: r, g, b = col = Namespace(r = 4, g = 3, b = 12) But alas, I guess that's not doable within the scope of the Namespace PEP. -- mvh Björn --

Re: Unit Testing in Python

2005-02-11 Thread BJörn Lindqvist
put it) PyUnit project. I'm sorry if this is a obvious question or one that has already been answered, but unit-testing sounds interesting and I'm not sure where to start. Hi Ryan. I belive this (http://www.xp123.com/xplor/xp0201/index.shtml) is a good way to learn about unit testing by

Re: RELEASED Python 2.4 (final)

2004-12-01 Thread BJörn Lindqvist
Christmas came early this year. Thank you all nice Python developers. -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators ?

2004-12-01 Thread BJörn Lindqvist
Some more decorator examples. How to create abstract methods using an @absractmethod decorator: http://www.brpreiss.com/books/opus7/html/page117.html Generics, property getters and setters. I don't know what these decorators are supposed to do: http://www.cis.upenn.edu/~edloper/pydecorators.html

Re: Best book on Python?

2004-12-12 Thread BJörn Lindqvist
I haven't read any Python paper books myself but as Christmas is coming up, I've checked up on what Python books other people recommend. Everyone who has reviewed Python books seem to like these books: * Python Essential Reference * Python Cookbook * Python in a Nutshell The last two are both

Getting rid of self.

2005-01-07 Thread BJörn Lindqvist
I think it would be cool if you could refer to instance variables without prefixing with self. I know noone else thinks like me so Python will never be changed, but maybe you can already do it with Python today? .import sys . .def magic(): .s = .for var in

Re: Getting rid of self.

2005-01-07 Thread BJörn Lindqvist
Thank you for your replies. But they don't deal with my original question. :) I have read the thousands of posts all saying self is good and they are right. But this time I want to be different m-kay? I figure that there might be some way to solve my problem by doing this: .def

Re: Securing a future for anonymous functions in Python

2005-01-07 Thread BJörn Lindqvist
The more features a language has, the harder it becomes to learn. An example of that is C++ which has almost everything. Classes, structs, templates, strange keywords that noone uses like auto, inline const, passing by reference/value, enum, union, lots of macros, multiple inheritance, namespaces

Re: Getting rid of self.

2005-01-09 Thread BJörn Lindqvist
how the situation is handled in Java and C++. Alex Martelli: Björn Lindqvist: I think it would be cool if you could refer to instance variables without prefixing with self. I know noone else thinks like me so Some do -- Kent Beck's excellent book on TDD-by-example has a specific grouse against

Re: Favorite non-python language trick?

2005-07-01 Thread BJörn Lindqvist
I like C++ templates so that you can ensure that a list only contain items of one type. I also like the JMP instruction in x86 assembler, you could do some nasty tricks with that. -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: list of all type names

2005-03-01 Thread BJörn Lindqvist
Python has one feature that I really hate: There are certain special names like 'file' and 'dict' with a predefined meaning. Yet, it is allowed to redefine these special names as in dict = [1:'bla'] dir(__builtins__) Yes, rebinding builtin names accidentally is an annoying and I think

Re: Best way to make a list unique?

2005-03-08 Thread BJörn Lindqvist
The Cookbook features another interesting way to do it: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297 -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-20 Thread BJörn Lindqvist
I like count() and appendlist() or whatever they will be named. But I have one question/idea: Why does the methods have to be put in dict? Can't their be a subtype of dict that includes those two methods? I.e.: .histogram = counting_dict() .for ch in text: .histogram.count(ch) Then maybe

Re: unittest vs py.test?

2005-04-06 Thread BJörn Lindqvist
py.test is awesome, but there is one slight flaw in it. It produces to much output. All I want to see when all tests pass is All X passes succeded! (or something similar). py.test's output can be distracting. -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

A little request about spam

2005-04-14 Thread BJörn Lindqvist
Please do not reply to spam. Replying to spam makes it much harder for spam filters to catch all the spam or will produce very many false positives. Atleast that's how gmail's filter works. And if you must reply, please change the subject line. On 13 Apr 2005 17:50:06 -0500, .@bag.python.org

Re: for-else

2008-03-04 Thread BJörn Lindqvist
On Tue, Mar 4, 2008 at 4:17 PM, Carl Banks [EMAIL PROTECTED] wrote: for ...: ... exhausted: ... broken: ... The meaning is explicit. While else seems to mean little there. So I may like something similar for Python 3.x (or the removal of the else). I

Re: List mutation method gotcha - How well known?

2008-03-13 Thread BJörn Lindqvist
On Thu, Mar 13, 2008 at 8:36 AM, Hendrik van Rooyen [EMAIL PROTECTED] wrote: foo = [1,2,3,4] x = foo.append(5) print x What will be the output (choose one): 1) [1,2,3,4] 2) [1,2,3,4,5] 3) That famous picture of Albert Einstein sticking out his tongue 4) Nothing - no output

Re: PyCon Feedback and Volunteers (Re: Pycon disappointment)

2008-03-16 Thread BJörn Lindqvist
On Mon, Mar 17, 2008 at 12:32 AM, Paul Boddie [EMAIL PROTECTED] wrote: On 17 Mar, 01:09, [EMAIL PROTECTED] (Aahz) wrote: PyCon is what YOU make of it. If you want to change PyCon, propose a presentation or join the conference committee (concom) -- the latter only requires signing up

Interesting math problem

2008-03-17 Thread BJörn Lindqvist
Here is an interesting math problem: You have a number X 0 and another number Y 0. The goal is to divide X into a list with length Y. Each item in the list is an integer. The sum of all integers is X. Each integer is either A or A + 1, those should be evenly distributed. Example: 17 // 5 = 3

Re: Interesting math problem

2008-03-19 Thread BJörn Lindqvist
On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle [EMAIL PROTECTED] wrote: def make_slope(distance, parts): step = distance / float(parts) intstep = int(step) floatstep = step - intstep steps = [] acc = 0.0 for i in range(parts): acc +=

Re: removing all instances of a certain value from a list

2008-03-19 Thread BJörn Lindqvist
On Wed, Mar 19, 2008 at 10:28 PM, Lee Sander [EMAIL PROTECTED] wrote: Hi, I have a float array ( eg [-1.3, 1.22, 9.2, None, 2.3] ) but there are many missing vlaues which are represented as None. I would like to remove all such instances in one go. There is a remove function but it

Re: ANN: pry unit testing framework

2008-04-05 Thread BJörn Lindqvist
On Sat, Apr 5, 2008 at 12:54 PM, Aldo Cortesi [EMAIL PROTECTED] wrote: Thus spake Matthieu Brucher ([EMAIL PROTECTED]): How does it compare to the nose framework ? As far as the base unit testing functionality is concerned, I think they try to address similar problems. Both have

Re: design choice: multi-threaded / asynchronous wxpython client?

2008-04-27 Thread BJörn Lindqvist
I think twisted is overkill for this problem. Threading, elementtree and urllib should more than suffice. One thread polling the server for each race with the desired polling interval. Each time some data is treated, that thread sends a signal containing information about what changed. The gui

Heuristically processing documents

2009-03-19 Thread BJörn Lindqvist
I have a large set of documents in various text formats. I know that each document contains its authors name, email and phone number. Sometimes it also contains the authors home address. The task is to find out the name, email and phone of as many documents as possible. Since the documents are

Re: arange randomly words in a list

2008-10-25 Thread BJörn Lindqvist
2008/10/20 william paul [EMAIL PROTECTED]: I have a list that looks like: name = name1 name2 name3 name4 and I would like to be able to arrange randomly this list, like: name = name 2 name 1 name3 name4 name = name4 name2 name1 name3 I have tried with random.shuffle, but still no

Re: Improving interpreter startup speed

2008-10-25 Thread BJörn Lindqvist
2008/10/25 Pedro Borges [EMAIL PROTECTED]: Is there a way to improve the interpreter startup speed? In my machine (cold startup) python takes 0.330 ms and ruby takes 0.047 ms, after cold boot python takes 0.019 ms and ruby 0.005 ms to start. How are you getting those numbers? 330 μs is still

Re: Improving interpreter startup speed

2008-10-26 Thread BJörn Lindqvist
2008/10/26 James Mills [EMAIL PROTECTED]: On Sun, Oct 26, 2008 at 11:23 AM, BJörn Lindqvist [EMAIL PROTECTED] wrote: How are you getting those numbers? 330 μs is still pretty fast, isn't it? :) Most disks have a seek time of 10-20 ms so it seem implausible to me that Ruby would be able to cold

Re: Improving interpreter startup speed

2008-10-29 Thread BJörn Lindqvist
2008/10/27 James Mills [EMAIL PROTECTED]: On Mon, Oct 27, 2008 at 5:40 PM, David Cournapeau [EMAIL PROTECTED] wrote: Depends on the tool: build tool and source control tools are example it matters (specially when you start interfaciing them with IDE or editors). Having fast command line tools

Re: Compare 2 files and discard common lines

2008-05-29 Thread BJörn Lindqvist
Open('3rd', 'w').writelines(set(open('2nd').readlines())-set(open('1st'))) 2008/5/29, loial [EMAIL PROTECTED]: I have a requirement to compare 2 text files and write to a 3rd file only those lines that appear in the 2nd file but not in the 1st file. Rather than re-invent the wheel I am

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread BJörn Lindqvist
On Mon, Jun 2, 2008 at 10:50 PM, Russ P. [EMAIL PROTECTED] wrote: On Jun 2, 6:41 am, Carl Banks [EMAIL PROTECTED] wrote: You are not realizing that only useful(**) thing about data hiding is that some code has access to the data, other code does not. If you hide data equally from everyone

Re: Why does python not have a mechanism for data hiding?

2008-06-07 Thread BJörn Lindqvist
On Wed, Jun 4, 2008 at 2:02 PM, Antoon Pardon [EMAIL PROTECTED] wrote: Now of course noone would defend such a limitation on the grounds that one doesn't need the general case and that the general case will only save you some vertical space. But when it came to the ternary operator that was

Re: Summing a 2D list

2008-06-13 Thread BJörn Lindqvist
On Fri, Jun 13, 2008 at 2:12 PM, Karsten Heymann [EMAIL PROTECTED] wrote: Although your problem has already been solved, I'd like to present a different approach which can be quite a bit faster. The most common approach seems to be using a dictionary: summed_up={} for user,vote in pairs:

Re: Summing a 2D list

2008-06-13 Thread BJörn Lindqvist
On Thu, Jun 12, 2008 at 3:48 PM, Mark [EMAIL PROTECTED] wrote: Hi all, I have a scenario where I have a list like this: UserScore 1 0 1 1 1 5 2 3 2 1 3 2 4 3 4

Re: learning unit testing in python

2008-06-23 Thread BJörn Lindqvist
On Mon, Jun 23, 2008 at 2:55 PM, Alex [EMAIL PROTECTED] wrote: Hi all. I'd like learn some basic unit testing with python. I red some articles about different testing framework like unittest or nose, but I'm a bit confused: what is the best choice? I'm not a professional developer (I'm a

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-04 Thread BJörn Lindqvist
On 6/22/07, Eduardo EdCrypt O. Padoan [EMAIL PROTECTED] wrote: Remember that pure CPython has no different compile time and runtiime. But Psyco and ShedSkin could use the annotations the way they want. . def compile(source: something compilable, filename: where the compilable

Re: What is the preferred doc extraction tool?

2007-07-09 Thread BJörn Lindqvist
On 7/9/07, Emin.shopper Martinian.shopper [EMAIL PROTECTED] wrote: Dear Experts, What is the preferred doc extraction tool for python? It seems that there are many very nice options (e.g., pydoc, epydoc, HappyDoc, and lots of others), but what is the standard tool or at least what is the tool

Re: Can a low-level programmer learn OOP?

2007-07-13 Thread BJörn Lindqvist
On 7/13/07, John Nagle [EMAIL PROTECTED] wrote: You can sometimes get better performance in C++ than in C, because C++ has inline. Inline expansion happens before optimization, so you can have abstractions that cost nothing. C99 has that too. Python is a relatively easy language,

Re: Best programs written completly in Python

2007-08-05 Thread BJörn Lindqvist
On 8/5/07, Franz Steinhäusler [EMAIL PROTECTED] wrote: Hello NG, wWhat are the best programs in your opinion, written entirly in pyhton, divided into categories like: a) Games b) Utilities/System c) Office d) Web/Newsreader/Mail/Browser For b; trac: http://trac.edgewall.org/ There

Re: decorators - more than just syntactic sugar

2007-08-13 Thread BJörn Lindqvist
On 8/11/07, Helmut Jarausch [EMAIL PROTECTED] wrote: How can I find out the predefined decorators? There are two in the standard library, @classmethod for declaring class methods and @staticmethod for declaring static methods. They are listed at the built ins page

Re: decorators - more than just syntactic sugar

2007-08-14 Thread BJörn Lindqvist
On 8/13/07, Bjoern Schliessmann [EMAIL PROTECTED] wrote: BJörn Lindqvist wrote: unpedagogically not separated from ordinary functions. Decorators _are_ ordinary functions. Remember the syntactic sugar in this thread? Remember also that syntactic sugar is important. Case in point, the OP

Re: advice about `correct' use of decorator

2007-08-17 Thread BJörn Lindqvist
On 8/16/07, Gerardo Herzig [EMAIL PROTECTED] wrote: @is_logued_in def change_pass(): bla bla And so on for all the other functions who needs that the user is still loged in. where obviosly the is_logued_in() function will determine if the dude is still loged in, and THEN execute

Re: do as a keyword

2007-12-13 Thread BJörn Lindqvist
On Dec 11, 2007 4:06 PM, Neil Cerutti [EMAIL PROTECTED] wrote: However, did you have an specific need for a do-while construct? Perhaps we could show you the alternatives. I have wanted do-while loops in exactly one kind of algorithms, when you generate something and you have to keep trying

Re: Can someone explain this unexpected raw_input behavior?

2008-01-24 Thread BJörn Lindqvist
On Jan 24, 2008 8:08 AM, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 24 Jan 2008 01:00:53 -0200, Mike Kent [EMAIL PROTECTED] escribió: Gabriel, thank you for clarifying the source of this behavior. Still, I'm surprised it would be hard-coded into Python. Consider an interactive

Re: Does anyone else use this little idiom?

2008-02-04 Thread BJörn Lindqvist
In Python, the direct translation of this is a for loop. When the index doesn't matter to me, I tend to write it as: for _ in xrange (1,n): some code An alternative way of indicating that you don't care about the loop index would be for dummy in xrange (1,n): some code I usually

Re: Should Python raise a warning for mutable default arguments?

2008-08-23 Thread BJörn Lindqvist
2008/8/22 Peter Otten [EMAIL PROTECTED]: [EMAIL PROTECTED] wrote: DrScheme is an implementation of Scheme that is very newbie-friendly. It has several limited sub-languages, etc. So maybe a command line option can be added to Python3 ( - newbie ? :-) ) that just switches on similar

Re: How to search the Python manuals

2008-08-24 Thread BJörn Lindqvist
2008/8/22 Terry Reedy [EMAIL PROTECTED]: [snip] On the left, click [+] for Language Reference (3.0: The Python language reference). Language Reference (for language lawyers) Language Lawyer? That's almost as worser than Grammar Nazi, no wonder no one is finding anything there. -- mvh Björn

Re: How to write verbose scripts

2008-09-03 Thread BJörn Lindqvist
2008/9/3 Hendrik van Rooyen [EMAIL PROTECTED]: Steven D'Aprano stev...bersource.com.au wrote: Is there a better way of doing this than the way I am going about it? Not sure if its better, but I would keep the messages in a table or dict and have different tables or dicts for different levels

Iterator for circulating a list

2007-11-13 Thread BJörn Lindqvist
L = somelist idx = 0 while True: item = L[idx] # Do something with item idx = (idx + 1) % len(L) wouldn't it be cool if there was an itertool like this: def circulate(L, begin = 0, step = 1): idx = begin while True: yield L[idx] idx = (idx + step) % len(L)

Re: Iterator for circulating a list

2007-11-13 Thread BJörn Lindqvist
On Nov 13, 2007 3:43 PM, Carsten Haese [EMAIL PROTECTED] wrote: On Tue, 2007-11-13 at 15:12 +0100, BJörn Lindqvist wrote: L = somelist idx = 0 while True: item = L[idx] # Do something with item idx = (idx + 1) % len(L) For begin=0 and step=1, itertools.cycle does

Re: the annoying, verbose self

2007-11-23 Thread BJörn Lindqvist
On Nov 23, 2007 11:54 PM, Steven D'Aprano [EMAIL PROTECTED] wrote: On Fri, 23 Nov 2007 23:38:24 +, BJörn Lindqvist wrote: I like that a lot. This saves 12 characters for the original example and removes the need to wrap it. 7return math.sqrt(.x * .x + .y * .y + .z * .z

Re: the annoying, verbose self

2007-11-23 Thread BJörn Lindqvist
On Nov 22, 2007 2:08 PM, Colin J. Williams [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Alexy: Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to use Ruby anywhere speed is not crucial especially for @ prefix is better- looking than self. Ruby speed

Re: the annoying, verbose self

2007-11-26 Thread BJörn Lindqvist
On Nov 24, 2007 11:55 AM, jakub silar [EMAIL PROTECTED] wrote: Below is my coding standard - I'm lazy, even lazy to persuade comutinties into strange (imho) language syntax extensions. class Vector: def __init__(s, x, y, z): s.x = x s.y = y

Re: Quote aware split

2007-05-16 Thread BJörn Lindqvist
How is the code different from shlex.split? -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

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

2007-05-29 Thread BJörn Lindqvist
On 5/29/07, Eric S. Johansson [EMAIL PROTECTED] wrote: A huge reason why this is important because the vast majority of software developers who are injured fall off the economic ladder. They leave the profession and had very few options for work that doesn't involve significant handy is. The

Re: Creating a distro of python... What would you include in it?

2007-05-30 Thread BJörn Lindqvist
On 30 May 2007 08:25:48 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am creating a distro of Python to be licensed as GPL am wondering, what would anyone suggest as to 3rd party modules being put into it (non-commercial of course!)? I know I'd put MySQLdb into it at the very least.

Re: itertools.groupby

2007-06-05 Thread BJörn Lindqvist
On 27 May 2007 10:49:06 -0700, 7stud [EMAIL PROTECTED] wrote: On May 27, 11:28 am, Steve Howell [EMAIL PROTECTED] wrote: The groupby method has its uses, but it's behavior is going to be very surprising to anybody that has used the group by syntax of SQL, because Python's groupby method

Re: Select one of 2 functions with the same name ?

2007-06-10 Thread BJörn Lindqvist
On 6/10/07, Stef Mientki [EMAIL PROTECTED] wrote: I can realize it with a simple switch within each function, but that makes the code much less readable: def Some_Function(): if simulation_level == 1: ... do things in a way elif simulation_level == 2: ... do things in

Re: a_list.count(a_callable) ?

2007-06-15 Thread BJörn Lindqvist
On 6/15/07, Ping [EMAIL PROTECTED] wrote: sum(1 for i in a_list if a_callable(i)) -- Carsten Haesehttp://informixdb.sourceforge.net This works nicely but not very intuitive or readable to me. First of all, the generator expression makes sense only to trained eyes. Secondly, using

Re: A patch to support L.count(value, cmp=None, key=None)

2007-06-18 Thread BJörn Lindqvist
I patched Objects/listobject.c to support L.count(value, cmp=None, key=None). I tested it with the same script above by replacing slist with built-in list. It worked correctly with this small test. The patch is below (126 lines, I hope that's not Great! If you want this change included

Re: Q: listsort and dictsort - official equivalents?

2007-06-19 Thread BJörn Lindqvist
In python I must kick off a sort on the line before I start the iteration. (This does make sense because at the end of the day the sort has complete BEFORE the for loop can proceed - that is... until the day when python lists have a secondary index ;-). group_list=group_dict.keys()

Re: Q: listsort and dictsort - official equivalents?

2007-06-20 Thread BJörn Lindqvist
On 6/20/07, Gabriel Genellina [EMAIL PROTECTED] wrote: It's not true that the sort must complete (or that the whole file must be read for that matter), Python has cool generators which makes the above possible. That's not possible, the input must be read completely before sorted() can

Re: code is data

2006-06-17 Thread BJörn Lindqvist
Personally, I would like to see macros in Python (actually Logix succeeding is good enough). But I am no language designer and the community has no interest in it. When I absolutely need macros, I will go elsewhere. One must wonder, when is that? When do you absolutely need macros? -- mvh

Re: code is data

2006-06-18 Thread BJörn Lindqvist
community has no interest in it. When I absolutely need macros, I will go elsewhere. I *like* 1..5 (ada, ruby) instead of range(5). If I had macros, I would have done it myself for *my* code. I think this example more is a symptom of a childish need to get things your way than of a

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-03 Thread BJörn Lindqvist
void usage(const char *proggie) { errx(EXIT_FAILURE, Usage: %s ip address, proggie); } int main(int argc, char **argv) { struct in_addr addr; if (argc != 2 || !inet_aton(argv[1], addr)) { usage(argv[0]); } (void)printf(%s\n,

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-04 Thread BJörn Lindqvist
/* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ /* * Copyright (c) 2003, 2004 David Young. All rights reserved. * * This code was written by David Young. [snip code] Am I the only one who found it hilarious that this piece of code was made up of 24 lines of actual code

cookielib incorrectly escapes cookie

2006-07-05 Thread BJörn Lindqvist
Hello, I have some very serious trouble getting cookes to work. After a lot of work (urllib2 is severly underdocumented, arcane and overengineerd btw) I'm finally able to accept cookes from a server. But I'm still unable to return them to a server. Specifically the script im trying to do logs on

Re: converting file formats to txt

2006-07-06 Thread BJörn Lindqvist
On 4 Jul 2006 08:38:47 -0700, Gaurav Agarwal [EMAIL PROTECTED] wrote: Thanks Steven, Actually i wanted a do text processing for my office where I can view all files in the system and use the first three to give a summary of the document. Instead of having somebody actually entering the

Re: When is List Comprehension inappropriate?

2007-03-19 Thread BJörn Lindqvist
On 19 Mar 2007 07:41:59 -0700, Ben [EMAIL PROTECTED] wrote: I have recently learned how list comprehension works and am finding it extremely cool. I am worried, however, that I may be stuffing it into places that it does not belong. What's the most pythony way to do this: even = [] for x

Re: An error of matrix inversion using NumPy

2007-04-04 Thread BJörn Lindqvist
On 4 Apr 2007 06:15:18 -0700, lancered [EMAIL PROTECTED] wrote: During the calculation, I noticed an apparent error of inverion of a 19x19 matrix. Denote this matrix as KK, U=KK^ -1, I found the product of U and KK is not equivalent to unit matrix! This apparently violate the

Re: Easy question: More items in a For loop?

2007-04-05 Thread BJörn Lindqvist
Here is some sample tuna: ['[7:55pm] P0ke My teachings goes back to the last iceage.\r\n', '[7:55pm] %Zack ahh now it does\r\n', '[7:55pm] %Zack ok\r\n', '[7:55pm] P0ke Or it is down just for you.\r\n', '[7:55pm] @FC3 which one? that -12000 ice age or the one before\r\n', '[7:55pm] P0ke the

Re: tuples, index method, Python's design

2007-04-10 Thread BJörn Lindqvist
On 4/10/07, Carsten Haese [EMAIL PROTECTED] wrote: i = p.index(current_player) opponents = p[:i-1] + p[i+1:] An alternative is this: opponents = tuple(x for x in p if x is not current_player) You may disagree, but in my opinion, the alternative is better because it is a more natural

Re: tuples, index method, Python's design

2007-04-10 Thread BJörn Lindqvist
On 4/10/07, Steve Holden [EMAIL PROTECTED] wrote: Paul Boddie wrote: On 10 Apr, 11:48, Antoon Pardon [EMAIL PROTECTED] wrote: On 2007-04-10, Duncan Booth [EMAIL PROTECTED] wrote: There is a cost to every new language feature: it has to be implemented, documented, maintained, and above

Re: tuples, index method, Python's design

2007-04-10 Thread BJörn Lindqvist
On 4/10/07, Carsten Haese [EMAIL PROTECTED] wrote: opponents = tuple(x for x in p if x is not current_player) Your alternative is wrong because it wont raise ValueError if current_player is not present in the tuple. Please revise your solution. You have a point. Here is my revised

Re: tuples, index method, Python's design

2007-04-10 Thread BJörn Lindqvist
while not game_has_ended: for current_player in p: player_does_something(current_player) I'm curious why someone would even consider using a tuple in this case regardless. I think that much of the desire for tuple.index is because people use a tuple where they could have a list,

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
Your idea isn't new and has already been discussed lots of time before. It was once planned to be implemented in py3k, but no longer is. One of the problems is that with a using statement, you always have to decide whether your code repeats some prefix enough times to use a using statement.

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
On 14 Apr 2007 07:24:32 -0700, jamadagni [EMAIL PROTECTED] wrote: You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like the ones in my example? You can't, of course. But using the with statement: using

Re: Python Feature Request: Add the using keyword which works like with in Visual Basic

2007-04-14 Thread BJörn Lindqvist
On 4/14/07, BJörn Lindqvist [EMAIL PROTECTED] wrote: On 14 Apr 2007 07:24:32 -0700, jamadagni [EMAIL PROTECTED] wrote: You already can emulate the using statement like this: You can emulate only assignments like this. How would you emulate function calls, like the ones in my example

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread BJörn Lindqvist
This comes up so often that I wonder whether Python should issue a warning when it sees [] or {} as a default argument. What do people think? A misuse or good use of warnings? I think Python should reevaluate the default values. -- mvh Björn --

Re: is laziness a programer's virtue?

2007-04-17 Thread BJörn Lindqvist
On 4/17/07, Mirco Wahab [EMAIL PROTECTED] wrote: The reason why I answered your posting at all (besides seeing your x-post going into 5 ng's) is your mentioning of 'God'. According to christian tradition (which is somehow on topic in a Perl group) it is exactly the case of Jesus (imho), who

Re: While we're talking about annoyances

2007-04-29 Thread BJörn Lindqvist
On 4/29/07, Steven D'Aprano [EMAIL PROTECTED] wrote: To do that, I needed to generate an index table first. In the book Numerical Recipes in Pascal by William Press et al there is a procedure to generate an index table (46 lines of code) and one for a rank table (five lines). 51 lines total.

Re: Is it possible to merge xrange and slice?

2007-04-30 Thread BJörn Lindqvist
On 30 Apr 2007 11:02:19 -0700, Bas [EMAIL PROTECTED] wrote: stupid question, but would it be possible to somehow merge xrange (which is supposed to replace range in py3k) and slice? Both have very similar start, stop and step arguments and both are lightweight objects to indicate a range. But

Re: What do you want in a new web framework?

2006-08-21 Thread BJörn Lindqvist
On 8/20/06, Dave Richards [EMAIL PROTECTED] wrote: Really, really good documentation. Dave ... Which is the one thing no Python web framework provides. :( A framework with really good documentation (preferably translated into multiple languages) would be, I'm sure, the PHP/Ruby on Rails killer

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

2006-08-24 Thread BJörn Lindqvist
Mechanize (http://wwwsearch.sourceforge.net/mechanize/) is another option, it can even fill out forms! -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: advice about `correct' use of decorator

2007-08-22 Thread BJörn Lindqvist
On 8/17/07, Gerardo Herzig [EMAIL PROTECTED] wrote: BJörn Lindqvist wrote: def is_logued_in(): if not user.is_logged_in(): raise NotLoggedInError It costs you one more line, but reduces complexity. And if you are worried about that extra line you can put it in a function

Re: advice about `correct' use of decorator

2007-08-23 Thread BJörn Lindqvist
On 8/22/07, Gabriel Genellina [EMAIL PROTECTED] wrote: On 22 ago, 10:00, BJörn Lindqvist [EMAIL PROTECTED] wrote: As I said, you can accomplish the exact same thing by calling a function from within the function that requires the user to be logged in. def change_pass

Re: advice about `correct' use of decorator

2007-08-29 Thread BJörn Lindqvist
On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def f(*args, **kwargs): if global_state.the_user.is_logged_in: return func(*args, **kwargs

Re: list index()

2007-08-31 Thread BJörn Lindqvist
On 8/30/07, Carsten Haese [EMAIL PROTECTED] wrote: Is the Pythonic way try: i = somelist.index(thing) # Do something with i except IndexError: # Do something if thing not found That is not the Pythonic way. # Do something with i might also raise an IndexError and they you are

[ANN] GtkImageView 1.5.0 and PyGtkImageView 1.0.0 -- Image viewer widget for GTK

2007-09-10 Thread BJörn Lindqvist
I'm pleased to finally announce GtkImageView 1.5.0. I'm even more pleased to ALSO announce PyGtkImageView 1.0.0: Description --- GtkImageView is a simple image viewer widget for GTK+. Similar to the image viewer panes in gThumb or Eye of Gnome. It makes writing image viewing and editing

Re: newbie: self.member syntax seems /really/ annoying

2007-09-13 Thread BJörn Lindqvist
On 9/12/07, Dave Hansen [EMAIL PROTECTED] wrote: The name self is just a convention. You can give it any name you wish. Using s is common. Not it's not common. And the name self is a convention codified in PEP8 which you shouldn't violate. And I agree with the OP that the convention is

Re: Needless copying in iterations?

2007-09-16 Thread BJörn Lindqvist
On 9/16/07, Steven D'Aprano [EMAIL PROTECTED] wrote: Maybe I'm being unfair, but it seems to me that the attitude is similar: 'there's no point optimizing the common case of printing (say) ints stored in a list, Just In Case the programmer wants the incredibly rare case of setting sys.stdout

Re: Try this

2007-09-17 Thread BJörn Lindqvist
On 9/16/07, GeorgeRXZ [EMAIL PROTECTED] wrote: Well you are speed That's an awesome party trick! But before I mail this to everyone at the office, must have a better sentence. Well you are speed is to gibberish. Something microsoft+evil... hm.. -- mvh Björn --

Re: SVG to raster conversion.

2007-09-17 Thread BJörn Lindqvist
On 9/16/07, J. Cliff Dyer [EMAIL PROTECTED] wrote: Does anybody know a good solution (preferably in python) for rasterizing SVG or other vector graphics. I'm thinking something like vector_image = SVGFile(path_to_image) raster_image = vector_image.rasterize(format, (width, height), dpi)

Re: using inspect on pygtk

2007-10-01 Thread BJörn Lindqvist
On 9/29/07, Chris Pax [EMAIL PROTECTED] wrote: Hello, I recently been trying to use the inspect module to inspect the arguments of gtk objects, such as gtk.Button. I tried like this: inspect.getargspec(gtk.Button.__init__) and get the fallowing error: File stdin, line 1, in module

Re: pytz has so many timezones!

2007-10-08 Thread BJörn Lindqvist
On 10/8/07, Sanjay [EMAIL PROTECTED] wrote: Hi All, I am using pytz.common_timezones to populate the timezone combo box of some user registration form. But as it has so many timezones (around 400), it is a bit confusing to the users. Is there a smaller and more practical set? If not, some

  1   2   >