which datastructure for fast sorted insert?

2008-05-24 Thread notnorwegian
im writing a webcrawler. after visiting a new site i want to store it in alphabetical order. so obv i want fast insert. i want to delete duplicates too. which datastructure is best for this? -- http://mail.python.org/mailman/listinfo/python-list

True random number generator

2008-05-24 Thread Zerge
truerandom.py is a Python module that generates true random numbers obtained from www.random.org. Use with the form: mylist=truerandom.getnum(min,max,amount) mylist will be a list containing the true random numbers. If for some reason the numbers cannot be generated, the list will contain -1. Y

Re: finding icons for Apps

2008-05-24 Thread Neil Hodgson
Sanoski: Where can I find icons to use with my programs? http://sourceforge.net/projects/icon-collection/ Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: module import problem

2008-05-24 Thread Matt Nordhoff
Milos Prudek wrote: > I have a Kubuntu upgrade script that fails to run: > > File "/tmp/kde-root//DistUpgradeFetcherCore.py", > line 34, in > import GnuPGInterface > ImportError > No module named GnuPGInterface > > I got a folder /usr/share/python-support/python-gnupginterface with > a "GnuPGI

Re: why is com-prompt faster and how do i start at cprompt at mydir/ ?

2008-05-24 Thread Gabriel Genellina
En Sat, 24 May 2008 00:30:10 -0300, <[EMAIL PROTECTED]> escribió: > when running a very computationalheavy program in the shell it > sometimes freezes but the commandprompt runs it without problems and > muh faster, why? My Palantir isn't working very well lately, so it's hard to tell what's wron

Re: function returns , but variable values has not changed in the interactive prompt

2008-05-24 Thread Gabriel Genellina
En Fri, 23 May 2008 16:04:43 -0300, davidj411 <[EMAIL PROTECTED]> escribió: > if you run execfile function to run a python script and that script > has variables and functions, should't those variable change in the > interactive prompt too? Yes, they do: C:\TEMP>type test.py a = 123 def foo():

Re: How to print a sorted list as a multi-column table

