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

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

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

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

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

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

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

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

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

<    1   2