Re: docstrings style question

2008-01-10 Thread Russ P.
On Jan 9, 11:51 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Steve Brown wrote: > > I've got a series of modules which look like this: > > > # > > # > > # Temperature Sense Test > > # > > # > > class Test3(ar_test.AR_TEST): > > """Temperature Sense Test""" > > > I don'

Re: Converting a bidimensional list in a bidimensional array

2008-01-10 Thread Santiago Romero
> C:\> \python25\python -m -s :-) Thanks a lot :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: docstrings style question

2008-01-10 Thread Jeroen Ruigrok van der Werven
-On [20080110 06:51], Steve Brown ([EMAIL PROTECTED]) wrote: >I don't like the duplicated information: But the comment is attractive, I find it unattractive to be honest. >and the docstring self.__doc__ is already in use in the test log. I've read >that all modules and

Re: Conventions for dummy name (was: for loop without variable)

2008-01-10 Thread Jeroen Ruigrok van der Werven
-On [20080110 00:21], Ben Finney ([EMAIL PROTECTED]) wrote: >The problem with the '_' name is that it is already well-known and >long-used existing convention for an entirely unrelated purpose: in >the 'gettext' i18n library, the '_' function to get the >l

Re: How to get memory size/usage of python object

2008-01-10 Thread Santiago Romero
> Would you care to precisely define "REAL size" first? Consider: > > >>> atuple = (1, 2) > >>> mylist = [(0, 0), atuple] > > Should sizeof(mylist) include sizeof(atuple) ? No, I'm talking about "simple" lists, without REFERENCES to another objects into it. I mean: lists = [ 0, 1, 2, 3, 4, (1

PyGILState_Release produces a seg fault

2008-01-10 Thread mathieu
Hello and happy new year folks, I am experiencing a seg fault while using the python interface to the VTK library (debian oldstable, python 2.3). The VTK library is wrapped by a custom mechanism to provide a python API. In particular they implemented a way so that a python function can be called

Re: alternating string replace

2008-01-10 Thread cokofreedom
On Jan 10, 3:46 am, [EMAIL PROTECTED] wrote: > Gordon C: > > > This is very cool stuff but I suspect that the code is unreadable > > to many readers, including me. Just for fun here is a complete program, > > written in Turbo Pascal, circa 1982, that does the job. Readable > > n'est pas? > > I thi

Re: Python too slow?

2008-01-10 Thread Bruno Desthuilliers
Ed Jensen a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >> And the reference implementation of Python (CPython) is not >> interpreted, it's compiled to byte-code, which is then executed by a VM >> (just like Java). > > Wow, this is pretty misleading. Ho yes ??? Why so, please ? Car

Re: Conventions for dummy name

2008-01-10 Thread Torsten Bronger
Hallöchen! Ben Finney writes: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > >> The underscore is used as "discarded" identifier. So maybe >> >> for _ in xrange(10): >> ... > > The problem with the '_' name is that it is already well-known and > long-used existing convention for an entir

Re: Learning Python via a little word frequency program

2008-01-10 Thread Bruno Desthuilliers
MRAB a écrit : > On Jan 9, 12:19 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: (snip) > That actually prints: > > kevin : 3 > fred : 2 > jock : 2 > andrew : 1 > bill : 1 > freddy : 1 > > It says that "fred" occurs twice because of "freddy". oops ! My bad, didn

FindWindowById returns None..... ?

2008-01-10 Thread Soren
Hi, I'm trying to split my GUI into several files since its beginning to become a bit large.. I've placed a panel class inside gui2.py, but it needs some information from a panel in gui1.py... if I import gui1 in gui2 and try to find the panel by its ID, (using the Id generated in gui1) I get a N

Re: Learning Python via a little word frequency program

2008-01-10 Thread Bruno Desthuilliers
Paul Hankin a écrit : > On Jan 9, 12:19 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Andrew Savige a écrit : >>> and the -x hack above to >>> achieve a descending sort feels a bit odd to me, though I couldn't think >>> of a better way to do it. >> The "other" way would be to pass a custom

Re: How to get memory size/usage of python object

