Re: List Count

2013-04-22 Thread Blind Anagram
On 23/04/2013 00:06, Oscar Benjamin wrote: > On 22 April 2013 22:25, Blind Anagram wrote: >> On 22/04/2013 21:18, Oscar Benjamin wrote: >>> On 22 April 2013 17:38, Blind Anagram wrote: >> >> I also wondered whether I had missed any obvious way of avoiding the >> slicing cost (intellectually it se

Re: Running simultaneuos "FOR" loops

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 4:40 PM, inshu chauhan wrote: > i have to implement the below line in one of my code: > > for p in sorted(segments.iterkeys()) and for k in > sorted(class_count.iterkeys()) and for j in sorted(pixel_count.iterkeys()): > > Its giving me a syntax error which is obvious, but

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Rui Maciel
Steven D'Aprano wrote: > Nobody forces you to do anything. Python is open source, and the source > code is freely available. That goes both ways, with the added benefit that python-tkinter is already available in distro's official repositories. If you want to install it, go for it. Nothing st

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 3:33 PM, Bob Martin wrote: > in 695509 20130422 081727 Steven D'Aprano > wrote: > >>I think that if you are worrying about the overhead of the tkinter >>bindings for Python, you're guilty of premature optimization. The tkinter >>pac

Running simultaneuos "FOR" loops

2013-04-22 Thread inshu chauhan
i have to implement the below line in one of my code: for p in sorted(segments.iterkeys()) and for k in sorted(class_count.iterkeys()) and for j in sorted(pixel_count.iterkeys()): Its giving me a syntax error which is obvious, but how can I make all three for loop run simultaneously or any other

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Bob Martin
in 695509 20130422 081727 Steven D'Aprano wrote: >I think that if you are worrying about the overhead of the tkinter >bindings for Python, you're guilty of premature optimization. The tkinter >package in Python 3.3 is trivially small, under 2 MB. "trivially smal

Re: Serial Port Issue

2013-04-22 Thread chandan kumar
Thanks Phil,You are right .with Port=20 it started working. Regards,Chandan. --- On Mon, 22/4/13, Phil Birkelbach wrote: From: Phil Birkelbach Subject: Re: Serial Port Issue To: python-list@python.org Cc: "chandan kumar" Date: Monday, 22 April, 2013, 8:43 PM Have you tried 'port=20'? The docu

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 19:47:26 -0500, Andrew Berg wrote: > On 2013.04.22 19:22, Steven D'Aprano wrote: >> It's only when I actually try to do something that requires an X >> display that it will fail. I won't show the entire traceback, because >> it is long and not particularly enlightening, but the

Re: optomizations

2013-04-22 Thread Steven D'Aprano
On Tue, 23 Apr 2013 00:20:59 -0400, Rodrick Brown wrote: > Got a doc or URL I have no experience working with python profilers. https://duckduckgo.com/html/?q=python%20profiler This is also good: http://pymotw.com/2/profile/ -- Steven -- http://mail.python.org/mailman/listinfo/python-li

Re: optomizations

2013-04-22 Thread Rodrick Brown
On Apr 22, 2013, at 11:18 PM, Dan Stromberg wrote: On Mon, Apr 22, 2013 at 6:53 PM, Roy Smith wrote: > > So, my real advice to you is to fire up the profiler and see what it > says. I agree. Fire up a line-oriented profiler and only then start trying to improve the hot spots. Got a doc o

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 2:03 PM, Steven D'Aprano wrote: > On Tue, 23 Apr 2013 10:36:38 +1000, Chris Angelico wrote: > >> On Tue, Apr 23, 2013 at 10:22 AM, Steven D'Aprano >> wrote: >>> It's only when I actually try to do something that requires an X >>> display that it will fail. I won't show the

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Steven D'Aprano
On Tue, 23 Apr 2013 10:36:38 +1000, Chris Angelico wrote: > On Tue, Apr 23, 2013 at 10:22 AM, Steven D'Aprano > wrote: >> It's only when I actually try to do something that requires an X >> display that it will fail. I won't show the entire traceback, because >> it is long and not particularly en

Re: optomizations

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 2:00 PM, Steven D'Aprano wrote: > Also, you're searching the file system *for every line* in the input > file. Pull this outside of the loop and have it run once: > > if not os.path.exists(outdir): > os.makedirs(outdir) > > Likewi

Re: optomizations

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 21:19:23 -0400, Rodrick Brown wrote: > I would like some feedback on possible solutions to make this script run > faster. > The system is pegged at 100% CPU and it takes a long time to complete. Have you profiled the app to see where it is spending all its time? What does "a

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread rusi
On Apr 23, 5:22 am, Steven D'Aprano wrote: > We're also glossing over what it means to be a dependency. This is not > obvious, and in fact I would argue that X is NOT a dependency for > tkinter, even though tkinter will not "work" without it, for some > definition of work. I can quite happily impo

Re: optomizations

2013-04-22 Thread Dan Stromberg
On Mon, Apr 22, 2013 at 6:53 PM, Roy Smith wrote: > > So, my real advice to you is to fire up the profiler and see what it > says. I agree. Fire up a line-oriented profiler and only then start trying to improve the hot spots. -- http://mail.python.org/mailman/listinfo/python-list

Re: optomizations

2013-04-22 Thread MRAB
On 23/04/2013 02:19, Rodrick Brown wrote: I would like some feedback on possible solutions to make this script run faster. The system is pegged at 100% CPU and it takes a long time to complete. #!/usr/bin/env python import gzip import re import os import sys from datetime import datetime impor

Re: optomizations

2013-04-22 Thread Roy Smith
In article , Rodrick Brown wrote: > I would like some feedback on possible solutions to make this script run > faster. If I had to guess, I would think this stuff: > line = line.replace('mediacdn.xxx.com', 'media.xxx.com') > line = line.replace('staticcd

Re: List Count

2013-04-22 Thread Dave Angel
On 04/22/2013 05:32 PM, Blind Anagram wrote: On 22/04/2013 22:03, Oscar Benjamin wrote: On 22 April 2013 21:18, Oscar Benjamin wrote: On 22 April 2013 17:38, Blind Anagram wrote: On 22/04/2013 17:06, Oscar Benjamin wrote: I don't know what your application is but I would say that my first

Re: optomizations

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 11:19 AM, Rodrick Brown wrote: > with gzip.open(args.inputfile) as datafile: > for line in datafile: > outfile = '{}{}{}_combined.log'.format(dateobj.year, > dateobj.month, dateobj.day) > outdir = (args.out

optomizations

2013-04-22 Thread Rodrick Brown
I would like some feedback on possible solutions to make this script run faster. The system is pegged at 100% CPU and it takes a long time to complete. #!/usr/bin/env python import gzip import re import os import sys from datetime import datetime import argparse if __name__ == '__main__': p

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Andrew Berg
On 2013.04.22 19:22, Steven D'Aprano wrote: > It's only when I actually try to do something that requires an X display > that it will fail. I won't show the entire traceback, because it is long > and not particularly enlightening, but the final error message explains > exactly why it isn't worki

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 10:22 AM, Steven D'Aprano wrote: > It's only when I actually try to do something that requires an X display > that it will fail. I won't show the entire traceback, because it is long > and not particularly enlightening, but the final error message explains > exactly why it

Re: Weird behaviour?

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 07:29:57 -0700, nn wrote: > On Apr 21, 9:19 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Mon, 22 Apr 2013 10:56:11 +1000, Chris Angelico wrote: >> > You're running this under Windows. The convention on Windows is for >> > end-of-line to be signalled with \

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 14:52:39 +0200, Antoon Pardon wrote: > Op 22-04-13 11:18, Steven D'Aprano schreef: >> On Mon, 22 Apr 2013 03:08:24 -0500, Andrew Berg wrote: >> >>> Much of the stdlib doesn't rely on anything but the core interpreter. >>> tkinter by itself is not the issue. As you said, the bin

Re: Weird behaviour?

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 9:06 AM, wrote: > On Tuesday, April 23, 2013 12:29:57 AM UTC+10, nn wrote: > >> Maybe it is related to this bug? >> >> http://bugs.python.org/issue11272 > > I'm running Python 2.7.2 (on Windows) and that version doesn't appear to have > that bug: > > Python 2.7.2 (defau

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 22:09:14 +0100, Rui Maciel wrote: > Steven D'Aprano wrote: > >> I think that if you are worrying about the overhead of the tkinter >> bindings for Python, you're guilty of premature optimization. > > I'm not worried about that. No one should be forced to install crap > that

Re: List Count

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 22:25:50 +0100, Blind Anagram wrote: > I have looked at solutions based on listing primes and here I have found > that they are very much slower than my existing solution when the sieve > is not large (which is the majority use case). Yes. This is hardly surprising. Algorithms

Re: Weird behaviour?

2013-04-22 Thread jussij
On Tuesday, April 23, 2013 12:29:57 AM UTC+10, nn wrote: > Maybe it is related to this bug? > > http://bugs.python.org/issue11272 I'm running Python 2.7.2 (on Windows) and that version doesn't appear to have that bug: Python 2.7.2 (default, Apr 23 2013, 11:49:52) [MSC v.1500 32 bit (Intel)]

Re: List Count

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 22:25, Blind Anagram wrote: > On 22/04/2013 21:18, Oscar Benjamin wrote: >> On 22 April 2013 17:38, Blind Anagram wrote: > > I also wondered whether I had missed any obvious way of avoiding the > slicing cost (intellectually it seemed wrong to me to have to copy the > list in ord

Re: List Count

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 15:15:19 +0100, Blind Anagram wrote: > But when using a sub-sequence, I do suffer a significant reduction in > speed for a count when compared with count on the full list. When the > list is small enough not to cause memory allocation issues this is about > 30% on 100,000,000

Re: Confusing Algorithm

2013-04-22 Thread Ian Kelly
On Mon, Apr 22, 2013 at 2:33 PM, Christian Gollwitzer wrote: > I'd agree with your interpretation. "Threads are straight lines and cannot > intersect towers" - I read it such that the answer is the "convex hull" of > the set of points given by the tower height. The convex hull can be computed > fo

Re: Confusing Algorithm

2013-04-22 Thread DJC
On 22/04/13 13:39, RBotha wrote: I'm facing the following problem: """ In a city of towerblocks, Spiderman can “cover” all the towers by connecting the first tower with a spider-thread to the top of a later tower and then to a next tower and then to yet another tower until he reaches the end of

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 22:03, Oscar Benjamin wrote: > On 22 April 2013 21:18, Oscar Benjamin wrote: >> On 22 April 2013 17:38, Blind Anagram wrote: >>> On 22/04/2013 17:06, Oscar Benjamin wrote: >>> I don't know what your application is but I would say that my first port of call here would be to

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 21:18, Oscar Benjamin wrote: > On 22 April 2013 17:38, Blind Anagram wrote: [snip] > If my description is correct then I would definitely consider using a > different algorithmic approach. The density of primes from 1 to 1 > billlion is about 5%. Storing the prime numbers themselve

Re: Lists and arrays

2013-04-22 Thread BartC
"Ana Dionísio" wrote in message news:de1cc79e-cbf7-4b0b-ae8e-18841a1ef...@googlegroups.com... Hello! I need your help! I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+ array[4] list: [a,1,2] When

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Rui Maciel
Steven D'Aprano wrote: > I think that if you are worrying about the overhead of the tkinter > bindings for Python, you're guilty of premature optimization. I'm not worried about that. No one should be forced to install crap that they don't use or will ever need, no matter how great the average

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Rui Maciel
lcrocker wrote: > I'm a programmer, I installed Tkinter, and use it. I'd like to deploy > programs written with it to others. **Those** people know nothing > about it, and **shouldn't have to**. They don't need to. The only person that needs to know what he is doing is you. You want to distr

Re: List Count

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 21:18, Oscar Benjamin wrote: > On 22 April 2013 17:38, Blind Anagram wrote: >> On 22/04/2013 17:06, Oscar Benjamin wrote: >> >>> I don't know what your application is but I would say that my first >>> port of call here would be to consider a different algorithmic >>> approach. An

Re: How to get JSON values and how to trace sessions??

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 6:09 AM, wrote: > But now i am wondering how to trace sessions? it is needed for a multiplayer > game, connected to a webserver. How do i trace a PHP-session? I suppose i > have to save a cookie with the sessionID from the webserver? Is this possible > with Python? Are

Re: Confusing Algorithm

2013-04-22 Thread Christian Gollwitzer
Am 22.04.13 16:57, schrieb Oscar Benjamin: On 22 April 2013 13:56, Chris Angelico wrote: On Mon, Apr 22, 2013 at 10:39 PM, RBotha wrote: Threads are straight lines and cannot intersect towers. Your task is to write a program that finds the minimal number of threads to cover all the towers.

Re: kbhit/getch python equivalent

2013-04-22 Thread woooee
> I'm looking for a kbhit/getch equivalent in python in order to be able to > stop my inner loop in a controlled way (communication with external hardware > is involved and breaking it abruptly may cause unwanted errors A curses example import curses stdscr = curses.initscr() curses.cbreak() s

Re: List Count

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 17:38, Blind Anagram wrote: > On 22/04/2013 17:06, Oscar Benjamin wrote: > >> I don't know what your application is but I would say that my first >> port of call here would be to consider a different algorithmic >> approach. An obvious question would be about the sparsity of this

How to get JSON values and how to trace sessions??

2013-04-22 Thread webmaster
Hi all, from python I post data to a webpage using urllib and can print that content. See code below. But now i am wondering how to trace sessions? it is needed for a multiplayer game, connected to a webserver. How do i trace a PHP-session? I suppose i have to save a cookie with the sessionID

Re: How to connect to a website?

2013-04-22 Thread webmaster
thanks! solved with: import urllib.request import urllib.parse user = 'user' pw = 'password' login_url = 'http://www.riskopoly.nl/test/index.php' data = urllib.parse.urlencode({'user': user, 'pw': pw}) data = data.encode('utf-8') # adding charset parameter to the Content-Type header. request =

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 18:48, Skip Montanaro wrote: >> But I was really wondering if there was a simple solution that worked >> without people having to add libraries to their basic Python installations. > > I think installing numpy is approximately > > pip install numpy > > assuming you have write a

Re: Encoding NaN in JSON

2013-04-22 Thread Wayne Werner
On Sat, 20 Apr 2013, Chris “Kwpolska” Warrick wrote: On Fri, Apr 19, 2013 at 9:42 PM, Grant Edwards wrote: The OP asked for a string, and I thought you were proposing the string 'null'. If one is to use a string, then 'NaN' makes the most sense, since it can be converted back into a floating

Re: Lists and arrays

2013-04-22 Thread Dave Angel
On 04/22/2013 02:13 PM, Ana Dionísio wrote: Hello! I need your help! I have an array I think you mean you have a numpy array, which is very different than a python array.array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] That's a li

Lists and arrays

2013-04-22 Thread Ana Dionísio
Hello! I need your help! I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+ array[4] list: [a,1,2] When I do it like this: list=array[0]+ array[3]+ array[4] I get an error: "TypeError: unsupported operan

Re: List Count

2013-04-22 Thread Skip Montanaro
> But I was really wondering if there was a simple solution that worked > without people having to add libraries to their basic Python installations. I think installing numpy is approximately pip install numpy assuming you have write access to your site-packages directory. If not, install u

Re: There must be a better way

2013-04-22 Thread Colin J. Williams
On 22/04/2013 10:42 AM, Neil Cerutti wrote: On 2013-04-21, Colin J. Williams wrote: On 20/04/2013 9:07 PM, Terry Jan Reedy wrote: On 4/20/2013 8:34 PM, Tim Chase wrote: In 2.x, the csv.reader() class (and csv.DictReader() class) offered a .next() method that is absent in 3.x In Py 3, .next

Python Developer Needed in Ottawa

2013-04-22 Thread alika . resumes
Python Programmer need in Ottawa, Ontario Canada. Must be eligible to work in Canada and preferably already in Ottawa with a security clearance in place. Phone Al at (613) 425-1634 -- http://mail.python.org/mailman/listinfo/python-list

Re: How to connect to a website?

2013-04-22 Thread MRAB
On 22/04/2013 17:16, webmas...@terradon.nl wrote: Hi, i just try to connect to a website, read that page and display the rules get from it. Then i get this error message: File "D:/Python/Py projects/socket test/sockettest.py", line 21, in fileobj.write("GET "+filename+" HTTP/1.0\n\n")

Re: How to connect to a website?

2013-04-22 Thread John Gordon
In <566767a8-35cc-47f2-9f75-032ce5629...@googlegroups.com> webmas...@terradon.nl writes: > Hi, > i just try to connect to a website, read that page and display the rules get > from it. > Then i get this error message: > File "D:/Python/Py projects/socket test/sockettest.py", line 21, in >

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 17:06, Oscar Benjamin wrote: > On 22 April 2013 16:50, Blind Anagram wrote: >>> >>> It would be very easy to subclass list and add this functionality in >>> cython if you decide that you do need a builtin method. > [snip] >> >> But I was really wondering if there was a simple solutio

Re: error importing modules

2013-04-22 Thread MRAB
On 22/04/2013 15:54, Rodrick Brown wrote: I'm using the fabric api (fabfile.org ) I’m executing my fab script like the following: $ fab -H server set_nic_buffers -f set_nic_buffers.py Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fabric/main

How to connect to a website?

2013-04-22 Thread webmaster
Hi, i just try to connect to a website, read that page and display the rules get from it. Then i get this error message: File "D:/Python/Py projects/socket test/sockettest.py", line 21, in fileobj.write("GET "+filename+" HTTP/1.0\n\n") io.UnsupportedOperation: not writable My code: # imp

Re: List Count

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 16:50, Blind Anagram wrote: >> >> It would be very easy to subclass list and add this functionality in >> cython if you decide that you do need a builtin method. [snip] > > But I was really wondering if there was a simple solution that worked > without people having to add librari

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 16:14, Oscar Benjamin wrote: > On 22 April 2013 15:15, Blind Anagram wrote: >> On 22/04/2013 14:13, Steven D'Aprano wrote: >>> On Mon, 22 Apr 2013 12:58:20 +0100, Blind Anagram wrote: >>> I would be grateful for any advice people can offer on the fastest way to count items

Re: List Count

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 15:15, Blind Anagram wrote: > On 22/04/2013 14:13, Steven D'Aprano wrote: >> On Mon, 22 Apr 2013 12:58:20 +0100, Blind Anagram wrote: >> >>> I would be grateful for any advice people can offer on the fastest way >>> to count items in a sub-sequence of a large list. >>> >>> I have

Re: Serial Port Issue

2013-04-22 Thread Phil Birkelbach
Have you tried 'port=20'? The documentation says that the port numbering starts at zero. I don't use Windows so I can't test it for you. You could also try port="COM21" Phil On Apr 22, 2013, at 4:34 AM, chandan kumar wrote: > Hi, > > I'm new to python and trying to learn serial communicatio

Re: itertools.groupby

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 12:49 AM, Oscar Benjamin wrote: > Iterators are > typically preferred over list slicing for sequential text file access > since you can avoid loading the whole file at once. This means that > you can process a large file while only using a constant amount of > memory. And,

Re: itertools.groupby

2013-04-22 Thread Neil Cerutti
On 2013-04-22, Oscar Benjamin wrote: > On 22 April 2013 15:24, Neil Cerutti wrote: >> >> Hrmmm, hoomm. Nobody cares for slicing any more. >> >> def headered_groups(lst, header): >> b = lst.index(header) + 1 >> while True: >> try: >> e = lst.index(header, b) >>

Re: Confusing Algorithm

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 13:56, Chris Angelico wrote: > On Mon, Apr 22, 2013 at 10:39 PM, RBotha wrote: >> I'm facing the following problem: >> >> """ >> In a city of towerblocks, Spiderman can >> “cover” all the towers by connecting the >> first tower with a spider-thread to the top >> of a later tower

Re: kbhit/getch python equivalent

2013-04-22 Thread Chris Angelico
On Mon, Apr 22, 2013 at 11:34 PM, alb wrote: > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). Catch Keyboa

Re: Confusing Algorithm

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 12:57 AM, Oscar Benjamin wrote: > On 22 April 2013 13:56, Chris Angelico wrote: >> There are other possible readings of the problem. > > I read it differently. I thought the threads would go 1->5->7->5->2. I hadn't thought of that one, but agreed, that's also plausible, a

Re: Error in "Import gv " module

2013-04-22 Thread Andreas Perstinger
You are still top posting. On 22.04.2013 14:43, Megha Agrawal wrote: yes, I did. They said, gv module doesn't exist for windows. Then I'm afraid you are out of luck. Two possible alternatives: 1) Save your graph to a file and use the command line tools: http://stackoverflow.com/a/12698636 2

error importing modules

2013-04-22 Thread Rodrick Brown
I'm using the fabric api (fabfile.org) I’m executing my fab script like the following: $ fab -H server set_nic_buffers -f set_nic_buffers.py Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fabric/main.py", line 739, in main *args, **kwargs File "/usr/lib/python

Re: itertools.groupby

2013-04-22 Thread Oscar Benjamin
On 22 April 2013 15:24, Neil Cerutti wrote: > > Hrmmm, hoomm. Nobody cares for slicing any more. > > def headered_groups(lst, header): > b = lst.index(header) + 1 > while True: > try: > e = lst.index(header, b) > except ValueError: > yield lst[b:] >

Re: There must be a better way

2013-04-22 Thread Neil Cerutti
On 2013-04-21, Colin J. Williams wrote: > On 20/04/2013 9:07 PM, Terry Jan Reedy wrote: >> On 4/20/2013 8:34 PM, Tim Chase wrote: >>> In 2.x, the csv.reader() class (and csv.DictReader() class) offered >>> a .next() method that is absent in 3.x >> >> In Py 3, .next was renamed to .__next__ for *al

Re: There must be a better way

2013-04-22 Thread Oscar Benjamin
On 21 April 2013 14:15, Colin J. Williams wrote: > In the end, I used: > > inData= csv.reader(inFile) > > def main(): > > if ver == '2': > headerLine= inData.next() > else: > headerLine= inData.__next__() > ... > for item in inData: > assert len(dataStore) =

Re: Weird behaviour?

2013-04-22 Thread nn
On Apr 21, 9:19 pm, Steven D'Aprano wrote: > On Mon, 22 Apr 2013 10:56:11 +1000, Chris Angelico wrote: > > You're running this under Windows. The convention on Windows is for > > end-of-line to be signalled with \r\n, but the convention inside Python > > is to use just \n. With the normal use of b

Re: itertools.groupby

2013-04-22 Thread Neil Cerutti
On 2013-04-20, Jason Friedman wrote: > I have a file such as: > > $ cat my_data > Starting a new group > a > b > c > Starting a new group > 1 > 2 > 3 > 4 > Starting a new group > X > Y > Z > Starting a new group > > I am wanting a list of lists: > ['a', 'b', 'c'] > ['1', '2', '3', '4'] > ['X', 'Y'

Re: Preparing sqlite, dl and tkinter for Python installation (no admin rights)

2013-04-22 Thread Serhiy Storchaka
On 21.04.13 23:31, James Jong wrote: I see, just to be clear, do you mean that Python 2.7.4 (stable) is incompatible with Tk 8.6 (stable)? Yes. -- http://mail.python.org/mailman/listinfo/python-list

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 14:13, Steven D'Aprano wrote: > On Mon, 22 Apr 2013 12:58:20 +0100, Blind Anagram wrote: > >> I would be grateful for any advice people can offer on the fastest way >> to count items in a sub-sequence of a large list. >> >> I have a list of boolean values that can contain many hundre

Re: kbhit/getch python equivalent

2013-04-22 Thread Grant Edwards
On 2013-04-22, alb wrote: > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). > > I'm programming on *nix sys

Re: kbhit/getch python equivalent

2013-04-22 Thread Peter Otten
alb wrote: > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). > > I'm programming on *nix systems, no need t

