Re: one more question

2009-07-14 Thread alex23
amr...@iisermohali.ac.in wrote: > I tried but its not coming. How much are you prepared to pay for help with this? Or are you just asking us to do all the work for you? -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-14 Thread Tim Roberts
"Dr. Phillip M. Feldman" wrote: > >Here's a related issue: I would like to see an option for type checking on >operands of logical operators, so that attempting to apply a logical >operator to non-Boolean entities generates a warning message. With operand >type checking, 'xor' and != would be dif

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

2009-07-14 Thread Mensanator
On Jul 14, 4:58�pm, Nobody wrote: > On Tue, 14 Jul 2009 11:47:08 -0700, Paul Rubin wrote: > >> - unlimited precision integers > >> - easy to program > >> - IDE not required > >> - reasonable speed > >> - math library needs to include number theoretic functions > >> � like GCD, LCM, Modular Inverse

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

2009-07-14 Thread Mensanator
On Jul 14, 1:47�pm, Paul Rubin wrote: > Mensanator writes: > > - unlimited precision integers > > - easy to program > > - IDE not required > > - reasonable speed > > - math library needs to include number theoretic functions > > � like GCD, LCM, Modular Inverse, etc.

one more question

2009-07-14 Thread amrita
Dear all, Just one more thing i want to ask that suppose i have a file like:--- 47 8 ALA H H 7.85 0.02 1 48 8 ALA HAH 2.98 0.02 1 49 8 ALA HBH 1.05 0.02 1 50 8 ALA C C179.39 0.3

Re: missing 'xor' Boolean operator

2009-07-14 Thread Miles Kaufmann
On Jul 15, 2009, at 12:07 AM, Dr. Phillip M. Feldman wrote: I appreciate the effort that people have made, but I'm not impressed with any of the answers. For one thing, xor should be able to accept an arbitrary number of input arguments (not just two) You originally proposed this in the c

Re: missing 'xor' Boolean operator

2009-07-14 Thread Dr. Phillip M. Feldman
I appreciate the effort that people have made, but I'm not impressed with any of the answers. For one thing, xor should be able to accept an arbitrary number of input arguments (not just two), and should return True if and only if the number of input arguments that evaluate to True is odd (see ww

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

2009-07-14 Thread Dave Angel
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 necessary. def func1(): ...

Re: Tkinter / Entry widget problem

2009-07-14 Thread John McMonagle
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 stri

Re: explode()

2009-07-14 Thread Dave Angel
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 reconfigure Apache on your own server if you have your own). With PHP, I can put them in any folder on

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

2009-07-14 Thread Paul Rubin
Douglas Alan writes: > I can't see that a binary search tree would typically have > particularly good cache-friendliness, so I can't see why a flat-array > representation, such as is done for a binary heap, would have > particularly worse cache-reference. That is a good point. Maybe we should be

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