2008-01-10 Thread Remco Gerlich
Hi, The only list without references to other objects in it is [ ]. 0, 1, 2, etc are objects. Every value in Python is a reference to an object. Remco On Jan 10, 2008 9:14 AM, Santiago Romero < [EMAIL PROTECTED]> wrote: > > > Would you care to precisely define "REAL size" first? Consider: > >

Re: FindWindowById returns None..... ?

2008-01-10 Thread Soren
On Jan 10, 9:43 am, Soren <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to split my GUI into several files since its beginning to > become a bit large.. I've placed a panel class inside gui2.py, but it > needs some information from a panel in gui1.py... if I import gui1 in > gui2 and try to find

Why my program (using pexpect to switch user) doesn't work well?

2008-01-10 Thread BlackjadeLin
I'm new to python I want to write a simple script to switch user,for example,from user_A to user_B. This my codes: #!/usr/bin/python import pexpect import os passwd="user_B" child = pexpect.spawn('su user_B') child.expect('Password:') child.sendline(passwd) child.expect('$') child.close() Maybe i

Re: How to get memory size/usage of python object

2008-01-10 Thread Steven D'Aprano
On Thu, 10 Jan 2008 00:14:42 -0800, Santiago Romero wrote: >> Would you care to precisely define "REAL size" first? Consider: >> >> >>> atuple = (1, 2) >> >>> mylist = [(0, 0), atuple] >> >> Should sizeof(mylist) include sizeof(atuple) ? > > No, I'm talking about "simple" lists, without REFEREN

Win32com and Excel

2008-01-10 Thread Mike P
Hi, I currently have an excel table (1 table each time) that has differing number of rows and differing number of columns each time, for another program i use (SPSS) to import the data i need to know the cell range of this data table. I.e what the last row of data is and the last column that has d

Using a proxy with urllib2

2008-01-10 Thread Jack
I'm trying to use a proxy server with urllib2. So I have managed to get it to work by setting the environment variable: export HTTP_PROXY=127.0.0.1:8081 But I wanted to set it from the code. However, this does not set the proxy: httpproxy = '127.0.0.1:3129' proxy_support = urllib2.ProxyHan

RE: docstrings style question

2008-01-10 Thread Ryan Ginstrom
> On Behalf Of Steve Brown > What do you think? I think that comments are for maintainers, and docstrings are for users. Some of the things I use comments for: * Visually separate classes (using a syntax-highlighting editor) * Explain algorithm choices * Explain bug fixes so I don't later "fix"

RE: Win32com and Excel

2008-01-10 Thread Ryan Ginstrom
> On Behalf Of Mike P > Does anyone have any code that does something similar? My > guess is i have to do something like thefollowing to enable > python to read xl? I think that what you want is UsedRange for row in sheet.UsedRange.Value: ... Regards, Ryan Ginstrom -- http://mail.python.

Re: Win32com and Excel

2008-01-10 Thread John Machin
On Jan 10, 8:21 pm, Mike P <[EMAIL PROTECTED]> wrote: > Hi, > > I currently have an excel table (1 table each time) that has differing > number of rows and differing number of columns each time, for another > program i use (SPSS) to import the data i need to know the cell range > of this data table

Import of cStringIO failing with "undefined symbol: PyObject_SelfIter" on python-2.3.3-88.9

2008-01-10 Thread grbgooglefan
I am importing cStringIO module in my PythonC++ embedded program. The import is failing with the following error: ImportError: /usr/lib/python2.3/lib-dynload/cStringIO.so: undefined symbol: PyObject_SelfIter I have python-2.3.3-88.9.x86 installed on my machine. Why is this error coming? how can I

Re: docstrings style question

2008-01-10 Thread Martin Marcher
Russ P. wrote: > On Jan 9, 9:47 pm, "Steve Brown" <[EMAIL PROTECTED]> wrote: >> I've got a series of modules which look like this: >> >> # >> # >> # Temperature Sense Test >> # >> # >> class Test3(ar_test.AR_TEST): >> """Temperature Sense Test""" >> >> I don't like the

Rebuild list of objects with redundancies on objects' attribute

2008-01-10 Thread Nico Grubert
Hi there I have a list of dummy objects which have the attributes 'location', 'name', 'gender'. Now I want to rebuild this list in order to avoid redundancies on objects with the same 'location'. Example: #-- class Dummy: pas

