More than 500 Free webhostings
Hi Friends In this world everyone is searching for free webhostings for their websites So only i found this website after some struggle it's a free webhosting directory www.webhostingsfree.com Having more than 500 free web hosting websites and free file hostings ,image hostings etc -- http://mail.python.org/mailman/listinfo/python-list
Timer runs only once.
The following program print hello world only once instead it has to print the string for every 5 seconds. from threading import Timer; class TestTimer: def __init__(self): self.t1 = Timer(5.0, self.foo); def startTimer(self): self.t1.start(); def foo(self): print("Hello, World!!!"); timer = TestTimer(); timer.startTimer(); (program - 1) But the following program prints the string for every 5 seconds. def foo(): print("World"); Timer(5.0, foo).start(); foo(); (program - 2) Why (program - 1) not printing the string for every 5 seconds ? And how to make the (program - 1) to print the string for every 5 seconds continuously. -- https://mail.python.org/mailman/listinfo/python-list
Re: Timer runs only once.
On Wednesday, November 30, 2016 at 7:35:46 PM UTC+5:30, siva gnanam wrote: > The following program print hello world only once instead it has to print the > string for every 5 seconds. > > from threading import Timer; > > class TestTimer: > > def __init__(self): > self.t1 = Timer(5.0, self.foo); > > def startTimer(self): > self.t1.start(); > > def foo(self): > print("Hello, World!!!"); > > timer = TestTimer(); > timer.startTimer(); > > >(program - 1) > > But the following program prints the string for every 5 seconds. > > def foo(): > print("World"); > Timer(5.0, foo).start(); > > foo(); > > (program - 2) > > Why (program - 1) not printing the string for every 5 seconds ? And how to > make the (program - 1) to print the string for every 5 seconds continuously. The use case : Create a class which contains t1 as object variable. Assign a timer object to t1. Then make the timer running. So we can check the timer status in the future. Is it possible ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Timer runs only once.
On Wednesday, November 30, 2016 at 8:11:49 PM UTC+5:30, vnthma...@gmail.com wrote: > from threading import Timer > > class TestTimer: > def foo(self): > print("hello world") > self.startTimer() > > def startTimer(self): > self.t1 = Timer(5, self.foo) > self.t1.start() > > timer = TestTimer() > timer.startTimer() I think in this example, We are creating Timer object every 5 seconds. So every time it will span a new Timer. I don't know what happened to the previous timers we created. -- https://mail.python.org/mailman/listinfo/python-list
Extracting real-domain-name (without sub-domains) from a given URL
Hi all, I need to extract the domain-name from a given url(without sub-domains). With urlparse, i am able to fetch only the domain-name(which includes the sub-domain also). eg: http://feeds.huffingtonpost.com/posts/ , http://www.huffingtonpost.de/, all must lead to *huffingtonpost.com or huffingtonpost.de** * Please suggest me some ideas regarding this problem. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting real-domain-name (without sub-domains) from a given URL
On Tue, Jan 13, 2009 at 1:50 PM, Chris Rebert wrote: > > On Mon, Jan 12, 2009 at 11:46 PM, S.Selvam Siva > wrote: > > Hi all, > > > > I need to extract the domain-name from a given url(without sub-domains). > > With urlparse, i am able to fetch only the domain-name(which includes the > > sub-domain also). > > > > eg: > > http://feeds.huffingtonpost.com/posts/ , http://www.huffingtonpost.de/, > > all must lead to huffingtonpost.com or huffingtonpost.de > > > > Please suggest me some ideas regarding this problem. > > That would require (pardon the pun) domain-specific logic. For most > TLDs (e.g. .com, .org) the domain name is just blah.com, blah.org, > etc. But for ccTLDs, often only second-level registrations are > allowed, e.g. for www.bbc.co.uk, so the main domain name would be > bbc.co.uk I think a few TLDs have even more complicated rules. > > I doubt anyone's created a general ready-made solution for this, you'd > have to code it yourself. > To handle the common case, you can cheat and just .split() at the > periods and then slice and rejoin the list of domain parts, ex: > '.'.join(domain.split('.')[-2:]) > > Cheers, > Chris Thank you Chris Rebert, Actually i tried with domain specific logic.Having 200 TLD like .com,co.in,co.uk and tried to extract the domain name. But my boss want more reliable solution than this method,any way i will try to find some alternative solution. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
python resource management
Hi all, I am running a python script which parses nearly 22,000 html files locally stored using BeautifulSoup. The problem is the memory usage linearly increases as the files are being parsed. When the script has crossed parsing 200 files or so, it consumes all the available RAM and The CPU usage comes down to 0% (may be due to excessive paging). We tried 'del soup_object' and used 'gc.collect()'. But, no improvement. Please guide me how to limit python's memory-usage or proper method for handling BeautifulSoup object in resource effective manner -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
python resource management
Hi all, I have found the actual solution for this problem. I tried using BeautifulSoup.SoupStrainer() and it improved memory usage to the greatest extent.Now it uses max of 20 MB(earlier it was >800 MB on 1GB RAM system). thanks all. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: python resource management
On Tue, Jan 20, 2009 at 7:27 PM, Tim Arnold wrote: > I had the same problem you did, but then I changed the code to create a new > soup object for each file.That drastically increased the speed. I don't > know why, but it looks like the soup object just keeps getting bigger with > each feed. > > --Tim > > I have found the actual solution for this problem. I tried using *BeautifulSoup.SoupStrainer()* and it improved memory usage to the greatest extent.Now it uses max of 20 MB(earlier it was >800 MB on 1GB RAM system). thanks all. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
String comparision
Hi all, I am developing spell checker for my local language(tamil) using python. I need to generate alternative word list for a miss-spelled word from the dictionary of words.The alternatives must be as much as closer to the miss-spelled word.As we know, ordinary string comparison wont work here . Any suggestion for this problem is welcome. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: String comparision
Thank You Gabriel, On Sun, Jan 25, 2009 at 7:12 AM, Gabriel Genellina wrote: > En Sat, 24 Jan 2009 15:08:08 -0200, S.Selvam Siva > escribió: > > > I am developing spell checker for my local language(tamil) using python. >> I need to generate alternative word list for a miss-spelled word from the >> dictionary of words.The alternatives must be as much as closer to the >> miss-spelled word.As we know, ordinary string comparison wont work here . >> Any suggestion for this problem is welcome. >> > > I think it would better to add Tamil support to some existing library like > GNU aspell: http://aspell.net/ That was my plan earlier,But i am not sure how aspell integrates with other editors.Better i will ask it in aspell mailing list. > You are looking for "fuzzy matching": > http://en.wikipedia.org/wiki/Fuzzy_string_searching > In particular, the Levenshtein distance is widely used; I think there is a > Python extension providing those calculations. > > -- > Gabriel Genellina The following code served my purpose,(thanks for some unknown contributors) def distance(a,b): c = {} n = len(a); m = len(b) for i in range(0,n+1): c[i,0] = i for j in range(0,m+1): c[0,j] = j for i in range(1,n+1): for j in range(1,m+1): x = c[i-1,j]+1 y = c[i,j-1]+1 if a[i-1] == b[j-1]: z = c[i-1,j-1] else: z = c[i-1,j-1]+1 c[i,j] = min(x,y,z) return c[n,m] a=sys.argv[1] b=sys.argv[2] d=distance(a,b) print "d=",d longer = float(max((len(a), len(b shorter = float(min((len(a), len(b r = ((longer - d) / longer) * (shorter / longer) # r ranges between 0 and 1 -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
date handling problem
Hi all, I need to parse rss-feeds based on time stamp,But rss-feeds follow different standards of date(IST,EST etc). I dont know,how to standardize this standards.It will be helpful if you can hint me. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: date handling problem
On Thu, Jan 29, 2009 at 2:27 PM, M.-A. Lemburg wrote: > On 2009-01-29 03:38, Gabriel Genellina wrote: > > En Wed, 28 Jan 2009 18:55:21 -0200, S.Selvam Siva > > escribió: > > > >> I need to parse rss-feeds based on time stamp,But rss-feeds follow > >> different > >> standards of date(IST,EST etc). > >> I dont know,how to standardize this standards.It will be helpful if > >> you can > >> hint me. > > > > You may find the Olson timezone database useful. > > http://pytz.sourceforge.net/ > > Or have a look at the date/time parser in mxDateTime: > > http://www.egenix.com/products/python/mxBase/mxDateTime/ > > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Jan 29 2009) > >>> Python/Zope Consulting and Support ...http://www.egenix.com/ > >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ > >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ > > > ::: Try our new mxODBC.Connect Python Database Interface for free ! > > > eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 >D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg > Registered at Amtsgericht Duesseldorf: HRB 46611 > http://www.egenix.com/company/contact/ > -- > http://mail.python.org/mailman/listinfo/python-list > Thank you all, The link was really nice and i will try it out. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
importing module-performance
Hi all, I have a small query, Consider there is a task A which i want to perform. To perform it ,i have two option. 1)Writing a small piece of code(approx. 50 lines) as efficient as possible. 2)import a suitable module to perform task A. I am eager to know,which method will produce best performance? -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: importing module-performance
On Mon, Feb 2, 2009 at 3:11 PM, Chris Rebert wrote: > On Mon, Feb 2, 2009 at 1:29 AM, S.Selvam Siva > wrote: > > Hi all, > > I have a small query, > > Consider there is a task A which i want to perform. > > > > To perform it ,i have two option. > > 1)Writing a small piece of code(approx. 50 lines) as efficient as > possible. > > 2)import a suitable module to perform task A. > > > > > > I am eager to know,which method will produce best performance? > > A. Your question seems much too vague to answer. > B. Premature optimization is the root of all evil. In all likelihood, > the time taken by the `import` will be absolutely trivial compared to > the rest of the script, so don't bother micro-optimizing ahead of > time; write readable code first, then worry about optimization once > it's working perfectly. > > Cheers, > Chris > -- > Follow the path of the Iguana... > http://rebertia.com Thank you Chris, I faced a optimization problem as follow, For fuzzy string comparison initially i used 15 lines of code which compares a word with 29,000 words in a list .For each set of words compared, the 15-line code produce number of differences characters of the two words. But when i used python-levenshtein module for same reason it has run faster than the old method.This invoked me to raise that query. Now i understood that, it is not an issue of importing the module/writing the code, but the problem must be with my 15-line code. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
string replace for back slash
Hi all, I tried to do a string replace as follows, >>> s="hi & people" >>> s.replace("&","\&") 'hi \\& people' >>> but i was expecting 'hi \& people'.I dont know ,what is something different here with escape sequence. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: string replace for back slash
On Thu, Feb 5, 2009 at 5:59 PM, wrote: > "S.Selvam Siva" wrote: > > I tried to do a string replace as follows, > > > > >>> s="hi & people" > > >>> s.replace("&","\&") > > 'hi \\& people' > > >>> > > > > but i was expecting 'hi \& people'.I dont know ,what is something > different > > here with escape sequence. > > You are running into the difference between the 'repr' of a string (which > is what is printed by default at the python prompt) and the actual > contents of the string. In the repr the backslash needs to be escaped > by prefixing it with a backslash, just as you would if you wanted to > enter a backslash into a string in your program. If you print the string, > you'll see there is only one backslash. Note that you didn't need to > double the backslash in your replacement string only because it wasn't > followed by a character that forms an escape...but the repr of that > string will still have the backslash doubled, and that is really the > way you should write it in your program to begin with for safety's sake. > > Python 2.6.1 (r261:67515, Jan 7 2009, 17:09:13) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> s="hi & people" > >>> replacementstring = "\&" > >>> replacementstring > '\\&' > >>> print replacementstring > \& > >>> x = s.replace("&","\\&") > >>> x > 'hi \\& people' > >>> print x > hi \& people > > -- > http://mail.python.org/mailman/listinfo/python-list Thank you all for your response, Now i understood the way python terminal expose '\'. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
BeautifulSoup -converting unicode to numerical representaion
Hi all, I need to parse feeds and post the data to SOLR.I want the special characters(Unicode char) to be posted as numerical representation, For eg, *'* --> ’ (for which HTML equivalent is ’) I used BeautifulSoup,which seems to be allowing conversion from ""( numeric values )to unicode characters as follow, *hdes=str(BeautifulStoneSoup(strdesc, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)) xdesc=str(BeautifulStoneSoup(hdes, convertEntities=BeautifulStoneSoup.XML_ENTITIES))* But i want *numerical representation of unicode characters.* I also want to convert html representation like ’ to its numeric equivalent ’ Thanks in advance. *Note:* The reason for the above requirement is i need a standard way to post to SOLR to avoid errors. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Levenshtein word comparison -performance issue
Hi all, I need some help. I tried to find top n(eg. 5) similar words for a given word, from a dictionary of 50,000 words. I used python-levenshtein module,and sample code is as follow. def foo(searchword): disdict={} for word in self.dictionary-words: distance=Levenshtein.ratio(searchword,word) disdict[word]=distance """ sort the disdict dictionary by values in descending order """ similarwords=sorted(disdict, key=disdict.__getitem__, reverse=True) return similarwords[:5] foo() takes a search word and compares it with dictionary of 50,000 and assigns each word a value(lies between 0 to 1). Then after sorting in descending order it returns top 5 similar words. The problem is, it* takes long time* for processing(as i need to pass more search words within a loop),i guess the code could be improved to work efficiently.Your suggestions are welcome... -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: Levenshtein word comparison -performance issue
On Sat, Feb 14, 2009 at 3:01 PM, Peter Otten <__pete...@web.de> wrote: > Gabriel Genellina wrote: > > > En Fri, 13 Feb 2009 08:16:00 -0200, S.Selvam Siva < > s.selvams...@gmail.com> > > escribió: > > > >> I need some help. > >> I tried to find top n(eg. 5) similar words for a given word, from a > >> dictionary of 50,000 words. > >> I used python-levenshtein module,and sample code is as follow. > >> > >> def foo(searchword): > >> disdict={} > >> for word in self.dictionary-words: > >>distance=Levenshtein.ratio(searchword,word) > >>disdict[word]=distance > >> """ > >> sort the disdict dictionary by values in descending order > >> """ > >> similarwords=sorted(disdict, key=disdict.__getitem__, reverse=True) > >> > >> return similarwords[:5] > > > > You may replace the last steps (sort + slice top 5) by heapq.nlargest - > at > > least you won't waste time sorting 49995 irrelevant words... > > Anyway you should measure the time taken by the first part (Levenshtein), > > it may be the most demanding. I think there is a C extension for this, > > should be much faster than pure Python calculations. > > > > [I didn't see the original post] > > You can use the distance instead of the ratio and put the words into bins > of > the same length. Then if you find enough words with a distance <= 1 in the > bin with the same length as the search word you can stop looking. > > You might be able to generalize this approach to other properties that are > fast to calculate and guarantee a minimum distance, e. g. set(word). > > Peter > -- > http://mail.python.org/mailman/listinfo/python-list > Thank you all for your response, [sorry,I was away for a while.] I used functools,heapq modules but that helped me a little, then i categorized the words depending on the length and compares with a small set(each set 5/4=12,500), so now its taking quarter of time as compared to older method. Further, can i use Thread to achieve parallel comparison ?,as i have little knowledge on python-thread. Will the following code achive parallelism? thread1= threading.Thread(target=self.findsimilar, args=("1",searchword,dic-word-set1) thread2= threading.Thread(target=self.findsimilar, args=("2",searchword,dic-word-set1) thread3= threading.Thread(target=self.findsimilar, args=("3",searchword,dic-word-set1) thread1.start() thread2.start() thread3.start() thread1.join() thread2.join() thread3.join() I would like to hear suggestion. Note:The issue is i am developing spell checker for my local languge,i may use more than 2.5 lakh words,so i need to have a best way to find out alternative wordlist -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Posting File as a parameter to PHP/HTML using HTTP POST
I am trying to post file from python to php using HTTP POST method. I tried mechanize but not able to pass the file object. from mechanize import Browser br=Browser() response=br.open("http://localhost/test.php";) br.select_form('form1') br['uploadedfile']=open("C:/Documents and Settings/user/Desktop/Today/newurl-ideas.txt") response=br.submit() print response.read() But, i get the error: br['uploadedfile']=open("C:/Documents and Settings/user/Desktop/Today/newurl -ideas.txt") File "C:\Python25\lib\site-packages\clientform-0.2.9-py2.5.egg\ClientForm.py", line 2880, in __setitem__ ValueError: value attribute is readonly But, When uploading is done using browser, it works. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
Re: Posting File as a parameter to PHP/HTML using HTTP POST
I myself have found the solution. Instead of: br[br['uploadedfile']=open("C:/ > > Documents and Settings/user/Desktop/Today/newurl-ideas.txt") We Need to use: br.add_file(open("C:/ > > Documents and Settings/user/Desktop/Today/newurl-ideas.txt"), > filename="newurl-ideas.txt",name="uploadedfile") > On Tue, Dec 2, 2008 at 1:33 PM, S.Selvam Siva <[EMAIL PROTECTED]>wrote: > I am trying to post file from python to php using HTTP POST method. I tried > mechanize but not able to pass the file object. > > from mechanize import Browser > br=Browser() > response=br.open("http://localhost/test.php";) > br.select_form('form1') > br['uploadedfile']=open("C:/Documents and > Settings/user/Desktop/Today/newurl-ideas.txt") > response=br.submit() > print response.read() > > But, i get the error: > br['uploadedfile']=open("C:/Documents and > Settings/user/Desktop/Today/newurl > -ideas.txt") > File > "C:\Python25\lib\site-packages\clientform-0.2.9-py2.5.egg\ClientForm.py", > line 2880, in __setitem__ > ValueError: value attribute is readonly > > But, > When uploading is done using browser, it works. > -- > Yours, > S.Selvam > -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
pygtkspell-help
Hello, i am in a process of writing spell checker for my local language(Tamil). I wrote a plugin for gedit with pygtk for gui.Recently i came to know about pygtkspell ,that can be used for spell checking and suggestion offering. I am bit congused about it and could not able to get useful info by googling.It will be nice if someone can direct me in right way(may be by giving appropriate links or example program) -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
parsing javascript
I have to do a parsing on webpagesand fetch urls.My problem is ,many urls i need to parse are dynamically loaded using javascript function (onload()).How to fetch those links from python? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Need to store dictionary in file
Hi all, I have a dictionary in which each key is associated with a list as value. eg: *dic={'a':['aa','ant','all']}* The dictionary contains *1.5 lakh keys*. Now i want to store it to a file,and need to be loaded to python program during execution. I expect your ideas/suggestions. Note:I think cPickle,bsddb can be used for this purpose,but i want to know the best solution which runs *faster*. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
python php/html file upload issue
Hi all, I want to upload a file from python to php/html form using urllib2,and my code is below PYTHON CODE: import urllib import urllib2,sys,traceback url='http://localhost/index2.php' values={} f=open('addons.xcu','r') values['datafile']=f.read() #is this correct ? values['Submit']='True' data = urllib.urlencode(values) req = urllib2.Request(url,data) response = urllib2.urlopen(req,data) the_page = response.read() print the_page PHP/HTML CODE: html> "; } else { ?> " method="post"> Please enter a file name : But the *$_FILES['datafile']['name']* in response is always empty...I can not guess what went wrong with my code , I will be happy, if you can figure out the problem. -- Yours, S.Selvam -- http://mail.python.org/mailman/listinfo/python-list
editor with autocompletion
Hi friends, I am writing a new language. So I want an editor with auto complete. I there any such tool in Python ?(not only in python any other) I want it for my new lang help me Thanks siva -- http://mail.python.org/mailman/listinfo/python-list
read from standard input
Hi all, I wrote a program to read some data through standard input and write in a file. the following code works fine in linux. but its giving ArgumentError in windows. Code: import sys orig_source = sys.stdin.read() file=open('data.txt','w') file.write(orig_source) file.close() please post some solution . and what is the command in windows for EOF (like Cntrl D in linux) thanks in advance Siva -- http://mail.python.org/mailman/listinfo/python-list
Re: read from standard input
Hi Chris, Thanks for you reply. The error log is here for my above program in windows: Traceback (most recent call last): File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in orig_source = sys.stdin.read() AttributeError: read Regards, Siva On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote: > On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote: > > Hi all, > > > > I wrote a program to read some data through standard input and write in a > > file. > > the following code works fine in linux. > > but its giving ArgumentError in windows. > > There's no such error in Python; you're thinking of Ruby. > Unless you give the /actual/ error (with message) and full traceback, > there's not much we can do to help you besides just guess. > > > > file=open('data.txt','w') > > Don't use `file` as a variable name, you're shadowing the built-in type. > > > and what is the command in windows for EOF (like Cntrl D in linux) > > http://tinyurl.com/yggsby3 > The *very first result* has the answer in its 6th sentence. > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: editor with autocompletion
Hi All, Thanks for your reply. What I want is An Editor which can support Dynamic Languages with Autocomplete. I have my own language with some file extension (for ex: *.fs ) I can add few keywords to editor, it should support autocomplte. thats what my idea. plz send me pointers (good if it is open source.) I have seen Komodo edit but it looks too big any help plz. Regards, Siva On Fri, Dec 4, 2009 at 8:04 PM, Gerhard Häring wrote: > Siva B wrote: > > Hi friends, > > > > I am writing a new language. > > So I want an editor with auto complete. > > I there any such tool in Python ?(not only in python any other) > > I want it for my new lang > > IDLE, the Integrated Development Environment included with your Python > installation nowadays has autocompletion (I just check with the one > included in Python 2.6). > > -- Gerhard > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: read from standard input
for the line of code you given, print type(sys.stdin), sys.stdin the output is: there is no change. I have tried it in python2.6 on windows platform. Thanks, Siva On Sat, Dec 5, 2009 at 12:57 PM, Chris Rebert wrote: > > On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote: > >> > >> On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote: > >> > Hi all, > >> > > >> > I wrote a program to read some data through standard input and write > in > >> > a > >> > file. > >> > the following code works fine in linux. > >> > but its giving ArgumentError in windows. > >> > >> There's no such error in Python; you're thinking of Ruby. > >> Unless you give the /actual/ error (with message) and full traceback, > >> there's not much we can do to help you besides just guess. > >> > >> > >> > file=open('data.txt','w') > >> > >> Don't use `file` as a variable name, you're shadowing the built-in type. > >> > >> > and what is the command in windows for EOF (like Cntrl D in linux) > >> > >> http://tinyurl.com/yggsby3 > >> The *very first result* has the answer in its 6th sentence. > > On Fri, Dec 4, 2009 at 11:13 PM, Siva B wrote: > > Hi Chris, > > Thanks for you reply. > > The error log is here for my above program in windows: > > > > Traceback (most recent call last): > > File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in > > > orig_source = sys.stdin.read() > > AttributeError: read > > Okay, that Shouldn't Be Happening (tm). Add the following before line > 3 and post the output: > > print type(sys.stdin), sys.stdin > > And while we're at it, what version of Python are your running? > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
using csv dictreader in python
Hello all, I am now trying to access the csv file using dictreader. import csv r25 = csv.DictReader(open('Report_ 25', 'rb'), delimiter=',') rownum = 1 for row in r25: # Save header row. if rownum == 0: header = row else: colnum = 0 for col in row: This only gets me the following output {'FieldName1': '4', 'FieldName2': '0.00', 'FieldName3': '4001433', 'FieldName4': '759'} 1. How do i access the 4, 0.00, ... the values ? 2. How do i compare it with another csv file ? Thanks in advance Siva -- http://mail.python.org/mailman/listinfo/python-list
python compare and process a csv file
Hello all, I am new on this list and computer programming I have two distinct statistical files (both csv) 1. Report_2_5 – this is a report dump containing over a 10 million records and is different every day 2. Customer_id dump – this is a daily dump of customers who have made payments. This is generally a million record I need to extract past history depending on customers who make regular payments For example, Report_2_5 Customer ID, Plan_NO, stat1, vol2, amount3 2134, Ins1, 1, 2, 10 2112, Ins3, 3, 2, 10 2121, Ins3, 3, 2, 10 2145, Ins2, 15000, 1, 5 2245, Ins2, 15000, 1, 5 0987, Ins1, 1, 2, 10 4546, Ins1, 10020, 21000, 10 6757, Ins1, 10200, 22000, 10 … customer_id dump 0987 4546 6757 2134 I need to process the Report_2_5 and extract the following output Stat1: 40220 Vol2 : 83000 Amount3 : 40 I am new to programming and I have been extracting this data using MS – Access and I badly need a better solution. Will really appreciate any sample code in python. Thanks in advance Siva -- http://mail.python.org/mailman/listinfo/python-list
messages
For Good messages please visit http://messagezonehere.blogspot.com/2010/03/friendly-messages.html -- http://mail.python.org/mailman/listinfo/python-list
Need Translation library
hi all, i wish to code for translation in python i want to parse a python program itself and make some keyword changes (replacement) tell me any library to parse python source code and another library to change some words phonetically to other language thanks in advance Siva -- http://mail.python.org/mailman/listinfo/python-list
Python Enhancement Proposal for List methods
Hey everyone, I am really new to Python contribution community want to propose below methods for List object. Forgive me if this is not the format to send an email. 1. *list.replace( item_to_be_replaced, new_item )*: which replaces all the occurrences of an element in the list instead of writing a new list comprehension in place. 2. *list.replace( item_to_be_replaced, new_item, number_of_occurrences )*: which replaces the occurrences of an element in the list till specific number of occurrences of that element. The number_of_occurrences can defaulted to 0 which will replace all the occurrences in place. 3. *list.removeall( item_to_be_removed )*: which removes all the occurrences of an element in a list in place. What do you think about these features? Are they PEP-able? Did anyone tried to implement these features before? Please let me know. Thank you, Sukumar -- https://mail.python.org/mailman/listinfo/python-list
Re: installing modules problem
Also make sure that the Pythonpath contains the folder where the modules are installed in your machine. - site packages folder. On Thu 8 Nov, 2018, 16:28 Thomas Jollans On 2018-11-08 06:04, Ian K. wrote: > > Hello, > > > > My name is Ian Kilty and I have been having trouble with pip. I have pip > > installed, and I have tried to install modules they say they are > installed > > in cmd, but when I go into python and import the module, it can't find > it. > > I hope there is a simple solution to this problem, please let me know as > > soon as possible. > > > > -- from Not A User because I don't want to be made fun of in Tron -- > > > > Hi! > > some questions: > > - is there any chance you have multiple versions of python installed? >Could you be using the wrong pip? > - what operating system are you using? > - what are you trying to install and use? > - how exactly are you trying to install and import this module? (exact >commands, exact copy-pasted output) > > -- Thomas > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
seek operation in python
file=open("input","r") line=file.seek(7) print line The above code is supposed to print a line but it prints "none". I don't know where the mistake is. Help.! -- https://mail.python.org/mailman/listinfo/python-list
Re: seek operation in python
There is a file named "input.cpp"(c++ file) that contains some 80 lines of code. -- https://mail.python.org/mailman/listinfo/python-list
ValueError: Input contains NaN, infinity or a value too large for dtype('float32')
Source Code: clean_train_reviews=[] for review in train["review"]: clean_train_reviews.append(review_to_wordlist(review, remove_stopwords=True)) trainDataVecs=getAvgFeatureVecs(clean_train_reviews, model, num_features) print "Creating average feature vecs for test reviews" clean_test_reviews=[] for review in test["review"]: clean_test_reviews.append(review_to_wordlist(review,remove_stopwords=True)) testDataVecs=getAvgFeatureVecs(clean_test_reviews, model, num_features) forest = RandomForestClassifier(n_estimators = 100) forest = forest.fit(trainDataVecs, train["sentiment"]) result = forest.predict(testDataVecs) output = pd.DataFrame(data={"id":test["id"], "sentiment":result}) output.to_csv("Word2Vec_AverageVectors.csv", index=False, quoting=3) Error Message: Traceback (most recent call last): File "/test_IMDB_W2V_RF.py", line 224, in result = forest.predict(testDataVecs) File "/.local/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 534, in predict proba = self.predict_proba(X) File "/.local/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 573, in predict_proba X = self._validate_X_predict(X) File "/.local/lib/python2.7/site-packages/sklearn/ensemble/forest.py", line 355, in _validate_X_predict return self.estimators_[0]._validate_X_predict(X, check_input=True) File "/.local/lib/python2.7/site-packages/sklearn/tree/tree.py", line 365, in _validate_X_predict X = check_array(X, dtype=DTYPE, accept_sparse="csr") File "/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 407, in check_array _assert_all_finite(array) File "/.local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 58, in _assert_all_finite " or a value too large for %r." % X.dtype) ValueError: Input contains NaN, infinity or a value too large for dtype('float32'). Process finished with exit code 1 Description : Can any one help with the error message. -- https://mail.python.org/mailman/listinfo/python-list
Reg : Wikipedia 1.4 package
Dear members, how to install wikipedia 1.4 package in python 2.7 above without PIP. from, Sivakumar S -- https://mail.python.org/mailman/listinfo/python-list
Reg : Wikipedia 1.4 package
Dear members, How to install Wikipedia 1.4 package in python 2.7 above without PIP. from, Sivakumar S -- https://mail.python.org/mailman/listinfo/python-list