RedNotebook 1.1.6

2011-05-11 Thread Jendrik Seipp
A new RedNotebook version has been released. You can get the tarball, the Windows installer and links to distribution packages at http://rednotebook.sourceforge.net/downloads.html What is RedNotebook? RedNotebook is a **graphical journal** and diary helping you keep

Re: Python backup programs?

2011-05-11 Thread Laurent Claessens
Le 11/05/2011 01:57, James Mills a écrit : On Wed, May 11, 2011 at 9:00 AM, Dan Strombergdrsali...@gmail.com wrote: What are your favorite backup programs written, in whole or in part, in Python? My favorite one is the one I wrote myself for myself ;) The point I like : 1. the backup

NewBie Doubt in Python Thread Programming

2011-05-11 Thread vijay swaminathan
Hi All, I'm new bie to thread programming and I need some assistance in understanding few concepts ... I have a very simple program which runs a thread and prints a string. import threading class MyThread(threading.Thread): def __init__(self, parent = None):

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Wed, May 11, 2011 at 4:57 PM, vijay swaminathan swavi...@gmail.com wrote:     for i in range(10):     MyThread_Object.start()     count = threading.activeCount() When I run this, I could see 10 thread being called. But when I print the active thread count it is only 2. Need some

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Gabriel Genellina
En Wed, 11 May 2011 03:57:13 -0300, vijay swaminathan swavi...@gmail.com escribió: Hi All, I'm new bie to thread programming and I need some assistance in understanding few concepts ... I have a very simple program which runs a thread and prints a string. import threading class

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread James Mills
On Wed, May 11, 2011 at 4:57 PM, vijay swaminathan swavi...@gmail.com wrote: [...] 1. How the total active thread is 2? Your threads are terminating as normal. Without some kind of loop in your run() method they will execute the instructions and terminate. 2. how do I stop a thread? does it

Py3k,email header handling

2011-05-11 Thread TheSaint
Hello, some time ago, I wrote a program to eliminate undesided emails from the server(s) and leave those which comply to certain filter criteria. I started it when I got to know whit Python 2.3. Now a days I'd like to spend some time to improve it, just for my interest, however it didn't

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
I'm responding to this on-list on the assumption that this wasn't meant to be private; apologies if you didn't intend for this to be the case! On Wed, May 11, 2011 at 6:38 PM, vijay swaminathan swavi...@gmail.com wrote: so If i understand correctly, once the run method of the thread is executed,

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread vijay swaminathan
Sorry. My intention was not to send out a private message. when I chose reply to all, I was confused if this would start as a new thread. so just did a reply.. coming back, I have developed a GUI based on pyQT4 which has a run button. when I click on run, it invokes a command prompt and runs a

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 07 May 2011 02:51:50 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : On Fri, 06 May 2011 14:57:21 -0700, scattered wrote: : : is there any problem with : : (3) if li == []: : : ? : : Seems to work when I test it and seems to clearly test what you are : trying

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 07 May 2011 02:49:53 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : On Fri, 06 May 2011 16:05:09 -0400, Adam Tauno Williams wrote: : : I'd never accept code like if not x as an empty test. : : So much the worse for you then. : : The point of the if x idiom is that

Re: checking if a list is empty

2011-05-11 Thread Laurent Claessens
In this case, the interpretation of an arbitrary object as a boolean is peculiar for python. An empty list is a real, existing object, and the supposition that [] be false is counter-intuitive. It can be learnt, and the shorthand may be powerful when it is, but it will confuse many readers.

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Sat, 07 May 2011 21:57:13 -0700, Ethan Furman et...@stoneleaf.us wrote: : If you're going to use a language, and use it well, you have to learn : how that language works. And if the world evolves around the compiler and you, that advice suffices. However, programming is often as much

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Wed, May 11, 2011 at 7:08 PM, vijay swaminathan swavi...@gmail.com wrote: Sorry. My intention was not to send out a private message. when I chose reply to all, I was confused if this would start as a new thread. so just did a reply.. No probs. If you just send your response to the list

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 11:48:16 +0200, Laurent Claessens wrote: Once I wrote something like: def f(x=None): if x: print x else: print I have no value The caller of that function was something like f(cos(2*theta)) where theta come from some computations. Well.