Re: docstrings style question

2008-01-10 Thread Steve Brown
"Russ P." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Jan 9, 11:51 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> Steve Brown wrote: >> > I've got a series of modules which look like this: >> >> > # >> > # >> > # Temperature Sense Test >> > # >> > # >

Re: Python too slow?

2008-01-10 Thread A.T.Hofkamp
On 2008-01-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm pretty new to Python, and even newer to Image/Video processing, > and trying to get started on a project similar to GRL Vienna's laser > marker. I found some sample code here > http://janto.blogspot.com/2006/01/motion-capture-in-pyt

Re: help with a problem from school??

2008-01-10 Thread Martin Marcher
Josh wrote: > Hello all I did a Google search and found this site and was hoping someone > could help me with what I am sure is a simple question that I cannot > figure out. Here goes: > > Given a simple straight through switch (SPST) with a supply of > 14V, and the need

Re: Python too slow?

2008-01-10 Thread Jeroen Ruigrok van der Werven
-On [20080110 11:46], A.T.Hofkamp ([EMAIL PROTECTED]) wrote: >In my experience however, differences in CPU execution time are usually >meaningless compared to differences in development time. I have to disagree with you to a point. Yes, maintenance of code is important, no denying that. H

Do you know mirror repository of PyUMLGraph, what do you thinks about this tools ?

2008-01-10 Thread KLEIN Stéphane
Hi, I've looked http://www.umlgraph.org/ tools. I think it's great to generate UML Diagram from source code and comment's. I read there are "Python version" of this tools : PyUMLGraph (http://pypi.python.org/pypi/ PyUMLGraph/0.1.10). Unfortunately, repository of this tools is down :( My questio

Re: Rebuild list of objects with redundancies on objects' attribute

2008-01-10 Thread Peter Otten
Nico Grubert wrote: > Hi there > > I have a list of dummy objects which have the attributes 'location', > 'name', 'gender'. > Now I want to rebuild this list in order to avoid redundancies on > objects with the same 'location'. > > Example: > > #---

SV: Conventions for dummy name

2008-01-10 Thread David.Reksten
Torsten Bronger wrote: >Hallöchen! > >Ben Finney writes: > >> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> >>> The underscore is used as "discarded" identifier. So maybe >>> >>> for _ in xrange(10): >>> ... >> >> The problem with the '_' name is that it is already well-known and >> long-u

Re: Python too slow?

2008-01-10 Thread [EMAIL PROTECTED]
For the most part, I agree with you, which is why I chose Python in the first place. I like quick development. Unfortunately, this is one of those cases where execution time is a factor. Who knows, maybe someone who's done camera vision with Python will come in and say it's just the algorithm in

SQLObject 0.7.10

2008-01-10 Thread Oleg Broytmann
Hello! I'm pleased to announce the 0.7.10 release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started wi

Re: Conventions for dummy name

2008-01-10 Thread Torsten Bronger
Hallöchen! [EMAIL PROTECTED] writes: > Torsten Bronger wrote: > >> [...] >> >> Right, that's because I've used "__" where not all returning >> values are interesing to me such as >> >> a, b, __ = function_that_returns_three_values(x, y) > > Variable name "dummy" serves the same purpose, such as:

Re: for loop without variable

2008-01-10 Thread Duncan Booth
erik gartz <[EMAIL PROTECTED]> wrote: > Hi. I'd like to be able to write a loop such as: > for i in range(10): > pass > but without the i variable. The reason for this is I'm using pylint > and it complains about the unused variable i. I can achieve the above > with more lines of code like: >

SQLObject 0.8.7

2008-01-10 Thread Oleg Broytmann
Hello! I'm pleased to announce the 0.8.7 release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started wi

SQLObject 0.9.3

2008-01-10 Thread Oleg Broytmann
Hello! I'm pleased to announce the 0.9.3 release of SQLObject. What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started wi

SV: Conventions for dummy name

2008-01-10 Thread David.Reksten
Torsten Bronger writes: >[EMAIL PROTECTED] writes: > >> Torsten Bronger wrote: >> >>> [...] >>> >>> Right, that's because I've used "__" where not all returning >>> values are interesing to me such as >>> >>> a, b, __ = function_that_returns_three_values(x, y) >> >> Variable name "dummy" serves the

