Re: Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 3:45 PM, Evan Driscoll wrote: > Third, and more wackily, you could technically create a C implementation > that works like Python, where it stores variables (whose addresses aren't > taken) in a dict keyed by name, and generates code that on a variable access > looks up the

Re: Objects in Python

2012-08-25 Thread 88888 Dihedral
Jan Kuiken於 2012年8月24日星期五UTC+8上午2時02分00秒寫道: > On 8/23/12 06:11 , Steven D'Aprano wrote: > > > > >> 2) Related to the above, you can infinitely nest scopes. There's nothing > > >> wrong with having six variables called 'q'; you always use the innermost > > >> one. Yes, this can hurt readability

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
On 08/24/2012 05:00 AM, Steven D'Aprano wrote: No. The compiler remembers the address of 'a' by keeping notes about it somewhere in memory during the compilation process. When you run the compiled program, there is no longer any reference to the name 'a'. ... The mapping of name:address is part

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
On 08/24/2012 10:04 PM, Steven D'Aprano wrote: The fact that the end result is the same is hardly surprising -- Python's VM is built on top of C pointer indirection, so of course you can start with pointers and end up with Python semantics. But the practice of coding are very different: * in C,

Re: Probability Algorithm

2012-08-25 Thread 月忧茗
Thanks for helps This code almost meets my needs . But not accurate probability when not enough source elements. So I give up the not enough elements situation. For source list is growing fast, the bast situation just appear in the program starting 2012/8/26 Steven D'Aprano > On 08/25/2012

Re: Computing win/loss records in Python

2012-08-25 Thread Ben Finney
Christopher McComas writes: > I have code that I run via Django that grabs the results from various > sports from formatted text files. The script iterates over every line > in the formatted text files, finds the team in the Postgres database > updates their w/l record depending on the outcome on

Re: Probability Algorithm

2012-08-25 Thread Steven D'Aprano
On 08/25/2012 12:03 PM, 月忧茗 wrote: > In the FinalList, > probability of ALIST's item appeared is 43% probability of BLIST's > item appeared is 37% probability of CLIST's item appeared is 19% > probability of DLIST's item appeared is 1% First, select one of the four lists with those approp

Re: Probability Algorithm

2012-08-25 Thread 月忧茗
Sorry, missing some conditions *already_picked_list* is get from db. > Why keep a counter? Rather than an iterated loop so , if use a iterated loop: for i in range(43): item = choice( ALIST ) ALIST.remove( item ) if item in already_picked_list: continue slot.appe

Re: Computing win/loss records in Python

2012-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2012 22:20:05 -0400, Christopher McComas wrote: > Marshall,24,Ohio State,48, > Kentucky,14,Indiana,10, > Marshall,10,Indiana,7, > Ohio State,28,Kentucky,10 > > That's just a quick example, I can handle seperating the data in the > lines, figuring it all out, I just am unsure of how

Re: Computing win/loss records in Python

2012-08-25 Thread Steven D'Aprano
On Sat, 25 Aug 2012 22:42:59 -0400, Steven W. Orr wrote: > win_count = defaultdict(int) > loss_count = defaultdict(int) When I try that, I get "NameError: name 'defaultdict' is not defined." I think it is rather unfair on beginners to show them code that almost, but not quite, works, and expect

Re: Computing win/loss records in Python

2012-08-25 Thread Steven W. Orr
On 8/25/2012 10:20 PM, Christopher McComas wrote: Greetings, I have code that I run via Django that grabs the results from various sports from formatted text files. The script iterates over every line in the formatted text files, finds the team in the Postgres database updates their w/l record

Re: Computing win/loss records in Python

2012-08-25 Thread Rodrick Brown
On Aug 25, 2012, at 10:22 PM, Christopher McComas wrote: > Greetings, > > I have code that I run via Django that grabs the results from various sports > from formatted text files. The script iterates over every line in the > formatted text files, finds the team in the Postgres database updates

Computing win/loss records in Python

2012-08-25 Thread Christopher McComas
Greetings, I have code that I run via Django that grabs the results from various sports from formatted text files. The script iterates over every line in the formatted text files, finds the team in the Postgres database updates their w/l record depending on the outcome on that line, saves the t

Re: ONLINE SERVER TO STORE AND RUN PYTHON SCRIPTS

2012-08-25 Thread coldfire
On Friday, 17 August 2012 18:16:08 UTC+5:30, coldfire wrote: > I would like to know that where can a python script be stored on-line from > were it keep running and can be called any time when required using internet. > > I have used mechanize module which creates a webbroswer instance to open a

Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sun, Aug 26, 2012 at 5:56 AM, Dennis Lee Bieber wrote: > On Sat, 25 Aug 2012 09:55:27 +0100, Mark Lawrence > declaimed the following in > gmane.comp.python.general: > >> >> I'm just wondering out aloud if the number of times this type of thread >> has been debated here will fit into a Python l

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Ian Kelly
On Sat, Aug 25, 2012 at 9:47 AM, wrote: > For those you do not know, the go language has introduced > the rune type. As far as I know, nobody is complaining, I > have not even seen a discussion related to this subject. Python has that also. We call it "int". More seriously, strings in Go are n

modeling complex data with sqlalchemy

2012-08-25 Thread Littlefield, Tyler
Hello all: I had a quick question. In my game, I have an is-a setup, where all objects contain data like an id for sqlalchemy, a name, a description and a list of contents. In order to add functionality to an object, you add components. So for example, a player would have the Player and Living c

[RELEASED] Python 3.3.0 release candidate 1

2012-08-25 Thread Georg Brandl
On behalf of the Python development team, I'm delighted to announce the first release candidate of Python 3.3.0. This is a preview release, and its use is not recommended in production settings. Python 3.3 includes a range of improvements of the 3.x series, as well as easier porting between 2.x

Re: issue with struct.unpack

2012-08-25 Thread MRAB
On 25/08/2012 19:34, 9bizy wrote: I am trying to unpack values from sensor data I am retrieving through a serial cable, but I get errors while using struct.unpack, how can I use struct.unpack to unload the data in a readable format? I checked the python documentation for struct and I can seen to

Re: issue with struct.unpack

2012-08-25 Thread Mark Lawrence
On 25/08/2012 19:34, 9bizy wrote: I am trying to unpack values from sensor data I am retrieving through a serial cable, but I get errors while using struct.unpack, how can I use struct.unpack to unload the data in a readable format? I checked the python documentation for struct and I can seen

issue with struct.unpack

2012-08-25 Thread 9bizy
I am trying to unpack values from sensor data I am retrieving through a serial cable, but I get errors while using struct.unpack, how can I use struct.unpack to unload the data in a readable format? I checked the python documentation for struct and I can seen to find any argument for this. I h

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Terry Reedy
On 8/25/2012 10:17 AM, Alex wrote: Yes, that appears to be the issue I was talking about and is, in fact, one of the threads I had looked at before posting here. Of course, I didn't pay enough attention to the dates. I see the most recent posting on the issue appears to have been made in January

Re: Probability Algorithm

2012-08-25 Thread Dave Angel
On 08/25/2012 12:03 PM, 月忧茗 wrote: > Hi, All, > > I have a problem of probability algorithm > > > The goal is obtain a list which contains three items. as the *FinalList* > > There has Four source lists. * > ALIST, BLIST, CLIST, DLIST > > There are all Unknown length. They contains unique elem

Probability Algorithm

2012-08-25 Thread 月忧茗
Hi, All, I have a problem of probability algorithm The goal is obtain a list which contains three items. as the *FinalList* There has Four source lists. * ALIST, BLIST, CLIST, DLIST There are all Unknown length. They contains unique elements* ( In fact, there are all empty at the program

Re: Publish unittest results from test discovery

2012-08-25 Thread Peter Otten
Lucretiel wrote: > So I've started using unittest, and I love it. I use testdiscovery (python > -m unittest discover) so that I can distribute my tests and don't have to > manage them all manually. I wanted to start publishing my test results to > xml, though. I found xmlrunner by googling around,

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread wxjmfauth
Le samedi 25 août 2012 11:46:34 UTC+2, Frank Millman a écrit : > On 25/08/2012 10:58, Mark Lawrence wrote: > > > On 25/08/2012 08:27, wxjmfa...@gmail.com wrote: > > >> > > >> Unicode design: a flat table of code points, where all code > > >> points are "equals". > > >> As soon as one attempts

Re: Filter versus comprehension (was Re: something about split()???)

2012-08-25 Thread Tim Golden
On 25/08/2012 13:57, David Robinow wrote: On Fri, Aug 24, 2012 at 3:03 PM, Walter Hurry wrote: On Fri, 24 Aug 2012 14:29:00 -0400, Dennis Lee Bieber wrote: It appears to be a change Google made in the last month or two... My hypothesis is that they are replacing hard EOL found in inbound NNTP

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Alex
Mark Lawrence wrote: > On 25/08/2012 13:50, Alex wrote: > > Terry Reedy wrote: > > > > > On 8/24/2012 6:33 PM, Alex wrote: > > > > Despite being configured to use a 4 space > > > > indentation > > ... > > > > sometimes IDLE's "smart" indentation insists upon using > > > > width-8 tabs. > > > > >

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Mark Lawrence
On 25/08/2012 13:50, Alex wrote: Terry Reedy wrote: On 8/24/2012 6:33 PM, Alex wrote: Despite being configured to use a 4 space indentation ... sometimes IDLE's "smart" indentation insists upon using width-8 tabs. [The 4-space indentation setting] applies to the editor and works in the edi

Re: Filter versus comprehension (was Re: something about split()???)

2012-08-25 Thread David Robinow
On Fri, Aug 24, 2012 at 3:03 PM, Walter Hurry wrote: > On Fri, 24 Aug 2012 14:29:00 -0400, Dennis Lee Bieber wrote: > >> It appears to be a change Google made in the last month or two... My >> hypothesis is that they are replacing hard EOL found in inbound NNTP >> with an HTML , and then on outgoi

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Alex
Terry Reedy wrote: > On 8/24/2012 6:33 PM, Alex wrote: > > Despite being configured to use a 4 space > > indentation ... > > sometimes IDLE's "smart" indentation insists upon using > > width-8 tabs. > > [The 4-space indentation setting] applies to the editor and works in > the editor for me and

Re: lpod-python

2012-08-25 Thread jerome . dumonteil
Le dimanche 12 août 2012 21:45:49 UTC+2, Agon Hajdari a écrit : > On Fri, 10 Aug 2012 19:37:16 +0200, Francesco wrote: > > > > > I'm trying to use the lpod-python module to programmatically read data > > > from Open Document files. My problem is: i can't download the module > > > from its auth

Re: Installation of yappi (timing module)

2012-08-25 Thread Virgil Stokes
On 24-Aug-2012 12:28, Virgil Stokes wrote: I have been doing some experiments with different modules for the timing of functions and code segments. One module I would like to test is yappi (thread aware timer) which is listed at PyPI. However, I have been unable to install it on Windows Vista a

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-08-25 Thread Terry Reedy
On 8/24/2012 6:33 PM, Alex wrote: I'm new to Python and have been using IDLE 3.2.3 to experiment with code as I learn. Despite being configured to use a 4 space indentation That applies to the editor and works in the editor for me and others. A tab becomes 4 space characters, and a backspace i

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Terry Reedy
On 8/25/2012 7:05 AM, Mark Lawrence wrote: I thought Terry Reedy had shot down any claims about performance overhead, and that the memory savings in many cases must be substantial and therefore worthwhile. Or have I misread something? No, you have correctly read what I and others have said. J

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 9:05 PM, Mark Lawrence wrote: > I thought Terry Reedy had shot down any claims about performance overhead, > and that the memory savings in many cases must be substantial and therefore > worthwhile. Or have I misread something? Or what? My reading of the thread(s) is/are

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Mark Lawrence
On 25/08/2012 10:46, Frank Millman wrote: On 25/08/2012 10:58, Mark Lawrence wrote: On 25/08/2012 08:27, wxjmfa...@gmail.com wrote: Unicode design: a flat table of code points, where all code points are "equals". As soon as one attempts to escape from this rule, one has to "pay" for it. The cr

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 7:46 PM, Frank Millman wrote: > Therefore, I think he is saying that he would have preferred that python > standardise on 4-byte characters, on the grounds that the saving in memory > does not justify the performance overhead. If that's indeed the argument, then at least i

Re: Objects in Python

2012-08-25 Thread Mark Lawrence
On 25/08/2012 11:23, Chris Angelico wrote: On Sat, Aug 25, 2012 at 6:55 PM, Mark Lawrence wrote: I'm just wondering out aloud if the number of times this type of thread has been debated here will fit into a Python long or float? Well, when I have to store currency information, I like to store

Re: Objects in Python

2012-08-25 Thread Chris Angelico
On Sat, Aug 25, 2012 at 6:55 PM, Mark Lawrence wrote: > I'm just wondering out aloud if the number of times this type of thread has > been debated here will fit into a Python long or float? Well, when I have to store currency information, I like to store it as an integer, using the native currenc

Re: python 6 compilation failure on RHEL

2012-08-25 Thread Anssi Saari
Cameron Simpson writes: > My personal habit to to build with (adjust to match): > > --prefix=/usr/local/python-2.6.4 > > and put some symlinks in /usr/local/bin afterwards (python2.6, etc). There's actually a program for that, it's called stow. -- http://mail.python.org/mailman/listinfo/pytho

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Frank Millman
On 25/08/2012 10:58, Mark Lawrence wrote: On 25/08/2012 08:27, wxjmfa...@gmail.com wrote: Unicode design: a flat table of code points, where all code points are "equals". As soon as one attempts to escape from this rule, one has to "pay" for it. The creator of this machinery (flexible string re

Segfault when setting an instance property on 2.7.3

2012-08-25 Thread Vincent Pelletier
Hi. (please keep me in CC for replies, I'm not subscribed) I wrote a ctypes-(wait, read on)-based binding[1] for libusb1, in which I'm triggering a segfault from an application[2] I wrote. I've been through several segfault caused by ctypes mis-usage, this one seems different enough. I think t

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Mark Lawrence
On 25/08/2012 08:27, wxjmfa...@gmail.com wrote: Le samedi 25 août 2012 02:24:35 UTC+2, Antoine Pitrou a écrit : Ramchandra Apte gmail.com> writes: The zen of python is simply a guideline What's more, the Zen guides the language's design, not its implementation. People who think CPyth

Re: Objects in Python

2012-08-25 Thread Mark Lawrence
On 25/08/2012 07:34, Chris Angelico wrote: On Sat, Aug 25, 2012 at 1:04 PM, Steven D'Aprano I'm just wondering out aloud if the number of times this type of thread has been debated here will fit into a Python long or float? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listin

Re: Publish unittest results from test discovery

2012-08-25 Thread Mark Lawrence
On 25/08/2012 02:03, Steven D'Aprano wrote: On Fri, 24 Aug 2012 17:25:05 -0700, Lucretiel wrote: [...] Is there a way to get unittest disover to work with xmlrunner Steady on there! It's only been about an hour and a half since you last asked this exact same question, almost word-for-word ide

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Ben Finney
wxjmfa...@gmail.com writes: > Unicode design: a flat table of code points, where all code > points are "equals". Yes, Unicode's design entails a flat table of hundreds of thousands of code points, expansible in future. This is in direct conflict with the design of all significant computers we ne

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread wxjmfauth
Le samedi 25 août 2012 02:24:35 UTC+2, Antoine Pitrou a écrit : > Ramchandra Apte gmail.com> writes: > > > > > > The zen of python is simply a guideline > > > > What's more, the Zen guides the language's design, not its implementation. > > People who think CPython is a complicated implement