itools 0.50.1 released

2009-01-02 Thread J. David Ibáñez
itools is a Python library, it groups a number of packages into a single meta-package for easier development and deployment: itools.abnf itools.ical itools.tmx itools.csv itools.isetup itools.uri itools.datatypesitools.odf

Re: Easy-to-use Python GUI

2009-01-02 Thread Dotan Cohen
2009/1/1 Gerhard Häring g...@ghaering.de: 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

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 no-s...@no-spam.invalid 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:

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... *The

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:

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 changed

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 st...@remove-this- 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

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).

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 ? --

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 make say 10

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

Re: Python logging question

2009-01-02 Thread koranthala
On Jan 2, 6:21 pm, Vinay Sajip vinay_sa...@yahoo.co.uk 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):      

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

Re: Triple quoted string in exec function ?

2009-01-02 Thread John Machin
On Jan 3, 12:39 am, Stef Mientki stef.mien...@gmail.com 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

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 actually tell

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 c...@rebertia.com wrote: On Thu, Jan 1, 2009 at 12:24 PM, excord80 excor...@gmail.com wrote: On Jan 1, 2:37 pm, Kay Schluehr kay.schlu...@gmx.net wrote: There is no solution to this problem from a Python perspective. Do what everyone does

Re: FW: python import sys.path

2009-01-02 Thread John Machin
On Jan 3, 1:09 am, Kelly, Brian brian.ke...@uwsp.edu 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

Re: mod_pylite?

2009-01-02 Thread excord80
On Jan 1, 11:40 pm, Graham Dumpleton graham.dumple...@gmail.com wrote: On Jan 2, 2:28 pm, excord80 excor...@gmail.com 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

Re: Why not Ruby?

2009-01-02 Thread Andreas Waldenburger
On 02 Jan 2009 12:45:36 GMT Steven D'Aprano st...@remove-this-cybersource.com.au 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

Re: Parsing Excel spreadsheets

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

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 gagsl-...@yahoo.com.arwrote: En Fri, 26 Dec 2008 15:11:44 -0200, Victor Subervi victorsube...@gmail.com escribió: On 12/26/08, Tino Wildenhain t...@wildenhain.de wrote: print Content-Type: text/html print print !DOCTYPE html PUBLIC

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 c...@rebertia.com 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

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

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread Michele Simionato
On Jan 2, 4:45 pm, ming_cuhk maming...@gmail.com 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

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread ming_cuhk
On Jan 2, 11:49 pm, Michele Simionato michele.simion...@gmail.com wrote: On Jan 2, 4:45 pm, ming_cuhk maming...@gmail.com 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

Re: Unreasonable memory usage under linux with a simple loop

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

Re: Unreasonable memory usage under linux with a simple loop

2009-01-02 Thread ming_cuhk
On Jan 2, 11:52 pm, Michele Simionato michele.simion...@gmail.com wrote: On Jan 2, 4:50 pm, ming_cuhk maming...@gmail.com wrote: On Jan 2, 11:49 pm, Michele Simionato michele.simion...@gmail.com wrote: On Jan 2, 4:45 pm, ming_cuhk maming...@gmail.com wrote: Hi all, I'm new to here

Re: Creating an application for Linux

2009-01-02 Thread lkcl
On Jan 1, 4:44 pm, Mike Driscoll kyoso...@gmail.com wrote: On Jan 1, 7:47 am,lkclluke.leigh...@googlemail.com wrote: On Dec 31 2008, 9:54 pm, Mike Driscoll kyoso...@gmail.com wrote: On Dec 31, 3:36 pm,lkclluke.leigh...@googlemail.com wrote: hiya mike: where do i know you from? i've

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

2009-01-02 Thread J Kenneth King
Tokyo Dan huff...@tokyo.email.ne.jp 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

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 rileyrg...@gmail.com 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

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) (options, args) =

Re: Py2exe issue

2009-01-02 Thread Mike Driscoll
On Jan 2, 10:19 am, rcmn rcm...@gmail.com 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, --output,

Re: Parsing Excel spreadsheets

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

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 different

Re: Why not Ruby?

2009-01-02 Thread r
On Jan 2, 6:45 am, Steven D'Aprano st...@remove-this- cybersource.com.au 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

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 igo...@yahoo.com 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:

Re: mod_pylite?

2009-01-02 Thread Fuzzyman
On Jan 2, 2:49 pm, excord80 excor...@gmail.com 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

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

