Re: interactive plots

2011-07-06 Thread Steven Howe
On 07/06/2011 09:59 AM, Ian Kelly wrote: On Wed, Jul 6, 2011 at 9:04 AM, Mihai Badoiu wrote: How do I do interactive plots in python? Say I have to plot f(x) and g(x) and I want in the plot to be able to click on f and make it disappear. Any python library that does this? Matplotlib can be i

Re: checking if a list is empty

2011-05-11 Thread Steven Howe
On 05/11/2011 02:47 PM, Steven D'Aprano wrote: On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: One principle of object oriented programming is to bestow the objects with properties reflecting known properties from the domain being modelled. Lists do not have truth values in the

Re: Playing WAV file with Python

2011-03-03 Thread Steven Howe
intriguing. Perhaps you can spool a wav file to a port, attach the analog out to an external amplifier. http://groups.google.com/group/python-on-a-chip?pli=1 Also, perhaps you should be looking atArduino and audio projects. http://www.ladyada.net/make/waveshield/ Good luck, Steven Howe -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking against NULL will be eliminated?

2011-03-02 Thread Steven Howe
Back at NCR, they stressed the axiom '90% of the time is spent fixing 10% of the code'. How true that axiom is. Never more so then when faced with a programming language fix like PEP 4000. Fortunately for me, I never trusted python's complex, or should I say 'overloaded' Boolean usage. If I

Re: Tkinter: Joking?

2011-01-17 Thread Steven Howe
On 01/16/2011 10:46 PM, Octavian Rasnita wrote: From: "Steven D'Aprano" Sent: Monday, January 17, 2011 1:04 AM Subject: Re: Tkinter: The good, the bad, and the ugly! Well, true, but people tend to *use* the parts of the GUIs that are simple and basic. Not only do the big complicated apps g

Re: Is it possible to let a virtual file created by cStringIO have a filename so that functions can read it by its filename?

2011-01-14 Thread Steven Howe
On 01/14/2011 12:51 PM, Chris Rebert wrote: On Fri, Jan 14, 2011 at 7:52 AM, Cun Zhang wrote: Hi,all I hope use cStringIO to create virtual file, but my customed function which is from a shared library imported by ctypes just accepts a filename(string type) as parameter. So I'm wondering wheth

Re: Code review request

2010-12-22 Thread Steven Howe
On 12/22/2010 10:34 AM, Jason Staudenmayer wrote: Hi All, I'm a python newbie so please be kind. I've been reading book after book and have written a script or two but this is my first real "program". Just looking for any suggestions and pointers. I've done some work with bash scripts and php (

Re: Style question for conditional execution

2010-11-24 Thread Steven Howe
Both paradigms are in the bash shell. Using a test switch (like -x for executiable) mixed with an && or ||. Example: [-x /usr/bin/firefox ] || exit I think it's very clear, to old hands, but not so much for a new or intermediate users. It certainly is the 'cleaner' form. Like the C styl

Re: Opposite of split

2010-08-15 Thread Steven Howe
On 08/15/2010 11:35 AM, Gary Herron wrote: On 08/15/2010 11:24 AM, Alex van der Spek wrote: Looking for a method that does the opposite of 'split', i.e. elements in a list are automatically concatenated with a user selectable spacer in between e.g. '\t'. This is to prepare lines to be written

Uses of a deprecated module 'string'

2010-06-22 Thread Steven Howe
;letters', but got: NameError: name 'letters' is not defined Thanks for any help. Steven Howe -- http://mail.python.org/mailman/listinfo/python-list

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-23 Thread Steven Howe
Really! Learn to use google better. I just used "python sort list" Look at: http://wiki.python.org/moin/HowTo/Sorting Read about list.sort. Try, at a command prompt (assuming you have a unix shell), "pydoc list" search for sort; read it. It mentions 'reverse'. then slice the list to your desi

Re: Merge two directories together

2010-04-16 Thread Steven Howe
. The arguments are the same as for the Popen constructor. Example: retcode = call(["ls", "-l"]) ----- Steven Howe On 04/16/2010 06:48 AM, Keith Hughitt wrote: Suppose you have two file-trees with common sub-directories but different files th

Re: How to open and read an unknown extension file

2010-04-08 Thread Steven Howe
On 04/08/2010 08:57 AM, Chris Colbert wrote: On Thu, Apr 8, 2010 at 11:42 AM, Kushal Kumaran wrote: On Thu, Apr 8, 2010 at 9:00 PM, varnikat t wrote: I am trying to do this if os.path.exists("*.*.txt"): file=open("*.*.txt") self.text_view.get_buffer().set_