HELP. This it is the code of tmb_import.py (to matter of .tmb to blender) I need tmb_exporter.py (to export of blender to .tmb) Thanks.

2011-05-11 Thread Jean Carlos Páez Ramírez
Buen día comunidad Hola. El archivo adjunto es un script de blender hecho en python que sirve para importar archivos .tmb (http://www.mediafire.com/?clmdgkymsfooddd), descargas blender y usa el script e importa el segundo archivo que te envio para que lo veas

HELP. This it is the code of tmb_import.py (to matter of .tmb to blender) I need tmb_exporter.py (to export of blender to .tmb) Thanks.

2011-05-11 Thread Jean Carlos Páez Ramírez
Buen día comunidad Hola. El archivo adjunto es un script de blender hecho en python que sirve para importar archivos .tmb (http://www.mediafire.com/?clmdgkymsfooddd), descargas blender y usa el script e importa el segundo archivo que te envio para que lo veas

Re: checking if a list is empty

2011-05-11 Thread Laurent Claessens
I believe you are grossly oversimplifying whatever code you had. Using the definition of f from above: theta = math.pi/4 f(math.cos(2*theta)) 6.12303176911e-17 Yes: its oversimplifued. The angle come from a normal vector of a curve and so on In particular, I was using Sage; the

Re: checking if a list is empty

2011-05-11 Thread Laurent Claessens
I believe you are grossly oversimplifying whatever code you had. Using the definition of f from above: theta = math.pi/4 f(math.cos(2*theta)) 6.12303176911e-17 Yes: its oversimplifued. The angle come from a normal vector of a curve and so on In particular, I was using Sage; the

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 10:02:42 +0100, Hans Georg Schaathun wrote: The problem with 'if x' is that it requires a much more detailed understanding of python. Much more detailed? Hardly. Understanding that Python accepts any and all objects in truth-testing concepts, and the rules thereof, is

Re: Non Programming in python

2011-05-11 Thread Calvin Spealman
If this is the non-programming side of python then maybe some of us have a lacking definition of what programming is. My mechanic stilll has to check the tire pressure and I need to update the version number in PyPI. On May 10, 2011 12:46 PM, rusi rustompm...@gmail.com wrote: Sorry for a silly

Re: Merge multiple source directories into one package with distutils?

2011-05-11 Thread Miki Tebeka
Greg, Is there a straightforward way to tell distutils to merge .py files from more than one source directory into a single package when installing? The Selenium Python bindings does something like that, have a look at http://selenium.googlecode.com/svn/trunk/setup.py The other option is to

Re: Python backup programs?

2011-05-11 Thread Emile van Sebille
On 5/10/2011 4:00 PM Dan Stromberg said... What are your favorite backup programs written, in whole or in part, in Python? bup What do you like about them? resilient and written in python Dislike about them? lack of a user accessible front-end to monitor and restore Are there any

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 10:14:38 +0100, Hans Georg Schaathun wrote: In this case, the interpretation of an arbitrary object as a boolean is peculiar for python. Incorrect. It is widespread among many languages. Programmers have been writing conditional tests using arbitrary values since 1958

Re: Py3k,email header handling

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 16:04:13 +0800, TheSaint wrote: Now python 3.2 (and some version before) started to use byte, rather than text strings, almost for all data handling in compliance to unicode. My problem arise that my program handle text strings, so I'd like to rewrite the code Before you

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 11:47:42 +0100, Hans Georg Schaathun wrote: On Sat, 07 May 2011 21:57:13 -0700, Ethan Furman et...@stoneleaf.us wrote: : If you're going to use a language, and use it well, you have to learn : how that language works. And if the world evolves around the compiler and

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 13:36:02 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : In this case, the interpretation of an arbitrary object as a boolean is : peculiar for python. : : Incorrect. It is widespread among many languages. Programmers have been : writing conditional

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 12:14:46 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : Not knowing that you can write if x instead of if x == [] is like not : knowing that you can write : : elif condition : : instead of : : else: : if condition My concern was

Re: checking if a list is empty

2011-05-11 Thread D'Arcy J.M. Cain
On Wed, 11 May 2011 11:47:42 +0100 Hans Georg Schaathun h...@schaathun.net wrote: However, programming is often as much about developing ideas in a large and complex community, where perfect universal mastery of one language is not an option, because half the community do not normally use that

Re: checking if a list is empty

2011-05-11 Thread D'Arcy J.M. Cain
On Wed, 11 May 2011 15:05:45 +0100 Hans Georg Schaathun h...@schaathun.net wrote: What could elif mean other than else: if? If run by an elf? Who knows. You do, of course, if you have learned the basics of the language you are using. if x could, for instance, mean if x is defined. It could

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 13:45:52 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : Do you think that we should avoid chained comparisons, class methods, : closures, co-routines, decorators, default values to functions, : delegation, doc tests, exceptions, factory functions,

Re: checking if a list is empty

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 12:00 AM, Hans Georg Schaathun h...@schaathun.net wrote: The fact that you need to list language by language which objects evaluate as false or equivalent to false illustrates that this has to be learnt language by language. Allowing arbitrary objects is one thing,

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Wojtek Mamrak
Is there any special reason you don't want to use QThread? http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details regards 2011/5/11 Chris Angelico ros...@gmail.com: On Wed, May 11, 2011 at 7:08 PM, vijay swaminathan swavi...@gmail.com wrote: Sorry. My intention was not

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak tacyt1...@gmail.com wrote: Is there any special reason you don't want to use QThread? http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details Other than that QThread is part of QT and threading isn't, what are the advantages

Re: checking if a list is empty

2011-05-11 Thread Redcat
On Wed, 11 May 2011 10:33:51 -0400, D'Arcy J.M. Cain wrote: Non-programmers should be able to program? Wasn't that sort of the premise behind Visual Basic? I don't know if that was the intention, but it sure was the result in a lot of cases. --

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
Hans Georg Schaathun wrote: On 11 May 2011 13:36:02 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : In this case, the interpretation of an arbitrary object as a boolean is : peculiar for python. : : Incorrect. It is widespread among many languages. Programmers have

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 15:05:45 +0100, Hans Georg Schaathun wrote: My concern was with the reader and not the writer. What could elif mean other than else: if? It could mean Oh, the author has made a stupid typo, I better fix it. It could mean What does the elif command do? The first time I

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Wojtek Mamrak
2011/5/11 Chris Angelico ros...@gmail.com: On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak tacyt1...@gmail.com wrote: Is there any special reason you don't want to use QThread? http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qthread.html#details Other than that QThread is part of QT

Re: checking if a list is empty

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 1:50 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 11 May 2011 15:05:45 +0100, Hans Georg Schaathun wrote: My concern was with the reader and not the writer. What could elif mean other than else: if? The first time I read Python code, I had

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 15:34:28 +0100, Hans Georg Schaathun wrote: On 11 May 2011 13:45:52 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : Do you think that we should avoid chained comparisons, class methods, : closures, co-routines, decorators, default values to

Re: Py3k,email header handling

2011-05-11 Thread TheSaint
Steven D'Aprano wrote: Before you re-write it, you should run 2to3 over it and see how much it can do automatically: Widely done, only the results from some query has radically changed on favour of unicode. Errors raising about results which are not strings anymore. I'm afraid I don't

py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Genstein
Hey all, Apologies if this is a dumb question (self = Python noob), but under py3k is it necessary to flush() a file between read/write calls in order to see consistent results? I ask because I have a case under Python 3.2 (r32:88445) where it does appear to be, on both Gentoo Linux and

Re: checking if a list is empty

2011-05-11 Thread Ian Kelly
On Wed, May 11, 2011 at 8:34 AM, Hans Georg Schaathun h...@schaathun.net wrote: E.g. Anyone who has used list/set comprehension in Z, haskell, set theory, or whereever will understand python list comprehension immediately. They would understand the underlying concept. But would somebody who

Re: checking if a list is empty

2011-05-11 Thread Eric Snow
All of this just boils down to Python providing an implicit bool cast in syntactic situations that expect conditional expressions, including if [1]. So if x: is equivalent to if bool(x). Perhaps that is the part that is not immediately obvious, being implicit to Python conditional syntax.

Proper way to handle errors in a module

2011-05-11 Thread Andrew Berg
I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering what is considered the best way to handle errors when writing a module. Do I just let exceptions go and raise custom exceptions for errors that don't trigger a standard one? Have the function/method

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
I don't mean to insult anyone, but I've heard and read all the arguments against Python's truth-testing, and they don't impress me in the slightest. Most of them strike me as silly. The only argument that carries any weight to me is one which I haven't seen anyone raise: if x: turns something

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
The audience I am concerned about is the ones who are over-educated into using and having used a score of different meanings of the same symbols. They will be used to their intuition being wrong when they move into a new context. Being explicit will help them. I find this argument to be

Re: Py3k,email header handling

2011-05-11 Thread Terry Reedy
On 5/11/2011 12:27 PM, TheSaint wrote: Steven D'Aprano wrote: Before you re-write it, you should run 2to3 over it and see how much it can do automatically: Widely done, only the results from some query has radically changed on favour of unicode. Errors raising about results which are not

Re: Proper way to handle errors in a module

2011-05-11 Thread Patty
- Original Message - From: Andrew Berg bahamutzero8...@gmail.com To: python-list@python.org Sent: Wednesday, May 11, 2011 10:29 AM Subject: Proper way to handle errors in a module I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering

Re: Proper way to handle errors in a module

2011-05-11 Thread MRAB
On 11/05/2011 18:29, Andrew Berg wrote: I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering what is considered the best way to handle errors when writing a module. Do I just let exceptions go and raise custom exceptions for errors that don't

Re: Proper way to handle errors in a module

2011-05-11 Thread Roy Smith
In article mailman.1415.1305134998.9059.python-l...@python.org, Andrew Berg bahamutzero8...@gmail.com wrote: I'm a bit new to programming outside of shell scripts (and I'm no expert there), so I was wondering what is considered the best way to handle errors when writing a module. Do I just

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:33:51 -0400, D'Arcy J.M. Cain da...@druid.net wrote: : Non-programmers should be able to program? That was not really what I suggested; I was primarily talking about reading programs and commenting on formulæ and algorithms. : Should non-doctors be able to doctor? If

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 16:26:40 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: : 1. My concern was not about clueless newbies. They need to :learn. My concern is about experienced scientists and engineers who :are simply new to python. : : Which makes them clueless newbies

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Thu, 12 May 2011 02:05:21 +1000, Chris Angelico ros...@gmail.com wrote: : In a Bourne shell script, if ends with fi... case ends with esac... so : file would end with... hmm. Yeah, I think it's best to know the : language you're trying to comprehend, and/or actually look at context :

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:27:49 -0400, D'Arcy J.M. Cain da...@druid.net wrote: : When did we come to the idea that people should be able to program in a : language without actually learning it? The fact that Python comes so : close to that possibility is nothing short of revolutionary.

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 10:31:59 -0600, Ian Kelly ian.g.ke...@gmail.com wrote: : (x + 3 for x in xs if x % 2 == 1) Interesting. Thanks. That might come in handy some time. -- :-- Hans Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Proper way to handle errors in a module

2011-05-11 Thread Andrew Berg
On 2011.05.11 12:57 PM, Patty wrote: Hi Andrew - Sometimes you want an exception come up and then use that information to take your program in some direction. Right, but I'm wondering how I should handle errors in a module, where different people will want their programs to do different

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 13:50:54 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: : I find this argument to be flawed. Should I stop using built-in : generators instead of range/xrange for looping through lists? : Certainly for loops with loop counting are understood more widely : than

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Terry Reedy
On 5/11/2011 12:27 PM, Genstein wrote: In py3k is it necessary to flush() a file between read/write calls in order to see consistent results? I ask because I have a case under Python 3.2 (r32:88445) where it does appear to be, on both Gentoo Linux and Windows Vista. I've naturally read

lightweight way to create new projects from templates

2011-05-11 Thread Jonathan Hartley
Hi. I'm looking for a quick way to create new Python projects from a template. I understand that 'Paste' (http://pythonpaste.org/) is one way to do this, but I find Paste very intimidating because of all the functionality it includes. I'm not even sure whether 'creating new projects from

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
Common to what? I'd try the lowest common denominator of legibility and effictiveness. It is just KISS. Fair enough. I am a sheep, so I do what other (more knowledgeable) people do. It is a fair assumption (for my specific code writing environments) that everyone who is going to read my code

Re: checking if a list is empty

2011-05-11 Thread Ethan Furman
Hans Georg Schaathun wrote: On Wed, 11 May 2011 13:50:54 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: : I find this argument to be flawed. Should I stop using built-in : generators instead of range/xrange for looping through lists? : Certainly for loops with loop counting are

Re: checking if a list is empty

2011-05-11 Thread Chris Torek
In article 4dcab8bf$0$29980$c3e8da3$54964...@news.astraweb.com Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: When you call len(x) you don't care about the details of how to calculate the length of x. The object itself knows so that you don't have to. The same applies to truth

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Genstein
On 11/05/2011 19:24, Terry Reedy wrote: writing and reading. If you want others to look at this more, you should 1) produce a minimal* example that demonstrates the questionable behavior, and 2) show the comparative outputs that raise your question. Thanks for a quick response. Perhaps I was

