Re: explode()

2009-07-14 Thread alex23
Fred Atkinson wrote: >         I wish the Python site was as well written as the PHP site. On > the PHP site, I can look up a command and they show not only the docs > on that command but a list of all other commands associated with it.   Hey Fred, My problem is the complete opposite, I wish I c

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Ben Finney
Steven D'Aprano writes: > Isn't that risky though? Won't that potentially change the exception- > handling behaviour of functions and classes he imports from other > modules? No, any existing ‘except’ clause will be unaffected by re-binding ‘sys.excepthook’. As I understand the documentation, th

Re: copy a file

2009-07-14 Thread Krishnakant
On Tue, 2009-07-14 at 12:27 +0530, amr...@iisermohali.ac.in wrote: > Dear all, > > Can anyone tell me that suppose i want to copy few lines from one text > file to another then how can i do that.Looking forward for soon reply. > very simple. open one file and open the source file. seek till to

Remote audio recording in a multiuser environment

2009-07-14 Thread nelson -
Hi all! I'm developing an application that will be used in a school. It will allow client connected over ssh to liste to a multimedia file on the server. The server componente will record the audio taken from a specified client microphone, or it would pair two client, allowing them to communicat

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Carl Banks
On Jul 13, 8:25 pm, Steven D'Aprano wrote: > On Mon, 13 Jul 2009 17:49:23 -0700, Carl Banks wrote: > > On Jul 13, 12:31 pm, Piet van Oostrum wrote: > >> > seldan24 (s) wrote: > >> >s> Hello, > >> >s> I'm fairly new at Python so hopefully this question won't be too s> > >> >awful.  I am writi

RE: list of all possible values

2009-07-14 Thread Andreas Tawn
> David Gibb: > > For example: if my values are ['a', 'b', 'c'], then all possible lists > > of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc. > > >>> from itertools import product > >>> list(product("abc", repeat=2)) > [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', > '

How to unbuffer Python's output

2009-07-14 Thread Lily Gao
Hi, All I am calling a python program in perl and use redirection, Like : `python x.py > 1.log 2>&1` When x.py crash, I get nothing from 1.log, and if I don’t use redirection, I can get useful log from the screen. How can I do to make x.py ‘s output un-buffered when redirection log to files ,jus

Re: MySQLdb + SSH Tunnel

2009-07-14 Thread R C
Got it working. Thanks for your help 1) login to B 2) setup a tunnel in the shell machine-B> ssh -L B_ip_address:B_port:C_ip_address:C_port u...@c_ip_address for example: machine-B has ip 1.1.1.1 machine-C has ip 2.2.2.2 then I would type: machine-B> ssh -L 1.1.1.1:3307:2.2

Re: MySQLdb + SSH Tunnel

2009-07-14 Thread Riley Crane
Got it working. Thanks for your help! 1) login to B 2) setup a tunnel in the shell machine-B> ssh -L B_ip_address:B_port:C_ip_address:C_port u...@c_ip_address for example: machine-B has ip 1.1.1.1 machine-C has ip 2.2.2.2 then I would type: machine-B> ssh -L 1.1.1.1:3307:2.

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Steven D'Aprano
On Tue, 14 Jul 2009 01:30:48 -0700, Carl Banks wrote: > Seriously, do you *ever* take more than 2 seconds to consider whether > you might be missing something obvious before following up with these > indignant knee-jerk responses? Obviously not. [...] > Or would you rather let all unexpected ex

Re: Passing python list from C to python

2009-07-14 Thread hartley
> > I'm very new at wrapping Python/C, and I have run into some problems. > > > I have one python module that provides me with a list (provideBuffer > > in provideBuff.py): > > >  Py_Initialize(); > >         pName = PyString_FromString("provideBuff"); > >         pModule = PyImport_Import(pName);

Re: How to unbuffer Python's output

2009-07-14 Thread Chris Rebert
2009/7/13 Lily Gao : > Hi, All > > I am calling a python program in perl and use redirection, > > Like : > > `python x.py > 1.log 2>&1` > > When x.py crash, I get nothing from 1.log, and if I don’t use redirection, I > can get useful log from the screen. > > How can I do to make x.py ‘s  output un-