Re: CPAN for python?

2010-03-30 Thread Steven Howe
This question comes up at least once a month, eliciting a thread that goes on for day. Wouldn't it be wise to put a link on the bottom of the mail list? Something like CPAN for Python == PyPi << make that an href or Python( CPAN ) = PyPi Not too many characters. sph On 03/30/2010 09:23 AM

Re: File existence check with partial filename

2010-03-15 Thread Steven Howe
What wrong with glob? --- Help on module glob: NAME glob - Filename globbing utility. FILE /usr/lib64/python2.6/glob.py FUNCTIONS glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildca

Re: compiler with python

2010-03-06 Thread Steven Howe
Is it possible he's talking about a 'quad core'? as in a CPU? In that case I think he wants to optimize a python program for a multiprocessor core with four processors. sph On 03/06/2010 07:56 AM, Dave Angel wrote: mohamed issolah wrote: 2010/3/6 Dave Angel mohamed issolah wrote: hey,

Re: Python Opportunity at OPNET

2010-03-04 Thread Steven Howe
On 03/04/2010 04:45 PM, Harold Meder wrote: I stumbled across this Job Posting at OPNET. I hope that it is acceptable to post this type of info on this mailing list. I do not know any further information regarding this opportun

Re: Personal criticisms and logical fallacies

2010-02-09 Thread Steven Howe
Really, is this a relevant topic on a program mail list? You guys need to get a room and start discussing angel counts on pinheads under the blankets. sph On 02/09/2010 10:51 PM, D'Arcy J.M. Cain wrote: On Wed, 10 Feb 2010 01:38:50 +0100 "Alf P. Steinbach" wrote: However, although in th

Re: Need help with a program

2010-01-28 Thread Steven Howe
On 01/28/2010 09:49 AM, Jean-Michel Pichavant wrote: evilweasel wrote: I will make my question a little more clearer. I have close to 60,000 lines of the data similar to the one I posted. There are various numbers next to the sequence (this is basically the number of times the sequence has been

Re: how to duplicate array entries

2010-01-11 Thread Steven Howe
try --- #!/usr/bin/env python from types import ListType, IntType def array_expander( ar=None, ex=None ): if type( ex ) != IntType: return [] if ex <= 0: return [] if type( ar ) != ListType: return [] # working code starts he

Re: % sign in python?

2008-07-17 Thread Steven Howe
Terry Reedy wrote: korean_dave wrote: What does this operator do? Specifically in this context test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) (Tried googling and searching, but the "%" gets interpreted as an operation and distorts the search results) Having seen a number

Re: remove all elements in a list with a particular value

2007-05-18 Thread Steven Howe
Steven Howe wrote: > MRAB wrote: >> On May 16, 4:21 pm, Lisa <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]> >> wrote: >> >> I am reading in data from a text file. I want to enter each value on >> the line into a list and retain the order of the ele

Re: alternative to eclipse [ python ide AND cvs ]

2007-05-18 Thread Steven Howe
Stargaming wrote: > yomgui schrieb: > > Hi, > > Eclipse is just not really working on linux 64 bit > (I tried ubuntu and centos, it is freesing and crashing > and extremly slow) > > I use eclipse for python and cvs, what is "the" good alternative ? > > thanks > > yomgui > Fond of Komodo. See

Re: remove all elements in a list with a particular value

2007-05-17 Thread Steven Howe
MRAB wrote: On May 16, 4:21 pm, Lisa <[EMAIL PROTECTED]> wrote: I am reading in data from a text file. I want to enter each value on the line into a list and retain the order of the elements. The number of elements and spacing between them varies, but a typical line looks like: ' SRCPARA

Re: how do I count spaces at the beginning of a string?

2007-05-17 Thread Steven Howe
Paul McGuire wrote: On May 16, 9:02 pm, walterbyrd <[EMAIL PROTECTED]> wrote: The strings start with whitespace, and have a '*' or an alphanumeric character. I need to know how many whitespace characters exist at the beginning of the string. using buitlin function len() and lstrip() a

Re: How do I count the number of spaces at the left end of a string?

2007-05-16 Thread Steven Howe
walterbyrd wrote: > I don't know exactly what the first non-space character is. I know the > first non-space character will be * or an alphanumeric character. > > using builtin function rindex st = 'asblde ' >>> st.rindex(' ') sph -- HEX: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

Re: Python Newbie Suggestions