RE: checking if a list is empty

2011-05-11 Thread Prasad, Ramit
Someone who knows how to program is never clueless starting a new language. Newbie, may be, but he knows most of the constructions and semantic principles to look for; most of it is learning the syntax. I claim to be able to program (Java/Python), but would be absolutely lost programming in

RE: Proper way to handle errors in a module

2011-05-11 Thread Prasad, Ramit
The simple but code heavy system is to create two functions. One that raises an error and one that returns None or something that is mutually agreed to be invalid. You can even get away with one of them doing the actual work and the other one just as a wrapper. I feel too lazy to fix the

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 14:59:34 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: : Fair enough. I am a sheep, so I do what other (more knowledgeable) : people do. It is a fair assumption (for my specific code writing : environments) that everyone who is going to read my code understands :

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 12:17:33 -0700, Ethan Furman et...@stoneleaf.us wrote: : 'if li' *is* KISS. It /might/ be in some contexts, but a priori it is not, as it superimposes a truth value on a data type which is otherwise a pretty accurate model of real objects (outside python). One principle of

Re: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On Wed, 11 May 2011 14:44:37 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: : Someone who knows how to program is never clueless starting a new : language. Newbie, may be, but he knows most of the constructions : and semantic principles to look for; most of it is learning the syntax. :

