Re: Tree views - Best design practices

2009-01-08 Thread Diez B. Roggisch
Filip Gruszczyński wrote: > Hi! > > I have certain design problem, which I cannot solve elegantly. Maybe > you know some good design patterns for this kind of tasks. > > Task: > > We have a model which has two kinds of objects: groups and elements. > Groups can hold other groups (subgroups) and

Re: Reading C# serialized objects into Python?

2009-01-08 Thread Diez B. Roggisch
Alex van der Spek wrote: > Is there a way to read C# serialized objects into Python? > > I know the definition and structure of the C# objects. The Python docs > say that pickle is specific to Python, which does not give me much hope. > There may be a library however that I haven't come across ye

Re: formatted 'time' data in calculations

2009-01-07 Thread Diez B. Roggisch
Ross wrote: > There seems to be no shortage of information around on how to use the > time module, for example to use time.ctime() and push it into strftime > and get something nice out the other side, but I haven't found anything > helpful in going the other way. > > That is, given some formatte

Re: Importing modules

2009-01-07 Thread Diez B. Roggisch
e4m...@gmail.com wrote: > Coming from a scripting background where we used to write everything > into one script, I'm now going modular with Python. I place related > functions in one module, and other functions in other modules. > > This all works OK, but I'm a bit confused about importing modul

Re: linked list with cycle structure

2009-01-07 Thread Diez B. Roggisch
David Hláčik wrote: > dictionary with cycle structure > > Hello guys, > > I have a linked list where *number of elements is unlimited* and > **last element points on random (can be first, last, in middle , > anywhere) element within linked list** - this is important . My goals > is to create an

Re: fetch image

2009-01-05 Thread Diez B. Roggisch
asit wrote: > import httplib > > class Server: > #server class > def __init__(self, host): > self.host = host > def fetch(self, path): > http = httplib.HTTPConnection(self.host) > http.request("GET", path) > r = http.getresponse() > print str(r.

Re: Port of python stdlib to other languages.

2009-01-03 Thread Diez B. Roggisch
vk schrieb: Have there been ports of the Python standard library to other languages? I would imagine using pickle, urllib, and sys in C (with pythonic naming conventions) would be easier than using other libraries to do the same thing. AFAIK not. You could try elmer (found on SF) to expose the

Re: Returning a string

2009-01-03 Thread Diez B. Roggisch
Kless schrieb: On 3 ene, 19:40, Simon Forman wrote: On Jan 3, 11:20 am, Kless wrote: Afghanistan AF Out[19]: u'AF' AFG Out[19]: u'AFG' 004 Out[19]: u'004' What? That's the output got from ipython. As you can see, it prints 'Afghanistan' but it can not returns it. In change, the another st

Re: Returning a string

2009-01-03 Thread Diez B. Roggisch
Kless schrieb: On 3 ene, 19:12, "Diez B. Roggisch" wrote: Kless schrieb: How is possible that I can print a variable, but when I use *return var* it returns an empty string http://paste.pocoo.org/show/97588/ I don't see anything that indicates that the returned object is t

Re: Returning a string

2009-01-03 Thread Diez B. Roggisch
Kless schrieb: How is possible that I can print a variable, but when I use *return var* it returns an empty string http://paste.pocoo.org/show/97588/ I don't see anything that indicates that the returned object is the empty string. Simply because there is no code testing for that. And of cou

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Diez B. Roggisch
sprad schrieb: I've done a good bit of Perl, but I'm new to Python. I find myself doing a lot of typecasting (or whatever this thing I'm about to show you is called), and I'm wondering if it's normal, or if I'm missing an important idiom. It is normal, although below you make things needlessly

Re: How to debug embeding Python?

2008-12-30 Thread Diez B. Roggisch
Hongtian schrieb: Hi Friends, My application is written in C/C++ and Python is embed to extend some functions (several .py files are invoked). But I am confused how to debug these embed Python? Can I use 'print-debuging'? and where can I capture the output string? Or Python can support 'break'

Re: Iterating over objects of a class

2008-12-24 Thread Diez B. Roggisch
Kottiyath schrieb: Hi, How can I iterate over all the objects of a class? I wrote the code like following: class baseClass(object): Consider adopting PEP 8 coding conventions. __registry = [] def __init__(self, name): self.__registry.append(self) self.name = n

Re: SyntaxError: encoding problem: with BOM

2008-12-24 Thread Diez B. Roggisch
NoName schrieb: On 25 дек, 00:37, "Diez B. Roggisch" wrote: NoName schrieb: i have 1.py in cp866 encoding: # -*- coding: cp866 -*- print ("ff") It's not work in Python 3.0 Error: File "", line 1 SyntaxError: encoding problem: with BOM what's wrong?

Re: python web programming for PHP programmers

2008-12-24 Thread Diez B. Roggisch
Nikola Skoric schrieb: I0m a python newbie with PHP background. I've tried to make a web app from one of my python scripts (which I haven't done before) and I ended up with: which works really nice :-D For some reason I can't find no "quick and dirty python web programming tutorial for PHP pro

