Re: one more question

2009-07-15 Thread alex23
On Jul 15, 4:50 pm, alex23 wrote: > [email protected] 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 with _your_

Re: one more question

2009-07-15 Thread Chris Rebert
On Tue, Jul 14, 2009 at 11:13 PM, 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: one more question

2009-07-15 Thread koranthala
On Jul 15, 11:13 am, [email protected] 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  

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

2009-07-15 Thread Piet van Oostrum
> Douglas Alan (DA) wrote: >DA> 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 indice

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 5: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), and should return True if and only > if the nu

Re: one more question

2009-07-15 Thread koranthala
On Jul 15, 11:56 am, alex23 wrote: > On Jul 15, 4:50 pm, alex23 wrote: > > > [email protected] 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: i

Re: The meaning of "="

2009-07-15 Thread Piet van Oostrum
> [email protected] (Aahz) (A) wrote: >A> In article , Piet van Oostrum >wrote: [email protected] (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__

Re: select lines in python

2009-07-15 Thread Krishnakant
On Tue, 2009-07-14 at 23:03 +0530, [email protected] 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

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

2009-07-15 Thread Paul Moore
2009/7/15 Scott David Daniels : > Aahz wrote: >> >> In article <[email protected]>, >> 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 posi

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

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 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 pool or a connec

Re: missing 'xor' Boolean operator

2009-07-15 Thread Asun Friere
On Jul 15, 5:44 pm, Mark Dickinson wrote: > On Jul 15, 5:07 am, "Dr. Phillip M. Feldman" > 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 once conditional tests,

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

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 1:42 AM, Mohan Parthasarathy wrote: > 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 argument passing lis

Re: missing 'xor' Boolean operator

2009-07-15 Thread Jonathan Gardner
On Jul 14, 4:48 pm, Ethan Furman 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 2) 3 [4]> (+

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 i

Re: missing 'xor' Boolean operator

2009-07-15 Thread pdpi
On Jul 15, 12:08 am, 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

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

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

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 abl

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

Re: select lines in python

2009-07-15 Thread Pierre Quentel
On 14 juil, 19:33, [email protected] 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 th

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

Re: promlems with threading and print

2009-07-15 Thread Piet van Oostrum
> Andreas Grommek (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 start programming with

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

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Tim Rowe
2009/7/15 Jeremiah Dodds : > 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 in Ada. I shall now en

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"

Re: Teaching pylint about keyword placeholders in string formatting

2009-07-15 Thread Ben Finney
Nicolas Chauvat 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: > http://lists.logilab.org/pipermail/python-proje

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 -- http://mail.pyth

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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Christian Heimes
pdpi wrote: > On Jul 15, 12:08 am, 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

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. -- http://mail.python.org/mailman/listinfo/pyth

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 wrote: > On Jul 14, 6:34 pm, Rick Lawson 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

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 widget

Re: Passing python list from C to python

2009-07-15 Thread John Machin
On Jul 15, 7:54 pm, hartley wrote: > On Jul 14, 2:21 pm, John Machin wrote: > > On Jul 14, 7:22 pm, hartley wrote:> > > I'm very new > > at wrapping Python/C, and I have run into some problems. [snip] /* the first telling */ > > > > statement C_embedding.buff = the_pylist ? > > > > > BTW C-em

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 > wrote: >> On Jul 14, 6:34 pm, Rick Lawson 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 specif

Re: Calling functions: Why this complicated ?

2009-07-15 Thread Jeremiah Dodds
On Wed, Jul 15, 2009 at 11:54 AM, Tim Rowe 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 mostly) ha

Re: The meaning of "="

2009-07-15 Thread Aahz
In article , Piet van Oostrum wrote: >> [email protected] (Aahz) (A) wrote: > >>A> In article , Piet van Oostrum >>wrote: > [email protected] (Aahz) (A) wrote: >>A> In article , Piet van Oostrum >>A> wrote: >>> And to get c.x = 4 working you also need a __se

Re: missing 'xor' Boolean operator

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

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 >> wrote: >>> On Jul 14, 6:34 pm, Rick Lawson 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: missing 'xor' Boolean operator

2009-07-15 Thread Hendrik van Rooyen
"Steven D'Aprano" wrote: >Unfortunately, outside of boolean algebra and simulating electrical >circuits, I can't think of any use-cases for an xor operator. Do you have >any? A bitwise xor is a poor man's comparator - if the result is binary zero, the operands were equal, no matter what they

import module unbelieveable behaviour

2009-07-15 Thread Peter Fodrek
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 Python 2.6 (r26:66714, Fe

Re: missing 'xor' Boolean operator

2009-07-15 Thread MRAB
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 abl

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 - [email protected] - http://www.smontanaro.net/ when i wake up with a heart r

Re: promlems with threading and print

2009-07-15 Thread Piet van Oostrum
> Piet van Oostrum (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 altogether

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, [email protected] 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 htt

Re: missing 'xor' Boolean operator

2009-07-15 Thread Bill Davy
"MRAB" wrote in message news:[email protected]... > 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. >

Re: import module unbelieveable behaviour

2009-07-15 Thread Tycho Andersen
On Wed, Jul 15, 2009 at 8:12 AM, Peter Fodrek 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 suspect it looks someth

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 wh

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: http://docs

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 ValueError("

Re: Best Way to Handle All Exceptions

2009-07-15 Thread Jean
On Jul 13, 6:26 am, seldan24 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 and perform

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 thin

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) + b

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

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 http://groups.google.com/group/comp.lang.python/m

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 e

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

2009-07-15 Thread John Machin
On Jul 15, 8:39 pm, David Lyon wrote: > On Wed, 15 Jul 2009 11:53:28 +0200, 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? > >

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 I

Re: select lines in python

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

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, ... Cheer

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

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): while(now()In

Re: missing 'xor' Boolean operator

2009-07-15 Thread Hrvoje Niksic
Jean-Michel Pichavant 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 in both C an

Re: Python Equivalent for dd & fold

2009-07-15 Thread seldan24
On Jul 15, 12:47 pm, Michiel Overtoom 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) > > Output:

Re: Python Equivalent for dd & fold

2009-07-15 Thread MRAB
seldan24 wrote: On Jul 15, 12:47 pm, Michiel Overtoom 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) Output: A

Re: missing 'xor' Boolean operator

2009-07-15 Thread Paul Rubin
Hrvoje Niksic 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 in both C

Re: missing 'xor' Boolean operator

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

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]) ... T

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 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:] You might still need to tweak the above code as regards ho

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

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 twic

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

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

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 = '' def e_raise(): if not MY_GLOBAL: MY_GLOBAL = 'bla' Traceback (most recent call last): File "glo.py", line 49, in

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 write

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 creat

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 thou

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

