Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Token Type
> Try backdenting that statement. You're currently doing it at every > > iteration of the loop - that's why it's so much slower. Thanks. I works now. >>> def average_polysemy(pos): synset_list = list(wn.all_synsets(pos)) sense_number = 0 lemma_list = [] for syns

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Donald Stufft
For a short list the difference is going to be negligible. For a long list the difference is that checking if an item in a list requires iterating over the list internally to find it but checking if an item is inside of a set uses a faster method that doesn't require iterating over the list. T

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Chris Angelico
On Sun, Sep 9, 2012 at 4:29 PM, John H. Li wrote: > However, if I don't put list(set(lemma_list)) to a variable name, it works > much faster. Try backdenting that statement. You're currently doing it at every iteration of the loop - that's why it's so much slower. But you'll probably find it b

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread John H. Li
Thanks first, I could understand the second approach easily. The first approach is a bit puzzling. Why are seen=set() and seen.add(x) still necessary there if we can use unique.append(x) alone? Thanks for your enlightenment. On Sun, Sep 9, 2012 at 1:59 PM, Donald Stufft wrote: > seen = set()

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread John H. Li
Many thanks. I put all the set result into a list first . Then it will work and work without result displayed. >>> import nltk >>> from nltk.corpus import wordnet as wn >>> def average_polysemy(pos): synset_list = list(wn.all_synsets(pos)) sense_number = 0 lemma_list =[] for synset in synset_list:

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Chris Angelico
On Sun, Sep 9, 2012 at 3:43 PM, Token Type wrote: > Is there a unique method in python to unique a list? thanks I don't believe there's a method for that, but if you don't care about order, try turning your list into a set and then back into a list. ChrisA -- http://mail.python.org/mailman/list

Re: Is there a unique method in python to unique a list?

2012-09-08 Thread Donald Stufft
If you don't need to retain order you can just use a set, set([1, 1, 2, 3, 4]) = set([1, 2, 3, 4]) But set's don't retain order. On Sunday, September 9, 2012 at 1:43 AM, Token Type wrote: > Is there a unique method in python to unique a list? thanks > -- > http://mail.python.org/mailman/lis

Is there a unique method in python to unique a list?

2012-09-08 Thread Token Type
Is there a unique method in python to unique a list? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-08 Thread John Nagle
On 9/8/2012 5:20 PM, John Gleeson wrote: > > On 2012-09-06, at 2:34 PM, John Nagle wrote: >> Yes, it should. There's no shortage of implementations. >> PyPi has four. Each has some defect. >> >> PyPi offers: >> >> iso8601 0.1.4 Simple module to parse ISO 8601 dates >> iso8601.

Re: how to run python2.6 module with absolute imports stand alone

2012-09-08 Thread Gelonida N
On 09/08/2012 02:13 AM, Mark Lawrence wrote: On 07/09/2012 23:04, Gelonida N wrote: Hi, many of my modules contain following section at the end def main(): do_something() if __name__ == '__main__': main() This allows me to run some basic example code or some small test in a stand a

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-08 Thread John Gleeson
On 2012-09-06, at 2:34 PM, John Nagle wrote: Yes, it should. There's no shortage of implementations. PyPi has four. Each has some defect. PyPi offers: iso8601 0.1.4 Simple module to parse ISO 8601 dates iso8601.py 0.1dev Parse utilities for iso8601 encoding

Re: Initial pointers for web based LAMP installation

2012-09-08 Thread Dwight Hutto
On Sat, Sep 8, 2012 at 7:42 PM, Dwight Hutto wrote: > > > On Sat, Sep 8, 2012 at 4:31 PM, Matteo Grämlin wrote: > >> Hi all >> >> This is what I want to do: On a LAMP server, people are able >> to request for an instance of a particular LAMP application >> by submitting a few options. That invol

Re: Initial pointers for web based LAMP installation

2012-09-08 Thread Dwight Hutto
On Sat, Sep 8, 2012 at 7:42 PM, Dwight Hutto wrote: > > > On Sat, Sep 8, 2012 at 4:31 PM, Matteo Grämlin wrote: > >> Hi all >> >> This is what I want to do: On a LAMP server, people are able >> to request for an instance of a particular LAMP application >> by submitting a few options. That invol

Re: Initial pointers for web based LAMP installation

