- Strength to Increase Rep
- +14
- Strength to Decrease Rep
- -3
- Upvotes Received
- 469
- Posts with Upvotes
- 366
- Upvoting Members
- 148
- Downvotes Received
- 17
- Posts with Downvotes
- 14
- Downvoting Members
- 10
Re: To make some futher i improvement's. All code is now in functions, explanation is moved into function so it work as doc-string(then it's possible to use `help()` on functions). I have removed all `global` statement which it's not good at all. Functions should be isolated code,that takes argument's and return … | |
Re: Hi see if this help you. [CODE]>>> str_input = '''AATTCCGGTTT CCTTAACCCCC''' >>> str_input 'AATTCCGGTTT\nCCTTAACCCCC' >>> x = str_input.replace ('\n', '') >>> x 'AATTCCGGTTTCCTTAACCCCC' >>> [/CODE] | |
Re: [QUOTE]but it says its not right, whats wrong with it?[/QUOTE] The code works,python always give you Traceback. Post Traceback next time. Run of code. [CODE]>>> generateNumber(0,10,2) [0, 2, 4, 6, 8, 10] >>> generateNumber(20,0,-3) [20, 17, 14, 11, 8, 5, 2] >>> [/CODE] | |
Re: This was very bad,not worth anyone times. The gui builder for wxpython could be better,but they are much better than this. | |
Re: Dont use bold character for everthing. Here is and example you can look at and try out. [CODE]#average.py #saved in python dir from __future__ import division def average(seq_in): if isinstance(seq_in, (list, tuple)): return sum(seq_in) / len(seq_in) else: return 'Input can only be list or tuple' [/CODE] So we save this … | |
Re: You are doing some strange stuff. Do you get urllib to work for this site? import urllib2 url = "http://www.blah.fi/" read_url = urllib2.urlopen(url).read() print read_url #403 error This site are blocking use of urllib. I had to use [Requests](http://docs.python-requests.org/en/latest/) to get source code. You can use BeautifulSoup to get all … | |
Re: You dont need to convert code just write it in python. I could of course convert it to look exactly like C++ over,but that had been stupid. Because python dos most stuff a lot eaiser than C/C++. [CODE] print 'Enter numers,use q to stop' l = [] while True: user_input … | |
Re: You have some mistake,and use code tag. See if this help. [CODE]def main(): phrase = input("Enter a sentence:") words = phrase.split() #Forget () wordCount = len(words) print("The total word count is: %s" % wordCount) #You have to include wordCount in print main()[/CODE] | |
Re: Something like this? import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) #--Panel so it look good on all platforms self.panel = wx.Panel(self) self.datepick = wx.DatePickerCtrl(self.panel,-1, pos=(20,15), style=wx.DP_DROPDOWN|wx.DP_SHOWCENTURY) self.datepick.Bind(wx.EVT_DATE_CHANGED, self.onAction) self.label = wx.StaticText(self.panel,-1,"", pos=(20,50)) def onAction(self, event): '''Process data from picked date''' selected = self.datepick.GetValue() … | |
Re: I have done some tesing and got it to work(windows 7 Ultimate) First my test code. #sound_test.py import pyttsx import time from datetime import date from datetime import datetime engine = pyttsx.init() date = date.today() time_now = datetime.now() date = date.strftime("%A %d %B") time_now = time_now.strftime('%H:%M:%S') engine.say('The date is {} … | |
Re: [CODE]import wx class my_window(wx.Frame): def __init__(self, parent, id): #error __int__ wx.Frame.__init__(self,parent,id,'My Window', size=(300,200)) #Panel for frame self.panel = wx.Panel(self) self.SetBackgroundColour('blue') if __name__ == "__main__": app=wx.PySimpleApp() frame=my_window(parent=None,id=-1) frame.Show() app.MainLoop()[/CODE] | |
Re: As posted by @dashing.adamhughes there are made a lot of stuff that can help you with this,another eksp is [pyfasta](http://pypi.python.org/pypi/pyfasta/) > How to get the start and end position of a particular pattern You can use `re.finditer` for this. >>> import re >>> s = '11ATGC1111ATGC11111ATGC' >>> p = 'ATGC' … | |
Re: Look like you use python 3 [CODE]>>> #Python3 has only input that return a string >>> user_input = input('Give me a number: ') Give me a number: 10 >>> user_input '10' >>> type(user_input) <class 'str'> >>> print 'Your number was %s' % (user_input) SyntaxError: invalid syntax (<pyshell#4>, line 1) >>> … | |
Re: [QUOTE]what has fileHandle been replaced with in python 3.1[/QUOTE] FileHandle is just a variable name used by vega. You can use whatever name you want. Here is the same code for python 3 [CODE] # Testet work for python 3 # read a text file as a list of lines … | |
Re: Start to read where you post,this is the python part of Daniweb. Post in VB forum. [QUOTE] Trying hard since 1 week... Cn u plz provide me a code for d same ??? I got submissions in few days... Pllzzz.... Thanx !![/QUOTE] And nowone post finsih code,if you dont show … | |
Re: The same for me "InBox" and "Send Message" has not work after change to Dazah. Both give `Rate limit exceeded: Please try your request again in a few minutes.. ` Same on all pc. Has to copy cookie to from working login,to other computer just to get login to work. … | |
Re: I see you have get good help from Gribouillis. As a note `with open` was new in python 2.5. python 2.2.1 is really old. Alternatives is to write your own parser that works for your files,it`s not so hard. If i use config file postet by Grib. cfg_dict = {} … | |
Re: Use wheel as posted bye Gribouillis. PyMongo has C depencies so to avoid this [Installing from source on Windows](https://api.mongodb.com/python/current/installation.html#installing-from-source-on-windows) Go [here](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymongo),when dowloaded your version. Do e.g **pip install pymongo-3.3.0-cp35-cp35m-win32.whl** Wheel(.whl) has all C depencies packed,no need to compile. | |
Re: To set it up more,correct and fix error. Capitale letters in `method == 'POST'` Have remove GET to avoid to confusion. foo\ app.py templates\ index.htm `app.py` from flask import Flask,redirect,url_for,request,render_template app = Flask (__name__) @app.route('/') def my_form(): return render_template("index.html") @app.route('/suc/<name>') def suc(name): return "hello Boss %s" % name @app.route('/login', methods=['POST']) … | |
Re: Your pasting of xml is a mess:) The best is to use [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/)/lxml. E.g from bs4 import BeautifulSoup xml ='''\ <?xml version="1.0" encoding="UTF-8"?> <note> <to>Hello</to> <from>wold</from> <msg timestamp="20160817 12:46:42.520" level="INFO">Info on CPU</msg> </note>''' #soup = BeautifulSoup(open("your.xml"), 'html.parser') #Read from a file soup = BeautifulSoup(xml, 'html.parser') msg = soup.find('msg') print(msg.text) … | |
Re: > I like python and I wanted to give it a try at web programming but the setup and management is too difficult. I'll just go back to php. It's not so difficult,and you do not need stuff like LAMP. Django and Flask has build in web-server this you use … | |
Re: It's in [http.cookie](https://docs.python.org/3/library/http.cookies.html) for Python 3.x. So import is `from http import cookies` For all about HTTP use [Requests](http://docs.python-requests.org/en/master/) >>> import requests >>> url = 'http://httpbin.org/cookies' >>> cookies = dict(cookies='are good to eat') >>> r = requests.get(url, cookies=cookies) >>> print(r.text) { "cookies": { "cookies": "are good to eat" } } | |
Re: > what if I need to take seperate nosetests html report for each file.. How can I do that ? Yes as bash script looping over files will work,or a Python script with `subprocess`. There are build into nose to test all files that start `test`. So naming your files … | |
Re: Command you has to be string and you concatenate "line" inside `os.system()`. So if i have i list of words and want to now lenght of each word, i can use linux command `expr length`. The command get executed on each line of words.txt. import os import time f = … | |
Re: The problem can be solved before give data to Pandas. As mention over there are lot of cases to think about. I would have made up rules with regex. Example. >>> import re >>> s = "Richard Wayne Van Dyke" >>> re.split(r"\s*(?:(?:[a-zA-Z]')|(Van \w.*))", s, re.I)[:-1] ['Richard Wayne', 'Van Dyke'] >>> … | |
Re: A more normal way to use __int__ (constructor) in a python class. And just some point that a class is storeing variables in a dictionary. [CODE]from math import sqrt class ageName(object): '''class to represent a person''' def __init__(self, name, age): self.name = name self.age = age worker1 = ageName('jon', 40) … | |
Re: Just some points,always use raw string [B]r' '[/B] with regex. For email validation re.match(),for extracting re.search, re.findall(). There is no simple soultion for this,diffrent RFC standard set what is a valid email. This has been up in several forum,here is a good one you can read. [url]http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses[/url] Just a quick … | |
Re: >Is that what gets returned if the letter is not in the dictionary? So if it can't find the letter it adds 0? Yes,and you can also return a more meaningful message. Here in function and return value out. def record(word): return { "t": 1, "f": 1, "c": 1, "b": … | |
| Re: >Beautiful Soup is for python . i am using windows and vb.net You should find a parser for vb.net,like [Html Agility Pack ](http://htmlagilitypack.codeplex.com/) >i have been doing some research. >and found out about Regular expressions..... Regex i bad tool for html,read this funny answer bye [bobince ](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags). >gives me pratice … |
Re: I have to say that i don't like this tagging system at all. Maybe it's get better when i get used to it,but i am not sure. In Python part of the old forum we had sticky thread, do we really need to search for those threads now? Or can … |