How to deal with optional argument evaluation

2011-05-11 Thread Rodrick Brown
I'm having a hard time dealing with the following scenario My class takes a hash like the following: rdargs = {'env:'prod','feed':'opra','hostname':'host13dkp1','process':'delta','side':'a','zone','ny'} All the keys in this hash can be optional. I'm having a hard time dealing with all 36

Re: checking if a list is empty

2011-05-11 Thread Ian
On 11/05/2011 20:13, Hans Georg Schaathun wrote: On Wed, 11 May 2011 12:17:33 -0700, Ethan Furman et...@stoneleaf.us wrote: : 'if li' *is* KISS. It /might/ be in some contexts, but a priori it is not, as it superimposes a truth value on a data type which is otherwise a pretty accurate

Re: How to deal with optional argument evaluation

2011-05-11 Thread Ethan Furman
Rodrick Brown wrote: I'm having a hard time dealing with the following scenario My class takes a hash like the following: rdargs = {'env:'prod','feed':'opra','hostname':'host13dkp1','process':'delta','side':'a','zone','ny'} All the keys in this hash can be optional. I'm having a hard time

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Hans Georg Schaathun wrote: Code is quite often published to document algorithms, methods and formulæ for the purpose of scientific research. Since there is no universal language which suits everything and everyone, this is exactly what happens. One has to have the rudimentary knowledge to