2007-05-15 Thread Steven Howe
[EMAIL PROTECTED] wrote: > I'm a mechanical engineer with little experience programming. I've > used C++ and machine language for getting micro-controllers to work > and thats about it. I work allot with software developers at my job > and can read C++ code pretty good (ie. I understand whats going

Re: Trying to choose between python and java

2007-05-15 Thread Steven Howe
Anthony Irwin wrote: > Hi All, > > I am currently trying to decide between using python or java and have > a few quick questions about python that you may be able to help with. > > #1 Does python have something like javas .jar packages. A jar file > contains all the program files and you can exec

Re: removing spaces between 2 names

2007-05-14 Thread Steven Howe
[EMAIL PROTECTED] wrote: > Hi, > Suppose i have a string stored in variable,how do i remove the > space between them,like if i have the name: > "USDT request" in a variable.i need "USDTrequest",without any space . > Thanks > > from string import replace st = 'abcd acdfgx

Re: os.listdir() doesn't work ??

2007-05-14 Thread Steven Howe
rnatively you could use glob.glob, after changing directory ( via os.chdir) to get a listing. from os import chdir, getcwd from glob import glob CWD = getcwd() chdir( 'd:/akto_yk/yk_controls') filelist = glob.glob('*.txt') chdir( CWD ) Steven Howe -- HEX

Re: Using "subprocess" without lists. . .?

2007-05-13 Thread Steven Howe
Michael Williams wrote: Hi All, I've recently seen the "subprocess" module and am rather confused by it's requirements. Is it not possible to execute an entire string without having to break them up into a list of arguments? For instance, I'd much rather do the following: subprocess.c

Re: SEO - Search Engine Optimization - Seo Consulting

2007-05-08 Thread Steven Howe
Steve Holden wrote: Steven D'Aprano wrote: On Wed, 02 May 2007 19:47:28 -0700, Huck Phin wrote: [a request for peace, love and understanding, concluding with] We all should be a little more considerate of each other. And if the hippy hug fest fails to stop spamming, perhaps

Re: File names and file objects [was Re: My Python annoyances]

2007-05-05 Thread Steven Howe
Steven D'Aprano wrote: On Fri, 04 May 2007 07:55:25 -0700, Alex Martelli wrote: What about the case where I have an array of objects that represent some particular binary file format. If the object is a file, then I want to copy its contents. If the object is a string, th

Re: Microsoft's Dynamic Languages Runtime (DLR)

2007-05-04 Thread Steven Howe
Fuzzyman wrote: > On May 4, 5:27 pm, Kaz Kylheku <[EMAIL PROTECTED]> wrote: > >> On May 2, 5:19 pm, sturlamolden <[EMAIL PROTECTED]> wrote: >> >> >>> On May 3, 2:15 am, Kaz Kylheku <[EMAIL PROTECTED]> wrote: >>> Kindly refrain from creating any more off-topic, cross-posted threa

Re: How to replace the last (and only last) character in a string?

2007-05-03 Thread Steven Howe
Dave Borne wrote: Let's suppose s='12345 4343 454' How can I replace the last '4' character? If the last '4' will not always be the last character in the string, you could do: 'X'.join(s.rsplit('4',1)) from string import rfind def replaceLast_X_with_Y( s, x, y ): lastX =

Re: How can I save command prompt screen

2007-04-27 Thread Steven Howe
ozan SARI wrote: Hi , I run a python acript with os.system('script.py') I want save command prompt screen in a text file (everything ) how can I do this? Thanks for your help Ozan check out using the subprocess module http://docs.python.org/lib/node529.html It s

Re: getting rid of EOL character ?

2007-04-27 Thread Steven Howe
stef wrote: hello, In the previous language I used, when reading a line by readline, the EOL character was removed. Now I'm reading a text-file with CR+LF at the end of each line, Datafile = open(filename,'r') line = Datafile.readline() now this gives an extra empty line print li

Re: My python annoyances so far

2007-04-26 Thread Steven Howe
[EMAIL PROTECTED] wrote: >> Well, why do some things in the library have to be functions, and >> other things have to be class methods? >> Perhaps because some things are more naturally function like? For 'instance' (pardon the pun), functions shouldn't retain data. They perform an operation

Re: Python not giving free memory back to the os get's me in real problems ...

2007-04-25 Thread Steven Howe
Grant Edwards wrote: > On 2007-04-25, Chris Mellon <[EMAIL PROTECTED]> wrote: > > >> "Returning memory to the OS" doesn't affect exhaustion of your virtual >> address space. More likely, your nested loops are just creating more >> objects than is possible to hold within a single process. >>

Re: popen2 results

2007-04-25 Thread Steven Howe
Robert Rawlins - Think Blue wrote: Hello guys, I've recently ported my application from bash to python, however there are still a few bash line utilities I -have- to use in the application as there isn't any alternative available to me. In the old days of bash I would have grep'd the output

Re: RPM error

2007-04-24 Thread Steven Howe
CSUIDL PROGRAMMEr wrote: > Hi folks > I am new to python > I am trying to write a program that will install rpm > using rpm -ivh xxx.rpm > > I want to know if python has in-built exceptions to catch no- > dependencies error. > > If not how can i build them > > thanks > > not really sure where y

Re: Catching a specific IO error

2007-04-24 Thread Steven Howe
Steve Holden wrote: > Thomas Krüger wrote: > >> Tina I schrieb: >> >>> Now, this works but of course it catches every IOError, and I can not >>> figure out how to restrict it to only catch the "[Errno 2]"? >>> >> There's an example that uses the error number: >> http://docs.python.or

Re: If Dict Contains a particular key

2007-04-24 Thread Steven Howe
Carsten Haese wrote: > On Tue, 2007-04-24 at 18:28 +0100, Robert Rawlins - Think Blue wrote: > >> Hello Guys, >> >> >> >> I’m Looking to build a quick if/else statement that checks a >> dictionary for a key like follows. >> >> >> >> If myDict contains ThisKey: >> >> Do this..

Re: comparison with None

2007-04-19 Thread Steven Howe
n it would be best to test the type of return object before using it. Then you program could handle the error gracefully (*wink* *wink* *wink*). As much as I love Python, it's ability to morph an object type can be a pain. Testing before using can prevent a program from Error-

Re: Byte-Array to String

2007-04-19 Thread Steven Howe
array element handling is probably a better, less error prone, method of attack. Not have the contents and defination of your dbus.array handy, I can't test this, but the approach seems reasonable. Steven Howe -- http://mail.python.org/mailman/listinfo/python-list

Re: comparison with None

2007-04-18 Thread Steven Howe
Alan Isaac wrote: "Terry Reedy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Should be in the reference manual section on comparisons. Only to this extent: http://www.python.org/doc/2.4/ref/comparisons.html objects of different types always compare unequal, and

Re: comparison with None

2007-04-18 Thread Steven Howe
rt NoneType x = None if type( x ) == NoneType: # true < code > else: # false; do something else. < more code > Steven Howe -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: import

2007-04-18 Thread Steven Howe
[EMAIL PROTECTED] wrote: I thought import used relative paths from either the python executable or the script being executed. I have a script pulling in code from an arbitrary directory. How is this happening? It's a RHEL 4 environment by the way. I couldn't find any relevant environment vari

Re: how to strip the domain name in python?

2007-04-15 Thread Steven Howe
[EMAIL PROTECTED] wrote: On Apr 14, 10:36 am, [EMAIL PROTECTED] wrote: On Apr 14, 12:02 am, Michael Bentley <[EMAIL PROTECTED]> wrote: On Apr 13, 2007, at 11:49 PM, [EMAIL PROTECTED] wrote: Hi,

Re: Why NOT only one class per file?

2007-04-05 Thread Steven Howe
Now we're at the '_/How many Angels can dance on the head of a pin/_' question (like anything with wings would waste time dancing. Ever seen eagles mate (not the football players)? Dance it's not, but it looks like /sex on a roller coaster only better/! Get me a pair of wings!). Religious war

