Re: Questions about os.waitpid(pid, options) on windows

2011-07-15 Thread Miki Tebeka
If you are spawning the process yourself, you can use subprocess.Popen and then call p.wait() which is cross platform. -- http://mail.python.org/mailman/listinfo/python-list

Re: Aw: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-15 Thread Steven D'Aprano
Rainer Grimm wrote: > I think it's relatively difficult to get a feeling what a are the key > points behind functional programming. So I think you should start > explaining the concepts behind functional programming. A few ideas. > - higher order functions > - first class functions > - currying >

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Steven D'Aprano
Chris Rebert wrote: > On Fri, Jul 15, 2011 at 7:47 PM, Steven D'Aprano > wrote: > >> Assertions are for testing internal program logic, not for validation. >> >> (I don't even like using assert for testing. How do you test your code >> with assertions turned off if you use assert for testing?) >

Aw: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-15 Thread Rainer Grimm
Hello, > > (My post did not appear in the mailing list, so this is my second try. > > Apology if it ends up posted twice) > > > > Hi, all, > > > > If you have read my previous posts to the group, you probably have some > > idea why I asked this question. > > > > I am giving a few presentations

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
Supplement: The assertion will not be handled anyway. I want AssertionError raise as early as possible.(mentinoed before) -- http://mail.python.org/mailman/listinfo/python-list

MemoryError vs malloc error

2011-07-15 Thread Amit Dev
Hi, I've a long running python process (running on freebsd). Sometimes when it uses too much memory it core dumps. I would've expected it to raise MemoryError. Normally, when would a python process raise MemoryError and when would it fail with malloc error and cores? This is happening in pure pyth

Re: Questions about os.waitpid(pid, options) on windows

2011-07-15 Thread Christopher Head
On Mon, 11 Jul 2011 20:59:29 -0700 (PDT) Fan wrote: > It seems that waitpid take process handle instead of process id as the > first parameter on Windows. On Unices platform, the first parameter > is process id. > > This interface is a little bit confusing. What's the purpose for such > a desig

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
> Perhaps you meant this? > > assert isinstance(user, User) Yes I meant this,sorry,my mistake. Thx for your and Ben's feedbacks first,it's appreciated. your points is taken by me,but I want to make my opinion more clearly. The assertion is JUST show to my function call

Re: Python threading/multiprocessing issue.

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 3:15 PM, Dennis Lee Bieber wrote: > And (so far as I understand it) each process can claim its own CPU > core, whereas threads share the active core. Threads can be put onto separate cores too, and can have their affinities set. But because of the GIL, actual CPython code

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Chris Rebert
On Fri, Jul 15, 2011 at 7:47 PM, Steven D'Aprano wrote: > Assertions are for testing internal program logic, not for validation. > > (I don't even like using assert for testing. How do you test your code with > assertions turned off if you use assert for testing?) I would think that would only m

Re: HOWTO: Parsing email using Python part2

