Re: how to convert a multiline string to an anonymous function?

2008-04-29 Thread Diez B. Roggisch
Danny Shevitz schrieb: Simple question here: I have a multiline string representing the body of a function. I have control over the string, so I can use either of the following: str = ''' print state return True ''' str = ''' def f(state): print state return True ''' and I want to convert

Re: timeout

2008-04-29 Thread Diez B. Roggisch
maehhheeyy schrieb: Hi, I was just wondering if there was such thing as a timeout module. time.sleep? Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: python command mis-interprets arrow keys

2008-04-29 Thread Diez B. Roggisch
Rahul schrieb: My python command line seems messed up. I can't seem to be able to use my backspace key nor my arrow keys. I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc. I access my Linux box via a SecureCRT console. Only after opening the python interpreter does this occur

Re: API's and hardware communication. Newbie

2008-04-29 Thread Diez B. Roggisch
Grayham schrieb: It seems to me that python needs to be extended with C in some form to able to do what i need. I think instead of learning two languages i am going to put all my efforts in to learning C as it seems that's where i am going to end up. It's your decision of course. But you will e

Re: python command mis-interprets arrow keys

2008-04-29 Thread Diez B. Roggisch
Rahul schrieb: "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: Is libreadline installed? Thanks for your help Diez. I did a locate and found: /usr/lib/libreadline.a /usr/lib/libreadline.so /usr/lib/libreadline.so.5 /usr/lib/libreadline.so.5.1 /usr/

Re: computing with characters

2008-04-30 Thread Diez B. Roggisch
However, join() is really bizarre. The list rather than the separator should be the leading actor. Certainly *not*! This would be the way ruby does it, and IMHO it does not make sense to add join as a string-processing related method/functionality to a general purpose sequence type. And as ot

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Diez B. Roggisch
Lance Gamet schrieb: Hi, python beginner starting a new project here. This project will store most of its actual data in a shared-database, but I have a small amount of user specific data that I need to be stored like configuration or preferences for example, the list of databases that the pr

Re: is +=1 thread safe

2008-05-01 Thread Diez B. Roggisch
believe that +=1 is not a thread safe operation. don't confuse augmented assignment with incrementation as it is offered by C (if your data-type actually fits into a single addressable memory spot, that is) python's += works like this a += b <=> a = a.__iadd__(b) Thus yo

Re: is +=1 thread safe

2008-05-02 Thread Diez B. Roggisch
Duncan Booth schrieb: Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: On Thu, 01 May 2008 15:33:09 -0700, Gary Herron wrote: Of course it's not thread safe. For the same reason and more basic, even the expression i++ is not thread safe in C++. Any such calculation, on modern processor

Re: creating a list from a inconsistent text file

2008-05-02 Thread Diez B. Roggisch
Jetus schrieb: On May 2, 7:19 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: On Fri, 02 May 2008 04:14:47 -0700, Jetus wrote: I have a comma delimited file that is separated by comma's, and then sometimes by "," c:\temp\05-06-08\Sale1,659 CECIL,"659 CECIL,40211", 1,659,CECIL,AVENUE,LOU

Re: pygame.key.get_pressed[K_a], K_a is not defined!?

2008-05-02 Thread Diez B. Roggisch
globalrev schrieb: if pygame.key.get_pressed[K_a]: print "Muppet" K_a is not defined. but yes it is. why do i get this error? No it isn't - otherwise you wouldn't get this error, wouldn't you? What IS defined is pygame.K_a Or if you do from pygame import K_a then K_a is defi

Re: pygame.key.get_pressed[K_a], K_a is not defined!?

2008-05-03 Thread Diez B. Roggisch
globalrev schrieb: On 2 Maj, 18:13, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: globalrev schrieb: if pygame.key.get_pressed[K_a]: print "Muppet" K_a is not defined. but yes it is. why do i get this error? No it isn't - otherwise you wouldn't

Re: Weird import problem

2008-05-04 Thread Diez B. Roggisch
Anton81 schrieb: I have a directory structure like NS/dir1/file1.py NS/dir2/file2.py This *must* be wrong or at least not the full directory listing - please read http://docs.python.org/tut/node8.html if in the python shell I type import NS.dir1.file1 it works, however typing import N

