one more question

2009-07-15 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: why did you choose the programming language(s)you currently use?

2009-07-15 Thread Mensanator
On Jul 14, 1:47�pm, Paul Rubin http://phr...@nospam.invalid wrote: Mensanator mensana...@aol.com 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,

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

2009-07-15 Thread Mensanator
On Jul 14, 4:58�pm, Nobody nob...@nowhere.com 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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Tim Roberts
Dr. Phillip M. Feldman pfeld...@verizon.net 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

Re: one more question

2009-07-15 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: one more question

2009-07-15 Thread alex23
On Jul 15, 4:50 pm, alex23 wuwe...@gmail.com wrote: 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? Or to be a _little_ less blunt: if you want people here to _assist_ you

Re: one more question

2009-07-15 Thread Chris Rebert
On Tue, Jul 14, 2009 at 11:13 PM, amr...@iisermohali.ac.in wrote: 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       HA    H      2.98     0.02     1  49     8   ALA       HB    H    

Re: one more question

2009-07-15 Thread koranthala
On Jul 15, 11:13 am, amr...@iisermohali.ac.in wrote: 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       HA    H      2.98     0.02     1  49     8   ALA       HB    H      1.05     0.02

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

2009-07-15 Thread Piet van Oostrum
Douglas Alan darkwate...@gmail.com (DA) wrote: DA I wrote: On Jul 14, 8:10 am, Piet van Oostrum p...@cs.uu.nl 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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 5:07 am, Dr. Phillip M. Feldman pfeld...@verizon.net 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), and should return True if and

Re: one more question

2009-07-15 Thread koranthala
On Jul 15, 11:56 am, alex23 wuwe...@gmail.com wrote: On Jul 15, 4:50 pm, alex23 wuwe...@gmail.com wrote: 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? Or to be a

Re: The meaning of =

2009-07-15 Thread Piet van Oostrum
a...@pythoncraft.com (Aahz) (A) wrote: A In article m27hybyo95@cs.uu.nl, Piet van Oostrum p...@cs.uu.nl wrote: a...@pythoncraft.com (Aahz) (A) wrote: A In article m24otg3hkk@cs.uu.nl, Piet van Oostrum A p...@cs.uu.nl wrote: And to get c.x = 4 working you also need a __setitem__.

Re: select lines in python

2009-07-15 Thread Krishnakant
On Tue, 2009-07-14 at 23:03 +0530, amr...@iisermohali.ac.in 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_value_error _Chem_shift_ambiguity_code 1 1 PHE

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

2009-07-15 Thread Paul Moore
2009/7/15 Scott David Daniels scott.dani...@acm.org: Aahz wrote: In article 4a5ccdd6$0$32679$9b4e6...@newsspool2.arcor-online.net, Stefan Behnel  stefan...@behnel.de wrote: Deep_Feelings wrote: So you have chosen programming language x so shall you tell us why you did so , and  what

promlems with threading and print

2009-07-15 Thread Andreas Grommek
Hi Newsgroup, I'm new to python and I am familiarizing myself with threads (haven't done any threading in any other language before...). I was playing around and discovered some weird behavior. Here is my code: import threading from time import sleep from random import random import sys class

A question of style .....

2009-07-15 Thread tuxagb
If I have to write an extension module with many objects, how can I organizing the code? I think: every object in a separate file, and a last file with the PyInit_. function. But is unmenageable . Solutions? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: missing 'xor' Boolean operator

2009-07-15 Thread Ethan Furman
Scott David Daniels wrote: 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

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

2009-07-15 Thread Jonathan Gardner
On Jul 14, 6:34 pm, Rick Lawson lawso...@gmail.com wrote: 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. Are you looking for something like a thread

Re: missing 'xor' Boolean operator

2009-07-15 Thread Asun Friere
On Jul 15, 5:44 pm, Mark Dickinson dicki...@gmail.com wrote: On Jul 15, 5:07 am, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: [snip]    for arg in args:       if bool(arg): result= not result It's more idiomatic to say if arg: ... rather than if bool (arg): Ah yes, but not