2012-09-08 Thread Dwight Hutto
On Sat, Sep 8, 2012 at 4:31 PM, Matteo Grämlin wrote: > Hi all > > This is what I want to do: On a LAMP server, people are able > to request for an instance of a particular LAMP application > by submitting a few options. That involves creating a couple > of directories, getting the code, writing

Re: AttributeError: 'list' object has no attribute 'lower'

2012-09-08 Thread Cameron Simpson
On 08Sep2012 13:45, Roy Smith wrote: | First, I don't understand this code: | | In article , | Token Type wrote: | > synset_list = list(wn.all_synsets(pos)) | > lemma_list = [synset.lemma_names for synset in synset_list] | | It looks like you're taking an iterable, converting it to a l

Re: set and dict iteration

2012-09-08 Thread Aaron Brady
On Thursday, August 23, 2012 1:11:14 PM UTC-5, Steven D'Aprano wrote: > On Thu, 23 Aug 2012 09:49:41 -0700, Aaron Brady wrote: > > > > [...] > > > The patch for the above is only 40-60 lines. However it introduces two > > > new concepts. > > > > > > The first is a "linked list", a classic

Re: set and dict iteration

2012-09-08 Thread MRAB
On 08/09/2012 21:06, Thomas Rachel wrote: Am 19.08.2012 00:14 schrieb MRAB: Can someone who is more familiar with the cycle detector and cycle breaker, help prove or disprove the above? In simple terms, when you create an immutable object it can contain only references to pre-existing objects

Re: set and dict iteration

2012-09-08 Thread Hans Mulder
On 8/09/12 22:06:08, Thomas Rachel wrote: > Am 19.08.2012 00:14 schrieb MRAB: > >>> Can someone who is more familiar with the cycle detector and cycle >>> breaker, help prove or disprove the above? >>> >> In simple terms, when you create an immutable object it can contain >> only references to pre

Re: simple client data base

2012-09-08 Thread Jorgen Grahn
On Sat, 2012-09-08, Mark R Rivet wrote: > On Thu, 6 Sep 2012 01:57:04 -0700 (PDT), Bryan > wrote: ... >>comp.lang.python tries to be friendly and helpful, and to that end >>responders have read and answered your question as directly as >>possible. There's good stuff available for Python. >> >>Mark

Re: simple client data base

2012-09-08 Thread Walter Hurry
On Sat, 08 Sep 2012 13:11:27 -0700, Paul Rubin wrote: > Mark R Rivet writes: >>>ones for a few dollars. You're reading about lists, tuples, and >>>dictionary data? Great, but other home accounting businesses have their >>>client databases automatically synced with their smart-phones and their >>>

Initial pointers for web based LAMP installation

2012-09-08 Thread Matteo Grämlin
Hi all This is what I want to do: On a LAMP server, people are able to request for an instance of a particular LAMP application by submitting a few options. That involves creating a couple of directories, getting the code, writing a config file, setting file permissions and creating a mysql user.

Re: simple client data base

2012-09-08 Thread Ian W
On Sat, Sep 8, 2012 at 3:11 PM, Paul Rubin wrote: > I think the idea is just to start with something simpler. If you are > interested in mechanical engineering, then building an automobile from > scratch, machining all the parts yourself etc., would be an ill-advised > choice as a first project.

Re: simple client data base

2012-09-08 Thread Paul Rubin
Mark R Rivet writes: >>ones for a few dollars. You're reading about lists, tuples, and >>dictionary data? Great, but other home accounting businesses have >>their client databases automatically synced with their smart-phones >>and their time-charging and their invoicing. > Well I have to say that

Re: set and dict iteration

2012-09-08 Thread Thomas Rachel
Am 19.08.2012 00:14 schrieb MRAB: Can someone who is more familiar with the cycle detector and cycle breaker, help prove or disprove the above? In simple terms, when you create an immutable object it can contain only references to pre-existing objects, but in order to create a cycle you need t

Re: Looking for download link for ArcPY

2012-09-08 Thread Dwight Hutto
Didn't see the download link, but a quick google search yielded this: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z000800 It seems it's part of a larger program ArcGIS 10. These are the docs for it, and how to use it, so it should be in there somewhere. -- Best Re

Re: simple client data base