Re: Real Time Midi File Playback - Reading and Writing midi at the same time

2008-05-04 Thread Diez B. Roggisch
Gilly schrieb: On May 4, 9:14 pm, David <[EMAIL PROTECTED]> wrote: On Sun, May 4, 2008 at 7:11 PM, Gilly <[EMAIL PROTECTED]> wrote: Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I

Re: pygame.mixer.load not working

2008-05-04 Thread Diez B. Roggisch
globalrev schrieb: import pygame pygame.mixer.music.load(example1.mp3) pygame.mixer.music.play(loops=1, start=0.0) Traceback (most recent call last): File "C:\Python25\myPrograms\pygameProgs\musicexp.py", line 3, in pygame.mixer.music.load(example1.mp3) NameError: name 'example1' is not

Re: Can I install Python 2.4 and 2.5 ?

2008-05-04 Thread Diez B. Roggisch
adolfo schrieb: I am reviewing various visualization programs (Scipy, PYGNL, etc) and IDE´s. Some run on Python 2.4 others in 2.5. Can I have both installed at the same time if I don´t run them concurrently? Now in Windows XP soon on Ubuntu 8 Appreciating your help, Yes you can. However you

Re: USB HID documentation?

2008-05-05 Thread Diez B. Roggisch
ETP wrote: > I have a little robot project I'm programming in python using the > Lynxmotion SSC-32 servo controller via serial. I'd like to use a USB > game controller (PS2 style) to control the robot. > > I've read a number of threads about the difficulty of using USB > without extensive unders

Re: pygame music, cant read mp3?

2008-05-05 Thread Diez B. Roggisch
globalrev wrote: > http://www.pygame.org/docs/ref/mixer.html > > import pygame > > #pygame.mixer.init(frequency=22050, size=-16, channels=2, > buffer=3072) //it complained abiout words= > so i guess its only the nbrs should be there// > > pygame.mixer.init(22050, -16, 2, 3072) > pygame.mixer.m

Re: confused about self, why not a reserved word?

2008-05-05 Thread Diez B. Roggisch
globalrev wrote: > class Foo(object): > def Hello(self): > print "hi" > > object is purple, ie some sort of reserved word. It is not. > why is self in black(ie a normal word) when it has special powers. > replacing it with sel for example will cause an error when calling > Hello. That must be

Re: Pygame and PGU

2008-05-05 Thread Diez B. Roggisch
Zaka wrote: > Hi. I need some help to make map system in PGU. For exmple we have 2 > maps and when we leave first we enter to second. > > > >! > > > ___ What is a PGU? What is a map-system? And what is that ascii art above? And what might you

Re: pygame music, cant read mp3?

2008-05-05 Thread Diez B. Roggisch
> directory = ['C:','Python25','myPrograms','pygameProgs','dront.mp3'] > os.path.join(directory) > > Then python can worry about the gritty details, and you don't have to. Or somewhat neater IMHO: os.path.join('C:','Python25','myPrograms','pygameProgs','dront.mp3') Diez -- http://mail.python.

Re: read line

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > hi every body, > > I'm a new python user and I'm making a program to run useing Abaqus > and there is something I can't do, > > if i have a text file that has a line like this " 10 20 30 40 > 50" and I wana do the coding to put every number of these like 10 or >

Re: parameters to lambda's executed at run time.

2008-05-06 Thread Diez B. Roggisch
wyleu wrote: > I'm trying to supply parameters to a function that is called at a > later time as in the code below: > > llist = [] > > for item in range(5): > llist.append(lambda: func(item)) > > def func(item): > print item > > for thing in llist: > thing() > > which produces the

Re: Confusion regarding the readline module

2008-05-06 Thread Diez B. Roggisch
Siddhant wrote: > Hi! > I am having some doubts related to the readline module. I hope someone > could clear them. > 1. What exactly does the readline.get_line_buffer() function do? Does > it return whatever is the current input by the user? If yes, then can > I use it to check the current inputs

Re: Bad form to access a *private variable* like _foo?