Re: Best Way to Handle All Exceptions

2009-07-15 Thread Steven D'Aprano
On Tue, 14 Jul 2009 08:53:33 -0700, Carl Banks wrote: On Jul 14, 2:14 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 1:42 AM, Mohan Parthasarathy surut...@gmail.comwrote: So, all four of them above has its use cases in practice i guess. thanks mohan As a hopefully semi-informative aside, I've been writing python code for a few years now, and I regularly use all four forms of

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jonathan Gardner
On Jul 14, 4:48 pm, Ethan Furman et...@stoneleaf.us wrote: A whole family of supers.  :) You should pick up Lisp. The whole concept of a binary operator doesn't exist over there. All the things binary operators can do, Lisp does with 0, 1, 2, or more arguments. [1] (+) 0 [2] (+ 1) 1 [3] (+ 1

Re: missing 'xor' Boolean operator

2009-07-15 Thread Steven D'Aprano
On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor' operator as well. I've often wished there was too, for the sake of completeness and aesthetics, I'd love to be able to write: a xor b

Re: missing 'xor' Boolean operator

2009-07-15 Thread pdpi
On Jul 15, 12:08 am, Christian Heimes li...@cheimes.de 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) +

Re: missing 'xor' Boolean operator

2009-07-15 Thread Tim Wintle
On Wed, 2009-07-15 at 02:02 -0700, Jonathan Gardner wrote: On Jul 14, 4:48 pm, Ethan Furman et...@stoneleaf.us wrote: A whole family of supers. :) All the things binary operators can do, Lisp does with 0, 1, 2, or more arguments. +1 n-ary operators are great, but binary operators are

Re: A question of style .....

2009-07-15 Thread Bearophile
tuxagb: If I have to write an extension module with many objects, how can I organizing the code? I think: every object in a separate file, and a last file with the PyInit_. function. But is unmenageable . Solutions? What do you think about using Cython? Bye, bearophile --

Re: missing 'xor' Boolean operator

2009-07-15 Thread Tim Golden
Steven D'Aprano wrote: On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor' operator as well. I've often wished there was too, for the sake of completeness and aesthetics, I'd love to be

convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Helmut Jarausch
Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does anybody know a tool/Python script to do so? I know, I could use dbfpy and create the SQLite table and import all data. But is there something easier? Many thanks for

Re: Passing python list from C to python

2009-07-15 Thread hartley
On Jul 14, 2:21 pm, John Machin sjmac...@lexicon.net wrote: On Jul 14, 7:22 pm, hartley hartle...@gmail.com 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

Re: select lines in python

2009-07-15 Thread Pierre Quentel
On 14 juil, 19:33, amr...@iisermohali.ac.in 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_value_error       _Chem_shift_ambiguity_code      1     1   PHE       H     H      

Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Ben Finney
Howdy all, A common idiom I use is:: def frobnicate(warble): foo = complex_computation() bar = long.access.path.leading.to.useful.value baz = (lengthy + expression * with_several_parts) spangulate(%(warble)s: %(foo)s%(bar)s [%(baz)d] % vars()) This allows the

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread David Lyon
On Wed, 15 Jul 2009 11:53:28 +0200, Helmut Jarausch jarau...@igpm.rwth-aachen.de wrote: Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does anybody know a tool/Python script to do so? I know, I could use dbfpy

Re: promlems with threading and print

2009-07-15 Thread Piet van Oostrum
Andreas Grommek a...@mozarellasalat.homelinux.net (AG) wrote: AG Hi Newsgroup, AG I'm new to python and I am familiarizing myself with threads AG (haven't done any threading in any other language before...). I was AG playing around and discovered some weird behavior. Here is my code: When you

