Posts
 
Reputation
Joined
Last Seen
Ranked #75
Strength to Increase Rep
+14
Strength to Decrease Rep
-3
96% Quality Score
Upvotes Received
469
Posts with Upvotes
366
Upvoting Members
148
Downvotes Received
17
Posts with Downvotes
14
Downvoting Members
10
85 Commented Posts

880 Posted Topics

Member Avatar for fonzali

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 …

Member Avatar for Thati
0
5K
Member Avatar for joe82

Hi see if this help you. [CODE]>>> str_input = '''AATTCCGGTTT CCTTAACCCCC''' >>> str_input 'AATTCCGGTTT\nCCTTAACCCCC' >>> x = str_input.replace ('\n', '') >>> x 'AATTCCGGTTTCCTTAACCCCC' >>> [/CODE]

Member Avatar for vishakha_3
0
23K
Member Avatar for pwolf

[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]

Member Avatar for Reverend Jim
1
1K
Member Avatar for macroasm

This was very bad,not worth anyone times. The gui builder for wxpython could be better,but they are much better than this.

Member Avatar for Titus_1
-4
2K
Member Avatar for novice20

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 …

Member Avatar for Cisco_1
0
37K
Member Avatar for r3bol

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 …

Member Avatar for happygeek
0
6K
Member Avatar for shibunath

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 …

Member Avatar for Zak_2
0
6K
Member Avatar for Fo.katia

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]

Member Avatar for woooee
0
13K
Member Avatar for ihatehippies

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() …

Member Avatar for gdtraveller
0
2K
Member Avatar for otengkwaku

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 {} …

Member Avatar for Thomas Karl
0
2K
Member Avatar for HoneyBadger

[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]

Member Avatar for Rufus_1
0
11K
Member Avatar for sudipta.mml

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' …

Member Avatar for Matej_1
0
350
Member Avatar for john_beginner

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) >>> …

Member Avatar for Reverend Jim
0
21K
Member Avatar for ruwach

[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 …

Member Avatar for gunjan_3
0
63K
Member Avatar for Ruchi224

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 …

Member Avatar for Schol-R-LEA
-1
202
Member Avatar for tinstaafl

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. …

Member Avatar for Dani
1
546
Member Avatar for hpoddar

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 = {} …

Member Avatar for Anand_10
0
12K
Member Avatar for <HHH>

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.

Member Avatar for ~s.o.s~
0
2K
Member Avatar for <HHH>

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']) …

Member Avatar for snippsat
0
597
Member Avatar for karthik_6

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) …

Member Avatar for snippsat
0
633
Member Avatar for lewashby

> 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 …

Member Avatar for lewashby
0
1K
Member Avatar for <HHH>

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" } }

Member Avatar for <HHH>
0
5K
Member Avatar for Karthik_4

> 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 …

Member Avatar for Karthik_4
0
13K
Member Avatar for pirulo64

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 = …

Member Avatar for pirulo64
0
279
Member Avatar for mattrweaver

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'] >>> …

Member Avatar for snippsat
0
3K
Member Avatar for checker

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) …

Member Avatar for Gribouillis
0
2K
Member Avatar for arindam31

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 …

Member Avatar for Syed Sulaiman
3
10K
Member Avatar for bryann

>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": …

Member Avatar for snippsat
0
267
Member Avatar for westsiderailway

>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 …

Member Avatar for overwraith
0
666
Member Avatar for Dani

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 …

Member Avatar for Nick Evan
2
1K
Member Avatar for v1shwa

>Where should I host a python project on linux? I'm sure there'd be multiple choices. So, Where would you host it & on what circumstances? Github,Bitbucket... If you mean web-host,pythonanywhere,Heroku,Webfaction,Digital ocean... >I understand that virtualenv creates a virtual environment separate from others. But, why should one need it? Do we …

Member Avatar for v1shwa
0
578
Member Avatar for ipman99

>I just started to learn python few days ago. This is a small program I made to practise. Ok,some points. names = ['(1) Sphere','(2) Right Circular Cone','(3) Cylinder'] x=0 while x < 3: print(names[x]) x +=1 This is not the way to loop in Python. You just iterate over list …

Member Avatar for snippsat
0
2K
Member Avatar for DragonMastur