2009-07-14 Thread Che M
On Jul 14, 11: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 ? As a hobbyist--and not a real programmer*--I think I chose Python (I don't really recall now) because of things like: - There

does python have a generic object pool like commons-pool in Java

2009-07-14 Thread Rick Lawson
Appreciate any help on this. I am porting an app from Java to python and need generic object pooling with hooks for object initialization / cleanup and be able to specify an object timeout. Thanks ! Rick -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading floats from Excel using COM

2009-07-14 Thread John Machin
Alagalah nekotaku.com> writes: > > Hi, I am using the Range function to return a tuple from Excel. [big snip] Exact duplicate of question asked by "KB" on http://groups.google.com/group/python-excel ... see my answer there. -- http://mail.python.org/mailman/listinfo/python-list

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

2009-07-14 Thread Martin P. Hellwig
Aahz wrote: In article <4a5ccdd6$0$32679$9b4e6...@newsspool2.arcor-online.net>, Stefan Behnel wrote: 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 ? *duck* Where do you get the duck programming

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

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 5:32 PM, greg wrote: > 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 ? > > This summarises my reasons for choosing Python > fairly well: > > http://www1.american.edu/cas

Re: Calling functions: Why this complicated ?

2009-07-14 Thread Mohan Parthasarathy
Chris, Thanks for your clarifications > > I am a newbie. I am reading > > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > > Defining a function with "N" arguments and calling them in "M" different > > ways. Why does it have to be this complicated ? I like the idea of > calling

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

2009-07-14 Thread greg
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 ? This summarises my reasons for choosing Python fairly well: http://www1.american.edu/cas/econ/faculty/isaac/choose_python.pdf -- Greg -- http://mail

Reading floats from Excel using COM

2009-07-14 Thread Alagalah
Hi, I am using the Range function to return a tuple from Excel. The data in the range (nREVENUE) in the excel file is 100.0, 101.0, 102.0, 103.0, 104.0 I can successfully iterate across the tuple and list, but when I try and cast to a float to do some math, I get: File "C:\Python25\lib\site-pa

compiling python

2009-07-14 Thread Mag Gam
At my university we are trying to compile python with --enable-shared however when I do a make many things fail. Is it a good idea to compile python with shared libraries? It seems mod-python needs it this way. TIA -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
Christian Heimes wrote: Chris Rebert wrote: Using the xor bitwise operator is also an option: bool(x) ^ bool(y) I prefer something like: bool(a) + bool(b) == 1 It works even for multiple tests (super xor): if bool(a) + bool(b) + bool(c) + bool(d) != 1: raise ValueError("Exactl

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

2009-07-14 Thread Douglas Alan
I wrote: > On Jul 14, 8:10 am, Piet van Oostrum wrote: > > > Of course you can take any BST algorithm and replace pointers by indices > > in the array and allocate new elements in the array. But then you need > > array elements to contain the indices for the children explicitely. > And why is t

Re: Calling functions: Why this complicated ?

2009-07-14 Thread Chris Rebert
On Tue, Jul 14, 2009 at 1:40 PM, Mohan Parthasarathy wrote: > Hi, > I am a newbie. I am reading > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html > Defining a function with "N" arguments and calling them in "M" different > ways. Why does it have to be this complicated ? I like the

Re: missing 'xor' Boolean operator

2009-07-14 Thread Scott David Daniels
Ethan Furman wrote: and returns the last object that is "true" A little suspect this. _and_ returns the first object that is not "true," or the last object. or returns the first object that is "true" Similarly: _or_ returns the first object that is "true," or the last object. so should

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

2009-07-14 Thread Douglas Alan
On Jul 14, 9:19 am, Scott David Daniels wrote: > It may well be that there is no good simple solution, and people avoid > writing about non-existent algorithms. I can't imagine why that should be the case. The CLRS textbook on algorithms, for instance, goes to some pains to mathematically prove

Re: decorators - would be nice if...

2009-07-14 Thread Jack Diederich
On Tue, Jul 14, 2009 at 5:44 PM, Ken Seehart wrote: > Almost every time I use decorators, I find myself wishing I had access > to the local namespace of the context from which the decorator is > executed.  In practice, decorator is being applied to a method, so the > namespace in question would be

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

2009-07-14 Thread Scott David Daniels
Aahz wrote: In article <4a5ccdd6$0$32679$9b4e6...@newsspool2.arcor-online.net>, Stefan Behnel wrote: 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 ? *duck* Where do you get the duck programming

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

2009-07-14 Thread Douglas Alan
On Jul 14, 8:10 am, Piet van Oostrum wrote: > Of course you can take any BST algorithm and replace pointers by indices > in the array and allocate new elements in the array. But then you need > array elements to contain the indices for the children explicitely. And why is this a problem? This is

Passing handlers between bound c++ libs

2009-07-14 Thread Freyr
I have a python bound physics library that uses handler to process events. The passing of handlers between c++ and python causes a huge overhead slowing down the process. Can I implement a handler in my custom python bound c++ lib B and pass it to blackbox python bound c++ lib A so that A would ca

Re: missing 'xor' Boolean operator

2009-07-14 Thread Christian Heimes
Chris Rebert wrote: > Using the xor bitwise operator is also an option: > bool(x) ^ bool(y) I prefer something like: bool(a) + bool(b) == 1 It works even for multiple tests (super xor): if bool(a) + bool(b) + bool(c) + bool(d) != 1: raise ValueError("Exactly one of a, b, c and d mus

Re: How to unbuffer Python's output

2009-07-14 Thread David Stanek
2009/7/14 Lily Gao : > Hi, All > > I am calling a python program in perl and use redirection, > > Like : > > `python x.py > 1.log 2>&1` Try tihs instead: python x.py 2>&1 > 1.log -- David blog: http://www.traceback.org twitter: http://twitter.com/dstanek -- http://mail.python.org/mailman/li

Re: The meaning of "="

2009-07-14 Thread Aahz
In article , Piet van Oostrum wrote: >> a...@pythoncraft.com (Aahz) (A) wrote: > >>A> In article , Piet van Oostrum >>A> wrote: > And to get c.x = 4 working you also need a __setitem__. > >>A> Nope. You do need __setitem__ so that this works: > >>A> c['x'] = 4 > >Sorry, I meant such

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

2009-07-14 Thread Douglas Alan
On Jul 14, 7:38 am, Florian Brucker wrote: > 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

Re: How to check if any item from a list of strings is in a big string?

2009-07-14 Thread Scott David Daniels
Nobody wrote: On Tue, 14 Jul 2009 02:06:04 -0300, Gabriel Genellina wrote: Matt, how many words are you looking for, in how long a string ? Were you able to time any( substr in long_string ) against re.compile ( "|".join( list_items )) ? There is a known algorithm to solve specifically this pro

Re: decorators - would be nice if...

2009-07-14 Thread Carl Banks
On Jul 14, 2:44 pm, Ken Seehart wrote: [snip] (e.g. there does not > seem to be a good way to use multiple metaclasses in a class hierarchy, > and more generally you can't stack them on top of each other (you can > only have one metaclass per class)). > > Thoughts? If "stacking" metaclasses (what

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
MRAB wrote: Ethan Furman wrote: Robert Kern wrote: On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != 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 sellin

Re: decorators - would be nice if...

2009-07-14 Thread Diez B. Roggisch
Ken Seehart schrieb: Almost every time I use decorators, I find myself wishing I had access to the local namespace of the context from which the decorator is executed. In practice, decorator is being applied to a method, so the namespace in question would be the dictionary of the class being cre

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

2009-07-14 Thread Nobody
On Tue, 14 Jul 2009 11:47:08 -0700, Paul Rubin wrote: >> - unlimited precision integers >> - easy to program >> - IDE not required >> - reasonable speed >> - math library needs to include number theoretic functions >> like GCD, LCM, Modular Inverse, etc. >> - not fucking retarded like F# > > Ha

Re: missing 'xor' Boolean operator

2009-07-14 Thread MRAB
Ethan Furman wrote: Robert Kern wrote: On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != 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 Py

Re: bad behaviour in interactive Python prompt

2009-07-14 Thread ~km
On 14 Jul., 15:26, Mark Dickinson wrote: > Where did your version of Python 2.6 come from? > > If you built your copy of Python 2.6 from source, then the problem is > probably that either the readline library is missing, or (much more > likely) the include files for the readline library are missin

Re: bad behaviour in interactive Python prompt

2009-07-14 Thread ~km
On 14 Jul., 15:26, Mark Dickinson wrote: > Where did your version of Python 2.6 come from? > > If you built your copy of Python 2.6 from source, then the problem is > probably that either the readline library is missing, or (much more > likely) the include files for the readline library are missin

decorators - would be nice if...

2009-07-14 Thread Ken Seehart
Almost every time I use decorators, I find myself wishing I had access to the local namespace of the context from which the decorator is executed. In practice, decorator is being applied to a method, so the namespace in question would be the dictionary of the class being created. Similarly, befo

Re: How to check if any item from a list of strings is in a big string?

2009-07-14 Thread Nobody
On Tue, 14 Jul 2009 02:06:04 -0300, Gabriel Genellina wrote: >> Matt, how many words are you looking for, in how long a string ? >> Were you able to time any( substr in long_string ) against re.compile >> ( "|".join( list_items )) ? > > There is a known algorithm to solve specifically this proble

Re: missing 'xor' Boolean operator

2009-07-14 Thread Ethan Furman
Robert Kern wrote: On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != 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

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

2009-07-14 Thread David Bolen
John Nagle writes: >Python 3 enforces the rule that you can't mix tabs and spaces > for indentation in the same file. That (finally) guarantees that > the indentation you see is what the Python parser sees. That's > enough to prevent non-visible indentation errors. Are you sure? It seems

Re: The meaning of "="

2009-07-14 Thread Piet van Oostrum
> a...@pythoncraft.com (Aahz) (A) wrote: >A> In article , Piet van Oostrum >A> wrote: >>> And to get c.x = 4 working you also need a __setitem__. >A> Nope. You do need __setitem__ so that this works: >A> c['x'] = 4 Sorry, I meant such that c.x = 4 does the same as c['x'] = 4 because th

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

2009-07-14 Thread Diez B. Roggisch
weafon schrieb: 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(): .

Re: missing 'xor' Boolean operator

2009-07-14 Thread Robert Kern
On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote: != 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.

Re: Best Way to Handle All Exceptions

2009-07-14 Thread Piet van Oostrum
> Carl Banks (CB) wrote: >CB> On Jul 14, 4:48 am, Lawrence D'Oliveiro central.gen.new_zealand> 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 >>> >

Calling functions: Why this complicated ?

2009-07-14 Thread Mohan Parthasarathy
Hi, I am a newbie. I am reading http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html Defining a function with "N" arguments and calling them in "M" different ways. Why does it have to be this complicated ? I like the idea of calling the function by explicitly naming the arguments, but

ANN: RuPy '09 Conference

2009-07-14 Thread Jakub P. Nowak
RuPy 2009 :: Strongly Dynamic Conference Poznan, Poland November 7-8, 2009 :: Call for speakers RuPy is a conference about dynamically typed programming languages. Held for the first time in April 2007 it gathered enthusiasts from Poland and other countries. The idea behind the conference is to

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

2009-07-14 Thread Aahz
In article <4a5ccdd6$0$32679$9b4e6...@newsspool2.arcor-online.net>, Stefan Behnel wrote: >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 ? > >*duck* Where do you get the duck programming lang

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

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

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

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

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

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

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

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

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

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_

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

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

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

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

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

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

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

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

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

  1   2   >