2012-09-08 Thread Jason Friedman
>>Mark R Rivet wrote: >>> Hello all, I am learning to program in python. I have a need to make a >>> program that can store, retrieve, add, and delete client data such as >>> name, address, social, telephone number and similar information. This >>> would be a small client database for my wife who h

Re: Looking for download link for ArcPY

2012-09-08 Thread Dave Angel
On 09/08/2012 03:19 PM, David Shi wrote: > Hi, All, > > Can anyone send me the link for downloading ArcPY? > > I came across it before, but can not find it anymore. > > Regards. > > David > Try this link; it looks promising. http://www.arcgis.com/home/item.html?id=3a790cd717514f4689ae197c7920580

Re: simple client data base

2012-09-08 Thread Mark R Rivet
On Thu, 6 Sep 2012 01:57:04 -0700 (PDT), Bryan wrote: >Mark R Rivet wrote: >> Hello all, I am learning to program in python. I have a need to make a >> program that can store, retrieve, add, and delete client data such as >> name, address, social, telephone number and similar information. This >>

Re: simple client data base

2012-09-08 Thread Mark R Rivet
On Wed, 5 Sep 2012 05:57:24 -0700 (PDT), Ramchandra Apte wrote: >On Monday, 3 September 2012 19:42:21 UTC+5:30, Manatee wrote: >> Hello all, I am learning to program in python. I have a need to make a >> >> program that can store, retrieve, add, and delete client data such as >> >> name, addre

Re: simple client data base

2012-09-08 Thread Mark R Rivet
On Tue, 04 Sep 2012 04:25:14 +0200, Thomas 'PointedEars' Lahn wrote: >Mark R Rivet wrote: > >> Hello all, I am learning to program in python. I have a need to make a >> program that can store, retrieve, add, and delete client data such as >> name, address, social, telephone number and similar inf

Re: simple client data base

2012-09-08 Thread Mark R Rivet
On Mon, 03 Sep 2012 16:50:14 +0200, Peter Otten <__pete...@web.de> wrote: >Chris Angelico wrote: > >> You may also be needlessly reinventing the wheel. Aren't there already >> several million basic contact databases around? Why roll your own? > >To learn a thing or two, and to stick it to the defe

Looking for download link for ArcPY

2012-09-08 Thread David Shi
Hi, All, Can anyone send me the link for downloading ArcPY? I came across it before, but can not find it anymore. Regards. David-- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-08 Thread André Malo
* Roy Smith wrote: > The third is that I never use methods I can't figure out how to > pronounce. here: strip'time nd -- Flhacs wird im Usenet grundsätzlich alsfhc geschrieben. Schreibt man lafhsc nicht slfach, so ist das schlichtweg hclafs. Hingegen darf man rihctig ruhig rhitcgi schreiben, we

Re: AttributeError: 'list' object has no attribute 'lower'

2012-09-08 Thread Roy Smith
In article , Token Type wrote: > I wrote the following function to solve it. However, it pops up > "AttributeError: 'list' object has no attribute 'lower'". Quite confused, I > supposed [synset.lemma_names for synset in synset_list] has made all the > lemma into a list, hasn't it? I'm not fa

wordnet NLTK Re: AttributeError: 'list' object has no attribute 'lower'

2012-09-08 Thread Token Type
I don't know why lemma_list = [synset.lemma_names for synset in synset_list] will lead to such an error. I have to use extend to solve the problem for lemma_list. The following codes are successful, take all the nouns as an example: >>> def average_polysemy(pos): synset_list = list(wn.all_s

AttributeError: 'list' object has no attribute 'lower'

2012-09-08 Thread Token Type
On page 77 of the book natural language processing with Python, we have such an exercise: The polysemy of a word is the number of senses it has. Using WordNet, we can determine that the noun doghas seven senses with len(wn.synsets('dog', 'n')). Compute the average polysemy of nouns, verbs, adjec

Re: Comparing strings from the back?

2012-09-08 Thread Gelonida N
On 09/07/2012 06:06 AM, Steven D'Aprano wrote: On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: Also of some interest is the best case: O(1) for unequal strings (they differ at the first character) and O(N) for equal strings. The worst case is O(N) or N characters the average case is O(1

Re: Comparing strings from the back?

