Re: Easy-to-use Python GUI

2009-01-02 Thread Dotan Cohen
2009/1/1 Gerhard Häring : > Dotan Cohen wrote: >> >> I have been following this thread with interest. Is there a way to >> build Qt apps with relative easy? I use KDE and would prefer the Qt >> toolkit for my GUI apps. Thanks. > > A few years ago, I've had bad experiences with wxPython (random thin

Re: yacc statement recognition [PLY]

2009-01-02 Thread Francesco Bochicchio
Slafs ha scritto: Hi ALL! I have to write in yacc an acceptor of files with lines matching this regexp: '[0-9],[0-9]' and I don't know what I am doing wrong beacuse this: tokens = ( 'NUMBER', ) literals = [','] t_NUMBER = r'\d' ... def p_statement_exp(p): '''statement :

Re: Switching user in a SSH connection

2009-01-02 Thread Tino Wildenhain
Shah Sultan Alam wrote: Hi Group, I am trying to connect to a Linux maching using paramiko. and able to run a command like "ls -l" Now I want to switch user being in the connection ( eg running something like "su -" ) Will you please let me know how to do that. You would for example run su

Re: similar words index?

2009-01-02 Thread John Machin
On Jan 2, 8:07 pm, robert wrote: > how can one index (text documents) for efficient similar word search? > existing modules? > what principles are used by search engines therefore? Only your second question is on-topic for this newsgroup. Try this: http://pylucene.osafoundation.org/ Looking at

Re: similar words index?

2009-01-02 Thread Jochen Schulz
* robert: > how can one index (text documents) for efficient similar word search? > existing modules? I implemented one approach in mspace.py: http://well-adjusted.de/mspace.py/ But beware that it is pure Python and not optimized for speed. You gain quite a lot by having Psyco installed, though.

Re: why cannot assign to function call

2009-01-02 Thread Derek Martin
On a mostly not related note: On Tue, Dec 30, 2008 at 07:52:26AM -0800, Aaron Brady wrote: > According to some rules, these are ungrammatical sentences, due to > plurality disagreement. Ex: > > The Morning Star is ... > The Evening Star is ... > *The Morning Star and The Evening Star is... > *T

Re: similar words index?

2009-01-02 Thread bearophileHUGS
Jochen Schulz: > I implemented one approach in mspace.py: > http://well-adjusted.de/mspace.py/ > But beware that it is pure Python and not optimized for speed. You gain > quite a lot by having Psyco installed, though. Something similar, I haven't compared performance, Psyco helps a lot here too: h

Re: why cannot assign to function call

2009-01-02 Thread Derek Martin
On Tue, Dec 30, 2008 at 02:21:29PM +, John O'Hagan wrote: > Fortunately, unlike the murky world of philosophy, Python (AIUI) > simplifies this question by simply declaring that yes, in the case > of mutable objects, we may say that we are still referring to the > same object although we've chan

Python logging question