2009-01-02 Thread Fuzzyman
On Jan 2, 3:02 pm, J Kenneth King ja...@agentultra.com wrote: Tokyo Dan huff...@tokyo.email.ne.jp 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

Re: FW: python import sys.path

2009-01-02 Thread Fuzzyman
On Jan 2, 2:28 pm, John Machin sjmac...@lexicon.net wrote: On Jan 3, 1:09 am, Kelly, Brian brian.ke...@uwsp.edu 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

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

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 fuzzy...@gmail.com wrote: On Jan 2, 3:02 pm, J Kenneth King ja...@agentultra.com wrote: Tokyo Dan huff...@tokyo.email.ne.jp writes: If your were going to program a game in python what technologies would you use? The game is a board game with

Re: Is there a better algorithm?

2009-01-02 Thread Fuzzyman
On Jan 2, 6:11 pm, Kottiyath n.kottiy...@gmail.com 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

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 exar...@divmod.com wrote: On Fri, 2 Jan 2009 09:44:55 -0800 (PST), Fuzzyman fuzzy...@gmail.com wrote: On Jan 2, 3:02 pm, J Kenneth King ja...@agentultra.com wrote: Tokyo Dan huff...@tokyo.email.ne.jp writes: If your were going to program a game in

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

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) = i ...

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 string

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

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

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 ...

Re: Is there a better algorithm?

2009-01-02 Thread Andreas Waldenburger
On Fri, 02 Jan 2009 19:55:43 +0100 Markus Brueckner n...@slash-me.net 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

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 and

Re: type conversion

2009-01-02 Thread Robert Kern
r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com 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

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.

Re: type conversion

2009-01-02 Thread r
On Jan 2, 1:46 pm, Robert Kern robert.k...@gmail.com wrote: r wrote: On Jan 1, 4:40 pm, Robert Kern robert.k...@gmail.com 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

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 different

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

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

Re: Is there a better algorithm?

2009-01-02 Thread J Kenneth King
Kottiyath n.kottiy...@gmail.com 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: ...

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 do so.

Re: Is there a better algorithm?

2009-01-02 Thread Paul Rubin
Kottiyath n.kottiy...@gmail.com 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

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 principle.

Re: Is there a better algorithm?

2009-01-02 Thread J Kenneth King
Paul Rubin http://phr...@nospam.invalid writes: Kottiyath n.kottiy...@gmail.com 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

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

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

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, in

Re: Is there a better algorithm?

2009-01-02 Thread Ned Deily
In article 85aba9h1e5@dozer.localdomain, J Kenneth King ja...@agentultra.com wrote: Kottiyath n.kottiy...@gmail.com 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

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: #

Re: Py2exe issue

2009-01-02 Thread rcmn
On Jan 2, 3:08 pm, rcmn rcm...@gmail.com 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

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

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 and a

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? --

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 about half an

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Benjamin Kaplan
On Fri, Jan 2, 2009 at 4:15 PM, sprad jsp...@gmail.com 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

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

Re: Is there a better algorithm?

2009-01-02 Thread Aaron Brady
On Jan 2, 12:11 pm, Kottiyath n.kottiy...@gmail.com 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

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 jsp...@gmail.com wrote:

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

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 of things,

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 tainted

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 vmi...@gmail.com 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

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

2009-01-02 Thread Tokyo Dan
On Jan 3, 12:02 am, J Kenneth King ja...@agentultra.com wrote: Tokyo Dan huff...@tokyo.email.ne.jp 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

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

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 and

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

Re: Why not Ruby?

2009-01-02 Thread Don Geddis
Richard Riley rileyrg...@gmail.com wrote on Thu, 01 Jan 2009: Tim Greer t...@burlyhost.com 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

Re: Noob question: Is all this typecasting normal?

2009-01-02 Thread Ben Finney
vk vmi...@gmail.com 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 =

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 are close

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

Re: Parsing Excel spreadsheets

2009-01-02 Thread John Machin
On Jan 3, 2:01 am, brooklineTom brookline...@gmail.com wrote: On Dec 31 2008, 9:56 am, John Machin sjmac...@lexicon.net wrote: On Dec 31 2008, 4:02 pm, brooklineTom brookline...@gmail.com wrote: andyh...@gmail.com wrote: Hi, Can anybody recommend an approach for loading and

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

  1   2   3   4   >