Re: [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Nicolas Chauvat
Hi, On Wed, Jul 15, 2009 at 08:08:13PM +1000, Ben Finney wrote: def frobnicate(warble): foo = complex_computation() bar = long.access.path.leading.to.useful.value baz = (lengthy + expression * with_several_parts) spangulate(%(warble)s: %(foo)s%(bar)s

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

2009-07-15 Thread denis
Sure, Aho-Corasick is fast for fixed strings; but without real numbers / a concrete goal Matt, how many words are you looking for, in how long a string ? a simple solution is good enough, satisficing. Matt asked how to make that function look nicer? but nice has many dimensions -- bicycles are

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Tim Rowe
2009/7/15 Jeremiah Dodds jeremiah.do...@gmail.com: As a hopefully semi-informative aside, I've been writing python code for a few years now, and I regularly use all four forms of argument passing listed above. Curiously, I never use the all-named style in Python, whereas it's my normal style

dictionary inherit and method overriding

2009-07-15 Thread fdb
Hi all, I need to extend and not replace the __getitem__ method of a dict class. Here is sample the code: class myDict(dict): ... def __getitem__(self, y): ... print(Doing something) ... dict.__getitem__(self, y) ... a=myDict() a[value] = 1 print a[value] None As you

Re: Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Ben Finney
Nicolas Chauvat nicolas.chau...@logilab.fr writes: On Wed, Jul 15, 2009 at 08:08:13PM +1000, Ben Finney wrote: That is, pylint is not aware that the names used by accessing the values from the dictionary returned by ‘vars()’. ... You are not the only one:

Re: [Python-projects] [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Nicolas Chauvat
On Wed, Jul 15, 2009 at 12:39:48PM +0200, Nicolas Chauvat wrote: Here is the ticket: https://www.logilab.net/elo/ticket/9634 Apologies: http://www.logilab.org/ticket/9634 -- Nicolas Chauvat logilab.fr - services en informatique scientifique et gestion de connaissances --

Re: dictionary inherit and method overriding

2009-07-15 Thread Christian Heimes
fdb wrote: Hi all, I need to extend and not replace the __getitem__ method of a dict class. Here is sample the code: class myDict(dict): def __getitem__(self, y): print(Doing something) dict.__getitem__(self, y) a=myDict() a[value] = 1 print

Re: missing 'xor' Boolean operator

2009-07-15 Thread Christian Heimes
pdpi wrote: On Jul 15, 12:08 am, Christian Heimes li...@cheimes.de 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) +

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

2009-07-15 Thread dzizes
Yes, that is what I was looking for. Greets!! -- View this message in context: http://www.nabble.com/how-to-set-timeout-while-colling-a-soap-method--tp24461403p24496577.html Sent from the Python - python-list mailing list archive at Nabble.com. --

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

2009-07-15 Thread Rick Lawson
On Jul 15, 4:53 am, Jonathan Gardner jgard...@jonathangardner.net wrote: On Jul 14, 6:34 pm, Rick Lawson lawso...@gmail.com wrote: 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

Re: dictionary inherit and method overriding

2009-07-15 Thread fdb
Only this! I'm going crazy! Than you! Code: class myDict(dict): def __getitem__(self, y): print(Doing something) return dict.__getitem__(self, y) a=myDict() a[value] = 1 print a[value] Christian Heimes ha scritto: How about returning the value? :] -- FabioBD --

Need help with oo design while using TreeWidget

2009-07-15 Thread Borivoj
I'm looking for objective oriented and pythonic way to solve my problem. I'm using IDLE's TreeWidget, by inheriting TreeItem and overriding some of it's methods. My tree structure is defined inside treedata, which is xml.dom.minidom object. MenuTreeFrame is responsible for displaying the

Re: Passing python list from C to python

2009-07-15 Thread John Machin
On Jul 15, 7:54 pm, hartley hartle...@gmail.com wrote: On Jul 14, 2:21 pm, John Machin sjmac...@lexicon.net wrote: On Jul 14, 7:22 pm, hartley hartle...@gmail.com wrote: I'm very new at wrapping Python/C, and I have run into some problems. [snip] /* the first telling */ statement

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

2009-07-15 Thread Diez B. Roggisch
Rick Lawson wrote: On Jul 15, 4:53 am, Jonathan Gardner jgard...@jonathangardner.net wrote: On Jul 14, 6:34 pm, Rick Lawson lawso...@gmail.com wrote: Appreciate any help on this. I am porting an app from Java to python and need generic object pooling with hooks for object initialization /

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 11:54 AM, Tim Rowe digi...@gmail.com wrote: Curiously, I never use the all-named style in Python, whereas it's my normal style in Ada. I shall now enter a period of self-refelection to try to work out why I am so inconsistent :-) I use it for functions that only (or

Re: The meaning of =

2009-07-15 Thread Aahz
In article m2vdluxt0j@cs.uu.nl, Piet van Oostrum p...@cs.uu.nl wrote: a...@pythoncraft.com (Aahz) (A) wrote: A In article m27hybyo95@cs.uu.nl, Piet van Oostrum p...@cs.uu.nl wrote: a...@pythoncraft.com (Aahz) (A) wrote: A In article m24otg3hkk@cs.uu.nl, Piet van Oostrum A

Re: missing 'xor' Boolean operator

2009-07-15 Thread pdpi
On Jul 15, 12:37 pm, Christian Heimes li...@cheimes.de wrote: pdpi wrote: On Jul 15, 12:08 am, Christian Heimes li...@cheimes.de 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

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

2009-07-15 Thread Diez B. Roggisch
Diez B. Roggisch wrote: Rick Lawson wrote: On Jul 15, 4:53 am, Jonathan Gardner jgard...@jonathangardner.net wrote: On Jul 14, 6:34 pm, Rick Lawson lawso...@gmail.com wrote: Appreciate any help on this. I am porting an app from Java to python and need generic object pooling with hooks

Re: [Python-projects] [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread skip
Nicolas Here is the ticket: Nicolas https://www.logilab.net/elo/ticket/9634 Is it possible to get read-only access to the tracker? It's prompting me for a login which I don't have. Thx, -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ when i wake up with a heart

Re: promlems with threading and print

2009-07-15 Thread Piet van Oostrum
Piet van Oostrum p...@cs.uu.nl (PvO) wrote: PvO def run(self): PvO with lock: All the 'with lock:' lines should have been 'with self.lock:' but as lock is also a global variable, it did work. Of course you can decide to use only the global variable and get rid of the self.lock

Re: [Python-projects] [TIP] Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Aurélien Campéas
On Wed, Jul 15, 2009 at 09:22:11AM -0500, s...@pobox.com wrote: Nicolas Here is the ticket: Nicolas https://www.logilab.net/elo/ticket/9634 Is it possible to get read-only access to the tracker? It's prompting me for a login which I don't have. Thx, that should be

Re: missing 'xor' Boolean operator

2009-07-15 Thread Bill Davy
MRAB pyt...@mrabarnett.plus.com wrote in message news:mailman.3158.1247667680.8015.python-l...@python.org... Steven D'Aprano wrote: On Tue, 14 Jul 2009 11:25:08 -0700, Dr. Phillip M. Feldman wrote: Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor'

Re: import module unbelieveable behaviour

2009-07-15 Thread Tycho Andersen
On Wed, Jul 15, 2009 at 8:12 AM, Peter Fodrekpeter.fod...@stuba.sk wrote: Would anyone be helpful for me to get more information about this problem because  pydb does not show anything usable for me,please? What is the directory structure for the HeeksCNC module? Although I'm no expert, I

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

2009-07-15 Thread Jean-Michel Pichavant
John Nagle wrote: 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

Re: Colour of output text

2009-07-15 Thread Jean-Michel Pichavant
Nobody wrote: On Fri, 10 Jul 2009 09:23:54 +, garabik-news-2005-05 wrote: I would like to learn a way of changing the colour of a particular part of the output text. I've tried the following On Unix operating systems this would be done through the curses interface:

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
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

Re: Best Way to Handle All Exceptions

2009-07-15 Thread Jean
On Jul 13, 6:26 am, seldan24 selda...@gmail.com wrote: Hello, I'm fairly new at Python so hopefully this question won't be too awful.  I am writing some code that will FTP to a host, and want to catch any exception that may occur, take that and print it out (eventually put it into a log file

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

2009-07-15 Thread skip
JM By the way why would you prevent us from using tabs for indenting ? JM If I'm not wrong, from a semantic point of view, that's what tabs JM are for: indenting. Spaces are meant to separate tokens, aren't they JM ? I love my tabs, don't take them away from me ! I don't think

Re: missing 'xor' Boolean operator

2009-07-15 Thread Robert Kern
On 2009-07-15 10:15, Jean-Michel Pichavant wrote: 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) +

Re: import module unbelieveable behaviour

2009-07-15 Thread Diez B. Roggisch
Peter Fodrek wrote: Dear conference! I have test Why python based script for HeeksCNC post-processing does not work... And I've got unbelievable behavior When importing module module manually it works, but same opertaion from script does not work as seen /opt/HeeksCAD8/HeeksCNC

Python-URL! - weekly Python news and links (Jul 15)

2009-07-15 Thread Gabriel Genellina
QOTW: Everyone gets so caught up in programming via languages that you get, well, people trying to teach 'Computer Programming' as if it were only necessary to grok a language, rather than grokking /symbol manipulation/ itself. - Simon Forman

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
Helmut Jarausch wrote: Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does anybody know a tool/Python script to do so? I know, I could use dbfpy and create the SQLite table and import all data. But is there something

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread John Machin
On Jul 15, 8:39 pm, David Lyon david.l...@preisshare.net wrote: On Wed, 15 Jul 2009 11:53:28 +0200, Helmut Jarausch jarau...@igpm.rwth-aachen.de wrote: Hi, I have a lot of old Dbase files (.dbf) and I'll like to convert these to SQLite databases as automatically as possible. Does

Python Equivalent for dd fold

2009-07-15 Thread seldan24
Hello, I have a shell script, that I'm attempting to convert to Python. It FTP's files down from an AS/400 machine. That part is working fine. Once the files arrive, the script converts them from EBCDIC to ASCII and then formats their line width based on a pre-determined size. For example, if

Re: select lines in python

2009-07-15 Thread Rhodri James
On Tue, 14 Jul 2009 20:10:32 +0100, 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

Re: convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Ethan Furman
John Machin wrote: If dbfpy can't handle any new-fangled stuff you may have in your files, drop me a line ... I have a soon-to-be released DBF module that should be able to read the new stuff up to dBase7 and VFP9, including memo files, conversion from whatever to Unicode if needed, ...

Re: Python Equivalent for dd fold

2009-07-15 Thread Michiel Overtoom
seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len): while s: print s[:len] s=s[len:] s=A very long string indeed. Really that long? Indeed. fold(s,10) Output: A very lon g string i ndeed. Rea lly that l ong? Indee d.

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

2009-07-15 Thread weafon
Hi DaveA, Thank for your responses even though my problem has been solved based on Miles' suggestion. I am writing programs by using the SimPy library, which is a discrete-event simulator library. Below is my actual code segment class RAID(Process): def ReqServ(self):

Re: missing 'xor' Boolean operator

2009-07-15 Thread Hrvoje Niksic
Jean-Michel Pichavant jeanmic...@sequans.com writes: While everyone's trying to tell the OP how to workaround the missing xor operator, nobody answered the question why is there no [boolean] xor operator ?. Probably because there isn't one in C. The bitwise XOR operator, on the other hand,

Re: Python Equivalent for dd fold

2009-07-15 Thread seldan24
On Jul 15, 12:47 pm, Michiel Overtoom mot...@xs4all.nl wrote: seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len):      while s:          print s[:len]          s=s[len:] s=A very long string indeed. Really that long? Indeed. fold(s,10)

Re: Python Equivalent for dd fold

2009-07-15 Thread MRAB
seldan24 wrote: On Jul 15, 12:47 pm, Michiel Overtoom mot...@xs4all.nl wrote: seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len): while s: print s[:len] s=s[len:] s=A very long string indeed. Really that long? Indeed.