Re: SyntaxError: encoding problem: with BOM

2008-12-24 Thread Diez B. Roggisch
NoName schrieb: i have 1.py in cp866 encoding: # -*- coding: cp866 -*- print ("ff") It's not work in Python 3.0 Error: File "", line 1 SyntaxError: encoding problem: with BOM what's wrong? I can only guess, but just because you write the coding-header that doesn't mean that the editor yo

[OT] Re: IMAP: How to implement GMail-like threaded conversations view

2008-12-20 Thread Diez B. Roggisch
Anything else is madness. And the fact the Outlook doesn't do proper referral fields just infuriates me. Sigh. I'm overjoyed about the opaque winmail.dat attachments I get. Which seem to appear randomly from the same sender sending the same stuff (like a meeting invitation) to me - depend

Re: PIL on 3.x?

2008-12-20 Thread Diez B. Roggisch
Méta-MCI (MVP) schrieb: Hi! This info is interesting for many people. IMO, it's a good idea to write the question in this newsgroup. Which only makes sense if the author of PIL reads it. Which he seems not to (or at least doesn't answer here, as he used to). Diez -- http://mail.python.org

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Diez B. Roggisch
Neal Becker wrote: > Diez B. Roggisch wrote: > >> Neal Becker wrote: >> >>> Tino Wildenhain wrote: >>> >>>> Neal Becker wrote: >>>> ... >>>>>>> So if __str__ is "meant for human eyes", then why isn&#x

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Diez B. Roggisch
Neal Becker wrote: > Tino Wildenhain wrote: > >> Neal Becker wrote: >> ... > So if __str__ is "meant for human eyes", then why isn't print using > it! it is: > print x str but dict just uses repr() for all its childs to print. T. >>> That makes no

Re: confused about __str__ vs. __repr__

2008-12-18 Thread Diez B. Roggisch
Neal Becker wrote: > Reading some FAQ, I see that __str__ is "meant for human eyes". > > But it seems that: > class X(object): >     def __str__(self): >         return "str" >     def __repr__(self): >         return "repr" > > x = X() > d = {0 : x} > print d > {0: repr} > > So if __str__ is "

Re: re.match() performance

2008-12-18 Thread Diez B. Roggisch
Emanuele D'Arrigo wrote: > Sorry for the previous post, hit the Enter button by mistake... here's > the complete one: > > Hi everybody! > > I've written the code below to test the differences in performance > between compiled and non-compiled regular expression matching but I > don't quite under

Re: Why no lexical scoping for a method within a class?

2008-12-17 Thread Diez B. Roggisch
walterbyrd wrote: > For a language as well structured as Python, this seems somewhat > sloppy, and inconsistant. Or is there some good reason for this? > > Here is what I mean: > > def a(): > x = 99 > print x > > def b(): > print x > > a() > b() # raises an exception because x is

Re: Python, XML and XPath