2009-01-02 Thread koranthala
Hi, I was reading through Python Logging tutorial, and I found one scenario which I couldnt properly understand. The tutorial (http://docs.python.org/library/logging.html) mentions at first that -- "Multiple calls to getLogger() with the same name will return a reference to the same logger

Re: Why not Ruby?

2009-01-02 Thread Steven D'Aprano
On Thu, 01 Jan 2009 16:19:38 -0800, Fuzzyman wrote: > On Jan 2, 12:16 am, Steven D'Aprano cybersource.com.au> wrote: >> On Thu, 01 Jan 2009 12:32:53 -0800, Paul Rubin wrote: >> > On many occasions I've wished for a functional dictionary >> > implementation in Python, like Haskell's Data.Map.  O

Open Source survey

2009-01-02 Thread Hendrik Kaju
Dear developers My name is Hendrik Kaju and I am a high school student and an open source enthusiast (and a Python programmer) from Estonia. As a part of my school project, I am conducting a survey on open source software development (how developing OSS is related to a developer's day job, etc). I

Re: Why not Ruby?

2009-01-02 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Thu, 01 Jan 2009 10:35:54 -0800, r wrote: (snip stupid troll) You really are an idiot. Steven, this bozo is just another Xah Lee, so don't waste your time with him. We all know how to deal with trolls, don't we ? -- http://mail.python.org/mailman/listinfo/py

Re: Why not Ruby?

2009-01-02 Thread Steven D'Aprano
On Thu, 01 Jan 2009 17:38:02 -0800, r wrote: > He was not cross posting. You don't actually know what cross-posting is, do you? You've just earned a plonking for the next month. Do try to have at least half a clue by February. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Python logging question

2009-01-02 Thread Vinay Sajip
On Jan 2, 11:31 am, koranth...@gmail.com wrote: > I am confused reading both together. I will try to explain my > confusion with an example: > > basicLogger =logging.getLogger("basic") > > Class A(): > def __init__(self): > self.logger =logging.getLogger("basic.class_a") > >Now, I ma

Re: Triple quoted string in exec function ?

2009-01-02 Thread Stef Mientki
Stef Mientki wrote: hello, I'm running scripts, with the execute function (Python 2.5), and it seems that triple quoted strings are not allowed. Is there a workaround, or is this a fundamental problem of the exec-function ? thanks, Stef Mientki thanks for all the answers, but I still don't un

Re: Python logging question

2009-01-02 Thread koranthala
On Jan 2, 6:21 pm, Vinay Sajip wrote: > On Jan 2, 11:31 am, koranth...@gmail.com wrote: > > >     I am confused reading both together. I will try to explain my > > confusion with an example: > > > basicLogger =logging.getLogger("basic") > > > Class A(): > >   def __init__(self): > >      self.logg

FW: python import sys.path

2009-01-02 Thread Kelly, Brian
After following your suggestions I was able to confirm that the 2.5 interpreter was being invoked. So then I grepped for all instances of python in the scripts that were imported as modules: from bacula_conf import * The calling script cleanup.py is invoking purge_client.py like an external scrip

Re: Triple quoted string in exec function ?

2009-01-02 Thread John Machin
On Jan 3, 12:39 am, Stef Mientki wrote: > Stef Mientki wrote: > > hello, > > > I'm running scripts, with the execute function (Python 2.5), > > and it seems that triple quoted strings are not allowed. > > > Is there a workaround, > > or is this a fundamental problem of the exec-function ? > > > th

Re: Triple quoted string in exec function ?

2009-01-02 Thread Steven D'Aprano
On Fri, 02 Jan 2009 14:39:25 +0100, Stef Mientki wrote: > thanks for all the answers, > but I still don't understand it yet :-( So maybe someone could explain > why the next few lines of code don't work: > > Code = '' > Code += """multiline comment > and more lines""" > exec ( Code ) You don't

Re: If your were going to program a game...

2009-01-02 Thread Steve Holden
Aaron Brady wrote: > On Jan 1, 2:55 pm, "Chris Rebert" wrote: >> On Thu, Jan 1, 2009 at 12:24 PM, excord80 wrote: >>> On Jan 1, 2:37 pm, Kay Schluehr wrote: There is no solution to this problem from a Python perspective. Do what everyone does right now: [snip] >>> It still surprises me

Re: FW: python import sys.path

2009-01-02 Thread John Machin
On Jan 3, 1:09 am, "Kelly, Brian" wrote: > After following your suggestions I was able to confirm that the 2.5 > interpreter was being invoked. So then I grepped for all instances of python > in the scripts that were imported as modules: from bacula_conf import * > > The calling script cleanup.py

Re: mod_pylite?

2009-01-02 Thread excord80
On Jan 1, 11:40 pm, Graham Dumpleton wrote: > On Jan 2, 2:28 pm, excord80 wrote: > > > > > On Jan 1, 9:12 pm, s...@pobox.com wrote: > > > >     > > > >>http://broadcast.oreilly.com/2008/12/five-features-perl-5-needs-now.html > > > >     >> and he mentions a neat-looking project called ``mod_perl

Re: Why not Ruby?

2009-01-02 Thread Andreas Waldenburger
On 02 Jan 2009 12:45:36 GMT Steven D'Aprano wrote: > You've just earned a plonking for the next month. Do try to have at > least half a clue by February. I will state again that there seems to have been a slight change of tone in clp lately. How about we Python guys work a bit harder on not cal

Re: Parsing Excel spreadsheets

2009-01-02 Thread brooklineTom
On Dec 31 2008, 9:56 am, John Machin wrote: > On Dec 31 2008, 4:02 pm, brooklineTom wrote: > > > andyh...@gmail.com wrote: > > > Hi, > > > > Can anybody recommend an approach for loading and parsing Excel > > > spreadsheets in Python. Any well known/recommended libraries for this? > > > > The onl

Re: Can´t Surf Python Pages in Windoze

2009-01-02 Thread Victor Subervi
On Fri, Dec 26, 2008 at 8:00 PM, Gabriel Genellina wrote: > En Fri, 26 Dec 2008 15:11:44 -0200, Victor Subervi < > victorsube...@gmail.com> escribió: > >> On 12/26/08, Tino Wildenhain wrote: >> > > print "Content-Type: text/html" print print """ >>> http://www.w3.org/TR/xhtml1/DTD

Re: AttributeError: 'module' object has no attribute 'DatagramHandler' (ubuntu-8.10, python 2.5.2)

2009-01-02 Thread Vinay Sajip
On Dec 29 2008, 12:18 pm, "Chris Rebert" wrote: > > "The StreamHandler and FileHandler classes are defined in the > coreloggingpackage. The other handlers are defined in a sub- > module,logging.handlers." > > There's your answer. I do agree though that the > "classlogging.DatagramHandler" line

Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread ming_cuhk
Hi all, I'm new to here and python. When I tried the code below to test python's speed... I found that python use more than 1.5G memory to run this and cost several minutes And this happened only under my linux os. Both jython and python... Is there something wrong with python under linux or m

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread Michele Simionato
On Jan 2, 4:45 pm, ming_cuhk wrote: > Hi all, I'm new to here and python. > When I tried the code below to test python's speed... > I found that python use more than 1.5G memory to run this and cost > several minutes And this happened only under my linux os. Both > jython and python...  Is the

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread ming_cuhk
On Jan 2, 11:49 pm, Michele Simionato wrote: > On Jan 2, 4:45 pm, ming_cuhk wrote: > > > Hi all, I'm new to here and python. > > When I tried the code below to test python's speed... > > I found that python use more than 1.5G memory to run this and cost > > several minutes And this happened o

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread Michele Simionato
On Jan 2, 4:50 pm, ming_cuhk wrote: > On Jan 2, 11:49 pm, Michele Simionato > wrote: > > > > > On Jan 2, 4:45 pm, ming_cuhk wrote: > > > > Hi all, I'm new to here and python. > > > When I tried the code below to test python's speed... > > > I found that python use more than 1.5G memory to run th

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread ming_cuhk
On Jan 2, 11:52 pm, Michele Simionato wrote: > On Jan 2, 4:50 pm, ming_cuhk wrote: > > > > > On Jan 2, 11:49 pm, Michele Simionato > > wrote: > > > > On Jan 2, 4:45 pm, ming_cuhk wrote: > > > > > Hi all, I'm new to here and python. > > > > When I tried the code below to test python's speed... >

Re: Creating an application for Linux

2009-01-02 Thread lkcl
On Jan 1, 4:44 pm, Mike Driscoll wrote: > On Jan 1, 7:47 am,lkcl wrote: > > > > > On Dec 31 2008, 9:54 pm, Mike Driscoll wrote: > > > > On Dec 31, 3:36 pm,lkcl wrote: > > > > > hiya mike: where do i know you from? i've heard your name somewhere > > > > and for the life of me can't remember where

Re: If your were going to program a game...

2009-01-02 Thread J Kenneth King
Tokyo Dan writes: > If your were going to program a game in python what technologies would > you use? > > The game is a board game with some piece animations, but no movement > animation...think of a chess king exploding. The game runs in a > browser in a window of a social site built around the

Please show some restraint (Was: Why not Ruby?)

2009-01-02 Thread D'Arcy J.M. Cain
On Fri, 02 Jan 2009 00:57:06 +0100 Richard Riley wrote: > You clearly have a personal issue with Xah Lee. Possibly it is better > you killfile him or your spring will over wind :-; What good does a killfile do if people insist on repeating his posts in their entirety? Please people, try to resis

Py2exe issue

2009-01-02 Thread rcmn
I'm using 2.6 (the issue was the same with 2.5) script.py: [code]import re from optparse import OptionParser parser = OptionParser() parser.add_option("-f", "--file", action="store", type="string", dest="filename") parser.add_option("-o", "--output", action="store", type="string", dest="fileout"

Re: Py2exe issue

2009-01-02 Thread Mike Driscoll
On Jan 2, 10:19 am, rcmn wrote: > I'm using 2.6 (the issue was the same with 2.5) > > script.py: > > [code]import re > > from optparse import OptionParser > parser = OptionParser() > parser.add_option("-f", "--file", action="store", type="string", > dest="filename") > parser.add_option("-o", "--ou

Re: Parsing Excel spreadsheets

2009-01-02 Thread Steve Holden
brooklineTom wrote: > On Dec 31 2008, 9:56 am, John Machin wrote: >> On Dec 31 2008, 4:02 pm, brooklineTom wrote: >> >>> andyh...@gmail.com wrote: Hi, Can anybody recommend an approach for loading and parsing Excel spreadsheets in Python. Any well known/recommended libraries for th

Re: why cannot assign to function call

2009-01-02 Thread Steve Holden
Derek Martin wrote: > On Tue, Dec 30, 2008 at 02:21:29PM +, John O'Hagan wrote: [...] > What the Python community often overlooks, when this discussion again > rears its ugly head (as it seems to every other hour or so), is that > its assignment model is BIZARRE, as in it's conceptually differe

Re: Why not Ruby?

2009-01-02 Thread r
On Jan 2, 6:45 am, Steven D'Aprano wrote: > On Thu, 01 Jan 2009 17:38:02 -0800, r wrote: > > He was not cross posting. > > You don't actually know what cross-posting is, do you? > > You've just earned a plonking for the next month. Do try to have at least > half a clue by February. > > -- > Steven

Re: 2to3 used in the Shootout

2009-01-02 Thread Isaac Gouy
On Dec 29 2008, 8:36 am, prueba...@latinmail.com wrote: > On Dec 23, 5:21 pm, Isaac Gouy wrote: > > > On Dec 23, 11:51 am, bearophileh...@lycos.com wrote: > > > > They have translated the Python benchmarks of theShootoutsite from > > > Py2 to Py3 using 2to3: > > > >http://shootout.alioth.debian.or

Re: mod_pylite?

2009-01-02 Thread Fuzzyman
On Jan 2, 2:49 pm, excord80 wrote: [snip...] > > It sounds interesting, however, after reading a bit about it, I see > that a large part of wsgi is providing a nice interface between web > server and webapp. I don't think I need any such interface, or at > least, a replacement for CGI. I just need

Re: If your were going to program a game...

2009-01-02 Thread Fuzzyman
On Jan 2, 3:02 pm, J Kenneth King wrote: > Tokyo Dan writes: > > If your were going to program a game in python what technologies would > > you use? > > > The game is a board game with some piece animations, but no movement > > animation...think of a chess king exploding. The game runs in a > > b

Re: FW: python import sys.path

2009-01-02 Thread Fuzzyman
On Jan 2, 2:28 pm, John Machin wrote: > On Jan 3, 1:09 am, "Kelly, Brian" wrote:> After > following your suggestions I was able to confirm that the 2.5 > > interpreter was being invoked. So then I grepped for all instances of python > > in the scripts that were imported as modules: from bacula_c

Is there a better algorithm?

2009-01-02 Thread Kottiyath
I have the following list of tuples: L = [(1, 2), (3, 4, 5), (6, 7)] I want to loop through the list and extract the values. The only algorithm I could think of is: >>> for i in l: ... u = None ... try: ... (k, v) = i ... except ValueError: ... (k, u, v) = i ... print k, u, v - 1 N

Re: If your were going to program a game...

2009-01-02 Thread Jean-Paul Calderone
On Fri, 2 Jan 2009 09:44:55 -0800 (PST), Fuzzyman wrote: On Jan 2, 3:02 pm, J Kenneth King wrote: Tokyo Dan writes: > If your were going to program a game in python what technologies would > you use? > The game is a board game with some piece animations, but no movement > animation...think o

Re: Is there a better algorithm?

2009-01-02 Thread Fuzzyman
On Jan 2, 6:11 pm, Kottiyath wrote: > I have the following list of tuples: > L = [(1, 2), (3, 4, 5), (6, 7)] > > I want to loop through the list and extract the values. > The only algorithm I could think of is:>>> for i in l: > > ...  u = None > ...  try: > ...   (k, v) = i > ...  except ValueErro

Workshop "Medical Imaging Systems" within EUROMEDIA 2009 – Announce & Call for Papers

2009-01-02 Thread tava...@fe.up.pt
Workshop “Medical Imaging Systems” within EUROSIS EUROMEDIA 2009 April 15-17, 2009, Novotel, Bruges, Belgium http://www.eurosis.org/cms/?q=taxonomy/term/172

Re: If your were going to program a game...

2009-01-02 Thread Fuzzyman
On Jan 2, 6:16 pm, Jean-Paul Calderone wrote: > On Fri, 2 Jan 2009 09:44:55 -0800 (PST), Fuzzyman wrote: > >On Jan 2, 3:02 pm, J Kenneth King wrote: > >> Tokyo Dan writes: > >> > If your were going to program a game in python what technologies would > >> > you use? > > >> > The game is a board

Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread imageguy
I am looking for the most efficient method of replacing a repeating sequence in a byte string returned from a imaging .dll, connected via I receive the byte string with the following sequence 'bgrbgrbgrbgr' and I would like to convert this to 'rbgrbgrbgrbg' FWIW, the string is created using ctypes

Re: Is there a better algorithm?

2009-01-02 Thread Steve Holden
Kottiyath wrote: > I have the following list of tuples: > L = [(1, 2), (3, 4, 5), (6, 7)] > > I want to loop through the list and extract the values. > The only algorithm I could think of is: for i in l: > ... u = None > ... try: > ... (k, v) = i > ... except ValueError: > ... (k, u, v

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread Steve Holden
imageguy wrote: > I am looking for the most efficient method of replacing a repeating > sequence in a byte string returned from a imaging .dll, connected via > > I receive the byte string with the following sequence 'bgrbgrbgrbgr' > and I would like to convert this to 'rbgrbgrbgrbg' > FWIW, the st

Re: Is there a better algorithm?

2009-01-02 Thread Markus Brueckner
Hi, Fuzzyman wrote: > I'm sure there is a clever one liner using the Python 2.5 ternary > expression syntax. On the other hand I'm not sure it would be very > readable, so a straightforward (if less clever) solution is probably > better. that would be something like this (using a generator) L =

is there a way to determine a relative path to the script?

2009-01-02 Thread tekion
Hello, I have a script in /usr/local/app/mypython.py and a configuration file relative to /usr/local/app/conf. When I call the script with an absolute path of /usr/local/app/mypthon.py I recieved an error similar to the below error: Traceback (most recent call last): File "script/art/auditlog.

Re: Is there a better algorithm?

2009-01-02 Thread Bruno Desthuilliers
Kottiyath a écrit : I have the following list of tuples: L = [(1, 2), (3, 4, 5), (6, 7)] I want to loop through the list and extract the values. The only algorithm I could think of is: for i in l: ... u = None ... try: ... (k, v) = i ... except ValueError: ... (k, u, v) = i ... print k

Re: Is there a better algorithm?

2009-01-02 Thread Francesco Bochicchio
Kottiyath ha scritto: I have the following list of tuples: L = [(1, 2), (3, 4, 5), (6, 7)] I want to loop through the list and extract the values. The only algorithm I could think of is: for i in l: ... u = None ... try: ... (k, v) = i ... except ValueError: ... (k, u, v) = i ... print

Re: Is there a better algorithm?

2009-01-02 Thread Andreas Waldenburger
On Fri, 02 Jan 2009 19:55:43 +0100 Markus Brueckner wrote: > g = ( ((e[0],None,e[1]) if len(e)==2 else (e[0],e[1],e[2])) for e in > L) If this isn't proof of Python's versatility, I don't know what is. In one line it can mimic both Lisp and Perl. Sweet. :) /W -- My real email address is const

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread Francesco Bochicchio
imageguy ha scritto: I am looking for the most efficient method of replacing a repeating sequence in a byte string returned from a imaging .dll, connected via I receive the byte string with the following sequence 'bgrbgrbgrbgr' and I would like to convert this to 'rbgrbgrbgrbg' FWIW, the string

Re: Why not Ruby?

2009-01-02 Thread Ryan McCoskrie
Xah Lee wrote: > Q: Do you condemn Ruby? > > No. I think it's reasonably elegant, but today there are too many > languages, so Ruby don't particularly standout for me. Many of them, > are arguably quite more elegant and powerful than Ruby. There is one thing that Ruby is exceptionally good for

Re: type conversion

2009-01-02 Thread Robert Kern
r wrote: On Jan 1, 4:40 pm, Robert Kern wrote: Hamish McKenzie wrote: sometimes I want to be able to initialize an instance with a variety of different data types. as an obvious example I might want to initialize a 4x4 matrix with either 16 floats, a list/tuple or 16 floats, another matrix o

Re: Py2exe issue

2009-01-02 Thread rcmn
I'm using py2exe-0.6.9.win32-py2.6.exe i used option 3. On a list of 500 i get the same error than previous. On a list of 250 once it just quit leaving the open file at 0k and on the second attempt it failed with the same error and a note about "TypeError: 'NoneType' object is not callable". Basic

Re: type conversion

2009-01-02 Thread r
On Jan 2, 1:46 pm, Robert Kern wrote: > r wrote: > > On Jan 1, 4:40 pm, Robert Kern wrote: > >> Hamish McKenzie wrote: > >>> sometimes I want to be able to initialize an instance with a variety of > >>> different data types. > >>> as an obvious example I might want to initialize a 4x4 matrix wit

Re: why cannot assign to function call

2009-01-02 Thread Derek Martin
On Fri, Jan 02, 2009 at 11:43:30AM -0500, Steve Holden wrote: > Derek Martin wrote: > > What the Python community often overlooks, when this discussion again > > rears its ugly head (as it seems to every other hour or so), is that > > its assignment model is BIZARRE, as in it's conceptually differe

Re: is there a way to determine a relative path to the script?

2009-01-02 Thread TechieInsite
import os base = __file__.split(os.sep) os.path.relpath('path/to/your/file/, base) I hope this helps. Greg tekion wrote: > Hello, > I have a script in /usr/local/app/mypython.py and a configuration file > relative to /usr/local/app/conf. When I call the script with an > absolute path of /usr/lo

Re: why cannot assign to function call

2009-01-02 Thread Erik Max Francis
Derek Martin wrote: On a mostly not related note: On Tue, Dec 30, 2008 at 07:52:26AM -0800, Aaron Brady wrote: According to some rules, these are ungrammatical sentences, due to plurality disagreement. Ex: The Morning Star is ... The Evening Star is ... *The Morning Star and The Evening Star

Re: Is there a better algorithm?

2009-01-02 Thread J Kenneth King
Kottiyath writes: > I have the following list of tuples: > L = [(1, 2), (3, 4, 5), (6, 7)] > > I want to loop through the list and extract the values. > The only algorithm I could think of is: for i in l: > ... u = None > ... try: > ... (k, v) = i > ... except ValueError: > ... (k, u,

Re: why cannot assign to function call

2009-01-02 Thread Steve Holden
Derek Martin wrote: > On Fri, Jan 02, 2009 at 11:43:30AM -0500, Steve Holden wrote: >> Derek Martin wrote: [...] >>> It's small wonder that neophytes try to cram Python behaviors into >>> terms and computing concepts they already understand from learning >>> other languages, and that they fail to d

Re: Is there a better algorithm?

2009-01-02 Thread Paul Rubin
Kottiyath writes: > I have the following list of tuples: > L = [(1, 2), (3, 4, 5), (6, 7)] > I want to loop through the list and extract the values. Others have suggested messy ways to code what you're asking. At another level, that list format seems like a code smell. You may be better off org

Re: Is there a better algorithm?

2009-01-02 Thread bearophileHUGS
Fuzzyman: > for i in l: >    u = None >    if len(i) == 2: >       k, v = i >    else: >        k, u, v = i That's the best solution I have seen in this thread so far (but I suggest to improve indents and use better variable names). In programming it's generally better to follow the KISS principl

Re: Is there a better algorithm?

2009-01-02 Thread J Kenneth King
Paul Rubin writes: > Kottiyath writes: >> I have the following list of tuples: >> L = [(1, 2), (3, 4, 5), (6, 7)] >> I want to loop through the list and extract the values. > > Others have suggested messy ways to code what you're asking. At another > level, that li

Re: why cannot assign to function call

2009-01-02 Thread Bruno Desthuilliers
Derek Martin a écrit : On Fri, Jan 02, 2009 at 11:43:30AM -0500, Steve Holden wrote: Derek Martin wrote: What the Python community often overlooks, when this discussion again rears its ugly head (as it seems to every other hour or so), is that its assignment model is BIZARRE, as in it's concept

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread Terry Reedy
imageguy wrote: I am looking for the most efficient method of replacing a repeating sequence in a byte string returned from a imaging .dll, connected via I receive the byte string with the following sequence 'bgrbgrbgrbgr' and I would like to convert this to 'rbgrbgrbgrbg' For speed, I would l

Re: is there a way to determine a relative path to the script?

2009-01-02 Thread TechieInsights
import os os.path.relpath('/path/to/your/file', os.path.dirname(__file__)) tekion wrote: > Hello, > I have a script in /usr/local/app/mypython.py and a configuration file > relative to /usr/local/app/conf. When I call the script with an > absolute path of /usr/local/app/mypthon.py I recieved an

Re: Py2exe issue

2009-01-02 Thread rcmn
I just tried to compile with gui2exe. And i ran the exe. it faile the same way but at least generate a log. Exception in thread Thread-1: Traceback (most recent call last): File "threading.pyc", line 522, in __bootstrap_inner File "pingable.py", line 35, in run File "subprocess.pyc", line 588

Re: Is there a better algorithm?

2009-01-02 Thread Ned Deily
In article <85aba9h1e5@dozer.localdomain>, J Kenneth King wrote: > Kottiyath writes: > > I have the following list of tuples: > > L = [(1, 2), (3, 4, 5), (6, 7)] > > > > I want to loop through the list and extract the values. > > The only algorithm I could think of is: > for i in l: > >

Noob question: Is all this typecasting normal?

2009-01-02 Thread sprad
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. For example: bet = raw_input("Enter your bet") if int(bet) == 0: # r

Re: Py2exe issue

2009-01-02 Thread rcmn
On Jan 2, 3:08 pm, rcmn wrote: > I just tried to compile with gui2exe. And i ran the exe. it faile the > same way but at least generate a log. > Exception in thread Thread-1: > Traceback (most recent call last): >   File "threading.pyc", line 522, in __bootstrap_inner >   File "pingable.py", line

Re: Is there a better algorithm?

2009-01-02 Thread Gerhard Häring
Kottiyath wrote: I have the following list of tuples: L = [(1, 2), (3, 4, 5), (6, 7)] I want to loop through the list and extract the values. The only algorithm I could think of is: [...] If this is part of a real program, instead of an exercise, you should fix the code that creates this list

Re: is there a way to determine a relative path to the script?

2009-01-02 Thread TechieInsights
Note: The os.path.relpath is new in 2.6. If you are using an older version you will have to write your own algorithm TechieInsights wrote: > import os > os.path.relpath('/path/to/your/file', os.path.dirname(__file__)) > > tekion wrote: > > Hello, > > I have a script in /usr/local/app/mypython.py

Re: If your were going to program a game...

2009-01-02 Thread Terry Reedy
Jean-Paul Calderone wrote: No, PyPy includes an RPython to JavaScript compiler. RPython and Python are different languages. My impression from a few years ago is that RPython stands for Restricted Python and that it was/is? a proper subset of Python. Has this changed? -- http://mail.pyth

Re: why cannot assign to function call

2009-01-02 Thread Derek Martin
On Fri, Jan 02, 2009 at 09:05:51PM +0100, Bruno Desthuilliers wrote: >> Python seems rather weird, and I think from the frequency >> with which these discussions occur on this list, clearly it *IS* >> difficult for a neophyte Python programmer to understand the >> assignment model. > > Took me abou

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Benjamin Kaplan
On Fri, Jan 2, 2009 at 4:15 PM, sprad wrote: > 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. > > For example: >

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: Is there a better algorithm?

2009-01-02 Thread Aaron Brady
On Jan 2, 12:11 pm, Kottiyath wrote: > I have the following list of tuples: > L = [(1, 2), (3, 4, 5), (6, 7)] > > I want to loop through the list and extract the values. > The only algorithm I could think of is:>>> for i in l: > > ...  u = None > ...  try: > ...   (k, v) = i > ...  except ValueErr

Re: Is there a better algorithm?

2009-01-02 Thread mr
As has been noted, the best is to fix the input to be regular-3- tuples. For the fun of it, here's another variation of a solution: tuples = [(1, 2), (3, 4, 5), (6, 7)] def triple_or_pair(seq): u = None try: k, u, v = seq except ValueError: k, v = seq return k, u,

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread TechieInsights
You can use the built-in string formatting options and operations. 2.5: http://www.python.org/doc/2.5.2/lib/typesseq-strings.html 2.6: http://docs.python.org/library/string.html In essence, you can do: print "You still have $%i remaining" %(money) On Jan 2, 2:15 pm, sprad wrote: > I've done a g

Request For (gozerbot) Testers

2009-01-02 Thread Bart Thate
So 0.9 is getting in shape and there is one issue that keeps me from releasing 0.9 and that is the upgrade path. 0.9 is vastely different from 0.8 so a special upgrade script has been written to aid with this. Now i have tested this on some gozerbot users but i need a more broader audience that wan

Re: why cannot assign to function call

2009-01-02 Thread Derek Martin
On Fri, Jan 02, 2009 at 12:50:44PM -0800, Erik Max Francis wrote: >>> Identity isn't defined on math objects, only on Python objects; there >>> is no notion of 'is' in math. >> >> This is also false, it even has its own operator (which requires >> Unicode to display): ≡ > > That can mean a number

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread vk
> You might better do > > bet = int(raw_input("Enter your bet")) > > because then you don't need to later on convert bet again and again. This is all fine until you give it to an end-user. This is what I picture: $ ./script.py Enter your bet: $10 .. or perhaps "ten", "all", or a jillion other ta

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Andreas Waldenburger
On Fri, 2 Jan 2009 14:36:04 -0800 (PST) vk wrote: > There needs to be a "user_io" or "sanitize" module in the standard > library to take care of this stuff. > [snip example] > Great idea! +1 > ... but there isn't, as far as I know. Well, get to it, then. ;) /W -- My real email address is co

Re: If your were going to program a game...

2009-01-02 Thread Tokyo Dan
On Jan 3, 12:02 am, J Kenneth King wrote: > Tokyo Dan writes: > > If your were going to program a game in python what technologies would > > you use? > > > The game is a board game with some piece animations, but no movement > > animation...think of a chess king exploding. The game runs in a > >

Re: why cannot assign to function call

2009-01-02 Thread Erik Max Francis
Derek Martin wrote: On Fri, Jan 02, 2009 at 12:50:44PM -0800, Erik Max Francis wrote: Identity isn't defined on math objects, only on Python objects; there is no notion of 'is' in math. This is also false, it even has its own operator (which requires Unicode to display): ≡ That can mean a nu

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread r
> There needs to be a "user_io" or "sanitize" module in the standard > library to take care of this stuff. [snip] +1 You are sooo right. You know, it is easy to forget about such things after you learn a language, i have written my own input logic, but i remember my __init__ days with python now a

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread MRAB
Francesco Bochicchio wrote: imageguy ha scritto: I am looking for the most efficient method of replacing a repeating sequence in a byte string returned from a imaging .dll, connected via I receive the byte string with the following sequence 'bgrbgrbgrbgr' and I would like to convert this to 'rb

Re: Why not Ruby?

2009-01-02 Thread Don Geddis
Richard Riley wrote on Thu, 01 Jan 2009: > Tim Greer writes: >> That poster has a frequent habit of cross posting to multiple, irrelevant >> news groups. There's no rhyme or reason to it. > > No rhyme nor reason? It's quite clear, to me, why. How is a comparison > article not relevant when he i

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Ben Finney
vk writes: > There needs to be a "user_io" or "sanitize" module in the standard > library to take care of this stuff. > Like: > > import userio > > logic = userio.userio() > > number = logic.getNumeric("blah: ") # will offer the user a "re-do" in > case of bad input > number = logic.forceGetNu

Re: Reverse order of bit in repeating seqence of byte string

2009-01-02 Thread bearophileHUGS
imageguy: > I receive the byte string with the following sequence 'bgrbgrbgrbgr' > and I would like to convert this to 'rbgrbgrbgrbg' > FWIW, the string is created using ctypes.create_string_buffer function MRAB: >  >>> a.tostring() > '210543876' That's not the required 'rbgrbgrbgrbg', but you ar

RE: type conversion

2009-01-02 Thread Hamish McKenzie
I actually have no idea what ur talking about... aren't conversations threaded by subject? -Original Message- From: python-list-bounces+hamish=valvesoftware@python.org [mailto:python-list-bounces+hamish=valvesoftware@python.org] On Behalf Of r Sent: Friday, January 02, 2009 1

Re: Parsing Excel spreadsheets

2009-01-02 Thread John Machin
On Jan 3, 2:01 am, brooklineTom wrote: > On Dec 31 2008, 9:56 am, John Machin wrote: > > On Dec 31 2008, 4:02 pm, brooklineTom wrote: > > > > andyh...@gmail.com wrote: > > > > Hi, > > > > > Can anybody recommend an approach for loading and parsing Excel > > > > spreadsheets in Python. Any well

Re: type conversion

2009-01-02 Thread Christian Heimes
Hamish McKenzie schrieb: > I actually have no idea what ur talking about... aren't conversations > threaded by subject? Nope, they are threaded by message id. The subject is used as fallback only. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread vk
> If there were, I would expect it to conform with PEP 8 (get those ugly > camelCase names outta there :-) haha, please forgive me. I'll try and think of some more creative names. atm, I've got a chem final to study for. I'll probably post something resembling useful code tomorrow morning. until

  1   2   >