2011-07-15 Thread Steven D'Aprano
aspineux wrote: > Hello > > I have written part 2 about parsing email. > > You can find the article here : > > http://blog.magiksys.net/parsing-email-using-python-content > > This part is a lot longer : Wow! Well done. Thank you for sharing this, this is extremely detailed and useful. --

Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-15 Thread Steven D'Aprano
Wanderer wrote: > But if you have the colon, why do you need the brackets or backslashes > in an if statement. > > Why not > > if condition1 or >condition2 or >condition3: > do_something() > > The statement ain't over til there's a colon. Because there are virtues in having the pa

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Steven D'Aprano
Inside wrote: > Why I use assertion,please check this code: > """ > class User(object):pass > > class Student(User):pass > > class Professional(User):pass > > def add(user): > assert(user, User) This does not do what you think it does. All it does is, in some Python versions, print Synta

Re: Possible File iteration bug

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 1:42 PM, Steven D'Aprano wrote: > Okay, we've come up with the solution of a new exception, PauseIteration, > that the iterator protocol will recognise. Now we have to: > > - write an implementation or patch adding that functionality; - and add it to our own personal buil

Re: Possible File iteration bug

2011-07-15 Thread Steven D'Aprano
Billy Mays wrote: > I was thinking that a convenient solution to this problem would be to > introduce a new Exception call PauseIteration, which would signal to the > caller that there is no more data for now, but not to close down the > generator entirely. It never fails to amuse me how often pe

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Steven D'Aprano
Ben Finney wrote: [...snip explanation of duck-typing...] > If you don't have comprehensive unit tests, that's where you should put > your effort of strict interface testing. Not type assertions in the > application code. I agree with everything Ben said here, but he has missed something even mor

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Gregory Ewing
Ethan Furman wrote: some of the return values (Logical, Date, DateTime, and probably Character) will have their own dedicated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) That doesn't seem like a good idea to me. It's common practice to use 'is'

Re: Liskov substitution principle

2011-07-15 Thread Ben Finney
Chris Angelico writes: > What if the base class implemented study(), and then LazyStudent > subclasses Student but makes study() raise NotImpl? Would that break > things? In a sense, it breaks the whole "this is a student so it > should act like a student" rule. That would break the Liskov subst

Re: Print encoding problems in console

2011-07-15 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 On 2011.07.15 07:02 PM, Pedro Abranches wrote: > Now, if you're using your python script in some shell script you > might have to store the output in some variable, like this: > > $ var=`python -c 'import sys; print sys.stdout.encoding; print > u

Re: Print encoding problems in console

2011-07-15 Thread Dan Stromberg
I've used the code below successfully to deal with such a problem when outputting filenames. Python2x3 is at http://stromberg.dnsalias.org/svn/python2x3/ , but here it's just being used to convert Python 3.x's byte strings to strings (to eliminate the b'' stuff), while on 2.x it's an identity func

Re: Liskov substitution principle (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 10:04 AM, Ben Finney wrote: >        def study(self, subject): >            raise NotImplementedError > > See? We can have overstretched analogies *and* remain within the Liskov > substitution principle. > Hehe! Of course I was speaking utterly in jest, but this raises (so

Liskov substitution principle (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Ben Finney
Chris Angelico writes: > The analogy with reality breaks down a bit here. I've seen plenty of > students with no idea of what it means to study. But Python can handle > that too - just 'del' the method in the subclass. No, please don't. That would break the Liskov substitution principle https://

Print encoding problems in console

2011-07-15 Thread Pedro Abranches
Hello everyone. I'm having a problem when outputing UTF-8 strings to a console. Let me show a simple example that explains it: $ python -c 'import sys; print sys.stdout.encoding; print u"\xe9"' UTF-8 é It's everything ok. Now, if you're using your python script in some shell script you might hav

Re: Looking for general advice on complex program

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 8:37 AM, Cameron Simpson wrote: > There are two approaches to this. > You can create a file while your umask is 0777... [or] > My personal habit is to make a directory for the lock Both viable options; I'd be inclined toward the second. Or, here's a third option. Instead o

Re: Is there a Programming FAQ for Python 3.x?

2011-07-15 Thread Richard D. Moores
On Fri, Jul 15, 2011 at 16:39, Thomas Jollans wrote: > On 07/16/2011 01:24 AM, Richard D. Moores wrote: >> Is there a Programming FAQ for Python 3.x? There is >> , but it's for 2.7 >> >> Thanks, >> >> Dick Moores > > http://docs.python.org/py3k/faq/inde

Re: abort python script from trace function

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 8:00 AM, Dave Stark wrote: > Hello, > > I have a multithreaded application that uses embedded python extensively. > The main thread creates python objects that interface test equipment, and > users execute their own python scripts that run in a separate thread. I did somet

Re: Is there a Programming FAQ for Python 3.x?

2011-07-15 Thread Thomas Jollans
On 07/16/2011 01:24 AM, Richard D. Moores wrote: > Is there a Programming FAQ for Python 3.x? There is > , but it's for 2.7 > > Thanks, > > Dick Moores http://docs.python.org/py3k/faq/index.html http://docs.python.org/py3k/faq/programming.html -- htt

Re: Python threading/multiprocessing issue.

2011-07-15 Thread Chris Angelico
2011/7/16 Lee Harr : > I am not a multiprocessing expert, but I think the problem you > are having is that Process is running your code in a separate > process, so there is no way you could see those object changes > in your main line code. > > In other words, Process is not an exact replacement fo

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 5:53 AM, Inside wrote: > def add(users): >    assert(users, (tuple, list)) >    #If necessary I'll also check every obj in the sequence to see whether > it's a User. > > I just follow some coding rules of me: > 1. Controlling "input" strictly. > 2. In a function keep doubt

Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Ben Finney
Inside writes: > I just follow some coding rules of me: > 1. Controlling "input" strictly. Asserting that the input is of a specific type is too strict. Does your code work if the input is not a list or tuple? I suspect strongly that the answer is yes, it works fine with any sequence, even ones

Is there a Programming FAQ for Python 3.x?

2011-07-15 Thread Richard D. Moores
Is there a Programming FAQ for Python 3.x? There is , but it's for 2.7 Thanks, Dick Moores -- http://mail.python.org/mailman/listinfo/python-list

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 4:56 AM, rantingrick wrote: > Hmm, that's strange considering that code MUST be formatted in certain > ways or you get a syntax error (indention, colons, parenthesis, etc, > etc). I don't hear the masses claiming that they are going over to > Ruby simply because of indentio

Re: Python ++ Operator?

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 6:26 AM, Dan Stromberg wrote: > > I don't regard this as a low level versus VHLL issue - I regard it as a > matter of operators with side effects being too error prone.  Adding such > operators to Python has been discussed (it'd almost certainly be easy to > add), and rejec

Re: Looking for general advice on complex program

2011-07-15 Thread Cameron Simpson
On 15Jul2011 16:03, Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote: | I remember reading that file locking doesn't work on network mounted | drives (specifically nfs mounts), but you might be able to simply | create a 'lock' (mydoc.xml.lock or the like) file for th

abort python script from trace function

2011-07-15 Thread Dave Stark
Hello, I have a multithreaded application that uses embedded python extensively. The main thread creates python objects that interface test equipment, and users execute their own python scripts that run in a separate thread. The users need to be able to pause/resume/abort a script that is curr

Re: Possible File iteration bug

2011-07-15 Thread Terry Reedy
On 7/15/2011 10:42 AM, Billy Mays wrote: On 07/15/2011 10:28 AM, Thomas Rachel wrote: Am 15.07.2011 14:52 schrieb Billy Mays: Really what would be useful is some sort of PauseIteration Exception which doesn't close the generator when raised, but indicates to the looping header that there is n

Re: difflib-like library supporting moved blocks detection?

2011-07-15 Thread Vlastimil Brom
2011/7/14 Chris Torek : > In article > Vlastimil Brom   wrote: >>I'd like to ask about the availability of a text diff library, like >>difflib, which would support the detection of moved text blocks. > > If you allow arbitrary moves, the "minimal edit distance" problem > (string-to-string edit) be

Re: Possible File iteration bug

2011-07-15 Thread Terry Reedy
On 7/15/2011 8:26 AM, Billy Mays wrote: On 07/15/2011 04:01 AM, bruno.desthuilli...@gmail.com wrote: On Jul 14, 9:46 pm, Billy Mays wrote: I noticed that if a file is being continuously written to, the file generator does not notice it: def getLines(f): lines = [] for line in f: lines.append(l

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Terry Reedy
On 7/15/2011 6:19 AM, Steven D'Aprano wrote: Use None as default. Requiring users to use your special value would be a nuisance. They may have data prepared separately from your module. Rob Williscroft wrote: MISSING = MissingObject() def mean( sequence, missing = MISSING ): This is also

Re: Python threading/multiprocessing issue.

2011-07-15 Thread Brandon Harris
I see. Well I was hoping to see the same result in the multiprocessing example as using the threading example. What you pointed out makes sense though, but what I don't understand is how modifying the queue in the example works fine in both. Possibly it was designed for that kind of use? Brand

Re: Python ++ Operator?

2011-07-15 Thread Stefan Behnel
Chris Angelico, 15.07.2011 10:06: 2011/7/15 Björn Lindqvist: Pre and post-increments are almost always confusing unless they are used as the counter-variable inside for-loops. I agree that they're often confusing (i+j) but there are several places where they're handy. array[count++]=value

Re: Possible File iteration bug

2011-07-15 Thread Ethan Furman
Billy Mays wrote: A sentinel does provide a work around, but it also passes the problem onto the caller rather than the callee The callee can easily take care of it -- just block until more is ready. If blocking is not an option, then the caller has to deal with it no matter how callee is im

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Stefan Behnel
Terry Reedy, 15.07.2011 05:00: On 7/14/2011 9:51 PM, Ben Finney wrote: Steven D'Aprano writes: Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? At one time (before 2.2), they were functions and not classes. They are still f

Re: Python threading/multiprocessing issue.

2011-07-15 Thread Lee Harr
> I'm working on a tool that runs a number of process is separate thread. > I've, up to this point, been using threading.Thread, but from what I > read multiprocess will allow multiple processors to be used >  From the python docs on multiprocessing. > leverage multiple processors on a giv

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 16:42 schrieb Billy Mays: A sentinel does provide a work around, but it also passes the problem onto the caller rather than the callee: That is right. BTW, there is another, maybe easier way to do this: for line in iter(f.readline, ''): do_stuff(line) This provides an ite

Re: Python ++ Operator?

2011-07-15 Thread Chris Torek
In article Chris Angelico wrote: >2011/7/15 Rafael Durán Castañeda : >> Hello all, >> What's the meaning of using i++? Even, does exist ++ operator in python? > >++i is legal Python but fairly useless. It's the unary + operator, >applied twice. It doesn't increment the variable. Well... cl

Python threading/multiprocessing issue.

2011-07-15 Thread Brandon Harris
I'm working on a tool that runs a number of process is separate thread. I've, up to this point, been using threading.Thread, but from what I read multiprocess will allow multiple processors to be used From the python docs on multiprocessing. I have run into an issue when modifying the thread obj

Re: Python ++ Operator?

2011-07-15 Thread Dan Stromberg
On Fri, Jul 15, 2011 at 1:06 AM, Chris Angelico wrote: > 2011/7/15 Björn Lindqvist : > > Pre and post-increments are > > almost always confusing unless they are used as the counter-variable > > inside for-loops. > > I agree that they're often confusing (i+j) but there are several > places whe

OpenCV Object Detection

2011-07-15 Thread T
Hi all.. what is the best way (using OpenCV) to go about detecting objects by color? Specifically, I need to detect multiple objects - first, a main object (a coin), then multiple objects within that main (green particles on the coin). I'm finding lots of info about facial recognition, but not mu

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
Why I use assertion,please check this code: """ class User(object):pass class Student(User):pass class Professional(User):pass def add(user): assert(user, User) def add(users): assert(users, (tuple, list)) #If necessary I'll also check every obj in the sequence to see whether it's