'unable to execute cc: No such file or directory' with distutils on Solaris

2009-07-14 Thread Tim Edwards
Hi, I'm trying to compile http://sourceforge.net/projects/astlib/ 0.17.1 on a Solaris 10 SPARC system. This python module uses distutils.ccompiler. The problem seems to be that although I have gcc installed in /usr/sfw/bin/gcc it keeps trying to execute the command 'cc', which doesn't work: cc -c

copy a few lines

2009-07-14 Thread amrita
Dear all, I want to know if i want to copy one paragraph from one text file to another then what command i have to use in python.Looking forwaard for soon reply. Thanks, Amrita Kumari Research Fellow IISER Mohali Chandigarh INDIA -- http://mail.python.org/mailman/listinfo/python-list

Re: copy a few lines

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 2:43 AM, wrote: > > > Dear all, > > I want to know if i want to copy one paragraph from one text file to > another then what command i have to use in python.Looking forwaard for > soon reply. Please don't double-post. It wastes everyone's time, especially when (a) your pre

Re: renice

2009-07-14 Thread JonPeirce
Note that with os.nice you can only *decrease* priority. For increasing priority you need to run; os.system("sudo renice -n %s %s" % (new_nice, os.getpid())) or simply set the nice level when you run python in the first place (you do also need sudo for this): sudo nice -n -15 python myScript.py

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Florian Brucker
Douglas Alan wrote: > Thank you. My question wasn't intended to be Python specific, though. > I am just curious for purely academic reasons about whether there is > such an algorithm. All the sources I've skimmed only seem to the > answer the question via omission. Which is kind of strange, since i

Re: Passing python list from C to python

2009-07-14 Thread hartley
On Jul 13, 6:35 pm, John Machin wrote: > On Jul 14, 1:47 am, hartley wrote: > > > > > I'm very new at wrapping Python/C, and I have run into some problems. > > > I have one python module that provides me with a list (provideBuffer > > in provideBuff.py): > > >  Py_Initialize(); > >         pName

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

2009-07-14 Thread dana
On Jul 10, 12:15 pm, "M.-A. Lemburg" wrote: > If you're looking for a stable and maintained ODBC for Python, > have a look at our mxODBC extension or mxODBC Connect package: > http://www.egenix.com/products/python/mxODBC/http://www.egenix.com/products/python/mxODBCConnect/ I'm looking for a free

Re: Tkinter / Entry widget problem

2009-07-14 Thread Peter Otten
Andras Szabo wrote: > Hello. I searched the archives but couldn't find a solution to a > problem related to the Entry widget in Tkinter. > > When creating a pop-up window in an app, which contains an Entry > widget, I want this widget to contain some default string, to have all > this default str

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Lawrence D'Oliveiro
In message <93f6a517-63d8-4c80- bf19-4614b7099...@m7g2000prd.googlegroups.com>, Carl Banks wrote: > Or would you rather let all unexpected exceptions print to standard > error, which is often a black hole in non-interactive sitations? Since when? Cron, for example, collects standard error and ma

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Lawrence D'Oliveiro
In message , seldan24 wrote: > For this particular script, all exceptions are fatal > and I would want them to be. I just wanted a way to catch them and > log them prior to program termination. You don't need to. They will be written to standard error anyway. -- http://mail.python.org/mailman/

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

2009-07-14 Thread Lawrence D'Oliveiro
In message , Steven D'Aprano wrote: > Are we supposed to interpret that post as Dumb Insolence or just Dumb? "Insolence" indeed ... another wanker to plonk, I think. -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Piet van Oostrum
> Douglas Alan (DA) wrote: >DA> On Jul 13, 3:57 pm, a...@pythoncraft.com (Aahz) wrote: >>> Still, unless your list is large (more than thousands of elements), >>> that's the way you should go.  See the bisect module.  Thing is, the >>> speed difference between C and Python means the constant

Re: Passing python list from C to python