importing module conflict

2008-01-10 Thread Matias Surdi
Hi, Suppose I've a module named "urllib" and from it I need to import the urllib module from the python standart library. ¿how can I do this? The problem I found is that when I do: import urrlib The imported module is itself, and not the one from the stdlib. Any idea? Thanks a lot. -- ht

Re: Python too slow?

2008-01-10 Thread Ant
On Jan 10, 12:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > For the most part, I agree with you, which is why I chose Python in > the first place. I like quick development. Unfortunately, this is > one of those cases where execution time is a factor. Who knows, maybe > someone who's do

Re: Python too slow?

2008-01-10 Thread [EMAIL PROTECTED]
On Jan 10, 3:00 am, Ant <[EMAIL PROTECTED]> wrote: > On Jan 10, 12:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > For the most part, I agree with you, which is why I chose Python in > > the first place. I like quick development. Unfortunately, this is > > one of those cases where e

Re: importing module conflict

2008-01-10 Thread Ben Finney
Matias Surdi <[EMAIL PROTECTED]> writes: > Suppose I've a module named "urllib" and from it I need to import > the urllib module from the python standart library. What you want is the "absolute import" behaviour, described in PEP 328 http://www.python.org/peps/pep-0328.html> and implemented in Py

Re: importing module conflict

2008-01-10 Thread Bruno Desthuilliers
Matias Surdi a écrit : > Hi, > > Suppose I've a module named "urllib" and from it I need to import the > urllib module from the python standart library. > > ¿how can I do this? > > The problem I found is that when I do: > > > import urrlib > > The imported module is itself, and not the one f

Embedding python code into text document question.

2008-01-10 Thread Thomas Troeger
Dear all, I've written a program that parses a string or file for embedded python commands, executes them and fills in the returned value. The input might look like this: process id: $$return os.getpid()$$ current date: $$return time.ctime()$$ superuser: $$ if os.geteuid(): return "Yes"

Image/Video Processing in Python

2008-01-10 Thread [EMAIL PROTECTED]
Hello, I'm trying to work on a project in Python that involves the use of a webcam to track a laser pointer. I found some example code here http://janto.blogspot.com/2006/01/motion-capture-in-python.html, but the problem is that it's quite slow (about a sec to process a 800 by 600 image). Can an

Re: Python or PowerShell ?

2008-01-10 Thread Martin P. Hellwig
[EMAIL PROTECTED] wrote: > On Jan 8, 1:57 pm, "Martin P. Hellwig" <[EMAIL PROTECTED]> wrote: >> And adding to that, if you don't care about cross platform anyway, why >> even bother with python? I am sure that MS has tools that can do in a >> point and click kind of way all the things you might en

Re: Python's great, in a word

2008-01-10 Thread Caleb
> The best thing about Python is ___. this. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding python code into text document question.

2008-01-10 Thread grflanagan
On Jan 10, 2:10 pm, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Dear all, > > I've written a program that parses a string or file for embedded python > commands, executes them and fills in the returned value. The input might > look like this: > > process id: $$return os.getpid()$$ > current date: $

Re: Embedding python code into text document question.

2008-01-10 Thread Thomas Troeger
Ok I've written a small example program to clarify matters: [SNIP] #!/usr/bin/python import os, sys, time def template(src, dst, sep): """ Copy file from src to dst, executing embedded python code. """ try: #

Re: New Tk look (aka Ttk or Tile widgets)

2008-01-10 Thread Rob Wolfe
Robert Hicks napisał(a): > Do I have to install something extra to use the new look? I managed to use Tile with Tk 8.4 and Python 2.5. After installing Tile I followed these advices: http://tkinter.unpythonic.net/wiki/UsingTile and used this code: http://tkinter.unpythonic.net/wiki/TileWrapper A

Re: I'm searching for Python style guidelines

2008-01-10 Thread rui
Thanks Caleb. Really liked some points. On Jan 10, 2008 11:20 AM, Caleb <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Anything written somewhere that's thorough? Any code body that should > > serve as a reference? > > 1. Don't use tabs (use spaces). > 2. Study "import this" > 3. Use