Re: checking if a list is empty

2011-05-11 Thread harrismh777
D'Arcy J.M. Cain wrote: Non-programmers should be able to program? Should non-doctors be able to doctor? Should cars be built so that anyone can intuitively fix them without a mechanic? Non-programmers should not be expected to program in 'C' nor in lisp... ... but non-programmers

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Terry Reedy
On 5/11/2011 3:08 PM, Genstein wrote: On 11/05/2011 19:24, Terry Reedy wrote: writing and reading. If you want others to look at this more, you should 1) produce a minimal* example that demonstrates the questionable behavior, and 2) show the comparative outputs that raise your question.

unicode by default

2011-05-11 Thread harrismh777
hi folks, I am puzzled by unicode generally, and within the context of python specifically. For one thing, what do we mean that unicode is used in python 3.x by default. (I know what default means, I mean, what changed?) I think part of my problem is that I'm spoiled (American, ascii

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 19:05:03 +, Chris Torek wrote: In article 4dcab8bf$0$29980$c3e8da3$54964...@news.astraweb.com Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: When you call len(x) you don't care about the details of how to calculate the length of x. The object itself knows

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: One principle of object oriented programming is to bestow the objects with properties reflecting known properties from the domain being modelled. Lists do not have truth values in the application domain Yes they do. Empty lists