Re: missing 'xor' Boolean operator

2009-07-15 Thread Paul Rubin
Hrvoje Niksic hnik...@xemacs.org writes: While everyone's trying to tell the OP how to workaround the missing xor operator, nobody answered the question why is there no [boolean] xor operator ?. Probably because there isn't one in C. The bitwise XOR operator, on the other hand, exists

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Wed, 15 Jul 2009 13:37:22 +0200, Christian Heimes li...@cheimes.de wrote: pdpi wrote: On Jul 15, 12:08 am, Christian Heimes li...@cheimes.de 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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). l = [(True, True), (True, False), (False, True), (False, False)] for p in l: ... p[0] or p[1] ... True True True False for p in l: ... not(not p[0] and not p[1]) ... True True

Re: Python Equivalent for dd fold

2009-07-15 Thread Emile van Sebille
On 7/15/2009 10:23 AM MRAB said... On Jul 15, 12:47 pm, Michiel Overtoom mot...@xs4all.nl wrote: seldan24 wrote: what can I use as the equivalent for the Unix 'fold' command? def fold(s,len): while s: print s[:len] s=s[len:] snip You might still need to tweak the

Re: missing 'xor' Boolean operator

2009-07-15 Thread Emile van Sebille
On 7/15/2009 10:43 AM Jean-Michel Pichavant said... Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). l = [(True, True), (True, False), (False, True), (False, False)] for p in l: ... p[0] or p[1] ... True True True False for

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote: Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). l = [(True, True), (True, False), (False, True), (False, False)] for p in l: ... p[0] or p[1] [snip] Did I make twice the