Re: List Count

2013-04-22 Thread Skip Montanaro
Numpy is a big improvement here. In Py 2.7 I get this output if I run Steven's benchmark: 2.10364603996 3.68471002579 4.01849389076 7.41974878311 10.4202470779 9.16782712936 3.36137390137 (confirming his results). If I then run the numpy idiom for this: import random f

comp.lang.python

2013-04-22 Thread M.gowtham M.gowtham
Hi, a few weeks back I posed a question about passing static data to a request server, and thanks to some useful suggestions, got it working. I see yesterday there is a suggestion to use a framework like Tornado rather than base classes. However I can't figure achieve the same effect using T

HTTPServer again

2013-04-22 Thread Tom P
Hi, a few weeks back I posed a question about passing static data to a request server, and thanks to some useful suggestions, got it working. I see yesterday there is a suggestion to use a framework like Tornado rather than base classes. However I can't figure achieve the same effect using To

Re: List Count

2013-04-22 Thread 88888 Dihedral
Blind Anagram於 2013年4月22日星期一UTC+8下午7時58分20秒寫道: > I would be grateful for any advice people can offer on the fastest way > > to count items in a sub-sequence of a large list. > > > > I have a list of boolean values that can contain many hundreds of > > millions of elements for which I want to c

kbhit/getch python equivalent