Re: New Tk look (aka Ttk or Tile widgets)

2008-01-10 Thread Guilherme Polo
2008/1/10, Robert Hicks <[EMAIL PROTECTED]>: > Do I have to install something extra to use the new look? > > Robert > -- > http://mail.python.org/mailman/listinfo/python-list > Tk 8.5 -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list

Re: docstrings style question

2008-01-10 Thread Neil Cerutti
On Jan 10, 2008 12:47 AM, Steve Brown <[EMAIL PROTECTED]> wrote: > I've got a series of modules which look like this: > > # > # > # Temperature Sense Test > # > # > class Test3(ar_test.AR_TEST): > """Temperature Sense Test""" > > > I don't like the duplicated information

New Tk look (aka Ttk or Tile widgets)

2008-01-10 Thread Robert Hicks
Do I have to install something extra to use the new look? Robert -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm searching for Python style guidelines

2008-01-10 Thread Caleb
[EMAIL PROTECTED] wrote: > Anything written somewhere that's thorough? Any code body that should > serve as a reference? 1. Don't use tabs (use spaces). 2. Study "import this" 3. Use lists and dictionaries as much as you possibly can 4. Use comprehensions and generators as much as you possibly ca

run shell commands

2008-01-10 Thread Riccardo Maria Bianchi
Hello! :) I'm trying to run shell commands both with os.system() and subprocess.Popen() class. But I can't run aliases or function defined in my .bashrc file, like in the login interactive shell. Can you help me? Maybe have I to add some commands to load the .bashrc? Thanks a lot! :) Ri

Re: Embedding python code into text document question.

2008-01-10 Thread tezlo
Thomas Troeger <[EMAIL PROTECTED]> wrote: > I've written a program that parses a string or file for embedded > python commands, executes them and fills in the returned value. > ... > I've tried several solutions using eval, execfile or compile, but > none of those would solve my problem. Does anyon

Re: Embedding python code into text document question.

2008-01-10 Thread Marc 'BlackJack' Rintsch
On Thu, 10 Jan 2008 14:10:05 +0100, Thomas Troeger wrote: > I've written a program that parses a string or file for embedded python > commands, executes them and fills in the returned value. The input might > look like this: > > process id: $$return os.getpid()$$ > current date: $$return time.c

Re: Strip lines from files

2008-01-10 Thread Caleb
Francesco Pietra wrote: > I am posting again as previous identical message had alleged suspicious > header. > > I used successfully script > > f=open("prod1-3_no_wat_pop.pdb", "r") > for line in f: > line=line.rstrip() > if "WAT" not in line: > print line > f.close() l

Problem with Tkinter.PhotoImage

2008-01-10 Thread Cédric Lucantis
Hi, I can only load gif images with Tkinter.PhotoImage and none with BitmapImage. I tried png, jpg, bmp and xpm and always got this errors : >>> img = Tkinter.PhotoImage(file='/home/omer/fgfs/fgsync/map.xpm') Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/l

Re: Import module conflict

2008-01-10 Thread jatin patni
>Suppose I've a module named "urllib" and from it I need to import the >urllib module from the python standart library. >¿how can I do this? >The problem I found is that when I do: >import urrlib >The imported module is itself, and not the one from the stdlib. >Any idea? Try this: *from stdl

Re: importing module conflict

2008-01-10 Thread Matias Surdi
Ben Finney escribió: > Matias Surdi <[EMAIL PROTECTED]> writes: > >> Suppose I've a module named "urllib" and from it I need to import >> the urllib module from the python standart library. > > What you want is the "absolute import" behaviour, described in PEP 328 > http://www.python.org/peps/pep

Re: ISO books of official Python docs

2008-01-10 Thread kj
In <[EMAIL PROTECTED]> gordyt <[EMAIL PROTECTED]> writes: >Howdy kynnjo, >> Is it possible to buy the official Python docs in book form? If >> so, I'd very much appreciate the name(s) and author(s) of the >> book(s). >I haven't seen them in print form, but you can download PDF's from >here: >h

Re: Problem with Tkinter.PhotoImage