2012-09-08 Thread Gelonida N
On 09/06/2012 10:33 AM, Steven D'Aprano wrote: On Wed, 05 Sep 2012 22:47:14 +, Oscar Benjamin wrote: I may have been overly-conservative earlier when I said that on average string equality has to compare half the characters. I thought I had remembered that from a computer science textbook, b

Re: set and dict iteration

2012-09-08 Thread Aaron Brady
On Monday, September 3, 2012 8:59:16 PM UTC-5, Steven D'Aprano wrote: > On Mon, 03 Sep 2012 21:50:57 -0400, Dave Angel wrote: > > > > > On 09/03/2012 09:26 PM, Steven D'Aprano wrote: > > > > >> An unsigned C int can count up to 4,294,967,295. I propose that you say > > >> that is enough iter

Re: Looking for an IPC solution

2012-09-08 Thread Ramchandra Apte
On Friday, 7 September 2012 02:25:15 UTC+5:30, Dave Angel wrote: > On 09/06/2012 04:33 PM, Dennis Lee Bieber wrote: > > > > > > > > Note that this difference mainly applies to how the processes are > > > themselves are created... How the library wraps shared data is > > > possibly different

Re: Language workbench written in python3

2012-09-08 Thread Ramchandra Apte
On Friday, 7 September 2012 01:18:45 UTC+5:30, Nestor Arocha wrote: > On Thursday, September 6, 2012 2:53:15 PM UTC+1, Ramchandra Apte wrote: > > > On Thursday, 6 September 2012 19:16:38 UTC+5:30, Dave Angel wrote: > > > > > > > On 09/06/2012 09:34 AM, Ramchandra Apte wrote: > > > > > > >

Re: PExpect Cross-Platform Alternative

2012-09-08 Thread freebee007
Hello Steve, I was wondering if you had working examples of your automated tasks in python ... I am asking because I am starting out in Python, and I believe I can save my company time and headaches by automating a lot of the tasks we have. I would like to study your code and see if I can use it

Re: Comparing strings from the back?

2012-09-08 Thread Oscar Benjamin
On 2012-09-08, Steven D'Aprano wrote: > On Fri, 07 Sep 2012 19:10:16 +, Oscar Benjamin wrote: > >> On 2012-09-07, Steven D'Aprano >> wrote: >> >> >> Would you say, then, that dict insertion is O(N)? > > Pedantically, yes. > > But since we're allowed to state (or even imply *wink*) whatever

Re: Accessing dll

2012-09-08 Thread Chris Angelico
On Sat, Sep 8, 2012 at 3:27 AM, Helpful person wrote: > On Sep 7, 5:16 am, Chris Angelico wrote: >> On Fri, Sep 7, 2012 at 1:44 AM, Helpful person wrote: >> > FYI >> >> > My Python version is 2.5.4 >> >> You may wish to upgrade, that's quite an old version. Unless >> something's binding you to v

Re: How to print something only if it exists?

2012-09-08 Thread Dave Angel
On 09/08/2012 06:02 AM, tinn...@isbd.co.uk wrote: > Dave Angel wrote: >> Would you like to define "exists" ? A list is not sparse, so all items >> exist if their subscript is less than the length of the list. So all >> you need to do is compare 2 to len(fld). >> > Yes, a I said a simple len(fld)

Re: How to print something only if it exists?

2012-09-08 Thread tinnews
Dave Angel wrote: > Would you like to define "exists" ? A list is not sparse, so all items > exist if their subscript is less than the length of the list. So all > you need to do is compare 2 to len(fld). > Yes, a I said a simple len(fld) will tell me if fld[2] 'exists' but it gets messy if I h

Re: Division help in python

2012-09-08 Thread Hans Mulder
On 8/09/12 09:03:12, garabik-news-2005...@kassiopeia.juls.savba.sk wrote: > Chris Angelico wrote: >> On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla wrote: >>> I am brand new to python. checking over basic stuff. I came across the >>> problem while doing so. If any body aware of the problem, kind

Re: Division help in python

2012-09-08 Thread garabik-news-2005-05
Chris Angelico wrote: > On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla wrote: >> I am brand new to python. checking over basic stuff. I came across the >> problem while doing so. If any body aware of the problem, kindly respond me. >> > 5/10 >> 0 > - 5/10 >> -1 >> >> The second case also