2008-05-06 Thread Diez B. Roggisch
> The way you wrote it here, yes. If there's no official way to do the > same operation and you have a real use case for it - in which case you > may want to add a commit() method to SQLObject's model base class and > submit the patch to SQLObject's maintainer. But I strongly suspect > there's a be

Re: Cannot install Pypvm (Python Parallel Virtual Machine)

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello. > > I am trying to install Pypvm (http://pypvm.sourceforge.net/), the > Python interface to PVM ("Parallel Virtual Machine"). Unfortunately, > installation fails. I am hoping someone can help me fix it. > > I am running Fedora Core 8 Linux. > > The official Pyp

Re: use php in python httpservers

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, that is my task: > I need to create python webserver-like extension(dll) which will run > php and python scripts as plugins. > I have no problems with dll creating and run python scripts, but I > cannot understand how to run php(CLI is not a solution). > Is there a w

Re: how to use subprocess.Popen execute "find" in windows

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > In cmd, I can use find like this. > > C:\>netstat -an | find "445" > TCP0.0.0.0:4450.0.0.0:0 LISTENING > UDP0.0.0.0:445*:* > > C:\> > > And os.system is OK. import os os.system('netstat -an | find "445"') >

Re: Comparing strings - akin to Perl's "=~"

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello gurus, > > I am learning Python to take the place of Perl in my toolbox of bits > and bobs, and writing something pretty simple in theory, but having a > hard time in Python with it - I am using a 3rd party module, and I am > sure the etiquette of this channel sta

Re: Am I missing something with Python not having interfaces?

2008-05-06 Thread Diez B. Roggisch
jmDesktop wrote: > Studying OOP and noticed that Python does not have Interfaces. Is > that correct? Yes. > Is my schooling for nought on these OOP concepts if I > use Python. Am I losing something if I don't use the "typical" oop > constructs found in other languages (Java, C# come to mind.

Re: sed to python: replace Q

2008-05-06 Thread Diez B. Roggisch
> Ah ha, thar's the disconnect. Thanks for all the pointers, my def is > now working. Still don't understand the logic behind this design though. > I mean why would any programming language have separate search or find > functions, one for regex and and another for non-regex based pattern > match

Re: Learning question...

2008-05-07 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Any idea why the following program does not work? I was learning IO on > Python and the following generates a TypeError: range() integer end > argument expected, got str. > I am a beginner. Because raw_input does return you as string which you need explicitly convert to

Re: PHP + TinyButStrong Python replacement

2008-05-07 Thread Diez B. Roggisch
pistacchio wrote: > Mike Driscoll ha scritto: >> On May 7, 6:12 am, pistacchio <[EMAIL PROTECTED]> wrote: >>> hi! i'm a php user and a python programmer. i'd love to use python for >>> my server side needs but i can't seem to find what i'm looking for. for >>> most of my php work i use mysql and t

Re: saving a webpage's links to the hard disk

2008-05-07 Thread Diez B. Roggisch
Jetus wrote: > On May 4, 7:22 am, [EMAIL PROTECTED] wrote: >> On May 4, 12:33 am, "Gabriel Genellina" <[EMAIL PROTECTED]> >> wrote: >> >> > En Sun, 04 May 2008 01:33:45 -0300, Jetus <[EMAIL PROTECTED]> >> > escribió: >> >> > > Is there a good place to look to see where I can find some code that >>

Re: Why don't generators execute until first yield?

2008-05-07 Thread Diez B. Roggisch
> Now to the main point. When a generator function is run, it immediately > returns a generator, and it does not run any code inside the generator. > Not until generator.next() is called is any code inside the generator > executed, giving it traditional lazy evaluation semantics. Why don't > genera

Re: pickle problem

2008-05-08 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > I'm wondering if anyone can help with a workaround for a problem I > currently have. I'm trying to set up a prefork tcp server. > Specifically, I'm setting up a server that forks children and has them > listen on pipes created with os.pipe(). The parent process for the

Re: Idea for P3K

2008-05-08 Thread Diez B. Roggisch
M�ta-MCI (MVP) wrote: > Hi! > >> I don't often feel like using this word > > Look at languages like OCAML or F # The point being? Yes, shockingly enough other languages have other syntax & semantics. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: How to kill Python interpreter from the command line?

2008-05-08 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello. > > I am running Fedora Linux and KDE, using the Konsole command line. > > When coding Python, I regularly make a bug causing my program to not > terminate. But how do I kill the non-terminating Python interpreter > without killing the entire Konsole? > > The d

Re: Python Syntax and misspelled variable and method name checker?

2008-05-08 Thread Diez B. Roggisch
neerashish schrieb: Is there a good Python Syntax and mis-spelled variable and method name checker available. I have been programming in python for last 6 months and misspelled variables and method names have been bane of my python life. In complied languages, compiler checks for these mista

Re: Python GUIs and custom controls

2008-05-09 Thread Diez B. Roggisch
Joe P. Cool schrieb: So far I have a little experience with Tkinter and wxPython. I wonder which of the numerous Python GUI kits would be the best choice for a multi platform application that makes heavy use of custom controls, 3D views and the like? Thanks in advance for your hints and advice.

Re: Find more than one error at once

2008-05-10 Thread Diez B. Roggisch
Joseph Turian schrieb: Is it possible to coax python to find more than one error at once? What kind of errors? Syntax-errors? Then use one of the python source code analyzers, such as pylint or pychecker. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Now what!?

2008-05-10 Thread Diez B. Roggisch
notbob schrieb: Grrr I'm following A Byte of Python and into the while loops chap. I cp/paste while.py to a file and give 777 perms. I mv while.py to while and run it (./while) as a standalone script. I get errors. Here is the script: while.py http://www.ibiblio.org/swaroopch/byteofpy

Re: Trying ZODB, background in Relational: mimic auto_increment?

2008-08-14 Thread Diez B. Roggisch
Jean-Paul Calderone schrieb: On Thu, 14 Aug 2008 16:15:11 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Jean-Paul Calderone wrote: On Thu, 14 Aug 2008 05:22:35 -0700 (PDT), Phillip B Oldham <[EMAIL PROTECTED]> wrote: [snip] How would one assign a unique ID to

Re: if in expression

2008-08-18 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hi, I'm using IronPython to evaluate expressions, so I can't use the return statement but have to say it in an one-liner. Using C/C++ I could use "cond ? then : else" to have an expression-if, but in Python there's no such operator. The "cond and then or else"-trick onl

Re: if in expression

2008-08-18 Thread Diez B. Roggisch
Hrvoje Niksic schrieb: "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: Since python 2.5, it is if else If you want lazy evaluation, you can use lambdas: iif(cond, lambda: then, lambda: else_)() Your code uses "iif" and attempts to evaluate a tuple; could you

Re: Bizarre method keyword-arg bug.

2008-08-18 Thread Diez B. Roggisch
Jasper schrieb: I'm stumped. I'm calling a method that has keyword args, but not setting them, and yet one of them starts off with data?! The class definition begins like so: class BattleIntentionAction( BattleAction ): def __init__( self, factionName, location, tactic='hold', targetFacNam

Re: Getting pid of a remote process

2008-08-18 Thread Diez B. Roggisch
srinivasan srinivas schrieb: Hi, Could you please suggest me a way to find pid of a process started on a remote machine by the current process?? I should get pid in the current process environment. The approach should be somewhat generic. It shouldn't expect the remote process to print its pid

Re: Python Substitute for PHP GD, Resizing an image on the client side

2008-08-18 Thread Diez B. Roggisch
brahmaforces schrieb: Hi Folks, I am using cherrypy and python. I am trying to get a user profile image to resize on the client side before uploading to the server. PHP has a gd library that does it it seems. Has anyone done this in a python environment without uploading to the server? Everyth

Re: Getting pid of a remote process

2008-08-19 Thread Diez B. Roggisch
srinivasan srinivas schrieb: HI, I am using Solaris and subprocess.Popen to spawn a process on a remote machine. No, you are *not* doing that. You are maybe using subproces to run SSH to spawn a remote process. Why don't you *show* us how you actually do that? DIEZ -- http://mail.python.org/

Re: Python Substitute for PHP GD, Resizing an image on the client side

2008-08-19 Thread Diez B. Roggisch
> Does anyone have any code that does the javascript "selecting the > rectangle bit" and uploading to the server. I've based my work in this field on some freely available JS, but don't know what it was called. Google is your friend here. > Also incidentally is ftp > or put the recommended way t

Re: Getting pid of a remote process

2008-08-19 Thread Diez B. Roggisch
srinivasan srinivas wrote: > This is wat i am doing : > > args = [ "SSH", ,  ] > I am giving this to subprocess.Popen() > Thanks, > Srini Then the answer is simple: how would you figure out the remote process pid using ssh? Once you found that out, pass that to Popen. Make sure you capture stdou

Re: WindowsXP / CTypes Module - unable to access function in a dll

2008-08-19 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, > > I'm using the CTYPES module of python to load a dll. My dll contains a > Get_Version function as: > long __stdcall af1xEvdoRDll_GetVersion(long version[4]); > > This function accepts a long array of 4 elements. > > Following is the python code I've written: >

Re: Getting pid of a remote process

2008-08-19 Thread Diez B. Roggisch
srinivasan srinivas wrote: > Thanks a lot. > But i am wondeing will it return correct pid if more than one instance of > run on the remote machine?? Thanks, What do you *think*? How about *trying* that out first? Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: who to call a list of method inside the class itself

2008-08-19 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: >> >> [EMAIL PROTECTED] wrote: >> >> > 1. return string names of required methods in getAllMethod >> > return ['method1', 'method2', 'method3'] >> > 2. use gettattr on self and then exetute methods in applyAll >> > def applyAll(self): >> > for

Re: Python Substitute for PHP GD, Resizing an image on the client side

2008-08-20 Thread Diez B. Roggisch
brahmaforces wrote: > Hi Diez: > The file browse button will get me a filename on the client machine. > You are saying post will transfer the file itself? I am using straight > cherrypy no turbo gears etc, so ill have to do manually. You need to use POST, and some enctype-this-or-that-stuff. Ther

Re: simple Question about using BeautifulSoup

2008-08-20 Thread Diez B. Roggisch
Alexnb wrote: > > Okay, I have used BeautifulSoup a lot lately, but I am wondering, how do > you open a local html file? > > Usually I do something like this for a url > > soup = BeautifulSoup(urllib.urlopen('http://www.website.com') > > but the file extension doesn't work. So how do I open on

Re: evaluating code lines above breakpoints ?

2008-08-21 Thread Diez B. Roggisch
Stef Mientki wrote: > hello, > > I'm trying to create a high level debugger, based on rpd2. > > So when the debugger enters a breakpoint, > I want to display the values of all variables in the, let's say, > 5 lines above the breakpoint (if possible). > Any hints on how I get a list of all vars i

Re: Is my thinking Pythonic?

2008-08-21 Thread Diez B. Roggisch
Hussein B wrote: > Hey, > Well, as you all know by now, I'm learning Python :) > One thing that is annoying my is the OOP in Python. > Consider this code in Java: > -- > public class Car { > private int speed; > private String brand; > // setters & get

Re: semantics of the |= operator

2008-08-21 Thread Diez B. Roggisch
akva wrote: > Hi All, > > what's the exact semantics of the |= operator in python? > It seems that a |= d is not always equivalent to a = a | d > > For example let's consider the following code: > > def foo(s): >s = s | set([10]) > > def bar(s): >s |= set([10]) > > s = set([1,2]) > >

Re: Is my thinking Pythonic?

2008-08-21 Thread Diez B. Roggisch
Craig Allen wrote: > generally, I name the members in the Class definition and set them to > None there... > > class Car: >speed = None >brand = None > >def __init__(): > self.speed = defaultspeed #alternately, and more commonly, get > this speed as a initializer argument >

Re: Having trouble with tail -f standard input

2008-08-21 Thread Diez B. Roggisch
sab schrieb: Hello, I have been working on a python script to parse a continuously growing log file on a UNIX server. The input is the standard in, piped in from the log file. The application works well for the most part, but the problem is when attempting to continuously pipe information into

Re: def X(l=[]): weirdness. Python bug ?

2008-08-22 Thread Diez B. Roggisch
Wojtek Walczak schrieb: On Fri, 22 Aug 2008 11:13:52 +0200, Bart van Deenen wrote: I've stumbled onto a python behavior that I don't understand at all. ... Does anyone have any pointers to the language documentation where this behavior is described? Yes, it's documented in FAQ: http://www.

Re: Trouble importing modules in IDLE (Win32)

2008-08-22 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and dbi modules. However, when I restart the shell and type "import odbc" at th

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

2008-08-22 Thread Diez B. Roggisch
Steven D'Aprano schrieb: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one starts up. I suggest that P

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

2008-08-22 Thread Diez B. Roggisch
Emile van Sebille schrieb: Steven D'Aprano wrote: Sometimes it seems that barely a day goes by without some newbie, or not- so-newbie, getting confused by the behaviour of functions with mutable default arguments. No sooner does one thread finally, and painfully, fade away than another one sta

Re: swig double[], under the gun and need help

2008-08-25 Thread Diez B. Roggisch
- > my test code looks like this: > import sys, os, rug520 > cmi=[0.0] *59 > > def getrug(mds): > results = rug520.RugCalc(mds, 'mcare', '34', 0, cmi) > print 'results', results > > datafile = open('mdsdata.txt') >

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Diez B. Roggisch
ssecorp schrieb: GvR wants to eliminate all the functional stuff (lambda map reduce filter) which kind of makes sense for Python, listcomprehensions are more efficient(at least as implemented inpython) from what i have gathered and they can express everything map/reduce/filter with crippled lambd

Re: python - firefox dom/xpath question/issue

2008-08-25 Thread Diez B. Roggisch
bruce schrieb: Hi. Got a test web page, that basically has two " . . . I've simplified things a bit... but basically, the 1st "html/body" is empty, with the 2nd containing the data/nodes I need. If that's your document, it is invalid XML - XML only allows *one* root. Thus the parsers

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Diez B. Roggisch
Luis M. González schrieb: Correction: I guess the link I provided above is old news... In the more recent Python 3000 FAQ, GvR says: Q. If you're killing reduce(), why are you keeping map() and filter()? A. I'm not killing reduce() because I hate functional programming; I'm killing it because a

Re: swig or ctypes , under the gun and need help

2008-08-25 Thread Diez B. Roggisch
Sells, Fred schrieb: Diez wrote... I don't know swig, but if all you have is a real C-API, try & use ctypes. It's much easier to create bindings for, keeps you fully in the warm and cozy womb of python programming and doesn't need no compilation to create the actual binding. You're right th

Re: Are dictionaries the same as hashtables?

2008-08-26 Thread Diez B. Roggisch
Martin Marcher wrote: > On 2008-08-26 00:32:20, cnb wrote: >> Are dictionaries the same as hashtables? > > Yes, but there is nothing in there that does sane collision handling > like making a list instead of simply overwriting. The term "collision" is rather well defined when talking about assoc

Re: Are dictionaries the same as hashtables?

2008-08-26 Thread Diez B. Roggisch
John Machin wrote: > On Aug 26, 7:36 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> Martin Marcher wrote: >> > On 2008-08-26 00:32:20, cnb wrote: >> >> Are dictionaries the same as hashtables? >> >> > Yes, but there is nothing

Re: property() usage - is this as good as it gets?

2008-08-26 Thread Diez B. Roggisch
> P.S. How did my post manage to ignite a mini flame war?! Because of the high resident troll quota in replies - which is created by just one rather annoying member of this community... Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: atomic increment

2008-08-26 Thread Diez B. Roggisch
Alexandru Mosoi wrote: > how can i do an atomic read+increment? something like > > with lock: >old = atomic_int >atomic_int += 1 > > but in one operation As above - the lock (under the assumption that it is actually a threading.Lock) will ensure that. Diez -- http://mail.python.org/ma

Re: Are dictionaries the same as hashtables?

2008-08-26 Thread Diez B. Roggisch
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>Martin Marcher wrote: >> >>> On 2008-08-26 00:32:20, cnb wrote: >>>> Are dictionaries the same as hashtables? > . > . > . >>P

Re: Using Python to shared memory resources between Linux and Windows

2008-08-26 Thread Diez B. Roggisch
Blubaugh, David A. schrieb: To All, To whom else if I may ask? I was wondering if it was possible to utilize python to share a memory resource between a linux and windows system?? It should be stated that both the Linux (CENTOS 5) and windows are physically located on the same computer. Is

Re: Using Python to shared memory resources between Linux and Windows

2008-08-27 Thread Diez B. Roggisch
Blubaugh, David A. schrieb: Diez, What you have said is extremely concerning. I am now using VMware. With Linux as the Master and windows as the guest operating system. I was wondering if you have ever had to develop a share memory resource between Linux and windows within a Vmware setup?

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
nisp schrieb: Hi all ! I'm trying to capture stderr of an external module I use in my python program. I'm doing this by setting up a class in my module overwriting the stderr file object method write. The external module outputs to stderr this way: from sys import std err print >

Re: SQL package

2008-08-27 Thread Diez B. Roggisch
Juan schrieb: Hi I am trying to write a little a script that can be configurable. This script should access to a database, that can be of any type (MySQL, Postgres, SQLite, MS, etc).It has only to perform 2 or 3 simple plain SQL queries. Hi have tested SQLAlchemy, and it is great, but too much f

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
alex23 schrieb: nisp <[EMAIL PROTECTED]> wrote: I've always been convinced of the equivalence of the two ways of using the import statement but it's clear I'm wrong :-( Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "cre

Re: Inspecting the Instance Vars in a class/object - How?

2008-08-27 Thread Diez B. Roggisch
BrendanC wrote: > I'm trying to understand reflection/introspection in Python. How can I > identify the the type of attribute (e.g. instance var) in a class? > The following returns all the class attributes (methods and instance > vars). > > However I'm interested in identifying the type of value

Re: use of Queue

2008-08-27 Thread Diez B. Roggisch
Alexandru Mosoi wrote: > how is Queue intended to be used? I found the following code in python > manual, but I don't understand how to stop consumers after all items > have been produced. I tried different approaches but all of them > seemed incorrect (race, deadlock or duplicating queue functio

Re: use of Queue

2008-08-27 Thread Diez B. Roggisch
> > Your solution works assuming that you know how many consumer threads > you have :). I don't :). More than that, it's not correct if you have > more than one producer :). Having a sentinel was my very first idea, > but as you see... it's a race condition (there are cases in which not > all item

Re: unexpected from/import statement behaviour

2008-08-27 Thread Diez B. Roggisch
nisp wrote: > On Aug 27, 9:56 am, Peter Otten <[EMAIL PROTECTED]> wrote: >> nisp wrote: >> > Hi all ! >> >> > I'm trying to capture stderr of an external module I use in my python >> > program. I'm doing this >> > by setting up a class in my module overwriting the stderr file object >> > method wr

Re: How to update value in dictionary?

2008-08-27 Thread Diez B. Roggisch
ssecorp wrote: > dict.update({"a":1}) SETS the dict item "a" 's value to 1. > > i want to increase it by 1. isnt that possible in an easy way? I > should use a tuple for this? 1) Don't use dict as name for a dictionary, it shadows the type dict 2) setdefault is your friend d = {} d['a'] = d.s

