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): threading.Thread.__init_

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Wed, May 11, 2011 at 4:57 PM, vijay swaminathan 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 understanding

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Gabriel Genellina
En Wed, 11 May 2011 03:57:13 -0300, vijay swaminathan 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 MyThread(threading.Thread):

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread James Mills
On Wed, May 11, 2011 at 4:57 PM, vijay swaminathan 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 get automatically

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 gather

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 wrote: > so If i understand correctly, once the run method of the thread is executed, > the thread is n

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

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 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 to test. The only problem migh

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 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 it is a polymorphic test which is

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

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 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 about developing ideas

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Wed, May 11, 2011 at 7:08 PM, vijay swaminathan 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 python-list@python.o

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

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 (http://www.mediafire

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 (http://www.mediafire.com/?lb

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 compu

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 compu

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" wrote: Sorry for a silly subject change:

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 wri

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 fea

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 w

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 y

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

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 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: checking if a list is empty

2011-05-11 Thread Hans Georg Schaathun
On 11 May 2011 12:14:46 GMT, Steven D'Aprano 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 with the reader and not the writer.

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 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 > language or ar

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 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 also mean "if

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 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, generator : expressions, inheritance, itera

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 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, the particular in

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 : > On Wed, May 11, 2011 at 7:08 PM, vijay swaminathan wrote: >> Sorry. My intention was not to send out a private message.

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak 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 of QThread? Is it

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

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

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 ti

Re: NewBie Doubt in Python Thread Programming

2011-05-11 Thread Wojtek Mamrak
2011/5/11 Chris Angelico : > On Thu, May 12, 2011 at 1:16 AM, Wojtek Mamrak 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 ar

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 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 literally no idea what to m

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 >wrote: > : Do you think that we should avoid chained comparisons, class methods, > : closures, co-routines, decorators, default values to functions, : > delegation, doc tests, exc

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 u

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 Wind

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 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 is not a Python pr

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

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 so

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 fla

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 stri

Re: Proper way to handle errors in a module

2011-05-11 Thread Patty
- Original Message - From: "Andrew Berg" To: 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 what is considered the best way to handle errors

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 trigger

Re: Proper way to handle errors in a module

2011-05-11 Thread Roy Smith
In article , 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 trigge

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 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 I were God, I mi

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 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 *about Python*. I don't care how

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 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 : instead of shoving a

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 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. Revolutionary indeed, s

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 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 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 generators. Should I stop using

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

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 temp

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

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 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 testing. > >I have a data type that

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 be

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 mistak

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 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 : "if x:" notation or is expe

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 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 object oriented pr

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 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. : : I claim to be able

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 possibl

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

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 read

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 were

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

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 he

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

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 list

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 the

Re: unicode by default

2011-05-11 Thread Ian Kelly
On Wed, May 11, 2011 at 3:37 PM, harrismh777 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 changed?) The `unicode'

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

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 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 changed?) > >   I think p

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 bool(lis

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 happenin

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 fals

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 seque

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 t

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.

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 mou

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 empt

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 tha

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 w

Re: checking if a list is empty

2011-05-11 Thread alex23
Hans Georg Schaathun 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 deeper knowledge o

Re: checking if a list is empty

2011-05-11 Thread alex23
On May 12, 7:24 am, harrismh777 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 to be bothered? -- h

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 >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 a thought paradi

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

Re: checking if a list is empty

2011-05-11 Thread Chris Torek
In article <4dc6a39a$0$29991$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano wrote: >In English, [the word "not"] negates a word or statement: > >"the cat is not on the mat" --> "the cat is on the mat" is false. As a mostly off topic aside, English is considerably more complicated than that.

Re: checking if a list is empty

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 7:02 AM, Ian wrote: > In the "real world"  lists of zero items do not exist. > You don't go shopping with a shopping list of zero items. Actually, yes you do. You maintain your shopping list between trips; whenever you need something, you put it on the list immediately. Th

  1   2   >