Re: Can we make a local variable in a function as global variable???

2007-04-05 Thread Steven Howe
sairam wrote: I have some local variables defined in one method and Can I make those variables as global variables? If so , can any one explain me how can I do that Thanks, Sairam See: http://www.faqs.org/docs/diveintopython/dialect_locals.html When a line of code asks for the value of a

Re: Why NOT only one class per file?

2007-04-05 Thread Steven Howe
Dennis Lee Bieber wrote: > On 4 Apr 2007 14:23:19 -0700, "Chris Lasher" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > >> A friend of mine with a programming background in Java and Perl places >> each class in its own separate file in . I informed him that keeping >> all

Re: how can I clear a dictionary in python

2007-04-04 Thread Steven Howe
Tempest in a teapot guys. Aahz wrote: > In article <[EMAIL PROTECTED]>, > Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> On 2007-04-03, Aahz <[EMAIL PROTECTED]> wrote: >> >>> In article <[EMAIL PROTECTED]>, >>> Larry Bates <[EMAIL PROTECTED]> wrote: >>> Aahz wrote:

Re: How can i compare a string which is non null and empty

2007-04-02 Thread Steven Howe
how about just testing it's length? >>> from types import StringType def stringTest(x): ... if type(x) == StringType: ... if len(x) == 0: ... print 'Empty String' ... else: ... print 'Not Empty String' ... else: ...