>I am trying to convert a file to a dictionary here is the contents of the file, You can data keep structure bye using serialization, then you don't have to struggle to recreate structure from a string. JSON is preferably over Pickle. import json record = { 'Name': 'DragonMastur', 'Hand': …

Member Avatar for Gribouillis
0
360
Member Avatar for Shailang

>A must read Or a better [read ](http://docs.python-requests.org/en/latest/user/advanced/#proxies) You should really look into and use [Requests](http://docs.python-requests.org/en/latest/) Shailang.

Member Avatar for Shailang
0
356
Member Avatar for Steven N

>really don't even know which webpage language I should use HTML, PHP, SQL something else?. You can of course use Python. Micro-framework like [Flask](http://flask.pocoo.org) can be a good place to start. Python has bigger Framework like [Django](https://www.djangoproject.com/), [web2py](http://www.web2py.com/) or CMS like [Django-cms](http://www.django-cms.org/en/). These has a lot of tools,and can be …

Member Avatar for steven.rose.94
0
384
Member Avatar for Slavi

If you search for cola you see this url. `https://datacvr.virk.dk/data/visninger?soeg=cola&type=Alle` Generate own search url's. >>> url = 'https://datacvr.virk.dk/data/visninger?soeg={}&type=Alle' >>> search_lst = ['car', 'train'] >>> for item in search_lst: ... print(url.format(item)) ... https://datacvr.virk.dk/data/visninger?soeg=car&type=Alle https://datacvr.virk.dk/data/visninger?soeg=train&type=Alle E.g of take out some data,here all title text when search for cola. import requests from bs4 …

Member Avatar for Slavi
0
384
Member Avatar for Zeinab_1

It work's for me when i do a little test,using Pyhon 3.4.2. mytxt1.txt: http://ascii.cl?parameter=%22Click+on+%27URL+Decode%27%21%22 login=bob%40%3CSCRipt%3Ealert%28Paros%29%3C%2FscrIPT%3E.parosproxy.org http://ascii.cl?parameter=%22Click+on+%27URL+Decode%27%21%22 login=bob%40%3CSCRipt%3Ealert%28Paros%29%3C%2FscrIPT%3E.parosproxy.org outtxt1.txt: http://ascii.cl?parameter="Click+on+'URL+Decode'!" login=bob@<SCRipt>alert(Paros)</scrIPT>.parosproxy.org http://ascii.cl?parameter="Click+on+'URL+Decode'!" login=bob@<SCRipt>alert(Paros)</scrIPT>.parosproxy.org

Member Avatar for Zeinab_1
0
338
Member Avatar for Niloofar24

from bs4 import BeautifulSoup import urllib2 html = ''' <img src="smiley.gif" alt="Smiley face" height="42" width="42">''' soup = BeautifulSoup(html) images = soup.find('img') print(images['src']) #smiley.gif

Member Avatar for Gribouillis
0
17K
Member Avatar for Zeinab_1

>Also, strings in Python 3 are unicode so enocde and decode are not necessary. That's only true if text is already inside Python 3. Here we are talking about taking text from outside into Python 3, then we must define a encoding like utf-8,latin-1..., or it will give an error …

Member Avatar for vegaseat
0
268
Member Avatar for Atul_4

Python do have build in libraries that can generate key which hold cryptographic strength. Her use [SHA-256](https://en.wikipedia.org/wiki/SHA-2) >>> import hashlib >>> hashlib.sha256(b"licence key").hexdigest() 'ad26f374a671d9add68a110b31769667691a54ed599e791b5c8eb065b16c9ddc' Will also metion [cryptography](https://github.com/pyca/cryptography) which is the future for cryptographic in Python.

Member Avatar for snippsat
0
659
Member Avatar for getanshub4u

2 books that are ok. [url]http://www.amazon.com/Beginning-Python-Professional-Magnus-Hetland/dp/1590599829/ref=sr_1_5?ie=UTF8&qid=1304460522&sr=8-5[/url] [url]http://www.amazon.com/Practical-Programming-Introduction-Pragmatic-Programmers/dp/1934356271/ref=sr_1_14?ie=UTF8&qid=1304460522&sr=8-14[/url] Reading starting python on site,a lot of good example. [url]http://www.daniweb.com/software-development/python/threads/20774[/url] [QUOTE]So,I have like 3-4 months to learn python and i wanna be really good at it[/QUOTE] You get the basic in 3-4 months,really good take long time.

Member Avatar for dewhales
0
449
Member Avatar for Niloofar24

The most Pythonic `[::-1]` There is also reversed used with join(). Python34 handels Unicode good if you get Persian language correct decoded into Python34. In Python34 *are all strings a sequences of Unicode characters*. Just so you know,there is a big difference between Unicode handling Python 2 and 3. >>> …

Member Avatar for megaflo
0
403
Member Avatar for halo_123

Kind off help whit some clear messages. [CODE]>>> we_dot_do_homework_if_no_effort_is_shown = 2 >>> 1 % we_dot_do_homework_if_no_effort_is_shown 1 >>> 2 % we_dot_do_homework_if_no_effort_is_shown 0 >>> 3 % we_dot_do_homework_if_no_effort_is_shown 1 >>> 4 % we_dot_do_homework_if_no_effort_is_shown 0 >>> stupid = 3 >>> show_effort = 4 >>> if stupid % we_dot_do_homework_if_no_effort_is_shown == 1: print'Odd' else: print 'even' …

Member Avatar for PartVIII
-11
2K
Member Avatar for Mark54

lxml need to be compiled,and for Python3.4 you most have Visual Studio C++ 2010(Windows). But there is an easier way,go to [Gohlke](http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml) pre-compiled wheel. Download `lxml‑3.4.4‑cp34‑none‑win32.whl` place it in `C:\python34\Scripts` folder. Start *cmd* navigate to `C:\python34\Scripts` folder. Then do `pip install lxml‑3.4.4‑cp34‑none‑win32.whl`. As info so is [pip](https://pip.pypa.io/en/stable/) pre-install(Scripts folder) on …

Member Avatar for DragonMastur
0
283
Member Avatar for Brandon500

Here is a hint. >>> user_input = 'The quick brown fox jumps over a lazy dog' >>> word_lst = user_input.split() >>> word_lst ['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'a', 'lazy', 'dog'] >>> len(word_lst) 9 >>> [len(c) for c in word_lst] [3, 5, 5, 3, 5, 4, 1, 4, 3] sum([len(c) …

Member Avatar for Brandon500
0
364
Member Avatar for wudie47

wudie47 read your [post](https://www.daniweb.com/software-development/python/threads/497089/file-name-as-a-string-parameter),just 1 day old, vegaseat did answer with the preferred way `os.path.splitext()`. >>> import os >>> filename = 'python.exe' >>> os.path.splitext(filename) ('python', '.exe') >>> os.path.splitext(filename)[-1] '.exe' >>> name, extension = os.path.splitext(filename) >>> name 'python' >>> extension '.exe'

Member Avatar for wudie47
0
507
Member Avatar for 승환

Need to see code to,and not just Traceback. Do `print(ser)` and `print(type(ser))`,then i think you see that's `ser` is an integer and not a fileobject. To create same Traceback. >>> ser = 5 >>> ser.readline() (most recent call last): File "<interactive input>", line 1, in <module> AttributeError: 'int' object has …

Member Avatar for snippsat
-1
239
Member Avatar for Irene26

There is also a [markdown2](https://github.com/trentm/python-markdown2) module. import markdown2 markdown = """\ # Hello, how are you I'm fine, thank you I know that it is not so **hard** but for me it's not so *easy* What is ##this? How about `*this*`? **it *wor`k`s!*** Let me put a bold link: [**stuff**](http://41.media.tumblr.com/49a58542fd70b8ca39b5bd0d9c9c53aa/tumblr_nob40mvTN41tb9nzio1_500.jpg) …

Member Avatar for Gribouillis
0
378
Member Avatar for jamesjohnson25

A good technique to understand code is to break it up in smaller parts. For this is interactive interpreter great to us, also us `print()` in code on places you wonder what's happends. So lets say you wonder about `deque(maxlen=history)`. >>> from collections import deque >>> lst = [1, 2, …

Member Avatar for snippsat
0
301
Member Avatar for vegaseat

[QUOTE]I was wondering if there are any GUI toolkits in python that create native-looking windows in Windows 7[/QUOTE] Wxpython-PyQt dont have the ugly and native-looking that Tkinter has on all windows version. Tkinter look better on linux,mac. I postet a wxpython picture here. [url]http://www.daniweb.com/forums/thread252780.html[/url] Wxpython are a very good gui-toolkit …

Member Avatar for vegaseat
9
45K

The End.