Re: how do I stop SocketServer()?

2008-08-27 Thread Diez B. Roggisch
Alexandru Mosoi wrote: > supposing that I have a server (an instance of SocketServer()) that > waits for a connection (ie is blocked in accept()) and in another > thread i want to stop the server, how do I do that? By setting a timeout on the socket using socket.settimeout, and then periodically

Re: Function References

2008-08-28 Thread Diez B. Roggisch
> Zen's lesson for today: > THOU SHALT NOT MESS WITH ANY PYTHON'S SEMI-GODS, DEMI-GODS, AND > PYTHON'S GOD. > > You're lucky Diez still want to help you with your attitude like that. > May I remind you that we here helps you for free in our free time, be > rude, especially to a frequent member, an

Re: Problem with list.insert

2008-08-28 Thread Diez B. Roggisch
SUBHABRATA schrieb: Some people in the room told I am kidding, but I learnt Python from Python docs which gives examples like these, But I write explicit comments, an excerpt from python docs: # Measure some strings: ... a = ['cat', 'window', 'defenestrate'] for x in a: ... print x, len(x)

Re: Problem with list.insert

2008-08-28 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: SUBHABRATA schrieb: Some people in the room told I am kidding, but I learnt Python from Python docs which gives examples like these, But I write explicit comments, an excerpt from python docs: # Measure some strings: ... a = ['cat', 'window', '