2009-07-14 Thread John Machin
On Jul 14, 7:22 pm, hartley wrote: > > > I'm very new at wrapping Python/C, and I have run into some problems. [snip] > > >         pValue = PyObject_CallObject(pFunc,NULL); > > > > pValue is now a PyList - i've even verified this with: > > > > int a = PyList_Check(pValue); > > >         printf("

Python code for testing well parenthesized expression

2009-07-14 Thread candide
Hi, I'm trying to implement in Python a function testing if an expression is well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik" is correctly parenthesized but this one "zx(4er(1(er(Yy)ol)ol)ik" is not. My code follows at the end. If you have a better algorithm or a better P

Re: explode()

2009-07-14 Thread Fred Atkinson
On Tue, 14 Jul 2009 05:41:40 GMT, Tim Harig wrote: >On 2009-07-14, Fred Atkinson wrote: >> The one thing I really dislike about Python over PHP is that >> Python can usually only appear in the cgi directory (unless other >> arragements are made with your hosting provider or if you reconfigu

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Jeremy Sanders
candide wrote: > I'm trying to implement in Python a function testing if an expression is > well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik" > is correctly parenthesized but this one "zx(4er(1(er(Yy)ol)ol)ik" is not. > > My code follows at the end. > > If you have a bette

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Adrian Dziubek
Strings are immutable, so your method of slicing one letter at time will be building lots of them. That shouldn't hurt you here, but it will when you hit a bigger problem. In the i() there should be "return op == 0" on the end. def well(expr): mapping = {'(':1, ')':-1} count = 0 for s in exp

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Diez B. Roggisch
Jeremy Sanders wrote: > candide wrote: > >> I'm trying to implement in Python a function testing if an expression is >> well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik" >> is correctly parenthesized but this one "zx(4er(1(er(Yy)ol)ol)ik" is not. >> >> My code follows at t

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Adrian Dziubek
> Don't you want to just test that the number of "("s equals the number of > ")"s or am I missing the point? I had this idea too, but there is additional requirement that any beginning must have greater or equal number of '(' than ')'. -- Adrian -- http://mail.python.org/mailman/listinfo/python-li

Re: explode()

2009-07-14 Thread Fred Atkinson
On Mon, 13 Jul 2009 23:54:11 -0700 (PDT), alex23 wrote: >Fred Atkinson wrote: >>         I wish the Python site was as well written as the PHP site. On >> the PHP site, I can look up a command and they show not only the docs >> on that command but a list of all other commands associated with it.

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Martin P. Hellwig
candide wrote: To add to your implementations; a readable version: +++file parantheses.py+++ """Parentheses Module Test""" def parentheses_are_paired(input_string): "Check if 'input_string' contains paired parentheses, if so return True." parenthesis_count = 0 parenthesis_open = '(

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Jeremy Sanders
Diez B. Roggisch wrote: > Yep, you are: > > "((((" > > is certainly not "well parenthized". Thanks for that! -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code for testing well parenthesized expression

2009-07-14 Thread David Smith
Jeremy Sanders wrote: > candide wrote: > >> I'm trying to implement in Python a function testing if an expression is >> well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik" >> is correctly parenthesized but this one "zx(4er(1(er(Yy)ol)ol)ik" is not. >> >> My code follows at the

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Scott David Daniels
Piet van Oostrum wrote: Douglas Alan (DA) wrote: DA> On Jul 13, 3:57 pm, a...@pythoncraft.com (Aahz) wrote: Still, unless your list is large (more than thousands of elements), that's the way you should go. See the bisect module. Thing is, the speed difference between C and Python means the

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Martin P. Hellwig
Martin P. Hellwig wrote: candide wrote: To add to your implementations; a readable version: +++file parantheses.py+++ """Parentheses Module Test""" def parentheses_are_paired(input_string): "Check if 'input_string' contains paired parentheses, if so return True." parenthesis_count = 0

Re: Python code for testing well parenthesized expression

2009-07-14 Thread John Machin
candide free.invalid> writes: > # The obvious iterative version > def i(s): > op = 0 # op : open parenthesis > for k in range(len(s)): > op += (s[k] == '(') - (s[k] == ')') > if op < 0: break > return op > E: H c, w t P. F: A c, b à P. Suggested better code: def it

Re: Python code for testing well parenthesized expression

2009-07-14 Thread John Machin
On Jul 14, 11:08 pm, David Smith wrote: > Jeremy Sanders wrote: > > candide wrote: > > >> I'm trying to implement in Python a function testing if an expression is > >> well parenthesized. For instance the expression "zx4er(1(er(Yy)ol)ol)ik" > >> is correctly parenthesized but this one "zx(4er(1(er

WHIFF 0.4 += repoze.who authentication + menus + calculator + docs.

2009-07-14 Thread Aaron Watters
WHIFF (WSGI HTTP Integrated Filesystem Frames) 0.4 released. The new WHIFF 0.4 release linked from http://whiff.sourceforge.net includes the following enhancements: Built in support for repoze.who based authentication (from http://static.repoze.org/whodocs/ ) + tutorial see: http://aaron

Re: Python code for testing well parenthesized expression

2009-07-14 Thread John Machin
Adrian Dziubek gmail.com> writes: > In the i() there should be "return > op == 0" on the end. Hard to tell. In the absence of any docs, we have to resort to divination on the function name :-P ... is "i" short for "iterative" or "imbalanced"? -- http://mail.python.org/mailman/listinfo/pytho

Re: PDF: finding a blank image

2009-07-14 Thread DrLeif
On Jul 13, 6:22 pm, Scott David Daniels wrote: > DrLeif wrote: > > I have about 6000 PDF files which have been produced using a scanner > > with more being produced each day.  The PDF files contain old paper > > records which have been taking up space.   The scanner is set to > > detect when there

Re: Infinite loops and synchronization

2009-07-14 Thread Aahz
In article , Vincent Gulinao wrote: > >lst = list() > >while True: > if len(lst) == SOME_NUMBER: > return lst > >Q2: operating on list from threads (mostly appends) must be safe, >right (synchronization)? What do you mean by "safe"? Python certainly won't crash, but there's

Re: compilation problem of python on AIX 6.1

2009-07-14 Thread Aahz
In article <51c556a8-7277-474d-821f-190adf155...@f16g2000vbf.googlegroups.com>, Amit wrote: > >THen I decided to compile python 2.5.4 on my AIX box. I downloaded the >python source code from www.python.org and tried to compile on my AIX >both using gcc. > > case $MAKEFLAGS in *-s*) CC='gc

one-time factory in python for an experienced java guy

2009-07-14 Thread phonky
Hi I have searched all over and haven't found the solution for my problem yet. I am new to python, and all the time realize I do program python in java, which is not great. Besides being a real-life problem, I want to solve it as elegant as I can, using it to also learn about python (I know I co

Re: PDF: finding a blank image

2009-07-14 Thread DrLeif
On Jul 13, 6:22 pm, Scott David Daniels wrote: > DrLeif wrote: > > I have about 6000 PDF files which have been produced using a scanner > > with more being produced each day.  The PDF files contain old paper > > records which have been taking up space.   The scanner is set to > > detect when there

Re: Tkinter / Entry widget problem

2009-07-14 Thread John Posner
Andras Szabo wrote: Hello. I searched the archives but couldn't find a solution to a problem related to the Entry widget in Tkinter. When creating a pop-up window in an app, which contains an Entry widget, I want this widget to contain some default string, to have all this default string s

Re: explode()

2009-07-14 Thread Piet van Oostrum
> Fred Atkinson (FA) wrote: >FA> On Tue, 14 Jul 2009 05:41:40 GMT, Tim Harig >FA> wrote: >>> On 2009-07-14, Fred Atkinson wrote: The one thing I really dislike about Python over PHP is that Python can usually only appear in the cgi directory (unless other arragements are mad

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Stefan Behnel
phonky wrote: > class Account(object): > def __init__(self, holder): > self.__accountnumber = self.__generate_account_number() > > Now, I do not know yet how the account number scheme looks like. > For now, I just want to have an incremental number; later, > when going to productio

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Paul Rubin
Stefan Behnel writes: > phonky wrote: > > class Account(object): > > def __init__(self, holder): > > self.__accountnumber = self.__generate_account_number() > > > > Now, I do not know yet how the account number scheme looks like. > > For now, I just want to have an incremental nu

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread phonky
Stefan, thanks first of all Use a global variable in the module. I have an account_number_generator variable in the module, I got that hint from searching the web. But where my stubborn java mind doesn't release me: what does the variable contain? Do I create the actual IncrementalGenerator o

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Paul Rubin
phonky writes: > But where my stubborn java mind doesn't release me: what does the > variable contain? Do I create the actual IncrementalGenerator object > there? Or the super class? Or just a string, which a factory method > takes to create the actual object? Ugh, just forget everything you eve

Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Xavier Ho
Why doesn't the second output print [1, 2, 3, , 7, 8, 9] ? The code is run at: http://codepad.org/wgLU4JZh class A(): def __init__(self): self.n = [1, 2, 3, 4, 5] a = A() print a.n print a.n.extend([6, 7, 8, 9]) #Output: #[1, 2, 3, 4, 5] #None I really don't know, but I'm proba

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread phonky
Thanks Paul, Ugh, just forget everything you ever knew about java. Do some Zen exercises to erase your mind. Then read a Python tutorial as if you're starting from nothing. Yeah, surely right, but easier said than done... I'm working on it. Taking your example. import itertools class

Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Pablo Torres N.
This has been asked extensively before, here and elsewhere. On Tue, Jul 14, 2009 at 09:52, Xavier Ho wrote: > Why doesn't the second output print [1, 2, 3, , 7, 8, 9] ? > The code is run at: http://codepad.org/wgLU4JZh > > class A(): >     def __init__(self): >     self.n = [1, 2, 3, 4, 5

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Mahmoud Abdelkader
What Paul was trying to elaborate on is that have your customers or whomever will use this implement their own generator protocol to generate whatever number format they need. Paul just gave you an example with itertools.count(), where it is an infinite generator that yields count+1 every time. Re

Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread MRAB
Xavier Ho wrote: Why doesn't the second output print [1, 2, 3, , 7, 8, 9] ? The code is run at: http://codepad.org/wgLU4JZh class A(): def __init__(self): self.n = [1, 2, 3, 4, 5] a = A() print a.n print a.n.extend([6, 7, 8, 9]) #Output: #[1, 2, 3, 4, 5] #None I reall

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Paul Rubin
phonky writes: > "itertools.count(): Make an iterator that returns consecutive integers > starting with n" > > to me that sounds like that solves the increment issue, but what about > future modules wanting to plug in a different > numbering format, e.g. 205434.1234 or whatever? You'd write a di

Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Jochen Schulz
Xavier Ho: > > Why doesn't the second output print [1, 2, 3, , 7, 8, 9] ? -- snip > print a.n.extend([6, 7, 8, 9]) extend doesn't fail. It just returns None and extends the list in place. In [1]: l = [1, 2, 3] In [2]: l.extend([4, 5, 6]) In [3]: l Out[3]: [1, 2, 3, 4, 5, 6] J. -- When I

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Peter Otten
phonky wrote: > Thanks Paul, > >> Ugh, just forget everything you ever knew about java. Do some Zen >> exercises to erase your mind. Then read a Python tutorial as if >> you're starting from nothing. > > Yeah, surely right, but easier said than done... > I'm working on it. > > Taking your exa

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Aahz
In article <23406$4a5c9c7d$d9a2f023$27...@news.hispeed.ch>, phonky wrote: > >import itertools > > class Account(object): >def __init__(self, holder, gen=itertools.count()): > self.__accountnumber = gen.next() > >If you consider my python illiteracy, > >"itertools.count(): Ma

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread pdpi
On Jul 14, 3:03 pm, phonky wrote: > Hi > > I have searched all over and haven't found the solution > for my problem yet. I am new to python, and all the time realize I > do program python in java, which is not great. > > Besides being a real-life problem, I want to > solve it as elegant as I can,

Re: Proposal: Decimal literals in Python.

2009-07-14 Thread Scott David Daniels
Tim Roberts wrote: My favorite notation for this comes from Ada, which allows arbitrary bases from 2 to 16, and allows for underscores within numeric literals: x23_bin : constant := 2#0001_0111#; x23_oct : constant := 8#27#; x23_dec : constant := 10#23#; x23_hex : constant := 16#17#;

Re: Why does extend() fail in this case, and what am I doing wrong?

2009-07-14 Thread Xavier Ho
I see. Thanks! Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ On Tue, Jul 14, 2009 at 11:20 PM, Jochen Schulz wrote: > Xavier Ho: > > > > Why doesn't the second output print [1,

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Carl Banks
On Jul 14, 2:14 am, Steven D'Aprano wrote: > On Tue, 14 Jul 2009 01:30:48 -0700, Carl Banks wrote: > > Seriously, do you *ever* take more than 2 seconds to consider whether > > you might be missing something obvious before following up with these > > indignant knee-jerk responses? > > Obviously no

Re: Proposal: Decimal literals in Python.

2009-07-14 Thread MRAB
Scott David Daniels wrote: Tim Roberts wrote: My favorite notation for this comes from Ada, which allows arbitrary bases from 2 to 16, and allows for underscores within numeric literals: x23_bin : constant := 2#0001_0111#; x23_oct : constant := 8#27#; x23_dec : constant := 10#23#; x2

why did you choose the programming language(s)you currently use?

2009-07-14 Thread Deep_Feelings
So you have chosen programming language "x" so shall you tell us why you did so , and what negatives or positives it has ? -- http://mail.python.org/mailman/listinfo/python-list

Re: The meaning of "="

2009-07-14 Thread Aahz
In article , Piet van Oostrum wrote: >> Lawrence D'Oliveiro (LD) wrote: > >>LD> In message , Aahz wrote: > >>Aahz> class AttrDict: >>Aahz> def __getitem__(self, key): >>Aahz> return getattr(self, key) > >>LD> OK, let's try it: > >>LD> >>> c = {} >>LD> >>> c["x"] = 3 >>LD> >>> c.x

how to determine if python is run interactively? (-i)

2009-07-14 Thread jfrancis4970
how do you determine, from within a python program, whether the python interpreter was launched in interactive mode? in other words, if i have a program called "test.py", i want to ensure that the program was launched with this command line: python -i test.py (and not just with "python test.py").

Re: Tkinter / Entry widget problem

2009-07-14 Thread Andras Szabo
So it's either that I use Python 2.5.1, or that I use it on a Mac. (John, your code still doesn't work the way it's supposed to here.) I guess I'll upgrade to 2.6.1 and see if it makes a difference. (The Tkinter/Tcl versions are the same for me.) Thanks for your help. andras On Jul 14, 200

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Carl Banks
On Jul 14, 4:48 am, Lawrence D'Oliveiro wrote: > In message <93f6a517-63d8-4c80- > > bf19-4614b7099...@m7g2000prd.googlegroups.com>, Carl Banks wrote: > > Or would you rather let all unexpected exceptions print to standard > > error, which is often a black hole in non-interactive sitations? > > Si

Re: why did you choose the programming language(s)you currently use?

2009-07-14 Thread MRAB
Deep_Feelings wrote: So you have chosen programming language "x" so shall you tell us why you did so , and what negatives or positives it has ? I've heard of "C" and "D", but not "x", unless you mean XPL (X Programming Language) or PLAN-X. :-) -- http://mail.python.org/mailman/listinfo/python-

Re: how to set timeout while colling a soap method?

2009-07-14 Thread ryles
On Jul 13, 9:07 am, dzizes wrote: > Hello! > > I wrote some some python code for executing a soap method: > > import SOAPpy > from SOAPpy import WSDL > > _server = WSDL.Proxy(some wsdl) > r=_server.generuj(some parameters...) > print r.encode('cp1250') > > It works fine. However, the execution tim

Re: how to determine if python is run interactively? (-i)

2009-07-14 Thread Duncan Booth
jfrancis4...@mailinator.com wrote: > how do you determine, from within a python program, whether the python > interpreter was launched in interactive mode? sys.flags.interactive or sys.flags.inspect -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code for testing well parenthesized expression

2009-07-14 Thread Duncan Booth
John Machin wrote: > Try an iterative version of checking that () [] and {} > are balanced and nested appropriately. Here's how I might approach the more general case: def balanced(s, parens=("()",)): ''' Example: >>> balanced('aAAA(b[bb(c]c))') True >>> balanced('aAAA(b[bb(

select lines in python

2009-07-14 Thread amrita
Dear all, Can anyone tell me that suppose i have a file having content like: _Atom_name _Atom_type _Chem_shift_value _Chem_shift_value_error _Chem_shift_ambiguity_code 1 1 PHE H H 8.49 0.02 1 2 1 PHE HAH 4.60

Re: select lines in python

2009-07-14 Thread David Gibb
try something like: for line in open("filename").readlines(): if (re.search("PHE|ASP",line): print line On Tue, Jul 14, 2009 at 1:33 PM, wrote: > Dear all, > > Can anyone tell me that suppose i have a file having content like: > >    _Atom_name >      _Atom_type >      _Chem_shift_va

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread phonky
Thanks for all replies. I need to practice much more pythonese In fact I don't think to understand all of your suggestions, so I'll need to go through them and decide what approach I am going to take. Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

Re: why did you choose the programming language(s)you currently use?

2009-07-14 Thread Mensanator
On Jul 14, 10:55 am, Deep_Feelings wrote: > So you have chosen programming language "x" so shall you tell us why > you did so , and  what negatives or positives it has ? language must have - unlimited precision integers - easy to program - IDE not required - reasonable speed - math library needs

ImportError: No module named _functools

2009-07-14 Thread Tony Lay
I'm sooo close to getting this meld program runninghad to install a lot of things in /usr/local to get to pygtk2 functional and I'm trying to run the meld program and get... RHEL4 server Traceback (most recent call last): File "/usr/local/bin/meld", line 35, in import gettext File "

Re: Why not enforce four space indentations in version 3.x?

2009-07-14 Thread John Nagle
walterbyrd wrote: I believe Guido himself has said that all indentions should be four spaces - no tabs. Since backward compatibility is being thrown away anyway, why not enforce the four space rule? At least that way, when I get python code from somebody else, I would know what I am looking at,

How to keep a function as a generator function when the yield operator is moved into its sub-functions??

2009-07-14 Thread weafon
Hi guys, I have a question about the usage of yield. As shown in the below example, in general, if there is a code segment commonly used by two or more functions, we may isolate the segment into a function and then call it from other functions if necessary. def func1(): while(cond

Re: select lines in python

2009-07-14 Thread Rhodri James
On Tue, 14 Jul 2009 18:48:06 +0100, David Gibb wrote: [Something top-posted, which I've shuffled down] On Tue, Jul 14, 2009 at 1:33 PM, wrote: Dear all, Can anyone tell me that suppose i have a file having content like:    _Atom_name      _Atom_type      _Chem_shift_value      _Chem_shift_

Re: How to keep a function as a generator function when the yield operator is moved into its sub-functions??

2009-07-14 Thread Miles Kaufmann
On Jul 14, 2009, at 2:03 PM, weafon wrote: Hi guys, I have a question about the usage of yield. As shown in the below example, in general, if there is a code segment commonly used by two or more functions, we may isolate the segment into a function and then call it from other functions if

missing 'xor' Boolean operator

2009-07-14 Thread Dr. Phillip M. Feldman
Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor' operator as well. -- View this message in context: http://www.nabble.com/missing-%27xor%27-Boolean-operator-tp24485116p24485116.html Sent from the Python - python-list mailing list archive at Nabble.com. --

Re: why did you choose the programming language(s)you currently use?

2009-07-14 Thread Stefan Behnel
Deep_Feelings wrote: > So you have chosen programming language "x" so shall you tell us why > you did so , and what negatives or positives it has ? Java, pays a living. *duck* Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-14 Thread Mark Dickinson
On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" wrote: > Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to > have an 'xor' operator as well. Hmm. I don't think 'nice' is sufficient. You'd need to make the case that it's sufficiently useful to justify adding a new keyword '

Re: select lines in python

2009-07-14 Thread amrita
Can i become more precise like instead of printing all lines for PHE and ASP is it possible that for PHE python will print only those lines which will have information about H and HA and for ASP it will print those lines which will have information about HA and HB. Thanks > On Tue, 14 Jul 2009 1

Re: select lines in python

2009-07-14 Thread Grant Edwards
On 2009-07-14, amr...@iisermohali.ac.in wrote: > Can i become more precise like instead of printing all lines > for PHE and ASP is it possible that for PHE python will print > only those lines which will have information about H and HA > and for ASP it will print those lines which will have > inf

python-list@python.org

2009-07-14 Thread ~km
Hi, I'm experiencing a strange behaviour of the Python prompt when using the four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of getting the previous and next command respectively I get ugly characters. See it yourself: http://tinypic.com/view.php?pic=m78cgp&s=3 This is not directly

bad behaviour in interactive Python prompt

2009-07-14 Thread ~km
Hi, I'm experiencing a strange behaviour of the Python prompt when using the four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of getting the previous and next command respectively I get ugly characters. See it yourself: http://tinypic.com/view.php?pic=m78cgp&s=3 This is not directly

Re: select lines in python

2009-07-14 Thread David Gibb
I think what Grant is saying is that you should read the documentation for the re module. David On Tue, Jul 14, 2009 at 3:12 PM, Grant Edwards wrote: > On 2009-07-14, amr...@iisermohali.ac.in wrote: > >> Can i become more precise like instead of printing all lines >> for PHE and ASP is it possib

Re: bad behaviour in interactive Python prompt

2009-07-14 Thread Mark Dickinson
On Jul 14, 8:20 pm, "~km" wrote: > I'm experiencing a strange behaviour of the Python prompt when using > the > four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of > getting > the previous and next command respectively I get ugly characters. See > it > yourself:http://tinypic.com/view

Re: missing 'xor' Boolean operator

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 11:47 AM, Mark Dickinson wrote: > On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" > wrote: >> Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to >> have an 'xor' operator as well. > > Hmm.  I don't think 'nice' is sufficient.  You'd need to make the cas

python-list@python.org

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 12:15 PM, ~km wrote: > Hi, > > I'm experiencing a strange behaviour of the Python prompt when using > the > four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of > getting > the previous and next command respectively I get ugly characters. See > it > yourself: > h

Re: missing 'xor' Boolean operator

2009-07-14 Thread Mark Dickinson
On Jul 14, 8:43 pm, Chris Rebert wrote: > On Tue, Jul 14, 2009 at 11:47 AM, Mark Dickinson wrote: > > (1) It's easy to emulate xor:  'x xor y' <-> bool(x) != bool(y) > > Using the xor bitwise operator is also an option: > bool(x) ^ bool(y) Good point. For some reason I expected bitwise operation

Re: missing 'xor' Boolean operator

2009-07-14 Thread Dr. Phillip M. Feldman
!= does do what I want, except that it doesn't indicate to someone reading the code that the operands are being treated as logicals. (Readability is supposed to be one of the major selling points of Python). But, this is probably good enough. Here's a related issue: I would like to see an optio

Re: one-time factory in python for an experienced java guy

2009-07-14 Thread Jonathan Gardner
On Jul 14, 7:03 am, phonky wrote: > > Now, I do not know yet how the account number scheme looks like. Exactly. The data store knows a lot more than the client (your program) will ever know. The correct answer is to do nothing. Use your data store to generate the IDs for you. The implementations

Re: missing 'xor' Boolean operator

2009-07-14 Thread Chris Rebert
> Mark Dickinson wrote: >> >> On Jul 14, 7:25 pm, "Dr. Phillip M. Feldman" >> wrote: >>> Current Boolean operators are 'and', 'or', and 'not'.  It would be nice >>> to >>> have an 'xor' operator as well. >> >> Hmm.  I don't think 'nice' is sufficient.  You'd need to make the case >> that it's suff

Re: explode()

2009-07-14 Thread Jonathan Gardner
On Jul 14, 6:56 am, Fred Atkinson wrote: > > Agreed, it doesn't.  But if my hosting provider won't change it, I'm > stuck with it.   > Nowadays you can find hosts that allow you to run FastCGI scripts in any language for dirt cheap. (Hostmonster for instance.) If your host doesn't allow it, it's

  1   2   >