python first assignment of a global variable

2009-07-15 Thread Rodrigue
Hi all, I came accross a strange behaviour in python today. Here is a simple example to describe my situation: MY_GLOBAL = '' def a(): print 'global is: ', MY_GLOBAL def b(): try: MY_GLOBAL += 'bla' except Exception, e: print 'b: ', e def c(): try:

Re: missing 'xor' Boolean operator

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:55 PM, Emile van Sebille wrote: On 7/15/2009 10:43 AM Jean-Michel Pichavant said... Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). Did I make twice the same obvious error ? No -- but in the not(not...

Re: python first assignment of a global variable

2009-07-15 Thread Emile van Sebille
On 7/15/2009 10:55 AM Rodrigue said... I came accross a strange behaviour in python today. Here is a simple example to describe my situation: MY_GLOBAL = '' snip def e_raise(): if not MY_GLOBAL: MY_GLOBAL = 'bla' snip Traceback (most recent call last): File glo.py, line

Re: missing 'xor' Boolean operator

2009-07-15 Thread Terry Reedy
Tim Golden wrote: I was pondering on this yesterday, and the only case I've come across in my code -- and it's reasonably common -- is checking that one and only one of two params has been passed. I have code which wants, say, an id or a name but doesn't want both. It's hardly difficult to

Re: python first assignment of a global variable

2009-07-15 Thread Miles Kaufmann
On Jul 15, 2009, at 1:55 PM, Rodrigue wrote: Basically, I was very surprised to discover that e() raises an exception, but even more that e_raise() points to if not MY_GLOBAL Is the problem not really when I assign? My assumption is that some reordering is happening behind the scenes that

Re: missing 'xor' Boolean operator

2009-07-15 Thread Dr. Phillip M. Feldman
I did initially ask for an infix xor operator, but eventually gave up on this. I like the first of your two one-line solutions below; this is clean and easy to understand. Thanks! I'd still like to be able to write an expression like '(a and b) xor (c and d) xor (e and f)', but it looks as

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

2009-07-15 Thread Miles Kaufmann
On Jul 14, 2009, at 5:06 PM, David Bolen wrote: Are you sure? It seems to restrict them in the same block, but not in the entire file. At least I was able to use both space and tab indented blocks in the same file with Python 3.0 and 3.1. It seems to me that, within an indented block, Python

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: On Jul 14, 7:25 pm, Dr. Phillip M. Feldman pfeld...@verizon.net 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

Re: Catching control-C

2009-07-15 Thread MCIPERF
On Jul 9, 7:28 pm, Miles Kaufmann mile...@umich.edu wrote: On Jul 9, 2009, at 9:20 AM, Lie Ryan wrote: Michael Mossey wrote: I want to understand better what the secret is to responding to a ctrl-C in any shape or form. Are you asking: when would the python interpreter process

mail

2009-07-15 Thread amrita
Dear all, Sorry that I am disturbing you all again and again but this is the way I am trying to solve my problem:--- import re exp = re.compile(CA) infile = open(file1.txt) for line in infile: ... values = re.split(\s+, line) ... if exp.search(line): ...print (%s %s CA = %s

Re: missing 'xor' Boolean operator

2009-07-15 Thread Robert Kern
On 2009-07-15 13:29, Wayne Brehaut wrote: On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: On Jul 14, 7:25 pm, Dr. Phillip M. Feldmanpfeld...@verizon.net wrote: Current Boolean operators are 'and', 'or', and 'not'. It would be nice to have an 'xor' operator

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 7:29 pm, Wayne Brehaut wbreh...@mcsnet.ca wrote: On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: I'd also guess that 'xor' would be much less used than 'and' or 'or', but maybe that's just a reflection of the sort of code that I tend to write.

Re: missing 'xor' Boolean operator

2009-07-15 Thread Anthony Tolle
On Jul 14, 2:25 pm, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: Current Boolean operators are 'and', 'or', and 'not'.  It would be nice to have an 'xor' operator as well. My $0.02 on this discussion: There would be nothing gained by having non-bitwise XOR operator. You can't

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jean-Michel Pichavant
Miles Kaufmann wrote: On Jul 15, 2009, at 1:43 PM, Jean-Michel Pichavant wrote: Hrvoje Niksic wrote: [snip] Note that in Python A or B is in fact not equivalent to not(not A and not B). l = [(True, True), (True, False), (False, True), (False, False)] for p in l: ... p[0] or p[1]

Re: mail

2009-07-15 Thread Grant Edwards
On 2009-07-15, amr...@iisermohali.ac.in amr...@iisermohali.ac.in wrote: Sorry that I am disturbing you all again and again but this is the way I am trying to solve my problem:--- We could probably be a lot more helpful if you would keep these postings all in a single thread so that people who

Re: mail

2009-07-15 Thread J. Cliff Dyer
On Thu, 2009-07-16 at 00:16 +0530, amr...@iisermohali.ac.in wrote: Dear all, Sorry that I am disturbing you all again and again but this is the way I am trying to solve my problem:--- import re exp = re.compile(CA) infile = open(file1.txt) for line in infile: ... values =

Re: compiling python

2009-07-15 Thread Stefan Behnel
Mag Gam wrote: At my university we are trying to compile python with --enable-shared Is there a reason why you need to compile the CPython interpreter yourself? however when I do a make many things fail. Is it a good idea to compile python with shared libraries? Perfectly fine, Linux

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Wed, 15 Jul 2009 11:51:44 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: On Jul 15, 7:29 pm, Wayne Brehaut wbreh...@mcsnet.ca wrote: On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson dicki...@gmail.com wrote: I'd also guess that 'xor' would be much less used than 'and' or

Persistent variable in subprocess using multiprocessing?

2009-07-15 Thread mheavner
I'm using multiprocessing to spawn several subprocesses, each of which uses a very large data structure (making it impractical to pass it via pipes / pickling). I need to allocate this structure once when the process is created and have it remain in memory for the duration of the process. The way

Re: Reading a large csv file

2009-07-15 Thread drozzy
On Jun 26, 6:47 am, Mag Gam magaw...@gmail.com wrote: Thankyou everyone for the responses! I took some of your suggestions and my loading sped up by 25% what a useless post... -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >