Re: Emacs Python-mode. Newbie problem.

2009-07-08 Thread Lacrima
On Jul 8, 10:54 pm, Piet van Oostrum wrote: > > Lacrima (L) wrote: > >L> Hello! > >L> I have just started using Emacs to write python scripts. > >L> I installed python-mode.el > >L> Then I just tried this code: > >L> print 'hello world' > >L> When I press C-c RET, new blank window is opened a

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Stefan Behnel
Paul Rubin wrote: > Daniel Austria writes: >> just one question. How can i remove all 0 values in a list? > > I prefer: > >newlist = list(x for x in oldlist if x != 0) > > to the square bracket list comprehension that a few people have > suggested. This is because in python 2.x, the listco

Re: Pydev 1.4.7 Released

2009-07-08 Thread Morten Nygaard Aasnes
On 2009-07-08, Fabio Zadrozny wrote: > Hi All, > > Pydev and Pydev Extensions 1.4.7 have been released > > Details on Pydev Extensions: http://www.fabioz.com/pydev > Details on Pydev: http://pydev.sf.net > Details on its development: http://pydev.blogspot.com Nice! Will this work in Eclipse 3.5 a

Re: tough-to-explain Python

2009-07-08 Thread greg
Dave Angel wrote: By the time I graduated, I had five six-level languages ^^^ Are they languages that you have to edit using vi? :-) -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: PyQt GUI

2009-07-08 Thread Helvin
On Jul 9, 11:29 am, Robert Kern wrote: > On 2009-07-08 18:10, Helvin wrote: > > > Thanks for the fast replies! I will look into how to use VTK now. > > Where would I find VTK's explicit support for PyQt? > > Wrapping/Python/vtk/qt4/ in the VTK sources. > > > Because I have installed VTK (using its

Re: Python Error from Apress book

2009-07-08 Thread Gabriel Genellina
En Wed, 08 Jul 2009 06:35:54 -0300, Dave Angel escribió: Gabriel Genellina wrote: Jul 2009 09:55:13 -0300, Dave Angel escribió: Gabriel Genellina wrote: En Mon, 06 Jul 2009 19:56:40 -0300, matt0177 escribió: When I try to run the command as outlined in the book "simple_markup2.py < test

Re: tough-to-explain Python

2009-07-08 Thread Simon Forman
(I wanted to reply to a few messages in one post so I quoted them all below. Let me know if this is bad etiquette.) On Jul 8, 8:23 am, kj wrote: > In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> Simon > Forman writes: > > >Frankly, I'm of the impression that it's a mistak

Re: IP Address Function

2009-07-08 Thread Nobody
On Wed, 08 Jul 2009 20:53:12 -0700, Fred Atkinson wrote: >>ipaddr = (getenv("HTTP_CLIENT_IP") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("HTTP_X_FORWARDED_FOR") or >> getenv("REMOTE_ADDR") or >> "UNKNOWN") >> >>print ipaddr > > That did it. > > I wonder why they don'

Re: IP Address Function

2009-07-08 Thread Fred Atkinson
On Wed, 08 Jul 2009 12:29:54 +0200, Piet van Oostrum wrote: >Something like: > >#! /usr/bin/env python > >import cgi >from os import getenv > >print "Content-type: text/html" >print > >ipaddr = (getenv("HTTP_CLIENT_IP") or > getenv("HTTP_X_FORWARDED_FOR") or > getenv("HTTP_X_FORWARDED_F

Re: PyQt GUI

2009-07-08 Thread Juan Pablo Romero Méndez
I use OpenInventor (Coin3d) which have a python binding called "pivy". It works great. http://pivy.coin3d.org/ Juan Pablo 2009/7/8 Helvin : > Hi experts! > > I'm developing a GUI for a software using PyQT, and need 3D > visualization. Should I use PyOpenGL or VTK? > I understand that the PyQt pa

Re: Clarity vs. code reuse/generality

2009-07-08 Thread kj
In Tim Rowe writes: >2009/7/4 kj : >> Precisely. =A0As I've stated elsewhere, this is an internal helper >> function, to be called only a few times under very well-specified >> conditions. =A0The assert statements checks that these conditions >> are as intended. =A0I.e. they are checks against

Re: count

2009-07-08 Thread J. Clifford Dyer
On Wed, 2009-07-08 at 14:45 -0700, Paul Rubin wrote: > a...@pythoncraft.com (Aahz) writes: > > >Avoid that len(tuple(g)), use something like the following, it's lazy > > >and saves some memory. > > The question is whether it saves time, have you tested it? > > len(tuple(xrange(1))) ... hmm

Re: Clarity vs. code reuse/generality

2009-07-08 Thread kj
In Scott David Daniels writes: >First, a quote which took me a bit to find: > Thomas William Körner paraphrasing Polya and Svego > in A Companion to Analysis: > Recalling that 'once is a trick, twice is a method, > thrice is a theorem, and four times a theory,' we >

Re: Clarity vs. code reuse/generality

2009-07-08 Thread kj
In Martin Vilcans writes: >On Fri, Jul 3, 2009 at 4:05 PM, kj wrote: >> I'm will be teaching a programming class to novices, and I've run >> into a clear conflict between two of the principles I'd like to >> teach: code clarity vs. code reuse. =A0I'd love your opinion about >> it. >In general,

Re: ANN: GMPY 1.10 alpha with support for Python 3

2009-07-08 Thread casevh
On Jul 8, 5:03 pm, Mensanator wrote: > On Jul 7, 12:47 am, Mensanator wrote: > > > > > On Jul 7, 12:16 am, casevh wrote: > > > > I discovered a serious bug with comparisons and have posted alpha2 > > > which fixes that bug and adds Unicode support for Python 2.x > > > > casevh > > > Damn! I was

Re: tkinter problem

2009-07-08 Thread Paul Simon
"Chris Rebert" wrote in message news:mailman.2863.1247095339.8015.python-l...@python.org... On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: > I have the "tkinter" problem and need some assistance to straighten it > out. > >From the web page "http://wiki.python.org/moin/TkInter"; I tested as i

Re: ANN: GMPY 1.10 alpha with support for Python 3

2009-07-08 Thread Mensanator
On Jul 7, 12:47 am, Mensanator wrote: > On Jul 7, 12:16 am, casevh wrote: > > > I discovered a serious bug with comparisons and have posted alpha2 > > which fixes that bug and adds Unicode support for Python 2.x > > > casevh > > Damn! I was just congatulating myself for pulling off > a hat trick

Re: walking a directory with very many files

2009-07-08 Thread Lawrence D'Oliveiro
In message , Lie Ryan wrote: > Lawrence D'Oliveiro wrote: > >> ... certainly it is characteristic of GUIs to show you all 400,000 files >> in a directory, or at least try to do so, and either hang for half an >> hour or run out of memory and crash, rather than give you some >> intelligent way of p

Re: PyQt GUI

2009-07-08 Thread Robert Kern
On 2009-07-08 18:10, Helvin wrote: Thanks for the fast replies! I will look into how to use VTK now. Where would I find VTK's explicit support for PyQt? Wrapping/Python/vtk/qt4/ in the VTK sources. Because I have installed VTK (using its installer) and pyVTK (using its setup.py file), but ho

Re: tkinter problem

2009-07-08 Thread Chris Rebert
On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: > I have the "tkinter" problem and need some assistance to straighten it out. > >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in "step > 1" and cannot import "_tkinter." I do not have that file on my computer, but > do have t

Re: regex help

2009-07-08 Thread Rhodri James
On Wed, 08 Jul 2009 23:06:22 +0100, David wrote: Hi I have a few regexs I need to do, but im struggling to come up with a nice way of doing them, and more than anything am here to learn some tricks and some neat code rather than getting an answer - although thats obviously what i would like

tkinter problem

2009-07-08 Thread Paul Simon
I have the "tkinter" problem and need some assistance to straighten it out. >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in "step 1" and cannot import "_tkinter." I do not have that file on my computer, but do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as t

Re: PyQt GUI

2009-07-08 Thread Helvin
On Jul 8, 9:23 pm, Phil Thompson wrote: > On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch" > > wrote: > > > > > > > Helvin wrote: > > >> Hi experts! > > >> I'm developing a GUI for a software using PyQT, and need 3D > >> visualization. Should I use PyOpenGL or VTK? > >> I understand that th

Pydev 1.4.7 Released

2009-07-08 Thread Fabio Zadrozny
Hi All, Pydev and Pydev Extensions 1.4.7 have been released Details on Pydev Extensions: http://www.fabioz.com/pydev Details on Pydev: http://pydev.sf.net Details on its development: http://pydev.blogspot.com Release Highlights in Pydev Extensions: ---

Re: regex help

2009-07-08 Thread Tim Harig
On 2009-07-08, Chris Rebert wrote: > On Wed, Jul 8, 2009 at 3:06 PM, David wrote: >> I want to extract the open, mkt cap and P/E values - but apart from >> doing loads of indivdual REs which I think would look messy, I can't >> think of a better and neater looking way. Any ideas? You are download

Re: Cleaning up after failing to contructing objects

2009-07-08 Thread Mattias Brändström
On Jul 6, 11:15 pm, Scott David Daniels wrote: > brasse wrote: > > I have been thinking about how write exception safe constructors in > > Python. By exception safe I mean a constructor that does not leak > > resources when an exception is raised within it. > > ... >  > As you can see this is less

Re: regex help

2009-07-08 Thread Chris Rebert
On Wed, Jul 8, 2009 at 3:06 PM, David wrote: > Hi > > I have a few regexs I need to do, but im struggling to come up with a > nice way of doing them, and more than anything am here to learn some > tricks and some neat code rather than getting an answer - although > thats obviously what i would like

Re: Clarity vs. code reuse/generality

2009-07-08 Thread Tim Rowe
2009/7/7 Steven D'Aprano : > Maybe the reason for "so much buggy software" is that people > inappropriately use assert, thus changing the behaviour of code depending > on whether it is run with the -O flag or not. I've done my share of code review and process audits, and assertions seem *far* to

Re: count

2009-07-08 Thread Aahz
In article <7xbpnuzw4u@ruckus.brouhaha.com>, Paul Rubin wrote: >a...@pythoncraft.com (Aahz) writes: >>Paul Rubin deleted an attribution: >>> >>>Avoid that len(tuple(g)), use something like the following, it's lazy >>>and saves some memory. >> >> The question is w

regex help

2009-07-08 Thread David
Hi I have a few regexs I need to do, but im struggling to come up with a nice way of doing them, and more than anything am here to learn some tricks and some neat code rather than getting an answer - although thats obviously what i would like to get to. Problem 1 - (25.47%) I want to extract 25

Re: count

2009-07-08 Thread Paul Rubin
a...@pythoncraft.com (Aahz) writes: > >Avoid that len(tuple(g)), use something like the following, it's lazy > >and saves some memory. > The question is whether it saves time, have you tested it? len(tuple(xrange(1))) ... hmm. -- http://mail.python.org/mailman/listinfo/python-list

Re: function local namespace question

2009-07-08 Thread Miles Kaufmann
On Jul 8, 2009, at 1:35 PM, Paul LaFollette wrote: I cannot figure out any way to get a hook into the local namespace of a user defined function. I have tried making a wrapper class that grabs the function call and then uses exec to invoke myfunction.__code__ with my own dictionaries. This run

Re: count

2009-07-08 Thread Paul Rubin
Bearophile writes: > >     print x, len(tuple(g)) > > Avoid that len(tuple(g)), use something like the following print x, sum(1 for _ in g) -- http://mail.python.org/mailman/listinfo/python-list

Re: ISO library ref in printed form

2009-07-08 Thread Piet van Oostrum
> kj (k) wrote: >k> In Piet van Oostrum writes: kj (kj) wrote: >kj> Does anyone know where I can buy the Python library reference in >kj> printed form? (I'd rather not print the whole 1200+-page tome >kj> myself.) I'm interested in both/either 2.6 and 3.0. >>> Maybe you can ha

Re: Emacs Python-mode. Newbie problem.

2009-07-08 Thread Piet van Oostrum
> Lacrima (L) wrote: >L> Hello! >L> I have just started using Emacs to write python scripts. >L> I installed python-mode.el >L> Then I just tried this code: >L> print 'hello world' >L> When I press C-c RET, new blank window is opened and emacs says: >L> (Shell command succeeded with no out

Re: count

2009-07-08 Thread Aahz
In article <050094ea-faf4-4e03-875d-9c2c63090...@y17g2000yqn.googlegroups.com>, Bearophile wrote: >Vilya Harvey: >> >> from itertools import groupby >> for x, g in groupby([fields[1] for fields in data]): >> =A0 =A0 print x, len(tuple(g)) > >Avoid that len(tuple(g)), use something like the follow

Re: ISO library ref in printed form

2009-07-08 Thread João Valverde
kj wrote: Does anyone know where I can buy the Python library reference in printed form? (I'd rather not print the whole 1200+-page tome myself.) I'm interested in both/either 2.6 and 3.0. TIA! kj Why not download the documentation, take it to a local copy shop and have it printed and bou

Re: A Bug By Any Other Name ...

2009-07-08 Thread Daniel Fetchinson
>> But this academic discussion is honestly a little pointless. The OP >> was referring to a expectation, coming from C, that is not fulfilled >> in python. What's wrong with mentioning it somewhere for the sake of >> helping C programmers? >> > And where does one stop? After all, my primary

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Paul Rubin
Daniel Austria writes: > just one question. How can i remove all 0 values in a list? I prefer: newlist = list(x for x in oldlist if x != 0) to the square bracket list comprehension that a few people have suggested. This is because in python 2.x, the listcomp "leaks" its index variable into

Re: ISO library ref in printed form

2009-07-08 Thread kj
In Piet van Oostrum writes: >> kj (kj) wrote: >>kj> Does anyone know where I can buy the Python library reference in >>kj> printed form? (I'd rather not print the whole 1200+-page tome >>kj> myself.) I'm interested in both/either 2.6 and 3.0. >Maybe you can have a copy printed at lulu.c

Re: ... remove all 0 values

2009-07-08 Thread Simon Forman
On Jul 8, 10:44 am, Daniel Austria wrote: > Hi python - hackers, > > just one question. How can i remove all 0 values in a list? Sure - i > can loop over it, but that s not a neat style.  list.remove() will > only remove the first occurence. Doing that while no exception is > raised is also uncool

Emacs Python-mode. Newbie problem.

2009-07-08 Thread Lacrima
Hello! I have just started using Emacs to write python scripts. I installed python-mode.el Then I just tried this code: print 'hello world' When I press C-c RET, new blank window is opened and emacs says: (Shell command succeeded with no output) So where is my 'hello world'? When I do C-c C-c,

function local namespace question

2009-07-08 Thread Paul LaFollette
Kind people, Using Python 3.1 under FreeBSD and WinXP. I've been tearing my hair out trying to solve this myself, but I need to ask for help. I want (for obscure reasons) to be able to log transactions in the namespace(s) of a script. Specifically I would like to log creation of identifiers, c

Re: OT: unix to Windows technology

2009-07-08 Thread Xah Lee
Xah Lee wrote: > • Switching from Mac/Unix To PC/Windows > http://xahlee.org/mswin/switch_to_windows.html Kenneth Tilton wrote: > You just discovered PCs are cheaper? > > The funny thing is that that is Microsoft's answer to the Apple Mac-PC > ads, they show people shopping for computers and just

Re: Check file is locked?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 21:31:12 -0700, Rajat wrote: >> > By the way most operating systems don't lock a file when it's opened for >> > reading or writing or even executed. >> >> The general conclusion seems to be that mandatory locking is more trouble >> than it's worth. > > My OS is a windows XP sp

Re: Python and webcam capture delay?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 22:11:12 -0700, Tim Roberts wrote: >>The webcam is bound to do some encoding; most of them use USB "full speed" >>(12Mbit/sec), which isn't enough for raw 640x480x24...@30fps data. > > That's not true. Most of the web cams made in the last 5 years or so run > at high speed, 4

Re: windows command-line

2009-07-08 Thread Emile van Sebille
On 7/8/2009 10:07 AM Lucas Junqueira said... Hi, I'd like to run a simple windows command-line program from within my python script and agt all the returt it generates. Is this possible? How can I do it? Depending on python version, look into subprocess, commands or os.pipe and related. Emi

windows command-line

2009-07-08 Thread Lucas Junqueira
Hi, I'd like to run a simple windows command-line program from within my python script and agt all the returt it generates. Is this possible? How can I do it? Thank you! Veja quais são os assuntos do mo

Problem with list of dicts and copying

2009-07-08 Thread Cameron Pulsford
Hello all, I'm redoing a sudoku solver of mine and I ran into an issue with lists of dicts. Bear with me for a second before I get to the actual problem... I'm representing the board as a dictionary, where the keys are (x, y) positions, and the values are candidates. So my program goes along pickin

Re: Python and webcam capture delay?

2009-07-08 Thread Nobody
On Tue, 07 Jul 2009 22:49:22 -0700, Dennis Lee Bieber wrote: > On Tue, 07 Jul 2009 23:37:43 +0100, Nobody > declaimed the following in gmane.comp.python.general: > >> AFAIK, the only real difference between "USB-1 conformant" and "USB-2 >> conformant" is that the latter actually passed a test of

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread Terry Reedy
kj wrote: To clarify, this comes from my reading of Fredrik Lundh's pages "Python Objects" (http://effbot.org/zone/python-objects.htm) and "Call By Object" (http://effbot.org/zone/call-by-object.htm). [snip] [END OF LENGTHY QUOTE] Therefore, extending just a bit beyond Lundh's explanation, if

Re: OT: unix to Windows technology

2009-07-08 Thread Kenneth Tilton
Xah Lee wrote: Dear unixers & lispers, i've been using Mac for the past 19 years, and been a professional sys admin or web app developers on the unix platform, since 1998 (maily Solaris, Apache, Perl, Java, SQL, PHP). In june, i bought a PC (not for the first time though), and made a switch to W

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Friðrik Már Jónsson
J Kenneth King wrote: I was wondering when someone would mention filter() I was happy to see that too. It's clean, faster than list comprehension and in terms of clarity it's only to be expected that the developer is familiar with, or at least willing to look up, the available built-in met

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread kj
In a...@pythoncraft.com (Aahz) writes: >In article , kj wrote: >> >>OK, so, scratching from my original post the case >> >>. = >> >>(as being a special case of = ), still, >>to the extent that I understand your post, the "=" in >> >> x = 1 >> >>means something fundamentally different (in ter

Re: Does cProfile include IO wait time?

2009-07-08 Thread Robert Kern
On 2009-07-04 19:03, Matthew Wilson wrote: I have a command-line script that loads about 100 yaml files. It takes 2 or 3 seconds. I profiled my code and I'm using pstats to find what is the bottleneck. Here's the top 10 functions, sorted by internal time: In [5]: _3.sort_stats('time').pr

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread J Kenneth King
Friðrik Már Jónsson writes: > ma wrote: >> filter(lambda x: x, your_list) > > Good call! Equivalent but more efficient: > > filter(None, your_list) > > Regards, > Friðrik Már I was wondering when someone would mention filter() -- http://mail.python.org/mailman/listinfo/python-list

OT: unix to Windows technology

2009-07-08 Thread Xah Lee
Dear unixers & lispers, i've been using Mac for the past 19 years, and been a professional sys admin or web app developers on the unix platform, since 1998 (maily Solaris, Apache, Perl, Java, SQL, PHP). In june, i bought a PC (not for the first time though), and made a switch to Windows, for the f

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread Aahz
In article , kj wrote: > >OK, so, scratching from my original post the case > >. = > >(as being a special case of = ), still, >to the extent that I understand your post, the "=" in > > x = 1 > >means something fundamentally different (in terms of Python's >underlying implementation) from the "

Re: tough-to-explain Python

2009-07-08 Thread Dave Angel
kj wrote: In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> Simon Forman writes: Frankly, I'm of the impression that it's a mistake not to start teaching programming with /the bit/ and work your way up from there. I'm not kidding. I wrote a (draft) article about this:

Re: Python Error from Apress book

2009-07-08 Thread Matthew Edmondson
I'm running XP SP3. The program now works great from either of the directories, as long as include 'python' before it. As far as looking at the error with stack trace, I really don't know enough yet to know how to do that. I'm running the file from command line, because I'm not sure how to run it r

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread Aahz
In article <0778f257-d36c-4e13-93ea-bf8d448c8...@b15g2000yqd.googlegroups.com>, Paul Boddie wrote: > >Almost. The latter can modify namespaces - the objects themselves - >but through properties or dynamic attribute access, they may choose >not to modify such a namespace. Really, we can phrase ass

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread kj
In <0778f257-d36c-4e13-93ea-bf8d448c8...@b15g2000yqd.googlegroups.com> Paul Boddie writes: >On 8 Jul, 16:04, kj wrote: >> >> =A0 =3D >> >> and not to those like, for example, >> >> =A0 [] =3D >> >> or >> >> =A0 . =3D >> >> The former are syntatic sugar for certain namespace modifications >>

Re: Remoting over SSH

2009-07-08 Thread Raúl Gómez C .
You also could use TwistedConch, which is an implementation of the SSH2 protocol for Python. I've done something with it, you can read my first questions on the TwistedConch list here

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Diez B. Roggisch
Daniel Austria wrote: > Hi python - hackers, > > just one question. How can i remove all 0 values in a list? Sure - i > can loop over it, but that s not a neat style. Why not? If you need to potentially look at *all* elements of a list, nothing but a loop will take you there. OTOH, your propose

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Friðrik Már Jónsson
ma wrote: filter(lambda x: x, your_list) Good call! Equivalent but more efficient: filter(None, your_list) Regards, Friðrik Már -- http://mail.python.org/mailman/listinfo/python-list

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread D'Arcy J.M. Cain
On Wed, 8 Jul 2009 10:54:09 -0400 ma wrote: > filter(lambda x: x, your_list) Or... [x for x in your_list if x] I'm not sure which one is more efficient but I like the syntax of the latter. A smart person could probably figure it out even without knowing Python syntax. Clarity is trump. --

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Charles Yeomans
On Jul 8, 2009, at 10:54 AM, ma wrote: filter(lambda x: x, your_list) On Wed, Jul 8, 2009 at 10:44 AM, Daniel Austria wrote: Hi python - hackers, just one question. How can i remove all 0 values in a list? Sure - i can loop over it, but that s not a neat style. list.remove() will only re

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Bruno Desthuilliers
Daniel Austria a écrit : Hi python - hackers, just one question. How can i remove all 0 values in a list? Sure - i can loop over it, but that s not a neat style. list.remove() will only remove the first occurence. Doing that while no exception is raised is also uncool, right? Some suggestions?

Re: Remoting over SSH

2009-07-08 Thread Djames Suhanko
Hello! I wrote a litle program that send commands to many cluster nodes: #!/usr/bin/env python #By: Djames Suhanko #servers list sincroniza =["server1.domain","server2.domain", "server3.domain"] import pexpect import sys from threading import Thread #the user and pass can be in ini file. #Te

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread Paul Boddie
On 8 Jul, 16:04, kj wrote: > >   = > > and not to those like, for example, > >   [] = > > or > >   . = > > The former are syntatic sugar for certain namespace modifications > that leave objects unchanged.  The latter are syntactic sugar for > certain object-modifying method calls that leave na

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread ma
filter(lambda x: x, your_list) On Wed, Jul 8, 2009 at 10:44 AM, Daniel Austria wrote: > Hi python - hackers, > > just one question. How can i remove all 0 values in a list? Sure - i > can loop over it, but that s not a neat style. list.remove() will > only remove the first occurence. Doing that

[0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Daniel Austria
Hi python - hackers, just one question. How can i remove all 0 values in a list? Sure - i can loop over it, but that s not a neat style. list.remove() will only remove the first occurence. Doing that while no exception is raised is also uncool, right? Some suggestions? Best, Dan -- http://mai

Re: Clarity vs. code reuse/generality

2009-07-08 Thread pdpi
On Jul 8, 2:24 am, Paul Rubin wrote: > pdpi writes: > >     while abs(func(guess) - target) > epsilon: > >         guess = (lo + hi) / 2. > >         if sense * func(guess) > sense * target: > >             hi = guess > >         elif sense * func(guess) < sense * ta

The meaning of "=" (Was: tough-to-explain Python)

2009-07-08 Thread kj
In kj writes: >I had not realized how *profoundly* different the meaning of the >"=" in Python's > spam = ham >is from the "=" in its > spam[3] = ham[3] To clarify, this comes from my reading of Fredrik Lundh's pages "Python Objects" (http://effbot.org/zone/python-objects.htm) and "Call B

Re: tough-to-explain Python

2009-07-08 Thread nn
On Jul 7, 5:18 pm, kj wrote: > In Chris Rebert > writes: > > >You might find the following helpful (partially): > >http://effbot.org/zone/call-by-object.htm > > Extremely helpful.  Thanks!  (I learned more from it than someone > who will teach the stuff would care to admit...) > > And it confir

Re: tough-to-explain Python

2009-07-08 Thread Paul Moore
2009/7/8 kj : > There is this > persistent idea "out there" that programming is a very accessible > skill, like cooking or gardening, anyone can do it, and even profit > from it, monetarily or otherwise, etc., and to some extent I am > actively contributing to this perception by teaching this cours

Re: Newbie needs help

2009-07-08 Thread Aahz
In article , Pablo Torres N. wrote: > >Give this one a try too: http://www.mikeash.com/getting_answers.html >It doesn't talk down to you...as much :P Nice! I'll try remembering that one. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "as long as we like the sa

Re: tough-to-explain Python

2009-07-08 Thread kj
In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> Simon Forman writes: >I'm not kidding. I wrote a (draft) article about this: "Computer >Curriculum" http://docs.google.com/View?id=dgwr777r_31g4572gp4 Very cool. kj -- http://mail.python.org/mailman/listinfo/python-list

Re: library search path when compiling python

2009-07-08 Thread nn
On Jul 7, 4:06 pm, Christian Heimes wrote: > nn wrote: > > I am trying to compile python with ssl support but the libraries are > > not in /usr/lib but in /opt/freeware/lib. How do I add that folder to > > the default library search path? > > > It looks like configure --libdir=DIR might do the job

Re: tough-to-explain Python

2009-07-08 Thread Steven D'Aprano
On Wed, 08 Jul 2009 12:23:50 +, kj wrote: > In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> > Simon Forman writes: > >>Frankly, I'm of the impression that it's a mistake not to start teaching >>programming with /the bit/ and work your way up from there. I'm not >>kiddi

Re: Fractions as result from divisions

2009-07-08 Thread Hans Nowak
Ulrich Eckhardt wrote: Bearophile wrote: For example a novice wants to see 124 / 38 to return the 62/19 fraction and not 3 or 3.263157894736842 :-) Python has adopted the latter of the three for operator / and the the second one for operator //. I wonder if it was considered to just return a f

Re: Check file is locked?

2009-07-08 Thread Steven D'Aprano
On Wed, 08 Jul 2009 00:06:11 -0700, Dennis Lee Bieber wrote: > Also, some applications may still have the file open, but Windows > allows one to make copies of that file... Not always though... some applications open files for exclusive read access. -- Steven -- http://mail.python.org

Re: Fractions as result from divisions (was: Re: tough-to-explain Python)

2009-07-08 Thread Steven D'Aprano
On Wed, 08 Jul 2009 11:24:28 +0200, Ulrich Eckhardt wrote: > Bearophile wrote: >> For example a novice wants to see 124 / 38 to return the 62/19 fraction >> and not 3 or 3.263157894736842 :-) > > Python has adopted the latter of the three for operator / and the the > second one for operator //.

Re: DBI module deprecated at Python 2.5--what to use in its place?

2009-07-08 Thread Paul Moore
2009/7/8 dana : > On Jul 8, 12:30 am, John Machin wrote: >> Deprecated certainly doesn't mean removed. >> For a start, none of (DBI, ODBC, dbi, odbc) are standard Python- >> supplied modules. Perhaps you are referring to the odbc (and dbi) from >> the pywin32 package? Where did you get them from?

Re: Remoting over SSH

2009-07-08 Thread Hendrik van Rooyen
"Hussein B" wrote: > Hey, > I want to perform commands on a remote server over SSH. > What do I need? > Thanks. Access privileges for the remote machine. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: tough-to-explain Python

2009-07-08 Thread kj
In <5f0a2722-45eb-468c-b6b2-b7bb80ae5...@q11g2000yqi.googlegroups.com> Simon Forman writes: >Frankly, I'm of the impression that it's a mistake not to start >teaching programming with /the bit/ and work your way up from there. >I'm not kidding. I wrote a (draft) article about this: "Computer >Cu

Re: Remoting over SSH

2009-07-08 Thread Lucas Carvalho
Hussein B wrote: Hey, I want to perform commands on a remote server over SSH. What do I need? Thanks. Hi, If you want to use the SSH2 protocol into a python code, you should take a look at this module: paramiko [1]. [1] http://www.lag.net/paramiko/ Regards, Lucas. -- http://mail.python.org/

Re: Fractions as result from divisions (was: Re: tough-to-explain Python)

2009-07-08 Thread kj
In Ulrich Eckhardt writes: >Bearophile wrote: >> For example a novice wants to see 124 / 38 to return the 62/19 >> fraction and not 3 or 3.263157894736842 :-) >Python has adopted the latter of the three for operator / and the the second >one for operator //. I wonder if it was considered to ju

Re: count

2009-07-08 Thread Bearophile
Vilya Harvey: > from itertools import groupby > for x, g in groupby([fields[1] for fields in data]): >     print x, len(tuple(g)) Avoid that len(tuple(g)), use something like the following, it's lazy and saves some memory. def leniter(iterator): """leniter(iterator): return the length of a g

Re: IP Address Function

2009-07-08 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Tue, 07 Jul 2009 22:54:03 -0300, "Gabriel Genellina" >FA> wrote: >>> En Tue, 07 Jul 2009 22:45:24 -0300, Fred Atkinson >>> escribió: >>> Is there a Python function I can use to get the user's IP address so I can display it on his browser? >>

Re: Catching control-C

2009-07-08 Thread Nick Craig-Wood
Steven D'Aprano wrote: > On Mon, 06 Jul 2009 15:02:26 -0700, Michael Mossey wrote: > > > On Jul 6, 2:47 pm, Philip Semanchuk wrote: > >> On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: > >> > >> > What is required in a python program to make sure it catches a > >> > control- > >> > c on the c

Re: DBI module deprecated at Python 2.5--what to use in its place?

2009-07-08 Thread dana
On Jul 8, 12:30 am, John Machin wrote: > Deprecated certainly doesn't mean removed. > For a start, none of (DBI, ODBC, dbi, odbc) are standard Python- > supplied modules. Perhaps you are referring to the odbc (and dbi) from > the pywin32 package? Where did you get them from? If you can't > remembe

Re: Re: Check file is locked?

2009-07-08 Thread Dave Angel
Rajat wrote: On Jul 8, 4:57 am, Lawrence D'Oliveiro wrote: In message , Christian Heimes wrote: By the way most operating systems don't lock a file when it's opened for reading or writing or even executed. The general conclusion seems to be that mandatory locking is more troub

Re: count

2009-07-08 Thread Tim Chase
I wanted to sort column 2 in assending order and I read whole file in array "data" and did the following: data.sort(key = lambda fields:(fields[2])) I have sorted column 2, however I want to count the numbers in the column 2. i.e. I want to know, for example, how many repeates of say '3' (first

Re: PyQt GUI

2009-07-08 Thread Diez B. Roggisch
Phil Thompson wrote: > On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch" > > wrote: >> Helvin wrote: >> >>> Hi experts! >>> >>> I'm developing a GUI for a software using PyQT, and need 3D >>> visualization. Should I use PyOpenGL or VTK? >>> I understand that the PyQt package comes with a o

Re: Python Error from Apress book

2009-07-08 Thread Dave Angel
Gabriel Genellina wrote: En Tue, 07 Jul 2009 09:55:13 -0300, Dave Angel escribió: Gabriel Genellina wrote: En Mon, 06 Jul 2009 19:56:40 -0300, matt0177 escribió: When I try to run the command as outlined in the book "simple_markup2.py < test_input.txt > test_output.html i get the follo

Fractions as result from divisions (was: Re: tough-to-explain Python)

2009-07-08 Thread Ulrich Eckhardt
Bearophile wrote: > For example a novice wants to see 124 / 38 to return the 62/19 > fraction and not 3 or 3.263157894736842 :-) Python has adopted the latter of the three for operator / and the the second one for operator //. I wonder if it was considered to just return a fraction from that opera

Re: PyQt GUI

2009-07-08 Thread Phil Thompson
On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch" wrote: > Helvin wrote: > >> Hi experts! >> >> I'm developing a GUI for a software using PyQT, and need 3D >> visualization. Should I use PyOpenGL or VTK? >> I understand that the PyQt package comes with a opengl module. What >> else would I

Re: PyQt GUI

2009-07-08 Thread Diez B. Roggisch
Helvin wrote: > Hi experts! > > I'm developing a GUI for a software using PyQT, and need 3D > visualization. Should I use PyOpenGL or VTK? > I understand that the PyQt package comes with a opengl module. What > else would I need? I think I need to download opengl. but how? where? > I have VTK and

Re: count

2009-07-08 Thread Vilya Harvey
2009/7/8 Dhananjay : > I wanted to sort column 2 in assending order  and I read whole file in array > "data" and did the following: > > data.sort(key = lambda fields:(fields[2])) > > I have sorted column 2, however I want to count the numbers in the column 2. > i.e. I want to know, for example, how

  1   2   >