Vote count: 0 when i execute this piece of code in the decorator the func.count=0 is not assigned and the incrementation is not done. Could anyone help me in solving this problem and make the decorator to retu the func.count and get the correct output as required def count_calls(skip_recursion=True): if skip_recursion==True: def ier(func): func.count=0 def counter(i): func.count+=1 retu func.count retu counter retu ier else: def ier(func): func.count=0 def counter(i): func.count+=1 retu func.count retu counter retu ier def test_calls_decorator(): @count_calls() def fib(n): if n...
ادامه مطلبVote count: 0 I have a list which contains english alphabets,Hindi alphabets,Greek Symbols and digits as well. I want to remove all alphabets except that of Hindi. Hindi alphabets range in unicode is u'0900'-u'097F'. For details about Hindi alphabets visit http://jrgraphix.net/r/Unicode/0900-097F. Input: l=['ग','1ए','==क','@','ऊं','abc123','η','θ','abcशि'] for i in l: print i Desired Output: ग ए क ऊं शि asked 38 secs agoishpreet Let's block ads!...
ادامه مطلبVote count: 0 I found this code for a simple chat server here http://www.ibm.com/developerworks/linux/tutorials/l-pysocks/ and it works using telnet. It works so beautifully and i really want to modify it to have a GUI.I don't understand how do i have the clients type in the messages through a GUI window instead of the terminal using telnet.I am attaching the code for ease : import socket import select class ChatServer: def __init__( self, port ): self.port = port; self.srvsock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) self.srvsock.setsockopt...
ادامه مطلبVote count: 0 enter image description here I want to get descriptive statistics in python using describe function in pandas library. I want the summary statistics for column contb_receipt_amt at level of cand_nm. I tried using aggreggate and groupby function but could nt implement it correctly. Also, how can i use decribe for a selective column in python. asked 38 secs agoAbhisek Gupta This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.Recommended article from FiveFilters.org: Most Labour MPs in the UK Are Revolting....
ادامه مطلبVote count: 0 Download not working in python? I've written a simple python program, to get files from FTP location but when executing it's give [Ero 13] Permission denied message. My code is as follows. Any idea why is this ? import ftplib from ftplib import FTP, error_perm def getFTPDir(dirpath): f = ftplib.FTP(ip, useame, password) try: f.cwd(dirpath) nameList = f.nlst() oldest = nameList[0] newest = nameList[-1] newest = oldest newDirPath = dirpath +'/'+ newest print f.cwd(newDirPath) subNameList = f.nlst() for i in range (len(subNameList)): f.cwd( newDirPath + '/' + str(subNameList[i]) ) nameList1 = f.nlst() filename = nameList1[i] print "downloading..............", filename f.retrbinary...
ادامه مطلبVote count: -1 I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API Python version - 2.7 The Java API is as follows There is a Process interface public interface Process { Future create(Client client) } There are two implementations of Process . For simplicity I have shown the implementation of one 1) FirstProcess2) SecondProcess public class FirstProcess implements Process { Future create(Client client) { } } There is a ProcessFactory public interface ProcessFactory { Process createProcess() } There are two implementations of ProcessFactory1) FirstProcessFactory2) SecondProcessFactory For simplicity I have just shown the implementation of one p...
ادامه مطلبVote count: 0 So I was trying to convert pixel to spatial coordinates when i found the package image_geometry. So i decided i would try to use it, i initialized it, and called the desired function, taken fro the API. Here's what i did import image_geometry from image_geometry import PinholeCameraModel self.img_geo = PinholeCameraModel() (r_x,r_y,r_z) = self.img_geo.projectPixelTo3dRay((359,285)) print(r_x) Obviously the self.img_geo is in my init function and then later on i use the projection function, and then get that error. Any ideas whats wrong? asked 24 secs agolaurent Let's block ads!...
ادامه مطلبVote count: 0 this myRDD data for 2 rows [u'#fields:excDate|schedDate|TZ|custID|muID|tvID|acdID|logonID|agentName|modify|exception|start|stop|LS Oracle Emp ID|Team Lead', u'06152016|06152016|CET|3|3000|1688|87||Ali, AbdElaziz|1465812004|Open|08:00|09:00|101021021|ElDeleify,Hisham'] How to replace the | with , so that i can build the dataframe. Is their any better way to build the Dataframe with such data. ? asked 4 mins agoSamir Matkar 1 Answer Vote count: 0 >>> data = [u'#fields:excDate|schedDate|TZ|custID|muID|tvID|acdID|logonID|agentName|modify|exception|start|stop|LS Oracle Emp ID|Team Lead', u'06152016|06152016|CET|3|3000|1688|87||Ali, AbdElaziz|1465812004|Open|08:00|09:00|101021021|ElD...
ادامه مطلبVote count: 0 How can I python to open a file on my mac? I am currently working on a project to proof read for curse words but I can't seem to be able to open the word document in which I want python to check. I have all the code done and dusted but I am having trouble opening the file for python to read. I am also a begier so if you could please explain it to me that would be great. Here is a sample of my code: def read_text(): quotes = open("/Users/AquaAurelius/Documents/Home/Programming/Houston") contents_of_file = quotes.read() #print contents of file print(contents_of_file) quotes.close() read_text() Thank you, Yours Sincerely, AquaAurelius asked 2 mins agoMarcus Let's block ads!...
ادامه مطلبVote count: 0 I want to create a web based scraper using Python, Selenium and PhantomJS where you can input a url into a form and the results from the scrape will be retued to the webpage. I can run it on my PC and I can also get it to work through the terminal. It is located in a virtual environment on Dreamhost shared hosting with Python3.5 installed. I have tested that the parameters are being passed in fine, and it does work using just lxml and requests. However, when I try to run the script from the form on the webpage using PhantomJS then it doesn't work properly. The following error in retued... Traceback (most recent call last): File "testscrape.py", line 140, in driver = init_driver...
ادامه مطلبVote count: 0 I have python code as below. It searches a google news page and prints hyperlinks and titles for each news. My problem is that googlenews groups news that are similar in one bucket and below script prints only 1st news in each bucket. How can I print all new from all buckets? from bs4 import BeautifulSoup import requests headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'} #r = requests.get('http://www.aflcio.org/Legislation-and-Politics/Legislative-Alerts', headers=headers) r = requests.get('https://www.google.com/search?q=%22eric+bledsoe%22&tbm=nws&tbs=qdr:d', headers=headers) r = requests.get('https:...
ادامه مطلبVote count: 0 I am creating folder after checking non-existance of folder with same name. However I am unable to check for the folder using 'isdir' if folder name contains only numbers. print(os.path.isdir('D:Git_FileIAutomationdir4534565')) True print(os.path.isdir('D:Git_FileIAutomation4534565')) False Is there any alteative way to do this? asked 1 min agoTester P Let's block ads!...
ادامه مطلبVote count: 0 Here is the code which i used for crawling a web page. The site I want to scrape has images lazy loading enabled, so scrapy can only grab 10 out of 100 images, the rest are all placeholder.jpg for item in items: listing = Item() listing['image'] = item.css('div.product img::attr(src)').extract() listing['url'] = item.css('div.item-name a::attr(href)').extract() listings.append(listing) What would be the best way to deal with lazy loading images? Thanks! asked 1 min agoWill W Let's block ads!...
ادامه مطلبVote count: 0 I am trying to create a .txt file in a folder which is not the directory the script is being run from. I have a folder where the script is, and I am able to create the folder in the same directory the script is in but It won't create the text file in the folder. I usually run in to one of two errors: PermissionError: [Ero 13] Permission deniedor, FileNotFoundError: [Ero 2] No such file or directory: This is for a password keeper btw, and to prevent five people telling me it's not secure, I am aware of this, this project is purely educational and I always use placeholders. Here is my code: def main(): import os import os.path abc = open("userpassfile.txt", "r+") userpassfile = a...
ادامه مطلبVote count: 0 I am writing a cypher and I've assigned numerical values to every letter in the alphabet, alphabet_dictionary = {'a': 0, 'b': 1, 'c': 2,... etc.}. I first convert the letter in message to numbers and do some arithmetic on them and store those numbers in a variable named code, but then I want to convert them back to letters, how do I go about doing that? so far this is what I have: for number in code: for letter, value in alphabet_dictionary.items(): if value == number: coded_message.append(letter) this actually works, I end up with a the correct coded message inside my coded_message list. But I am wondering if there is something better or more efficient I can do. ps: If you cou...
ادامه مطلبVote count: 0 I am writing an automation script in python using argparse module in which I want to use the -s as an option which takes file/file path as an argument. Can somebody help me to do this? asked 1 min agoAlagu Jeeva Let's block ads!...
ادامه مطلبVote count: 0 Teaching myself Python out of a book and I'm stuck on this exercise: A movie theater charges different ticket prices depending on a person’s age. If a person is under the age of 3, the ticket is free; if they are between 3 and 12, the ticket is $10; and if they are over age 12, the ticket is $15. Write a loop in which you ask users their age, and then tell them the cost of their movie ticket. I know how to make it work without using a loop but I am a uncertain how to make it work using a while loop. Any advice or examples would be greatly appreciated. asked 3 mins agoiriejams This entry passed through the Full-Text RSS service - if this is your content and you're reading it on ...
ادامه مطلب