2013-04-22 Thread alb
Hi everyone, I'm looking for a kbhit/getch equivalent in python in order to be able to stop my inner loop in a controlled way (communication with external hardware is involved and breaking it abruptly may cause unwanted errors on the protocol). I'm programming on *nix systems, no need to be porta

Re: List Count

2013-04-22 Thread Peter Otten
Blind Anagram wrote: > I would be grateful for any advice people can offer on the fastest way > to count items in a sub-sequence of a large list. > > I have a list of boolean values that can contain many hundreds of > millions of elements for which I want to count the number of True values > in a

Re: itertools.groupby

2013-04-22 Thread Wolfgang Maier
Jason Friedman gmail.com> writes: > > Thank you for the responses!  Not sure yet which one I will pick. > Hi again, I was working a bit on my own solution and on the one from Steven/Joshua, and maybe that helps you deciding: def separate_on(iterable, separator): # based on groupby sep

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Chris Angelico
On Mon, Apr 22, 2013 at 9:18 PM, lcrocker wrote: > On Apr 21, 11:36 pm, Rui Maciel wrote: >> Steven D'Aprano wrote: >> > It's only easy to install a package on Ubuntu if you know that you have >> > to, and can somehow work out the name of the package. >> >> No one actually has to install tkinter.

Re: List Count

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 12:58:20 +0100, Blind Anagram wrote: > I would be grateful for any advice people can offer on the fastest way > to count items in a sub-sequence of a large list. > > I have a list of boolean values that can contain many hundreds of > millions of elements for which I want to co