Re: class definition syntax

2008-08-29 Thread Diez B. Roggisch
harryos wrote: > hi > i have seen some class definitions like > > class MyClass(object): > def __init__(self): > > > what does the object keyword inside the braces in MyClass() mean? > Has it got any significance? It indicates a so-called new-style-class. The new style classes h

Re: problem with execv command

2008-08-29 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hi, > > I'm facing problem with the execv command: > > my command is : > os.execv(' C:\Program Files\Subversion\bin\svn ', ( 'list', ' \" > http://subversion.stv.abc.com/svn/Eng \" ' ) ) > > The error I'm getting is : > OSError: [Errno 22] Invalid argument > > > I t

Re: translating "create Semaphore" to Linux

2008-08-29 Thread Diez B. Roggisch
GHUM wrote: > hello, > > in my application I am using > > hSem = win32event.CreateSemaphore (None, 1, > 1,"stringincludinginterfaceandport") > rt=win32event.WaitForSingleObject (hSem, 0) > if rt != win32event.WAIT_TIMEOUT: >really_do_start_my_app() > else: >print "application allready ru

Re: Beginner's question about string's join() method

2008-08-29 Thread Diez B. Roggisch
Macygasp wrote: > Hi, > > Can anybody tell me why and how this is working: > ','.join(str(a) for a in range(0,10)) > '0,1,2,3,4,5,6,7,8,9' > > I find this a little weird because join takes a sequence as argument; > so, it means that somehow, from the "str(a) ... " expression, a > sequence