Re: checking if a list is empty

2011-05-11 Thread Steven Howe
On 05/11/2011 02:47 PM, Steven D'Aprano wrote: On Wed, 11 May 2011 20:13:35 +0100, Hans Georg Schaathun wrote: One principle of object oriented programming is to bestow the objects with properties reflecting known properties from the domain being modelled. Lists do not have truth values in

Re: unicode by default

2011-05-11 Thread Ian Kelly
On Wed, May 11, 2011 at 3:37 PM, harrismh777 harrismh...@charter.net wrote: hi folks,   I am puzzled by unicode generally, and within the context of python specifically. For one thing, what do we mean that unicode is used in python 3.x by default. (I know what default means, I mean, what

Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-11 Thread Hans Mulder
On 03/05/2011 09:52, rusi wrote: [If you believe it is, then try writing a log(n) fib iteratively :D ] It took me a while, but this one seems to work: from collections import namedtuple Triple = namedtuple('Triple', 'hi mid lo') Triple.__mul__ = lambda self, other: Triple( self.hi *

Re: py3k buffered IO - flush() required between read/write?

2011-05-11 Thread Martin P. Hellwig
On 11/05/2011 19:08, Genstein wrote: On 11/05/2011 19:24, Terry Reedy wrote: writing and reading. If you want others to look at this more, you should 1) produce a minimal* example that demonstrates the questionable behavior, and 2) show the comparative outputs that raise your question. Thanks

Re: unicode by default