Re: Error in "Import gv " module

2013-04-22 Thread Megha Agrawal
yes, I did. They said, gv module doesn't exist for windows. On Mon, Apr 22, 2013 at 5:56 PM, Andreas Perstinger wrote: > Please avoid top posting and answer to the list. > > > On 22.04.2013 12:38, Megha Agrawal wrote: > >> Widows 7, and i have pygraphviz library in python27-> lib-> >> site-packa

Re: List Count

2013-04-22 Thread Blind Anagram
On 22/04/2013 13:51, Dave Angel wrote: > On 04/22/2013 07:58 AM, Blind Anagram wrote: >> I would be grateful for any advice people can offer on the fastest way >> to count items in a sub-sequence of a large list. >> >> I have a list of boolean values that can contain many hundreds of >> millions of

Re: Confusing Algorithm

2013-04-22 Thread Chris Angelico
On Mon, Apr 22, 2013 at 10:39 PM, RBotha wrote: > I'm facing the following problem: > > """ > In a city of towerblocks, Spiderman can > “cover” all the towers by connecting the > first tower with a spider-thread to the top > of a later tower and then to a next tower > and then to yet another tower

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread Antoon Pardon
Op 22-04-13 11:18, Steven D'Aprano schreef: > On Mon, 22 Apr 2013 03:08:24 -0500, Andrew Berg wrote: > >> Much of the stdlib doesn't rely on anything but the core interpreter. >> tkinter by itself is not the issue. As you said, the bindings are tiny. >> However, in order to be usable, it requires q