Re: Python graphics question:pixel scrolling

2008-08-29 Thread Diez B. Roggisch
Raymond Luxury-Yacht wrote: > To learn python, I've been trying to write a simple graphics program > which displays a 1D cellular automaton's evolution. The last time I > wrote this program, it was in C for a CGA adaptor (!) in which the > display was mapped to two interlaced blocks of memory, an

Re: Module __file__ attribute in Python 3

2008-08-29 Thread Diez B. Roggisch
> That will mean that there will be no (easy?) way to determine after the > import whether the module was imported from a source file or a compiled > file. I've suggested that the original justification for the patch no > longer applies, and that the secondary purpose of the patch is better > solve

Re: Which is faster?

2008-08-30 Thread Diez B. Roggisch
cnb schrieb: how does doing something twice not change complexity? yes it maybe belongs to the same complexity-class but is still twice as slow no? Because big O notation is not about constant factors. Or even subterms with lower powers. http://en.wikipedia.org/wiki/Big_O_notation Diez -- h

Re: Segmentation Fault on CDLL reloading

2008-08-30 Thread Diez B. Roggisch
Marcus.CM schrieb: Hi, I use the following ctype to load a .so library in Linux. vr = ctypes.CDLL(sstr) And the following to release it so that i can reload the library without quiting the python script. _ctypes.dlclose(vr._handle) These calls are guarded by a writer lock and access to

Re: Mako --> Genshi

2008-08-31 Thread Diez B. Roggisch
Chris Babcock schrieb: Is there a cheap way to convert Myghty/Mako templates to Kid/Genshi? There's some code written for Pylons that I want to incorporate into a TurboGears 2 project and Genshi templates are more likely to behave themselves with the tools I'm used to. Not that I'm aware of. An

Re: Processes in Linux from Python

2008-08-31 Thread Diez B. Roggisch
Johny schrieb: To get a number of the http processes running on my Linux( Debia box) I use ps -ef | grep "[h]ttpd" | wc -l But If I want to use to get a number of the http processes from my Python program I must use a popen command e.g. popen2.popen3('ps -ef | grep "[h]ttpd" | wc -l') that is

Re: Using NLTK in Java

2008-09-01 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: I am trying to convert a python module (that contains the use of NLTK.Corpus) by jythonc. It is not able to include nltk dependencies within the java class it creates. So when i use this class in java, it fails to recognize nltk. Can anyone please let me know how should

<    31   32   33   34   35   36   37   38   39   40   >