Re: Catching control-C

2009-07-15 Thread MCIPERF
On Jul 9, 7:28 pm, Miles Kaufmann 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 > > Keyboar

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): ...prin

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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Mark Dickinson
On Jul 15, 7:29 pm, Wayne Brehaut wrote: > On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson > 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. > > You're right about that!. I

Re: missing 'xor' Boolean operator

2009-07-15 Thread Anthony Tolle
On Jul 14, 2: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. My $0.02 on this discussion: There would be nothing gained by having non-bitwise XOR operator. You can't short-circuit XOR, because y

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, [email protected] 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 didn't read the first p

Re: mail

2009-07-15 Thread J. Cliff Dyer
On Thu, 2009-07-16 at 00:16 +0530, [email protected] 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:

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 dist

Re: missing 'xor' Boolean operator

2009-07-15 Thread Wayne Brehaut
On Wed, 15 Jul 2009 11:51:44 -0700 (PDT), Mark Dickinson wrote: >On Jul 15, 7:29 pm, Wayne Brehaut wrote: >> On Tue, 14 Jul 2009 11:47:41 -0700 (PDT), Mark Dickinson >> wrote: >> >I'd also guess that 'xor' would be much less used than 'and' or 'or', >> >but maybe that's just a reflection of th

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 t

Re: Reading a large csv file

2009-07-15 Thread drozzy
On Jun 26, 6:47 am, Mag Gam 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

Re: missing 'xor' Boolean operator

2009-07-15 Thread Hrvoje Niksic
Jean-Michel Pichavant writes: > 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] [...] Try with a different data se

Re: Persistent variable in subprocess using multiprocessing?

2009-07-15 Thread Diez B. Roggisch
mheavner schrieb: 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 th

  1   2   >