2011-05-11 Thread Benjamin Kaplan
On Wed, May 11, 2011 at 2:37 PM, harrismh777 harrismh...@charter.net wrote: hi folks,   I am puzzled by unicode generally, and within the context of python specifically. For one thing, what do we mean that unicode is used in python 3.x by default. (I know what default means, I mean, what

Re: checking if a list is empty

2011-05-11 Thread harrismh777
Steven D'Aprano wrote: modelled. Lists do not have truth values in the application domain Yes they do. Empty lists are nothing, ergo false, and non-empty lists are something, ergo true. No they don't. Empty lists are empty lists... which just happen to become False when type cast

Re: Merge multiple source directories into one package with distutils?

2011-05-11 Thread Gregory Ewing
Miki Tebeka wrote: .py files from more than one source directory into a single package when installing? The Selenium Python bindings does something like that, have a look at http://selenium.googlecode.com/svn/trunk/setup.py Unless I'm missing something, nothing out of the ordinary is

Re: unicode by default

2011-05-11 Thread harrismh777
Ian Kelly wrote: Ian, Benjamin, thanks much. The `unicode' class was renamed to `str', and a stripped-down version of the 2.X `str' class was renamed to `bytes'. ... thank you, this is very helpful. If I do not specify any code points above ascii 0xFF does any of this matter

Re: checking if a list is empty

2011-05-11 Thread Gregory Ewing
Hans Georg Schaathun wrote: 0 is a number as real and existent as any other, one would think that the empty list is also as real and existent as any other list. 0 does have some special properties, though, such as being the additive identity and not having a multiplicative inverse. Adding

Re: checking if a list is empty

2011-05-11 Thread harrismh777
harrismh777 wrote: Lists by themselves, empty or not, cannot have a 'truth' in an of themselves. ... forgot., Based on Ian's comment a couple of days ago... if alist: ... is actually : if bool(alist): I think this is more than just semantics or silly argumentation.

Re: unicode by default

2011-05-11 Thread John Machin
On Thu, May 12, 2011 8:51 am, harrismh777 wrote: Is it true that if I am working without using bytes sequences that I will not need to care about the encoding anyway, unless of course I need to specify a unicode code point? Quite the contrary. (1) You cannot work without using bytes

urllib2 request with binary file as payload

2011-05-11 Thread Michiel Sikma
Hi there, I made a small script implementing a part of Youtube's API that allows you to upload videos. It's pretty straightforward and uses urllib2. The script was written for Python 2.6, but the server I'm going to use it on only has 2.5 (and I can't update it right now, unfortunately). It seems

Re: urllib2 request with binary file as payload

2011-05-11 Thread John Machin
On Thu, May 12, 2011 10:20 am, Michiel Sikma wrote: Hi there, I made a small script implementing a part of Youtube's API that allows you to upload videos. It's pretty straightforward and uses urllib2. The script was written for Python 2.6, but the server I'm going to use it on only has 2.5

pymultimouse access violation error

2011-05-11 Thread jpiee
A couple of years back Oscar Lindberg wrote a program called pymultimouse, which has a homepage at http://code.google.com/p/pymultimouse/. I've been using the file rawinputreader.py, which is avaliable in the zipped folder in the downloads section of the above link. I'm trying to get raw

Re: checking if a list is empty

2011-05-11 Thread Steven D'Aprano
On Wed, 11 May 2011 17:38:58 -0500, harrismh777 wrote: Steven D'Aprano wrote: modelled. Lists do not have truth values in the application domain Yes they do. Empty lists are nothing, ergo false, and non-empty lists are something, ergo true. No they don't. Empty lists are empty lists...

Re: unicode by default

2011-05-11 Thread harrismh777
John Machin wrote: (1) You cannot work without using bytes sequences. Files are byte sequences. Web communication is in bytes. You need to (know / assume / be able to extract / guess) the input encoding. You need to encode your output using an encoding that is expected by the consumer (or use an

Re: unicode by default

2011-05-11 Thread MRAB
On 12/05/2011 02:22, harrismh777 wrote: John Machin wrote: (1) You cannot work without using bytes sequences. Files are byte sequences. Web communication is in bytes. You need to (know / assume / be able to extract / guess) the input encoding. You need to encode your output using an encoding

Re: unicode by default

2011-05-11 Thread Steven D'Aprano
On Thu, 12 May 2011 03:31:18 +0100, MRAB wrote: Another question... in mail I'm receiving many small blocks that look like sprites with four small hex codes, scattered about the mail... mostly punctuation, maybe? ... guessing, are these unicode code points, and if so what is the best way to

Re: checking if a list is empty

2011-05-11 Thread alex23
Hans Georg Schaathun h...@schaathun.net wrote: Revolutionary indeed, so why don't we exploit the revolution and write the programs to be as accessible as possible? Where do you draw the line, though? No decorators, as they're not intuitively obvious? No custom descriptors, as that requires a

Re: checking if a list is empty

2011-05-11 Thread alex23
On May 12, 7:24 am, harrismh777 harrismh...@charter.net wrote:  We need to move away from 'canned apps' to a new day where the masses can sit down to their computer and solve new problems with it through intuitive language skills.  Why not? Because the vast majority of them don't seem to want

Learning new languages (was: checking if a list is empty)

2011-05-11 Thread Teemu Likonen
* 2011-05-11T20:26:48+01:00 * Hans Georg Schaathun wrote: On Wed, 11 May 2011 14:44:37 -0400, Prasad, Ramit ramit.pra...@jpmchase.com wrote: I claim to be able to program (Java/Python), but would be absolutely lost programming in Lisp. It is more than just learning the syntax, it includes

Re: unicode by default

2011-05-11 Thread harrismh777
Steven D'Aprano wrote: You need to understand the difference between characters and bytes. http://www.joelonsoftware.com/articles/Unicode.html is also a good resource. Thanks for being patient guys, here's what I've done: astr=pound sign asym= \u00A3 afile=open(myfile, mode='w')

  1   2   3   >