Re: Looking for general advice on complex program

2011-07-15 Thread Billy Mays
On 07/15/2011 03:47 PM, Josh English wrote: I remember reading that file locking doesn't work on network mounted drives (specifically nfs mounts), but you might be able to simply create a 'lock' (mydoc.xml.lock or the like) file for the XML doc in question. If that file exists you could ei

Looking for general advice on complex program

2011-07-15 Thread Josh English
Maybe not to the gurus here, but for me, this is a complex problem and I want to make sure I understand the real problem. All of this is in Python 2.7 and wxPython I have several XML files on a shared drive. I have applications on other machines that need to access this XML file. These applicati

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-15 Thread rantingrick
On Jul 15, 2:13 am, Chris Angelico wrote: > On Fri, Jul 15, 2011 at 9:02 AM, rantingrick wrote: > > Too many folks > > are refusing to document properly and so i will take this time to > > hammer out a spec. > > The tighter you squeeze your fist, Lord Rick, the more star > programmers will slip t

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread OKB (not okblacke)
Steven D'Aprano wrote: > Rob Williscroft wrote: >> MISSING = MissingObject() >> def mean( sequence, missing = MISSING ): > > So you think the right API is to allow the caller to specify what > counts as a missing value at runtime? Are you aware of any other > statistics packages that do that?

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Ethan Furman
Mel wrote: Steven D'Aprano wrote: Well yes, but None is an explicit missing value too. The question I have is if I should support None as that value, or something else. Or if anyone can put a good case for it, both, or neither and so something completely different. If it's any help, I think (

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Eric Snow
On Thu, Jul 14, 2011 at 11:28 PM, Steven D'Aprano wrote: > Hello folks, > > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: > > mean([1, 2,

Python 2.6.6 on Windows 7 problem - "ImportError: No module named site"

2011-07-15 Thread Mark Ohrboot
Hello! If I start python -v, I get "# installing zipimport hook import zipimport # builtin # installed zipimport hook 'import site' failed; traceback ImportError: No module named site" Entering any command yields "LookupError: no codec search functions registered: can't find encoding" I reinsta

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-15 Thread George Rodrigues da Cunha Silva
Em sexta-feira, 15 de julho de 2011 04:13:43, Chris Angelico escreveu: On Fri, Jul 15, 2011 at 9:02 AM, rantingrick wrote: Too many folks are refusing to document properly and so i will take this time to hammer out a spec. The tighter you squeeze your fist, Lord Rick, the more star programmer

Re: Possible File iteration bug

2011-07-15 Thread Billy Mays
On 07/15/2011 10:28 AM, Thomas Rachel wrote: Am 15.07.2011 14:52 schrieb Billy Mays: Also, in the python docs, file.next() mentions there being a performance gain for using the file generator (iterator?) over the readline function. Here, the question is if this performance gain is really rele

Re: subprocess & isql

2011-07-15 Thread sturlamolden
On 15 Jul, 04:47, "peterff66" wrote: > I am working on a project that retrieves data from remote Sybase. I have to > use isql and subprocess to do this. Is the following correct? > I once had to hammer a nail, but I had to use a screw driver. Didn't work. > Did anybody do similar work before?

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 14:52 schrieb Billy Mays: Also, in the python docs, file.next() mentions there being a performance gain for using the file generator (iterator?) over the readline function. Here, the question is if this performance gain is really relevant AKA "feelable". The file object seems to

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 15.07.2011 14:26 schrieb Billy Mays: I was thinking that a convenient solution to this problem would be to introduce a new Exception call PauseIteration, which would signal to the caller that there is no more data for now, but not to close down the generator entirely. Alas, an exception thr

Re: how to get Python to insert special characters in an xml file?

2011-07-15 Thread Philip Semanchuk
On Jul 15, 2011, at 7:53 AM, hackingKK wrote: > Hello all. > I am currently developing a python application which reads and writes some > data to an xml file. > I use the elementTree library for doing this. > My simple question is that if I have some thing like & as in "kk & company " > as orga

Re: Multiplicity and Asininity in Tkinter Event API

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 11:54 PM, rantingrick wrote: > Ok Mr. Pedantic. I suppose for unity sake we should use the sequence > name "" instead of . I'll give you that one. > It is very significant; if you call it Click, people will assume it means Press, Release within a certain maximum time and w

Re: Multiplicity and Asininity in Tkinter Event API

2011-07-15 Thread rantingrick
On Jul 15, 1:17 am, Chris Angelico wrote: > On Fri, Jul 15, 2011 at 8:34 AM, rantingrick wrote: > >   > >   > >   > >   > >   > >   > > > That's it. Go ahead, try to prove me wrong! > > Does MouseClick mean Mouse Button Down, or does it mean Mouse Button > Pressed Then Released Within A Short Tim

Re: subprocess & isql

2011-07-15 Thread Frank Millman
"peterff66" wrote in message news:ivo9or+j...@egroups.com... Hello Python community, I am working on a project that retrieves data from remote Sybase. I have to use isql and subprocess to do this. Is the following correct? 1. call subprocess.popn to run isql, connect to Sybase 2. run sql (

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Mel
Steven D'Aprano wrote: > Well yes, but None is an explicit missing value too. The question I have > is if I should support None as that value, or something else. Or if anyone > can put a good case for it, both, or neither and so something completely > different. If it's any help, I think (some of

Re: Possible File iteration bug

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 10:52 PM, Billy Mays wrote: > Really what would be useful is some sort of PauseIteration Exception which > doesn't close the generator when raised, but indicates to the looping header > that there is no more data for now. > All you need is a sentinel yielded value (eg None

Re: Possible File iteration bug

2011-07-15 Thread Billy Mays
On 07/15/2011 08:39 AM, Thomas Rachel wrote: Am 14.07.2011 21:46 schrieb Billy Mays: I noticed that if a file is being continuously written to, the file generator does not notice it: Yes. That's why there were alternative suggestions in your last thread "How to write a file generator". To rep

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Jul 15, 2011 at 8:46 PM, Steven D'Aprano > wrote: >> In general, you have missing values in statistics because somebody >> wouldn't answer a question, and the Ethics Committee frowns on >> researchers torturing their subjects to get information. They make you >> fi

Re: Possible File iteration bug

2011-07-15 Thread Thomas Rachel
Am 14.07.2011 21:46 schrieb Billy Mays: I noticed that if a file is being continuously written to, the file generator does not notice it: Yes. That's why there were alternative suggestions in your last thread "How to write a file generator". To repeat mine: an object which is not an iterator

Re: Possible File iteration bug

2011-07-15 Thread Billy Mays
On 07/15/2011 04:01 AM, bruno.desthuilli...@gmail.com wrote: On Jul 14, 9:46 pm, Billy Mays wrote: I noticed that if a file is being continuously written to, the file generator does not notice it: def getLines(f): lines = [] for line in f: lines.append(line) return

how to get Python to insert special characters in an xml file?

2011-07-15 Thread hackingKK
Hello all. I am currently developing a python application which reads and writes some data to an xml file. I use the elementTree library for doing this. My simple question is that if I have some thing like & as in "kk & company " as organisation name, how can I have Python take this as a litte

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 8:46 PM, Steven D'Aprano wrote: > In general, you have missing values in statistics because somebody wouldn't > answer a question, and the Ethics Committee frowns on researchers torturing > their subjects to get information. They make you fill out forms. > Which, then, is

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Teemu Likonen
* 2011-07-15T03:02:11-07:00 * bruno wrote: > On Jul 15, 10:28 am, Teemu Likonen wrote: >> How about accepting anything but ignoring all non-numbers? > > Totally unpythonic. Better to be explicit about what you expect and > crash as loudly as possible when you get anything unexpected. Sure, but s

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Jul 15, 2011 at 3:28 PM, Steven D'Aprano > wrote: >> My question is, should I accept None as the missing value, or a dedicated >> singleton? >> >> In favour of None: it's already there, no extra code required. People may >> expect it to work. >> >> Against None: it

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
On 15Jul2011 20:17, Steven D'Aprano wrote: | Cameron Simpson wrote: | > I suppose there's no scope for having the append-to-the-list step sanity | > check for the sentinel (be it None or otherwise)? | | It is not my responsibility to validate data during construction, only to do | the right thin

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Rob Williscroft wrote: > Steven D'Aprano wrote in news:4e1fd009$0$29986$c3e8da3 > $54964...@news.astraweb.com in gmane.comp.python.general: > >> I'm designing an API for some lightweight calculator-like statistics >> functions, such as mean, standard deviation, etc., and I want to support >> miss

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Cameron Simpson wrote: > On 15Jul2011 15:28, Steven D'Aprano > wrote: > | In favour of None: it's already there, no extra code required. People > | may expect it to work. > > Broadly, I like this one for the reasons you cite. > > | Against None: it's too easy to mistakenly add None to a data se

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 10:28 am, Teemu Likonen wrote: > > How about accepting anything but ignoring all non-numbers? Totally unpythonic. Better to be explicit about what you expect and crash as loudly as possible when you get anything unexpected. -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 9:44 am, Cameron Simpson wrote: > On 15Jul2011 15:28, Steven D'Aprano > wrote: > | Against MISSING: users may expect to be able to choose their own sentinel by > | assigning to MISSING. I don't want to support that. > > Well, we don't have readonly values to play with :-( > Personally

subprocess & isql

2011-07-15 Thread peterff66
Hello Python community, I am working on a project that retrieves data from remote Sybase. I have to use isql and subprocess to do this. Is the following correct? 1. call subprocess.popn to run isql, connect to Sybase 2. run sql ("select ...from ...") 3. write retrieved data to subprocess.pipe 4

Re: Installing PyPy alongside Python 2.7 on Windows?

2011-07-15 Thread cjrh
Fair enough. FWIW I have struggled to install binary packages on PyPy on Windows. -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Teemu Likonen
* 2011-07-15T15:28:41+10:00 * Steven D'Aprano wrote: > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to > support missing values. Missing values should be just ignored. E.g.: > > mean([1, 2, MISSING, 3]) => 6/3

Re: Freeze statically

2011-07-15 Thread Sebastien Dudek
Actually, there is a solution but not very clean. I was surprise by two différent tools: - Statifier (but it needs to be compiled without ASLR) - And ErminePro which is very powerful to transform dynamic executables to static. But if someone is aware about compiling python code to static more pro

Re: Python ++ Operator?

2011-07-15 Thread Chris Angelico
2011/7/15 Björn Lindqvist : > Pre and post-increments are > almost always confusing unless they are used as the counter-variable > inside for-loops. I agree that they're often confusing (i+j) but there are several places where they're handy. array[count++]=value; or the more direct pointer m

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 7:28 am, Steven D'Aprano wrote: > > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: (snip) > Against None: it's too easy to m

Re: Possible File iteration bug

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 14, 9:46 pm, Billy Mays wrote: > I noticed that if a file is being continuously written to, the file > generator does not notice it: > > def getLines(f): >      lines = [] >      for line in f: >          lines.append(line) >      return lines what's wrong with file.readlines() ? -- http:

Re: Please critique my script

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 5:19 PM, bruno.desthuilli...@gmail.com wrote: >> (It would have been a lot cleaner if Python exposed its operators as >> functions. > > from operator import add Ah yes, I forgot that module. Yep, that cleans up the code a bit. ChrisA -- http://mail.python.org/mailman/lis

Re: Python ++ Operator?

2011-07-15 Thread Chris Angelico
2011/7/15 Rafael Durán Castañeda : > Hello all, > What's the meaning of using i++? Even, does exist ++ operator in python? ++i is legal Python but fairly useless. It's the unary + operator, applied twice. It doesn't increment the variable. Now, i+=1 IS valid Python, and WILL do what a C programme

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 8:08 am, Chris Angelico wrote: > > Agreed that float('nan') and "" and "spam" are all bad values for > Missings. Possibly "" should come out as 0 "In the face of ambiguity, refuse the temptation to guess." As far as I'm concerned, I'd expect this to raise a TypeError... -- http://m

Re: Python ++ Operator?

2011-07-15 Thread Björn Lindqvist
2011/7/15 Rafael Durán Castañeda : > What's the meaning of using i++? Even, does exist ++ operator in python? No it doesn't, which is a good thing. Python differentiates between expressions and variable assignments. "i++" in C both assigns the value i + 1 to i AND evaluates to i. Pre and post-incr

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Rob Williscroft
Steven D'Aprano wrote in news:4e1fd009$0$29986$c3e8da3 $54964...@news.astraweb.com in gmane.comp.python.general: > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
On 15Jul2011 15:28, Steven D'Aprano wrote: | In favour of None: it's already there, no extra code required. People may | expect it to work. Broadly, I like this one for the reasons you cite. | Against None: it's too easy to mistakenly add None to a data set by mistake, | because functions retur

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Carl Banks
On Thursday, July 14, 2011 8:00:16 PM UTC-7, Terry Reedy wrote: > I once proposed, I believe on the tracker, that 'built-in functions' be > expanded to 'built-in function and classes'. That was rejected on the > basis that people would then expect the full class documentation that is > in the 'b

Python ++ Operator?

2011-07-15 Thread Rafael Durán Castañeda
Hello all, I seem something like this on python code: for : for : spam[i][eggs] = ham ++i . . . What's the meaning of using i++? Even, does exist ++ operator in python? Bye -- http://mail.python.org/mailman/listinfo/python-list

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 9:27 am, "bruno.desthuilli...@gmail.com" wrote: > On Jul 15, 4:58 am, Inside wrote: > > > Hey guy,thx for you feedback first. > > > But I can't follow your opinion.Why?because of the list & tuple are placed > > at built-in function,so before I type 'list' unintentionally on the pyshel

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 4:58 am, Inside wrote: > Hey guy,thx for you feedback first. > > But I can't follow your opinion.Why?because of the list & tuple are placed at > built-in function,so before I type 'list' unintentionally on the pyshell and > it show me "", I never know that the name 'list' is a type,I

Re: Please critique my script

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 8:36 am, Chris Angelico wrote: > This can alternatively be done with map(): > > sortlist = map(lambda x,y: x+y, npalist, nxxlist) > > > (It would have been a lot cleaner if Python exposed its operators as > functions. from operator import add -- http://mail.python.org/mailman/list

Re: Proposal to extend PEP 257 (New Documentation String Spec)

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 9:02 AM, rantingrick wrote: > Too many folks > are refusing to document properly and so i will take this time to > hammer out a spec. The tighter you squeeze your fist, Lord Rick, the more star programmers will slip through your fingers. Make it so docstrings HAVE to be i

  1   2   >