2008-01-10 Thread Kevin Walzer
Cédric Lucantis wrote: > Hi, > > I can only load gif images with Tkinter.PhotoImage and none with BitmapImage. > I tried png, jpg, bmp and xpm and always got this errors : > That's because Tk only supports the gif format natively. You need to install an additional photo library to support addi

Re: New Tk look (aka Ttk or Tile widgets)

2008-01-10 Thread Robert Hicks
On Jan 10, 9:08 am, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2008/1/10, Robert Hicks <[EMAIL PROTECTED]>: > > > Do I have to install something extra to use the new look? > > > Robert > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Tk 8.5 > > -- > -- Guilherme H. Polo Goncalve

ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread kj
I'm looking for "example implementations" of small projects in Python, similar to the ones given at the end of most chapters of The Perl Cookbook (2nd edition, isbn: 0596003137). (Unfortunately, the otherwise excellent Python Cookbook (2nd edition, isbn: 0596007973), by the same publisher (O'Re

PIL rotate : Rotate By Shear / Paeth Rotation?

2008-01-10 Thread IanJSparks
I've been doing some image rotation with PIL and comparing the images with imagemagick's convert -rotate output. Imagemagick uses an RBS / Paeth rotation algorithm that appears to give better results than PIL's rotate method. However, I love PIL and don't want to have to shell out to imagemagick

Re: ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread kyosohma
On Jan 10, 10:13 am, kj <[EMAIL PROTECTED]> wrote: > I'm looking for "example implementations" of small projects in > Python, similar to the ones given at the end of most chapters of > The Perl Cookbook (2nd edition, isbn: 0596003137). (Unfortunately, > the otherwise excellent Python Cookbook (2nd

urllib2 rate limiting

2008-01-10 Thread Dimitrios Apostolou
Hello list, I want to limit the download speed when using urllib2. In particular, having several parallel downloads, I want to make sure that their total speed doesn't exceed a maximum value. I can't find a simple way to achieve this. After researching a can try some things but I'm stuck on th

Re: SQLObject 0.9.3

2008-01-10 Thread kyosohma
On Jan 10, 6:38 am, Oleg Broytmann <[EMAIL PROTECTED]> wrote: > Hello! > > I'm pleased to announce the 0.9.3 release of SQLObject. > > What is SQLObject > = > > SQLObject is an object-relational mapper. Your database tables are described > as classes, and rows are instances of thos

Re: ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread ajcppmod
Have a look at Dive into Python by Mark Pilgrim. It is available for free here http://www.diveintopython.org/. Andy -- http://mail.python.org/mailman/listinfo/python-list

Re: run shell commands

2008-01-10 Thread Noah Dain
On Jan 10, 2008 9:24 AM, Riccardo Maria Bianchi <[EMAIL PROTECTED]> wrote: > > Hello! :) > > I'm trying to run shell commands both with os.system() and > subprocess.Popen() class. > > But I can't run aliases or function defined in my .bashrc file, like in > the login interactive shell. > > Can you

Re: Why my program (using pexpect to switch user) doesn't work well?

2008-01-10 Thread Noah
On Jan 10, 12:59 am, BlackjadeLin <[EMAIL PROTECTED]> wrote: > I'm new to python > I want to write a simple script to switch user,for example,from user_A > to user_B. > This my codes: > > #!/usr/bin/python > importpexpect > import os > passwd="user_B" > child =pexpect.spawn('su user_B') > child.exp

Re: Using a proxy with urllib2

2008-01-10 Thread Rob Wolfe
"Jack" <[EMAIL PROTECTED]> writes: > I'm trying to use a proxy server with urllib2. > So I have managed to get it to work by setting the environment > variable: > export HTTP_PROXY=127.0.0.1:8081 > > But I wanted to set it from the code. However, this does not set the proxy: > httpproxy = '127

Re: subprocess "handle is invalid" error

2008-01-10 Thread Daniel Serodio
Thomas Heller-2 wrote: > > Grant Edwards schrieb: > > [snip] > >> >> Traceback (most recent call last): >> File "surfedit.py", line 28, in ? >> File "Gnuplot\_Gnuplot.pyc", line 178, in __init__ >> File "Gnuplot\gp_win32.pyc", line 117, in __init__ >> File "subprocess.pyc",