Re: List Count

2013-04-22 Thread Dave Angel
On 04/22/2013 07:58 AM, Blind Anagram wrote: I would be grateful for any advice people can offer on the fastest way to count items in a sub-sequence of a large list. I have a list of boolean values that can contain many hundreds of millions of elements for which I want to count the number of Tru

Confusing Algorithm

2013-04-22 Thread RBotha
I'm facing the following problem: """ In a city of towerblocks, Spiderman can “cover” all the towers by connecting the first tower with a spider-thread to the top of a later tower and then to a next tower and then to yet another tower until he reaches the end of the city. Threads are straigh

Re: How to set my gui?

2013-04-22 Thread Gene Heskett
On Friday 19 April 2013 22:16:18 Chris Angelico did opine: > On Sat, Apr 20, 2013 at 9:10 AM, Dennis Lee Bieber > > wrote: > > On Fri, 19 Apr 2013 09:24:36 +1000, Chris Angelico > > > > declaimed the following in gmane.comp.python.general: > >> On Fri, Apr 19, 2013 at 8:57 AM, Walter Hurry w

Re: Error in "Import gv " module

2013-04-22 Thread Andreas Perstinger
Please avoid top posting and answer to the list. On 22.04.2013 12:38, Megha Agrawal wrote: Widows 7, and i have pygraphviz library in python27-> lib-> site-package folder. Sorry don't know much about Windows. Have you read through all the issues involving "import gv" errors?: https://code.goo