2008-12-17 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > Hole wrote: > >> Hi all, >> >> I hope this is not an "overasked" question but I find myself quite >> confused about python xml management (I have to use python for a >> project and I come from java world, you know...where

Re: Python, XML and XPath

2008-12-17 Thread Diez B. Roggisch
Hole wrote: > Hi all, > > I hope this is not an "overasked" question but I find myself quite > confused about python xml management (I have to use python for a > project and I come from java world, you know...where frameworks, > libraries and tools to use are standard de iure or standard de facto

Re: [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Diez B. Roggisch
Duncan Booth schrieb: "Diez B. Roggisch" wrote: David Hlá�ik schrieb: Hi guys, i am really sorry for making offtopic, hope you will not kill me, but this is for me life important problem which needs to be solved within next 12 hours.. I have to create stable algorithm for

Re: [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Diez B. Roggisch
David Hláčik schrieb: Hi guys, i am really sorry for making offtopic, hope you will not kill me, but this is for me life important problem which needs to be solved within next 12 hours.. I have to create stable algorithm for sorting n numbers from interval [1,n^2] with time complexity O(n) . C

Re: Best way of debigging a C extension

2008-12-11 Thread Diez B. Roggisch
Christian Heimes schrieb: Diez B. Roggisch schrieb: I never tried this on windows - but what happens if you start python inside GDB, and then set breakpoints inside your extension? This works flawlessly for me under *nix. The debug-build of python isn't needed for this - and I doubt

Re: HGE and Python (again)

2008-12-11 Thread Diez B. Roggisch
Cro schrieb: Good day. I've been trying to port HGE (http://hge.relishgames.com) to Python for more than 4 months now... HGE is a hardware accelerated 2D game engine. It comes with the source and examples. In the folder "include", you can find "hge.h", the file that i am talking about in all the

Re: Best way of debigging a C extension

2008-12-11 Thread Diez B. Roggisch
Grant Edwards schrieb: On 2008-12-11, Diez B. Roggisch wrote: I never tried this on windows - but what happens if you start python inside GDB, and then set breakpoints inside your extension? This works flawlessly for me under *nix. The debug-build of python isn't needed for this -

Re: Best way of debigging a C extension

2008-12-11 Thread Diez B. Roggisch
Paul Moore schrieb: I'm writing a C extension. My environment is Python 2.5, with the mingw compiler, on Windows XP. At the moment I'm debugging by scattering printf() statements around, but it's not always easy. Is there a better way of debugging - particularly for diagnosing crashes? I have gd

Re: Python, threading

2008-12-11 Thread Diez B. Roggisch
SMALLp wrote: > Hy. I have a problem! I'm making multi thread application (client, > server) using wxPython for GUI, and threading.Thread for threding. > > Clients connect and when they are connected (evry thread handles one > connection) threads change main window. > > I neded tip how to make c

Re: How do I manually uninstall setuptools (installed by egg)?

2008-12-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > On Dec 9, 10:04 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: >> So, why do you think apt and not setuptools is The Right Way(tm)? > > I like to keep > 1 Python on my computer. > > 1. First, there's the system Python, which is installed by my OS and > which I try not t

Re: ORB for Python and PHP

2008-12-09 Thread Diez B. Roggisch
Laszlo Nagy schrieb: There are others but they do not support both Python and PHP. Should I implement my own ORB, or do you know a suitable solution? The whole purpose of an ORB ist that it is interoperable. So if you have a good python orb (I personally prefer OmniORB), and a good one f

Re: Public imports

2008-12-08 Thread Diez B. Roggisch
Márcio Faustino schrieb: So, no chance of doing this: # "A.py" from __future__ import division, with_statement # "B.py" from A import * print 1 / 2 ...and printing 0.5, right? Too bad :) Au contraire - *very* good. If it were otherwise, what would happen to code that _relies_ on / returning

Re: xml.dom.minidom bug ?

2008-12-08 Thread Diez B. Roggisch
Sampsa Riikonen schrieb: Dear All, I am experiencing a weird problem with the xml.dom.minidom module: [EMAIL PROTECTED]:~/python> python easyxml.py Traceback (most recent call last): File "easyxml.py", line 1, in import xml.dom.minidom File "/u

Re: ORB for Python and PHP

2008-12-08 Thread Diez B. Roggisch
Laszlo Nagy schrieb: We have a problem here. We have a website written in PHP. and many programs written in Python. The communication between the components is messy. os.system calls are mixed with popen, xml-rpc and others. We would like to make it consistent and portable. We would like to use

Re: easy_install of module produces un-importable result

2008-12-08 Thread Diez B. Roggisch
Val schrieb: I've written my first module, " " and uploaded it as an egg to PyPI. I can use easy_istall to install my own module, but when I try to import it I get an ImportError "No module named gpsparser". So I've done some research and found that in my site-packages/ directory gpsparser exi

Re: Equivalent of 'wget' for python?

2008-12-08 Thread Diez B. Roggisch
Jean-Paul Calderone wrote: > On Mon, 08 Dec 2008 17:29:35 +0100, "Diez B. Roggisch" > <[EMAIL PROTECTED]> wrote: >>Robert Dailey wrote: >> >>> Hi, >>> >>> I'm looking for a portable way to download ZIP files on the internet

Re: Equivalent of 'wget' for python?

2008-12-08 Thread Diez B. Roggisch
Robert Dailey wrote: > Hi, > > I'm looking for a portable way to download ZIP files on the internet > through Python. I don't want to do os.system() to invoke 'wget', since > this isn't portable on Windows. I'm hoping the core python library has > a library for this. Note that I'll be using Pytho

Re: how to get a beep, OS independent ?

2008-12-07 Thread Diez B. Roggisch
Peter Pearson schrieb: On Sun, 07 Dec 2008 00:40:53 +0100, Stef Mientki wrote: I want to give a small beep, for windows there's message-beep, and there seems to be something like " curses" , but that package seems to be totally broken in P2.5 for windows. Any other suggestions ? Many people h

Re: Importing the re module fails

2008-12-07 Thread Diez B. Roggisch
Andreas Waldenburger schrieb: This is a little puzzling. Using ipython: [EMAIL PROTECTED] Logstuff]$ ipython Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) Type "copyright", "credits" or "license" for more information. [snip ipython help message] In [1]: import re

Re: var or inout parm?

2008-12-07 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: How can I make a "var" parm, where the called function can modify the value of the parameter in the caller? def f(x): x = x + 1 n = 1 f(n) # n should now be 2 Chris showed one way, another is simply returning it. As python can return ad-hoc created tuples & unp

Re: Can I load a python program at the interactive >>> prompt?

2008-12-05 Thread Diez B. Roggisch
Tim Golden schrieb: walterbyrd wrote: I am running cygwin on xp. and I just noticed this vital bit. So not sure how much of my other post applies. Sorry. Maybe it'll help anyway. :) Everything. The atrocity that the windows terminal window is isn't mitigated by an out-of-the-box cygwi

Re: Python Runtime Method Call Binding

2008-12-04 Thread Diez B. Roggisch
k3xji wrote: > Hi, > > Is there a way to hook a function call in python? I know __getattr__ > is doing for variables, it is giving us a chance before a field is > initialized. Do we have same functionality for methods? > > Example: > > class Foo(object): > def __call_method__(self, ...) # j

Re: help me~!about base64

2008-12-02 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > my code: > − > import base64 > def deflashget(st): > if st.startswith('Flashget://'): > return base64.decodestring(st[len('Flashget://'):])[10:-10] > elif st.startswith('http://') or st.startswith('ftp://'): >

Re: best way to do this

2008-12-02 Thread Diez B. Roggisch
TP wrote: > Hi everybody, > c=[(5,3), (6,8)] > > From c, I want to obtain a list with 5,3,6, and 8, in any order. > I do this: > [i for (i,j) in c] + [ j for (i,j) in c] > [5, 6, 3, 8] > > Is there a quicker way to do this? dunno if it's faster, but less cluttered: list(sum(c, ()))

Re: newbie question: parse a variable inside an RE?

2008-12-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hi All, How do I parse a variable inside an RE? What is the re.search() syntax when your search string is a variable? It's easy to parse hardcoded RE's but not if you use a variable. Both are exactly equal in difficulty. Here is my code, input and runtime: $ cat t

Re: Import of egg packages installed with easy_install

2008-12-01 Thread Diez B. Roggisch
Alexey Vlasov wrote: > Hi. > > There's an already installed with easy_install packet, let's say flup, > to the home catalog: > $ ls -la ~/python/lib/python2.5/site-packages/ > total 176 > drwxr-xr-x 3 4096 Nov 29 18:57 . > drwxr-xr-x 3 4096 Nov 29 18:51 .. > -rw-r--r-- 1 208 Nov 29 18:57 easy-

Re: RE multiline

2008-11-30 Thread Diez B. Roggisch
Guy Doune schrieb: Hi, I try to figure out what gonna be the equivalent of : (.*?) For the same purpose on multiline basis. I would like completed the variable part of elements that I searching for. Example : align="center"> Is the begining of the variable element that I wanna completed..

Re: PYTHONPATH in Windows

2008-11-29 Thread Diez B. Roggisch
waltbrad schrieb: PYTHONPATH is a concept I've never been able to get straight. I can't see the difference between this and just setting paths in the Windows environment variables. So, for the longest time I just never worried about it. Now, I'm going through James Bennett's "Practical Django P

Re: HELP!...Google SketchUp needs a Python API

2008-11-28 Thread Diez B. Roggisch
r schrieb: The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. Thanks Bruno, I never said Ruby is a bad Language! -food for though

Re: HELP!...Google SketchUp needs a Python API

2008-11-28 Thread Diez B. Roggisch
r schrieb: The fact _you_ don't like Ruby doesn't make it a bad language. If what you want is a Python API to SketchUp, bashing Ruby certainly won't help - quite on the contrary. And it won't help promoting Python neither. Thanks Bruno, I never said Ruby is a bad Language! -food for though

Re: Great exercise for python expert !

2008-11-28 Thread Diez B. Roggisch
Steven D'Aprano wrote: > On Fri, 28 Nov 2008 02:36:28 -0800, manatlan wrote: > >> I'd like to make a "jquery python wrapper" > [...] >> here is my code : > [...] > > What is the purpose of this code? As near as I can see, it would make an > excellent entry to the Obfuscated Python Competition, e

Re: Great exercise for python expert !

2008-11-28 Thread Diez B. Roggisch
> > I just want to make a jquery wrapper, and let people use it to write > jquery call on the server side in a python way ... > > o is a object, imagine a widget : like a textarea or input box > "js" is a special attribut of "o", which will let you write javascript > for this object. > > o=MyObj

Re: Is there any project whose patches are all available?

2008-11-28 Thread Diez B. Roggisch
ZelluX schrieb: Hi, all I want to write a version-tracking tool for Python projects, and need some sample projects whose even smallest modifications can be downloaded from the internet. Could you recommend some to me? Well, most of them have ... TADA ... Versioncontrol systems they use. Whic

Re: how to construct a list of only one tuple

2008-11-27 Thread Diez B. Roggisch
TP schrieb: [EMAIL PROTECTED] wrote: a=("1","2") b=[("3","4"),("5","6")] list(a)+b ['1', '2', ('3', '4'), ('5', '6')] a = ("1", "2") b = [("3", "4"), ("5", "6")] [a] + b [('1', '2'), ('3', '4'), ('5', '6')] Thanks a lot. Why this difference of behavior between list(a) and [a]? Because th

Re: Applying a decorator to a module

2008-11-27 Thread Diez B. Roggisch
lkcl schrieb: On Nov 27, 7:43 pm, [EMAIL PROTECTED] wrote: lkcl> Very simple question: how do you apply a decorator to an entire lkcl> module? Function-by-function or class-by-class. There is no decorator support for modules. awWww! i'm going to quietly throw my toys out of my pram.

Re: Help with capturing error

2008-11-27 Thread Diez B. Roggisch
tekion schrieb: Hello, I am getting the following error and my script is bailing out because of it. I have tried capturing it but it does not seem to work. Below is the error: ValueError: I/O operation on closed file the above error is received when, the following code snippet is executed:

Re: time function problem

2008-11-27 Thread Diez B. Roggisch
willie wrote: > My code: > > from time import time > def leibniz(terms): > > > acc = 0.0 > num = 4.0 # numerator value remains constant in the series > den = 1 > count = 0 > start_time = 0.0 > for aterm in range(terms): > nextterm = num/den * (-1)**aterm # (-1)

Re: trapping signal

2008-11-27 Thread Diez B. Roggisch
tekion wrote: > I have a while iterates forever. I would like to trap a SIGTERM signal > and execute some clean up code. How would I do this in python? Thanks. look into module "signal" Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating classes and objects more than once?

2008-11-27 Thread Diez B. Roggisch
Viktor Kerkez wrote: > Here is the situation: > > $ ls > test > $ cd test > $ ls > __init__.py data.py > $ cat __init__.py > > $ cat data.py > DATA = {} > > $ cd .. > $ python import os from test.data import DATA DATA['something'] = 33 os.chdir('test') from data import

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread Diez B. Roggisch
della wrote: > On 27 Nov, 11:21, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > >> You can't do that. How should python distinguish between the two modules >> with the same name? > > That's why I was trying to import them with different na

Re: Loading multiple versions of the same package at the same time

2008-11-27 Thread Diez B. Roggisch
della wrote: > Hi all, > > I've got some pickled files representing graphs (using networkx, > http://networkx.lanl.gov if you're interested) that were produced > using version 0.36 of the library. > > Now, they have released a new version of the library which is > incompatible with respect to pi

Re: Python equivalent of Common Lisp Macros?

2008-11-26 Thread Diez B. Roggisch
dpapathanasiou schrieb: I'm using the feedparser library to extract data from rss feed items. After I wrote this function, which returns a list of item titles, I noticed that most item attributes would be retrieved the same way, i.e., the function would look exactly the same, except for the sing

Re: Is the behavior expected?

2008-11-26 Thread Diez B. Roggisch
Alphones wrote: > On 11月26日, 下午9时28分, [EMAIL PROTECTED] wrote: >> Alphones: >> >> > it is a little deferent from other script language. >> >> See also here:http://en.wikipedia.org/wiki/Dynamic_scope#Dynamic_scoping >> >> Python doesn't have such automatic closures, probably for performance >> reas

Re: [lambda]Is the behavior expected?

2008-11-26 Thread Diez B. Roggisch
Alphones wrote: > Hi all, > > > def getFunc(x): > return lambda y : x + y > > if __name__ == '__main__': > todo = [] > proc = getFunc(1) > todo.append(lambda: proc(1)) > proc = getFunc(2) > todo.append(lambda: proc(1)) > proc = getFunc(3) > todo.append(lambda: pr

Re: Python C/API simple debugging

2008-11-26 Thread Diez B. Roggisch
k3xji wrote: > On Nov 26, 1:34 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> k3xji wrote: >> > I am new to Python C API and finding it difficult to debug C >> > extensions. So, basically I want to see the value of an integer value >> > during the C API. Here is the code: >> >> > #define LAST_MIX

Re: end of print = lower productivity ?

2008-11-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: On Nov 25, 5:05 pm, peter <[EMAIL PROTECTED]> wrote: BUT you now can do p = print p("f") Voila, 4 keystrokes saved :-) All right. Let's talk about that. When I write "print", it is both effortless and instantaneous : my hands do not move, a wave goes through my f

Re: SWIG vs. ctypes (Was: ANN: PyEnchant 1.5.0)

2008-11-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: On Nov 25, 4:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: You can't use ctypes for C++, only for C-style APIs. Diez With some work, you can convert your C++ objects to PyObject* and then return the latter in a function with C bindings.

Re: end of print = lower productivity ?

2008-11-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > On Nov 25, 4:53 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> I used to use print a lot. Once I found >> >> import pdb; pdb.set_trace() >> >> I massively lost interest in it. And gained *much* more debugging >&

Re: end of print = lower productivity ?

2008-11-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > I want my productivity back. > > In Python 2.x, I could easily write things like -- print "f" / print > "add" / print "done" -- to a lot of different places in my code, which > allowed me to find bugs that I could not track otherwise. When I found > out that "f" was not

Re: SWIG vs. ctypes (Was: ANN: PyEnchant 1.5.0)

2008-11-25 Thread Diez B. Roggisch
Roy Smith wrote: > In article <[EMAIL PROTECTED]>, > Ryan Kelly <[EMAIL PROTECTED]> wrote: > >> * Migrated from SWIG to ctypes for the C binding: > > Ryan, > > I'm looking at a doing a Python wrapper for a C++ library. We've already > done a Perl wrapper for this library using SWIG (I wasn't

Re: Python 3000

2008-11-24 Thread Diez B. Roggisch
alex23 wrote: > On Nov 24, 5:47 pm, Dokorek <[EMAIL PROTECTED]> wrote: >> Python 3000 (a.k.a. "Py3k", and released as Python 3.0) is a new >> version of the language that is incompatible with the 2.x line of >> releases. The language is mostly the same, but many details, >> especially how built-in

Re: Install modules with no root privilegies

2008-11-24 Thread Diez B. Roggisch
Philipp Pagel wrote: > Alfons Nonell-Canals <[EMAIL PROTECTED]> wrote: >> Install python modules in a linux computer is really easy, it is because >> the module is a package of the distribution or because the python >> installation is really easy. But, in both situations, you need root >> privileg

Re: build minimal python 2.6 on linux

2008-11-23 Thread Diez B. Roggisch
r schrieb: I would like to install minimal version if python 2.6 on a linux laptop (and no there is not one already installed...i checked) i have no way to access the net with the laptop. So basicly i down loaded the 2.6 source and unpacked it on my other PC. The files weigh in at 51MB and some c

Re: can the sequence of entries in a dictionary be depended on?

2008-11-21 Thread Diez B. Roggisch
Priya wrote: > Hi, > I'm writing a program where i iterate through the entries in a > dictionary using a for loop. This for-loop is enclosed by another loop > which traverses through a list and checks the relation between each > entry in the list and each entry in the dictionary. > while I know th

Re: Custom Formatting The Output Of subprocess.Popen

2008-11-21 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello, > > I'm launching a script as follows: > > p = subprocess.Popen(['./p.py', 'aa']) > > p.wait() > > > If p.py writes to sys.stdout, then it is shown on the console. > Looking at the console, then, it is hard to distinguish the output of > p.py from that

Re: Can't find Python Library packages in Ubuntu (Debian)

2008-11-20 Thread Diez B. Roggisch
Jerzy Jalocha N wrote: > I'm new in this list (and to Python), so I'd like to start saying > hello to everyone first. I am really enjoying this new language! > > I am trying to use the standard tests (like test_list.py or > test_dict.py) from the standard library (Python2.5), but they aren't > av

Re: Multiple equates

2008-11-17 Thread Diez B. Roggisch
Arnaud Delobelle wrote: > jzakiya <[EMAIL PROTECTED]> writes: > >> I looked online and in books, but couldn't find a definitive answer to >> this. >> >> I have an array and set multiple elements to either True or False at >> one time. >> >> Question: Which way is faster (or does it matter)? >> >>

Re: Installing Python2.6 on Mac Os (Leopard)

2008-11-17 Thread Diez B. Roggisch
> Sorry if I misinformed; I have such symlinks in /usr/local/bin dated > the same day as my custom Python install. I guess I could have created > them myself, but I don't think I would have bothered creating a > symlink for pythonw, for example since I never use it. > Did you really create a fram

Re: Suggestions for an education programming project

2008-11-17 Thread Diez B. Roggisch
Eric wrote: > Hi, > > I've been trying to get my son interested in learning some simple > programming for a while. While I understand that a structured tutorial > is best, I think if we can write something cool at least once, it will > encourage him to learn more. While I have a lot of experience

Re: Installing Python2.6 on Mac Os (Leopard)

2008-11-17 Thread Diez B. Roggisch
Philip Semanchuk wrote: > > On Nov 17, 2008, at 10:53 AM, Massi wrote: > >> Hi everyone, I'm trying to install Python2.6 on my mac (Leopard >> 10.5.5), but I'm encountering some problems. To install the package I >> followed the instructions I found at this link: >> http://wiki.python.org/moin/M

Re: Uninstall one of two Python's

2008-11-17 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, > > Is it possible to remove one of two instances of Python installed on > the same machine? I have two Python-2.5.2, one in /usr/local/bin/ > python2.5 and the other one in /usr/bin/python2.5. The latter has the > modules I use (kinterbasdb, psycopg, mod_python,...

Re: re.match and non-alphanumeric characters

2008-11-16 Thread Diez B. Roggisch
John Machin schrieb: On Nov 17, 4:44 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Match matches the whole string. *ONLY* if the pattern ends with "$" or r"\Z" You think so? import re rex = re.compile("abc.*def") if rex.match(&q

Re: re.match and non-alphanumeric characters

2008-11-16 Thread Diez B. Roggisch
The Web President wrote: > Dear all, > > this is really driving me nuts and any help would be extremely > appreciated. > > I have a string that contains some numeric data. I want to isolate > these data using re.match, as follows. > > bogus = "IFC(35m)" > data = re.match(r'(\d+)',bogus) > print

Re: Is this optparse object abuse?

2008-11-16 Thread Diez B. Roggisch
John O'Hagan wrote: > On Sun, 16 Nov 2008, Diez B. Roggisch wrote: >> > In other words, using the optparse object to hold as attributes >> > everything needed by all the functions and methods in the module, and >> > simply passing it holus bolus to a

Re: Is this optparse object abuse?

2008-11-16 Thread Diez B. Roggisch
> In other words, using the optparse object to hold as attributes everything > needed by all the functions and methods in the module, and simply passing > it holus bolus to all them and just pulling out what's actually needed > inside the function, even adding new attributes or reassigning old ones

Re: Python IF THEN chain equivalence

2008-11-13 Thread Diez B. Roggisch
jzakiya schrieb: I'm translating a program in Python that has this IF Then chain IF x1 < limit: --- do a --- IF x2 < limit: --- do b --- IF x3 < limit: --- do c --- .- -- IF x10 < limt: --- do j ---

Re: Installing packages

2008-11-13 Thread Diez B. Roggisch
Alan Baljeu schrieb: I'm new to Python, and just downloaded Py2.6. I also want to use Nose. So I downloaded the latest sources, but it's not at all clear what's the best way to put this stuff into the Python package system. Nose supports easy_install, easy_install doesn't have an installer for

Re: problem with JSON-RPC

2008-11-12 Thread Diez B. Roggisch
Michel Perez wrote: > Hi everybody: > I'm trying to use JSON-RPC to provide my services but produce this > exception: > > Traceback (most recent call last): > File "", line 1, in > File "jsonrpc/proxy.py", line 43, in __call__ > resp = loads(respdata) > File "jsonrpc/json.py", line 21

Re: Project layout / Import files from different subdirectories

2008-11-11 Thread Diez B. Roggisch
Markus Mayer schrieb: Hi folks. I'm new to python and have a slight problem importing - or maybe understanding - modules. I'm writing a GUI application using Qt4 and wanted to separate the business from the view logic. So I have my folder structure as following: project/ main.py import

Re: sorting list of complex numbers

2008-11-09 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: The thread on sorting in Python 3 got me to thinking. How could I sort a list of complex numbers using key? >>> lst = [random.random()+random.random()*1j for i in range(10)] >>> lst [(0.32672251849959244+0.41428983433288791j), (0.35238056484609881+0.92758

Re: Python 3.0 - is this true?

2008-11-09 Thread Diez B. Roggisch
Roy Smith schrieb: In article <[EMAIL PROTECTED]>, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Also, I thought that part of the python philosophy was to allow any sort of object in a list, and to allow the same methods to work with whatever was in list. Not really. W

Re: Python 3.0 - is this true?

2008-11-09 Thread Diez B. Roggisch
Also, I thought that part of the python philosophy was to allow any sort of object in a list, and to allow the same methods to work with whatever was in list. Not really. When the usual argument about the existence (and justification) of lists & tuples comes along, one common distinction is t

Re: contextlib.nested()

2008-11-06 Thread Diez B. Roggisch
> Diez, Robert, > > OK. The practice of "going live" or doing non-trivial initialization > in __enter__ is new to me. I'm new to Python with a C++ background, so > that shouldn't be a surprise. :-) > > Ideally I would like to put all initialization in __init__ since then > I would be able to use

Re: bind to HTMLayout or ubrowser

2008-11-06 Thread Diez B. Roggisch
oyster wrote: > http://www.terrainformatica.com/htmlayout/ "uses its own lightweight > HTML rendering engine", helps you to create applications with the "Web > style" user interface > > http://ubrowser.com/ "is a library that makes it a little easier to > embed the Mozilla Gecko rendering engine

Re: How to re-import a function from a module?

2008-11-06 Thread Diez B. Roggisch
Kurda Yon wrote: > Hi, > > I have the following small problem. I run Python interactively. In the > beginning of the run I import many functions from many modules. Than I > execute some commands and notice that one of the imported functions > contains a mistake. I open another terminal in which I

Re: contextlib.nested()

2008-11-06 Thread Diez B. Roggisch
brasse wrote: > Hello! > > I have been running in to some problems when using > contextlib.nested(). My problem arises when using code similar to > this: > > from __future__ import with_statement > > from contextlib import nested > > class Foo(object): > > def __init__(self, tag, fail=Fal

Re: Inheritance problem

2008-11-05 Thread Diez B. Roggisch
Mr.SpOOn wrote: > Hi, > I have a problem with this piece of code: > > > class NoteSet(OrderedSet): > def has_pitch(self): > pass > def has_note(self): > pass > > class Scale(NoteSet): > def __init__(self, root, type): > self.append(root) > self.type =

<    5   6   7   8   9   10   11   12   13   14   >