Re: Python too slow?

2008-01-10 Thread Fredrik Lundh
A.T.Hofkamp wrote: > Now the question you need to answer for yourself, is how much more worth is > your own time compared to the gain in CPU time. If you think they are equal > (ie > the problem as a whole should be solved as fast as possible, thus the sum of > development time + execution time s

What is "lambda x=x : ... " ?

2008-01-10 Thread [EMAIL PROTECTED]
I'm reading this page: http://www.ps.uni-sb.de/~duchier/python/continuations.html and I've found a strange usage of lambda: Now, CPS would transform the baz function above into: def baz(x,y,c): mul(2,x,lambda v,y=y,c=c: add(v,y,c)) ### What does "y=

Re: urllib2 rate limiting

2008-01-10 Thread Rob Wolfe
Dimitrios Apostolou <[EMAIL PROTECTED]> writes: > P.S. And something simpler: How can I disallow urllib2 to follow > redirections to foreign hosts? You need to subclass `urllib2.HTTPRedirectHandler`, override `http_error_301` and `http_error_302` methods and throw `urllib2.HTTPError` exception.

Re: Collecting Rich Data Structures for students

2008-01-10 Thread [EMAIL PROTECTED]
On Jan 10, 1:01 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Wed, 9 Jan 2008 15:05:25 -0800 (PST), "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > Sometimes we spare the students (whomever they may be) this added > > step and just hand them a di

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Tim Chase
> What does "y=y" and "c=c" mean in the lambda function? the same thing it does in a function definition: def myfunct(a, b=42, y=3.141): pass > # > x = 3 > y = lambda x=x : x+10 > > print y(2) > ## > > It prints 12, so it doesn't bind the variable in th

Re: ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread Robert Hicks
On Jan 10, 11:13 am, kj <[EMAIL PROTECTED]> wrote: > I'm looking for "example implementations" of small projects in > Python, similar to the ones given at the end of most chapters of > The Perl Cookbook (2nd edition, isbn: 0596003137). (Unfortunately, > the otherwise excellent Python Cookbook (2nd

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread [EMAIL PROTECTED]
I've figured it out, it is default argument. print y() gives 13 as result. It's a bit evil though. I hope this post will be useful some newbie like i'm now someday :) On Jan 10, 7:25 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm reading this > page:http://www.ps.uni-sb.de/~duchier/py

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > > Now, CPS would transform the baz function above into: > > def baz(x,y,c): > mul(2,x,lambda v,y=y,c=c: add(v,y,c)) > > ### > > What does "y=y" and "c=c" mean in the lambda function? they bind the argument "y" to the *obje

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Mike Meyer
On Thu, 10 Jan 2008 10:25:27 -0800 (PST) "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm reading this page: > http://www.ps.uni-sb.de/~duchier/python/continuations.html > and I've found a strange usage of lambda: > > > Now, CPS would transform the baz function above in

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread [EMAIL PROTECTED]
You're talking about syntax from the bad old days when the scope rules were different. If not too archeological for your tastes, download and boot a 1.5 and see what happens. Less empirically, here're some key references: http://www.python.org/doc/2.2.3/whatsnew/node9.html http://www.python.org/

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Fredrik Lundh
Mike Meyer wrote: >> What does "y=y" and "c=c" mean in the lambda function? > > Older versions of python didn't make variables in an outer scope > visible in the inner scope. This was the standard idiom to work > around that. lexically scoped free variables and object binding are two different

Re: Python too slow?

2008-01-10 Thread George Sakkis
On Jan 10, 3:37 am, Bruno Desthuilliers wrote: > I fail to see how the existence of JIT compilers in some Java VM changes > anything to the fact that both Java (by language specification) and > CPython use the byte-code/VM scheme. Because these "some Java VMs" with JIT compilers are the de facto

Persistent HTTP Connections with Python?

2008-01-10 Thread Scott Sharkey
Hello All, I am trying to write a python script to talk to an xml-based stock feed service. They are telling me that I must connect and login, and then "issue refresh requests" to fetch the data. This sounds a lot (to me) like HTTP 1.1 persistent connections. Can I do that with the urllib f

Re: Problem with Tkinter.PhotoImage

2008-01-10 Thread Fredrik Lundh
Cédric Lucantis wrote: > I can only load gif images with Tkinter.PhotoImage and none with BitmapImage. > I tried png, jpg, bmp and xpm and always got this errors : > img = Tkinter.PhotoImage(file='/home/omer/fgfs/fgsync/map.xpm') > Traceback (most recent call last): > File "", line 1, in

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Mike Meyer
On Thu, 10 Jan 2008 19:59:23 +0100 Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Mike Meyer wrote: > >> What does "y=y" and "c=c" mean in the lambda function? > > > > Older versions of python didn't make variables in an outer scope > > visible in the inner scope. This was the standard idiom to work >

Re: for loop without variable

2008-01-10 Thread Mike Meyer
On Thu, 10 Jan 2008 08:42:16 +0100 Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Mike Meyer <[EMAIL PROTECTED]> writes: > > It sounds to me like your counter variable actually has meaning, > It depends how the code is written. In the example such as: > > for meaningless_variable in xrange(number_of_

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Fredrik Lundh
Mike Meyer wrote: What does "y=y" and "c=c" mean in the lambda function? >>> >>> Older versions of python didn't make variables in an outer scope >>> visible in the inner scope. This was the standard idiom to work >>> around that. >>> >> lexically scoped free variables and object binding are

XML+Logs to Latex. XSLT?

2008-01-10 Thread Florencio Cano
Hi! I'm thinking about implementing a script in Python to do this task. I have a XML log and logs from other programs. My aim is to do a report about all this information. I'm thinking in using Python to transform the plain logs to XML and combine them with the XML document I have and later use som

Re: Python too slow?

2008-01-10 Thread Ross Ridge
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > And the reference implementation of Python (CPython) is not > interpreted, it's compiled to byte-code, which is then executed by a VM > (just like Java). Ed Jensen a écrit : > Wow, this is pretty misleading. Bruno Desthuilliers <[EMAIL PROTECTE

Re: XML+Logs to Latex. XSLT?

2008-01-10 Thread Fredrik Lundh
Florencio Cano wrote: > I'm thinking about implementing a script in Python to do this task. I > have a XML log and logs from other programs. My aim is to do a report > about all this information. I'm thinking in using Python to transform > the plain logs to XML and combine them with the XML docume

Re: urllib2 rate limiting

2008-01-10 Thread Dimitrios Apostolou
On Thu, 10 Jan 2008, Rob Wolfe wrote: > Dimitrios Apostolou <[EMAIL PROTECTED]> writes: > >> P.S. And something simpler: How can I disallow urllib2 to follow >> redirections to foreign hosts? > > You need to subclass `urllib2.HTTPRedirectHandler`, override > `http_error_301` and `http_error_302` m

Re: XML+Logs to Latex. XSLT?

2008-01-10 Thread Florencio Cano
2008/1/10, Fredrik Lundh <[EMAIL PROTECTED]>: > Florencio Cano wrote: > > > I'm thinking about implementing a script in Python to do this task. I > > have a XML log and logs from other programs. My aim is to do a report > > about all this information. I'm thinking in using Python to transform > > t

open excel file while it is being used.

2008-01-10 Thread barry . zhao
Hi, I have a python program that constantly updates an excel spreadsheet. I would like to be able to view its updates while using excel to edit other excel files. Below are the test codes I have: -- from time impo

Re: urllib2 rate limiting

2008-01-10 Thread Rob Wolfe
Dimitrios Apostolou <[EMAIL PROTECTED]> writes: > On Thu, 10 Jan 2008, Rob Wolfe wrote: > >> Dimitrios Apostolou <[EMAIL PROTECTED]> writes: >> >>> P.S. And something simpler: How can I disallow urllib2 to follow >>> redirections to foreign hosts? >> >> You need to subclass `urllib2.HTTPRedirectHa

Re: Embedding python code into text document question.

2008-01-10 Thread MRAB
On Jan 10, 1:10 pm, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Dear all, > > I've written a program that parses a string or file for embedded python > commands, executes them and fills in the returned value. The input might > look like this: > > process id: $$return os.getpid()$$ > current date: $

  1   2   >