Selenium Webdriver + Python (How to get started ??)

2013-04-22 Thread arif7d . auto
Note that:- I have some experience of using Selenium IDE and Webdriver (Java). but no prior experience of Python. Now there is a project for which I will need to work with webdriver + Python. So far I have done following steps.. Install JDK Setup Eclipse download & Installed Python v3.3.1 Dow

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread rusi
On Apr 22, 4:18 pm, lcrocker wrote: > On Apr 21, 11:36 pm, Rui Maciel wrote: > > > Steven D'Aprano wrote: > > > It's only easy to install a package on Ubuntu if you know that you have > > > to, and can somehow work out the name of the package. > > > No one actually has to install tkinter.  That's

List Count

2013-04-22 Thread Blind Anagram
I would be grateful for any advice people can offer on the fastest way to count items in a sub-sequence of a large list. I have a list of boolean values that can contain many hundreds of millions of elements for which I want to count the number of True values in a sub-sequence, one from the start

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread rusi
On Apr 22, 11:35 am, Rui Maciel wrote: > lcrocker wrote: > > > > I recently recommended > > Python to a friend who wants to start learning programming. Hurdles > > like this don't help someone like him. > > If your friend believes that having to do an extra pair of clicks or typing > sudo apt-get

Re: Ubuntu package "python3" does not include tkinter

2013-04-22 Thread lcrocker
On Apr 21, 11:36 pm, Rui Maciel wrote: > Steven D'Aprano wrote: > > It's only easy to install a package on Ubuntu if you know that you have > > to, and can somehow work out the name of the package. > > No one actually has to install tkinter.  That's the whole point of providing > it as a separate

Re: Error in "Import gv " module

2013-04-22 Thread Dave Angel
On 04/22/2013 06:13 AM, Megha Agrawal wrote: https://code.google.com/p/python-graph/wiki/Example When I am trying to run the code to draw a graph, given on above link, I am getting following error: ImportError: No module named gv What can be the reasons? Simplest is that you haven't instal

  1   2   >