2008-05-24 Thread Gabriel Genellina
En Fri, 23 May 2008 15:03:16 -0300, Mensanator <[EMAIL PROTECTED]> escribió: > On May 23, 10:30 am, Sverker Nilsson <[EMAIL PROTECTED]> wrote: >> Why are tables formatted like the following, when sorted? (Both in >> linux eg ls, ftp help, and in Python help() when listing (eg) >> modules)) >> >> (

Re: Google Treasure solution in python - first time python user, help whats wrong

2008-05-24 Thread Gabriel Genellina
En Fri, 23 May 2008 05:40:26 -0300, x40 <[EMAIL PROTECTED]> escribió: > I try to learn python thru solving some interisting problem, found > google trasure hunt, > write first program ( but cant find whats wrong). And what happens? You don't get the expected result? The program aborts with an ex

finding icons for Apps

2008-05-24 Thread Sanoski
This might be a dumb question. I don't know. I'm new to all this. How do you find icons for your programs? All GUI applications have cool icons that represent various things. For instance, to save is often represented as a disk, etc. You know, the small little picture references that give meaning t

Re: class-oriented rather than object-oriented?

2008-05-24 Thread Michele Simionato
On May 25, 4:34 am, [EMAIL PROTECTED] wrote: > i have some confusion over this. > > sure a class is basically a classification, like for example an animal > or flower. and an object/instance of that class is then for example a > cat. > > an object is an instance of a class. that i know, i also know

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Aahz
In article <[EMAIL PROTECTED]>, Sh4wn <[EMAIL PROTECTED]> wrote: > >first, python is one of my fav languages, and i'll definitely keep >developing with it. But, there's 1 one thing what I -really- miss: >data hiding. I know member vars are private when you prefix them with >2 underscores, but I ha

Re: class-oriented rather than object-oriented?

2008-05-24 Thread Ben Finney
[EMAIL PROTECTED] writes: > does object-oriented refer to that everything(strings, ints etc) are > all objects? so there is a class string somewhere in the > implementation rather than a primitive or somehing? The term is used (and abused) in different ways. The term "object oriented" is usually

Re: Decorator metaclass

2008-05-24 Thread Gabriel Genellina
En Fri, 23 May 2008 16:25:19 -0300, Thomas Karolski <[EMAIL PROTECTED]> escribió: > Turns out the first msg I sent did not reach the list, so I'll just post > what I've achieved by now: [snip a couple of long metaclasses] > Now the reason why I'm using decorators, is because I want to be ably t

class-oriented rather than object-oriented?

2008-05-24 Thread notnorwegian
i have some confusion over this. sure a class is basically a classification, like for example an animal or flower. and an object/instance of that class is then for example a cat. an object is an instance of a class. that i know, i also know how to program with classes etc. i am just confused abo

Re: Code correctness, and testing strategies

2008-05-24 Thread Michael L Torrie
David wrote: > Seriously, 10 hours of testing for code developed in 10 hours? What > kind of environment do you write code for? This may be practical for > large companies with hordes of full-time testing & QA staff, but not > for small companies with just a handful of developers (and where you > n

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > Yes! One of the biggest advantages to unit testing is that you never > ever deliver the same bug to the client twice. More specifically, this is a benefit of putting all unit tests into an automated test suite, and running that test suite all the t

Re: Loading contents behind the scenes

2008-05-24 Thread Gabriel Genellina
En Thu, 22 May 2008 14:05:42 -0300, MRAB <[EMAIL PROTECTED]> escribió: > On May 22, 3:20 pm, [EMAIL PROTECTED] wrote: >> > > In my case, what I'm doing is sending the return value through a >> > > socket: >> >> > > sock.send(f.read()) >> >> > I would go with: > > f = file("filename", "rb") > while

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > On Sat, 24 May 2008 17:51:23 +0200 > David <[EMAIL PROTECTED]> wrote: > > If I did start doing some kind of TDD, it would be more of the > > 'smoke test' variety. Call all of the functions with various > > parameters, test some common scenarios, all

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
Duncan Booth <[EMAIL PROTECTED]> writes: > You still need human testing and QA, the difference is that with a > good set of unit tests you reduce the number of times code comes > back from QA before it can be passed and make it more likely that > the customer will be happy with the first version.

Re: Code correctness, and testing strategies

2008-05-24 Thread Terry Reedy
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | > But once you track down problems like the above you can write more | > unit tests to catch those exact bugs in the future. This is one case | > where I do favour unit tests. | | Yes! One of the biggest advantages

Re: Showing the method's class in expection's traceback

2008-05-24 Thread Gabriel Genellina
En Thu, 22 May 2008 07:55:44 -0300, Duncan Booth <[EMAIL PROTECTED]> escribió: > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >> Not to say that your concerns are pointless, and that things cannot be >> improved somehow, but this is not that trivial, and there may be >> ambuiguities in some not

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
Roy Smith <[EMAIL PROTECTED]> writes: > But, you are right, there are certainly cases which are difficult or > impossible to test for. TDD is a very powerful tool, but it's just > that: a tool. It's not a magic wand. > > My suggestion is to make using TDD a habit, but don't turn it into a > relig

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
David <[EMAIL PROTECTED]> writes: > Is it considered to be cheating if you make a test case which always > fails with a "TODO: Make a proper test case" message? I consider it so. What I often do, though, is write a TODO comment in the unit test suite: # TODO: test_frobnitz_produces_widget_f

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Terry Reedy
"Benjamin Kaplan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Sat, May 24, 2008 at 10:14 AM, Fuzzyman <[EMAIL PROTECTED]> wrote: || > For example, at Resolver Systems we expose the spreadsheet object | > model to our users. It hasa public, documented, API - plus a host of | >

Re: Assignment and comparison in one statement

2008-05-24 Thread Carl Banks
On May 24, 7:12 am, Johannes Bauer <[EMAIL PROTECTED]> wrote: > Carl Banks schrieb: > > > p = myfunction() > > if p: > > print p > > > (I recommend doing it this way in C, too.) > > This is okay for if-clauses, but sucks for while-loops: > > while (fgets(buf, sizeof(buf), f)) { > printf

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
David <[EMAIL PROTECTED]> writes: > Problem 1: You can only code against tests > > Basically, with TDD you write the tests first, then the code which > passes/fails the tests as appropriate. However, as you're writing > the code you will also think of a lot of corner cases you should > also handl

Re: Assignment and comparison in one statement

2008-05-24 Thread William McBrine
On Sat, 24 May 2008 13:12:13 +0200, Johannes Bauer wrote: > char *tmp; > tmp = fgets(buf, sizeof(buf), f); > while (tmp) { > printf("%s\n", buf); > tmp = fgets(buf, sizeof(buf), f); > } I think a more Pythonic way to write this, in general, would be: while (1) { char *tmp = fgets

Re: problem with import / namespace

2008-05-24 Thread Gabriel Genellina
En Sat, 24 May 2008 08:57:37 -0300, ohad frand <[EMAIL PROTECTED]> escribió: > Thanks for your reply but it stil didnt work: > i opened python shell, changed active directory to \\one and imported tmp1. > now the correct file is loaded. > now i deleted tmp1 > i dir os.chdir(\\two) and imported tmp

Re: Organizing a Python project

2008-05-24 Thread Gabriel Genellina
En Wed, 21 May 2008 07:44:50 -0300, Casey McGinty <[EMAIL PROTECTED]> escribió: Just my own opinion on these things: > 1. Script code should be as basic as possible, ideally a module import line > and function or method call. This is so you don't have to worry about script > errors and/or increas

Re: Python, Daemons and D-Bus

2008-05-24 Thread PurpleServerMonkey
On May 25, 5:46 am, Sebastian 'lunar' Wiesner <[EMAIL PROTECTED]> wrote: > [ PurpleServerMonkey <[EMAIL PROTECTED]> ] > > > Would you use D-Bus or a more traditional IPC method such as sockets? > > Although D-Bus is relatively new it looks interesting, just not sure > > it would work well in this k

Re: Newbie Question: How to use a .pth file on a Macintosh

2008-05-24 Thread J Peyret
Hmmm, for lack of a better response, here are some suggestions, based on what I've seen on Windows+Linux. #1 put the .pth in the site-packages directory (this is what I do on Linux). I think Python considers it special and looks for pth. you can probably get that directory from doing import sys

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread John Machin
Sebastian 'lunar' Wiesner wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [ zxo102 <[EMAIL PROTECTED]> ] how to change the hexadecimal 'ED6F3C01' (or 'ED 6F 3C 01') to "\xED\x6F\x3C\x01" in python coding? When I take 'ED6F3C01' as a string and insert '\x' into it, I just got the error

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread John Machin
zxo102 wrote: Hi, how to change the hexadecimal 'ED6F3C01' (or 'ED 6F 3C 01') to "\xED\x6F\x3C\x01" in python coding? If by "in python coding" you mean "in Python source code", then just type it in with \x in front of each pair of hex digits, like you did above. However if you mean e.g.

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread J. Clifford Dyer
On Sat, 2008-05-24 at 15:59 -0700, zxo102 wrote: > But this is not "\xED\x6F\x3C\x01". I need it for > struct.unpack('f',"\xED\x6F\x3C\x01") to calculate the decimal value > (IEEE 754). > Any other suggestions? > > ouyang > In fact it is exactly the same string. The repr of a string always sub

webspider getting stuck

2008-05-24 Thread notnorwegian
i am writing a simple webspider . how do i avoid getting stuck at something like this: Enter username for W3CACL at www.w3.org: ? i can obv add an if-clause for the specific site but since i guess there will be more of the same thats ov not a viable approach in the long run. -- http://mail.pytho

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread J. Clifford Dyer
On Sat, 2008-05-24 at 15:36 -0700, zxo102 wrote: > Hi, >how to change the hexadecimal 'ED6F3C01' (or 'ED 6F 3C 01') to > "\xED\x6F\x3C\x01" in python coding? > When I take 'ED6F3C01' as a string and insert '\x' into it, I just got > the error information : invalid \x escape. >Thanks. > >

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread zxo102
On 5月25日, 上午6时59分, zxo102 <[EMAIL PROTECTED]> wrote: > But this is not "\xED\x6F\x3C\x01". I need it for > struct.unpack('f',"\xED\x6F\x3C\x01") to calculate the decimal value > (IEEE 754). > Any other suggestions? > > ouyang > > On 5月25日, 上午6时46分, Sebastian 'lunar' Wiesner <[EMAIL PROTECTED]> > w

Re: for some reason the actual tries figure is not right

2008-05-24 Thread Gabriel Genellina
En Sat, 24 May 2008 15:32:56 -0300, garywood <[EMAIL PROTECTED]> escribió: > can someone explain why the tries displays the wrong number > thanks > orginally i started off with tries = 0 but it was off by 2 How would you count that if you were playing the game "for real"? I'd say that you start

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread zxo102
But this is not "\xED\x6F\x3C\x01". I need it for struct.unpack('f',"\xED\x6F\x3C\x01") to calculate the decimal value (IEEE 754). Any other suggestions? ouyang On 5月25日, 上午6时46分, Sebastian 'lunar' Wiesner <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > [ zxo102

Re: Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread Sebastian 'lunar' Wiesner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [ zxo102 <[EMAIL PROTECTED]> ] >how to change the hexadecimal 'ED6F3C01' (or 'ED 6F 3C 01') to > "\xED\x6F\x3C\x01" in python coding? > When I take 'ED6F3C01' as a string and insert '\x' into it, I just got > the error information : invalid \x es

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Paddy
On May 24, 3:14 pm, Fuzzyman <[EMAIL PROTECTED]> wrote: > On May 24, 2:58 pm, Ben Finney <[EMAIL PROTECTED]> > wrote: > > > Sh4wn <[EMAIL PROTECTED]> writes: > > > first, python is one of my fav languages, and i'll definitely keep > > > developing with it. But, there's 1 one thing what I -really- m

Re: module import problem

2008-05-24 Thread Sebastian 'lunar' Wiesner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [ Milos Prudek <[EMAIL PROTECTED]> ] > If I cd into /usr/share/python-support/python-gnupginterface and launch > Python I can "import GnuPGInterface". But when I run > DistUpgradeFetcherCore.py in that folder it always fails with No module > named Gnu

Hexadecimal: how to convert 'ED6F3C01' to "\xED\x6F\x3C\x01" in python coding?

2008-05-24 Thread zxo102
Hi, how to change the hexadecimal 'ED6F3C01' (or 'ED 6F 3C 01') to "\xED\x6F\x3C\x01" in python coding? When I take 'ED6F3C01' as a string and insert '\x' into it, I just got the error information : invalid \x escape. Thanks. ouyang -- http://mail.python.org/mailman/listinfo/python-list

module import problem

2008-05-24 Thread Milos Prudek
I have a Kubuntu upgrade script that fails to run: File "/tmp/kde-root//DistUpgradeFetcherCore.py", line 34, in import GnuPGInterface ImportError No module named GnuPGInterface I got a folder /usr/share/python-support/python-gnupginterface with a "GnuPGInterface.py" but no __init__.py. In pyt

Re: Code correctness, and testing strategies

2008-05-24 Thread Roy Smith
David <[EMAIL PROTECTED]> wrote: > While it is possible to describe all problems in docs, it can be very > hard to write actual test code. > > For example: sanity tests. Functions can have tests for situations > that can never occur, or are very hard to reproduce. How do you unit > test for those

Re: Code correctness, and testing strategies

2008-05-24 Thread Roy Smith
David <[EMAIL PROTECTED]> wrote: > Problem 1: You can only code against tests Yup. That's the flavor of Kool-Aide being served at a convenient TDD outlet near you. > Basically, with TDD you write the tests first, then the code which > passes/fails the tests as appropriate. However, as you're wr

Re: Code correctness, and testing strategies

2008-05-24 Thread Casey McGinty
> Seriously, 10 hours of testing for code developed in 10 hours? What > > kind of environment do you write code for? This may be practical for > > large companies with hordes of full-time testing & QA staff, but not > > for small companies with just a handful of developers (and where you > > need t

Newbie Question: How to use a .pth file on a Macintosh

2008-05-24 Thread Robbie
Hello All, Hopefully this is an easy question: I'd like to use a .pth file on my Macintosh so that I can easily import modules that I've created in my own working directory. I've created a file called Robbie.pth. It includes a single line: /Robbie/PythonWork I can't seem to figure out where

Re: Code correctness, and testing strategies

2008-05-24 Thread Duncan Booth
David <[EMAIL PROTECTED]> wrote: > So, at what point do you start writing unit tests? Do you decide: > "Version 1 I am going to definitely throw away and not put it into > production, but version 2 will definitely go into production, so I > will start it with TDD?". If you are going to prototype

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Benjamin Kaplan
On Sat, May 24, 2008 at 10:14 AM, Fuzzyman <[EMAIL PROTECTED]> wrote: > On May 24, 2:58 pm, Ben Finney <[EMAIL PROTECTED]<[EMAIL PROTECTED]> > > > wrote: > > Sh4wn <[EMAIL PROTECTED]> writes: > > > first, python is one of my fav languages, and i'll definitely keep > > > developing with it. But, th

Re: Code correctness, and testing strategies

2008-05-24 Thread D'Arcy J.M. Cain
On Sat, 24 May 2008 21:14:36 +0200 David <[EMAIL PROTECTED]> wrote: > Is it considered to be cheating if you make a test case which always > fails with a "TODO: Make a proper test case" message? Yes. It's better to have the daily reminder that some code needs to be finished. > While it is possib

Re: Code correctness, and testing strategies

2008-05-24 Thread Patrick Mullen
I can see both sides of this argument, and I think TDD is great in some cases and not so great in others. I have used it before, but don't use it often, as the programs I write are very difficult to automatically test. (Games, which many of the bugs have to do with whether an optimization produces

Re: Code correctness, and testing strategies

2008-05-24 Thread D'Arcy J.M. Cain
On Sat, 24 May 2008 17:51:23 +0200 David <[EMAIL PROTECTED]> wrote: > Basically, with TDD you write the tests first, then the code which > passes/fails the tests as appropriate. However, as you're writing the > code you will also think of a lot of corner cases you should also > handle. The natural

Re: Code correctness, and testing strategies

2008-05-24 Thread David
>> In order to get a new system working, it's nice to be able to throw >> together a set of modules quickly, and if that doesn't work, scrap it >> and try something else. There's a rule (forget where) that your first >> system will always be a prototype, regardless of intent. > > That's fine. It's

Re: persistent deque version 4

2008-05-24 Thread Gabriel Genellina
En Thu, 22 May 2008 12:20:56 -0300, inhahe <[EMAIL PROTECTED]> escribió: > I thought about the fact that a decorator is merely syntactic sugar, so it > shouldn't have any closure magic that I can't make myself, and I realized > that I could have done it the following way: > > def makefunc(func): >

Re: Overloading __getitem__

2008-05-24 Thread Gabriel Genellina
En Thu, 22 May 2008 20:38:39 -0300, Andreas Matthias <[EMAIL PROTECTED]> escribió: > [EMAIL PROTECTED] wrote: > >> actually i ddin't think about the fact that you're overloading dict, which >> can already take multiple values in getitem > > Oh, I didn't know that. I totally misinterpreted the err

Re: Python, Daemons and D-Bus

2008-05-24 Thread Sebastian 'lunar' Wiesner
[ PurpleServerMonkey <[EMAIL PROTECTED]> ] > Would you use D-Bus or a more traditional IPC method such as sockets? > Although D-Bus is relatively new it looks interesting, just not sure > it would work well in this kind of project. DBus is not really intended for private communication between pro

Re: Scipy+SQLite crashes... , was: Re: SQLite import fails sometimes ?

2008-05-24 Thread Stef Mientki
hello, through the scipy group I found a solution (no explanation yet), import sqlite3 from scipy import * solves the problem. cheers, Stef Stef Mientki wrote: John Machin wrote: Stef Mientki wrote: I don't know if this matters, but I also use sqlite3 from other than Python programs.

Re: need some help in serving static files inside a wsgi apps

2008-05-24 Thread Sebastian 'lunar' Wiesner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [ Diez B. Roggisch <[EMAIL PROTECTED]> ] >> I finally managed to work with static files with a little hack, but it's >> ugly because I'm reading each static file per request. > > How else should that work? Apache does that the same way. I guess, Apac

Re: Code correctness, and testing strategies

2008-05-24 Thread David
Hi again list. > > As you come up with the corner case, write a test for it and leave the > implementation > for later. The hard part of coding is always defining your problem. Once it is > defined (by a test) the solution is just a matter of tidy work. > Is it considered to be cheating if you m

for some reason the actual tries figure is not right

2008-05-24 Thread garywood
can someone explain why the tries displays the wrong number thanks orginally i started off with tries = 0 but it was off by 2 # Word Jumble # # The computer picks a random word # The player has to guess the original word can give hint import random tries = 1 # create a sequence of words to

Re: Relationship between GUI and logic?

2008-05-24 Thread Matthew Woodcraft
David C. Ullrich <[EMAIL PROTECTED]> wrote: > Matthew Woodcraft <[EMAIL PROTECTED]> wrote: >> For example, if you were writing the 'logic' for a chess program you >> might choose a way of modelling the board that can't represent a >> position with more than one black king. And then when you got ro

Re: csv iterator question

2008-05-24 Thread David Jackson
Thanks, Ethan. that was a great solution. i just tested it. On Fri, May 23, 2008 at 7:08 PM, Ethan Furman <[EMAIL PROTECTED]> wrote: > davidj411 wrote: > > When you save an open file to a variable, you can re-use that variable >> for membership checking. >> it does not seem to be that way with

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Sh4wn
On 24 mei, 15:58, Ben Finney <[EMAIL PROTECTED]> wrote: > Sh4wn <[EMAIL PROTECTED]> writes: > > first, python is one of my fav languages, and i'll definitely keep > > developing with it. But, there's 1 one thing what I -really- miss: > > data hiding. I know member vars are private when you prefix t

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Fuzzyman
On May 24, 6:18 pm, [EMAIL PROTECTED] wrote: > Ben Finney: > > >In Python, the philosophy "we're all consenting adults here" applies.< > > Michael Foord: > > > They will use whatever they find, whether it is the best way to > > achieve a goal or not. Once they start using it they will expect us to

Re: Code correctness, and testing strategies

2008-05-24 Thread Duncan Booth
David <[EMAIL PROTECTED]> wrote: > Problem 2: Slows down prototyping > > In order to get a new system working, it's nice to be able to throw > together a set of modules quickly, and if that doesn't work, scrap it > and try something else. There's a rule (forget where) that your first > system wi

Re: need some help in serving static files inside a wsgi apps

2008-05-24 Thread Diez B. Roggisch
kib schrieb: Diez B. Roggisch a écrit : Tool69 schrieb: Hi, Until now, I was running my own static site with Python, but I'm in need of dynamism. After reading some cgi tutorials, I saw Joe Gregorio's old article "Why so many Python web frameworks?" about wsgi apps [http:// bitworking.org/new

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread bearophileHUGS
Ben Finney: >In Python, the philosophy "we're all consenting adults here" applies.< Michael Foord: > They will use whatever they find, whether it is the best way to > achieve a goal or not. Once they start using it they will expect us to > maintain it - and us telling them it wasn't intended to be

Re: unittest: Calling tests in liner number order

2008-05-24 Thread Fuzzyman
On May 24, 3:57 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > >  Fuzzyman <[EMAIL PROTECTED]> wrote: > > Whilst I understand your point, I think the danger is that you end up > > with hidden dependencies on the test order - which you're not aware of > > and that the

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Fuzzyman
On May 24, 4:56 pm, [EMAIL PROTECTED] (Ville M. Vainio) wrote: > Fuzzyman <[EMAIL PROTECTED]> writes: > > The 'we told you not to use that' approach, when applied to paying > > customers doesn't really work... all they see is that you broke > > their spreadsheet code by changing your API. > > And t

Re: Partial download with ftplib and retrbinary

2008-05-24 Thread MRAB
On May 24, 11:53 am, [EMAIL PROTECTED] wrote: > I am breaking/interrupting my connection with the ftp server at > present when doing a partial download of a file. I have a callback > with retrbinary that raises an exception and ends the download. The > problem is that the server is not notified and

Re: Code correctness, and testing strategies

2008-05-24 Thread Jacob Hallen
In article <[EMAIL PROTECTED]>, David <[EMAIL PROTECTED]> wrote: >> I work in small increments, writing one test at a time, then some code, >> then another test, then some more code, etc. In fact, I take this to what >> many people might call an extreme. > >Thanks for the replies. > >I've read ab

Re: Assignment and comparison in one statement

2008-05-24 Thread Grant Edwards
On 2008-05-23, Johannes Bauer <[EMAIL PROTECTED]> wrote: > I'm just starting with Python and am extremely unexperienced with it so > far. Having a strong C/C++ background, I wish to do something like > > if (q = getchar()) { > printf("%d\n", q); > } > > or translated to Python: > > if (p =

ero magazines

2008-05-24 Thread yura
http://ero-mag.net -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Ville M. Vainio
Fuzzyman <[EMAIL PROTECTED]> writes: > The 'we told you not to use that' approach, when applied to paying > customers doesn't really work... all they see is that you broke > their spreadsheet code by changing your API. And the customer point of view is quite reasonable - they have a job to do, a

Re: Code correctness, and testing strategies

2008-05-24 Thread David
> I work in small increments, writing one test at a time, then some code, > then another test, then some more code, etc. In fact, I take this to what > many people might call an extreme. Thanks for the replies. I've read about the TDD (and similar) approaches. Maybe I need to try it and get used

Re: raising an exception when multiple inheritance involves same base

2008-05-24 Thread Arnaud Delobelle
Michael Hines <[EMAIL PROTECTED]> writes: > Hello, > I have a class factory that supports single inheritance but it is > an error if the base appears twice. e.g > class Foo(hclass(h.Vector), hclass(h.List)): > should raise an exception since h.Vector and h.List are really the same > extension clas

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Fuzzyman <[EMAIL PROTECTED]> wrote: > The 'we told you not to use that' approach, when applied to paying > customers doesn't really work... all they see is that you broke their > spreadsheet code by changing your API. I hear what you're saying, friend, and I feel

Re: unittest: Calling tests in liner number order

2008-05-24 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Fuzzyman <[EMAIL PROTECTED]> wrote: > Whilst I understand your point, I think the danger is that you end up > with hidden dependencies on the test order - which you're not aware of > and that the tests never expose. Well, yes. But, this is no worse than the curr

Re: need some help in serving static files inside a wsgi apps

2008-05-24 Thread kib
Diez B. Roggisch a écrit : Tool69 schrieb: Hi, Until now, I was running my own static site with Python, but I'm in need of dynamism. After reading some cgi tutorials, I saw Joe Gregorio's old article "Why so many Python web frameworks?" about wsgi apps [http:// bitworking.org/news/Why_so_many_

Re: unittest: Calling tests in liner number order

2008-05-24 Thread Eric Wertman
>I can't relate to anyone that want to oppose a change that would give >more freedom to a programmer. While in general I agree with this.. I think in the case of python part of it's base philosophy seems to be a tendency to encourage a single way of doing things, and create a path of least resista

Re: Code correctness, and testing strategies

2008-05-24 Thread Scott David Daniels
David wrote: Specifically, if you've just written 100 new lines of Python code, then: 1) How do you test the new code? 2) How do you ensure that the code will work correctly in the future? Short version: For (1) I thoroughly (manually) test code as I write it, before checking in to version cont

Re: need some help in serving static files inside a wsgi apps

2008-05-24 Thread Diez B. Roggisch
Tool69 schrieb: Hi, Until now, I was running my own static site with Python, but I'm in need of dynamism. After reading some cgi tutorials, I saw Joe Gregorio's old article "Why so many Python web frameworks?" about wsgi apps [http:// bitworking.org/news/Why_so_many_Python_web_frameworks] and h

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Fuzzyman
On May 24, 2:58 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Sh4wn <[EMAIL PROTECTED]> writes: > > first, python is one of my fav languages, and i'll definitely keep > > developing with it. But, there's 1 one thing what I -really- miss: > > data hiding. I know member vars are private when you prefix

Re: unittest: Calling tests in liner number order

2008-05-24 Thread Fuzzyman
On May 24, 2:44 pm, Roy Smith <[EMAIL PROTECTED]> wrote: > In article > <[EMAIL PROTECTED]>, > > Fuzzyman <[EMAIL PROTECTED]> wrote: > > Also, like others, I have had wonderful experiences of trying to track > > down test failures that depend on the order that tests run in. Having > > interdepende

Re: Python is slow

2008-05-24 Thread Eric Wertman
> if python is such a good programming/scripting language, why can't they > build a faster interpreter/compiler engine? and beat php and zend. > to the python team, rebuild your interpreter! while this is just a boring troll.. it does bring me to a more interesting point... it would be cool if the

raising an exception when multiple inheritance involves same base

2008-05-24 Thread Michael Hines
Hello, I have a class factory that supports single inheritance but it is an error if the base appears twice. e.g class Foo(hclass(h.Vector), hclass(h.List)): should raise an exception since h.Vector and h.List are really the same extension class, HocObject. So far I have only been able to do this

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > If you want the users of your code to know that an attribute should > not be used as a public API for the code, use the convention of > naming the attribute with a single leading underscore. This is a > string signal that the attribute is part of the implem

Re: Assignment and comparison in one statement

2008-05-24 Thread Paul McGuire
On May 24, 6:12 am, Johannes Bauer <[EMAIL PROTECTED]> wrote: > Carl Banks schrieb: > > > p = myfunction() > > if p: > >     print p > > > (I recommend doing it this way in C, too.) > > This is okay for if-clauses, but sucks for while-loops: > > while (fgets(buf, sizeof(buf), f)) { >         printf

Re: Why does python not have a mechanism for data hiding?

2008-05-24 Thread Ben Finney
Sh4wn <[EMAIL PROTECTED]> writes: > first, python is one of my fav languages, and i'll definitely keep > developing with it. But, there's 1 one thing what I -really- miss: > data hiding. I know member vars are private when you prefix them with > 2 underscores, but I hate prefixing my vars, I'd rat

About events

2008-05-24 Thread Gandalf
As i said before I work with the WX library on a windows XP operation system. Now i wont to create an application which ran at the background and wait till the user double click on a text word OF any other python or none python application which ran on the desktop, and when this event append i w

Re: C-like assignment expression?

2008-05-24 Thread Paul McGuire
This version is a bit better, since it follows the convention that '<<' should return self. class TestValue(object): """Class to support assignment and test in single operation""" def __init__(self,v=None): self.value = v """Add support for quasi-assignment syntax using '<<' i

Scipy+SQLite crashes... , was: Re: SQLite import fails sometimes ?

2008-05-24 Thread Stef Mientki
John Machin wrote: Stef Mientki wrote: I don't know if this matters, but I also use sqlite3 from other than Python programs. You have an instance of sqlite3.dll in P:\Python\DLLs for use with Python, and (I guess) you have another instance of sqlite3.dll somewhere else, for use "from other

Re: Code correctness, and testing strategies

2008-05-24 Thread Ben Finney
David <[EMAIL PROTECTED]> writes: > What strategies do you use to ensure correctness of new code? Behaviour Driven Development http://behaviour-driven.org/>. * Start with an automated unit test suite that passes. * Describe, as formally or informally as you like, but *not* in code, the new or

Re: unittest: Calling tests in liner number order

2008-05-24 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Fuzzyman <[EMAIL PROTECTED]> wrote: > Also, like others, I have had wonderful experiences of trying to track > down test failures that depend on the order that tests run in. Having > interdependencies between tests is a recipe for madness... I agree that tests sh

Re: C-like assignment expression?

2008-05-24 Thread Paul McGuire
On May 21, 4:38 am, [EMAIL PROTECTED] wrote: > Hello, > > I have an if-elif chain in which I'd like to match a string against > several regular expressions. Also I'd like to use the match groups > within the respective elif... block. The C-like idiom that I would > like to use is this: > > if (matc

Why does python not have a mechanism for data hiding?

2008-05-24 Thread Sh4wn
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you prefix them with 2 underscores, but I hate prefixing my vars, I'd rather add a keyword before it. Python a

Re: Unhandled exceptions checking

2008-05-24 Thread Scott David Daniels
Yosifov Pavel wrote: Does somebody know existent tool for checking unhandled exceptions? Like in Java when method throws exception but in code using this method, try...catch is missed. May be something like PyChecker? I've seen this a number of places. Apparently there are a number of programm

Re: SQLite import fails sometimes ?

2008-05-24 Thread John Machin
Stef Mientki wrote: I don't know if this matters, but I also use sqlite3 from other than Python programs. You have an instance of sqlite3.dll in P:\Python\DLLs for use with Python, and (I guess) you have another instance of sqlite3.dll somewhere else, for use "from other than Python programs

Re: Code correctness, and testing strategies

2008-05-24 Thread Roy Smith
In article <[EMAIL PROTECTED]>, David <[EMAIL PROTECTED]> wrote: > Hi list. > > What strategies do you use to ensure correctness of new code? > > Specifically, if you've just written 100 new lines of Python code, then: > > 1) How do you test the new code? > 2) How do you ensure that the code w

  1   2   >