Posts
 
Reputation
Joined
Last Seen
Ranked #3K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
2
Posts with Upvotes
2
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
1 Commented Post
0 Endorsements
Ranked #746
~72.1K People Reached
Favorite Tags

73 Posted Topics

Member Avatar for vegaseat

Or, sort a list of class objects by an attribute (similar idea as above): [CODE=python]import operator import string def normcaps(strg): s = string.upper(strg[0]) + strg[1:] return s class Man: def __init__(self,name,pos,age): self.name = name.lower() self.pos = pos.lower() self.age = age def __getitem__(self,key): return self.__dict__[key] def __repr__(self): return self.__str__() def __str__(self): …

Member Avatar for vegaseat
23
34K
Member Avatar for Zebibyte

Also, you might want to make sure you are always dealing withe floats: [CODE=python]>>> float(499.99) 499.99000000000001 >>> float(500) - float(499.99) 0.0099999999999909051 >>> round(float(500) - float(499.99),2) 0.01 >>> type(499.99) <type 'float'> >>> type(500) <type 'int'>[/CODE] And round is definitely a must.

Member Avatar for newbieee
0
748
Member Avatar for zachabesh

There seems to be a variety of ways to do this on the net, does anybody have a tested solution? Suggestions to look at various modules and such appreciated. I don't need the full code.

Member Avatar for zarfishan
0
5K
Member Avatar for AnjaliThukral
Member Avatar for vegaseat
-1
1K
Member Avatar for Clueless86

Heh heh, I love eclipse, but the interactive shell (a la IDLE) is pretty darn awesome for testing stuff out. Example: [CODE=python]>>> #start with your function >>> def count_chars(char,string): """A functiont that counts how many chars in the string""" pass >>> strg = 'bunnies' >>> count_chars('n',strg) #nothing happens! >>> def …

Member Avatar for Stefano Mtangoo
0
322
Member Avatar for huskeraider

From what you've said, it sounds like you have to print out elements 3 through 6 (if 0 is the first element) of a list. This will print those 4 elements, doesn't matter how long the list is. [CODE=python]n = 3 while n <= 6: print lst[n] n += 1 …

Member Avatar for lllllIllIlllI
0
5K
Member Avatar for bgk111

I would suggest that instead of storing the data in separate lists, store all the data in a class. example: [CODE=python]class Data: def __init__(self,row,value,var1,var2): self.row = row self.value = value self.var1 = var1 self.var2 = var2 [/CODE] Call this for each row of data, put all of the classes in …

Member Avatar for bgk111
0
94
Member Avatar for zachabesh

Hi all, Here's my issue: [CODE=python]>>> a = [1,2,3] #all good so far >>> b = a #make a copy of a, called b >>> b.remove(1) #remove value 1 from b ONLY >>> print a #grrr, value has also been removed from a [2, 3] >>> print b #and b! …

Member Avatar for zachabesh
0
102
Member Avatar for Dan08
Member Avatar for Dan08
0
252
Member Avatar for nondecorum

More info, plz. State clearly what you are trying to to. Are you going to try and use python to parse the results (via html scrape)? Because that would likely mean regular expressions and that would be tough.

Member Avatar for woooee
0
345
Member Avatar for flipjoebanana

Should be noted that Python won't mutate your string. If you say [ICODE]s = "'Quote Example'\tby person\n"[/ICODE] s will always be that string unless you reassign it. When you print it, python interprets the '\t's to be tabs, but s is still the same.

Member Avatar for zachabesh
0
117
Member Avatar for zachabesh

Hi all, I'm trying to mimic an html form that calls a script on the web. When I put the form together on a page, it works, and I was wondering if there was a way I could "scrape" this post request and see what I'm missing when I try …

Member Avatar for zachabesh
0
99
Member Avatar for zachabesh

Hey all, Here's my problem: I have a class that I want to be able to save and and load. But I need the class to be mutable I guess. Check it out: [CODE=python]class Tool: def __init__(self,name,function): self.name = name self.function = function self.savename = self.name + '.txt' def save(self): …

Member Avatar for foosion
0
101
Member Avatar for Missy_poo

Whenever I start a script I usually write out in plain English what I want to do. It will keep you organized and you will never not know "where to start." Comment out the plain english, and script around it. For example, here is the "skeleton" for a script to …

Member Avatar for Stefano Mtangoo
0
103
Member Avatar for leanne86

[QUOTE=leanne86;934802]That's the problem, I don't know where I can find the pstats code. I was just given the link and asked to fix it. Normally if it was something like [url]www.mycompany.com.au/files/something.html[/url] - I would know to log on to my website then go to the folder files and then edit …

Member Avatar for jlm699
0
191
Member Avatar for dilbert_here00

Your code looks somewhat roundabout. Quick sanity check, make the Label this and see if it works: [CODE=python]label = Label(parent,text = 'Hi world!',background = 'yellow')[/CODE] If theres a highlighted piece of text ('Hi World') your label works and it's an issue with displaying the image. Whenever I do anything, I …

Member Avatar for dilbert_here00
0
445
Member Avatar for darangho
Member Avatar for darangho
0
3K
Member Avatar for penguin22

Neither am I. Interacting with mail servers like yahoo and gmail is unfortuanaetly not as simple as: connect, login, email. See below for what I use, but you may need to experiment with yahoo. The basic flow is connect, say hi,encryt, say hi (all secret like), log in, mail stuff. …

Member Avatar for zachabesh
0
1K
Member Avatar for mishra59
Member Avatar for sleign

What is the obsession with global variables? Seriously. Pass the necessary elements to your function, and return them back. You seem to be doing half of this, but you are not putting your return variables into anything. as in: [CODE=python]checkLimb(armRight) #bad, your return value isn't put into anything.[/CODE] This is …

Member Avatar for woooee
0
383
Member Avatar for ChipT

I would say it depends on your server configuration. Python has a MySQLdb module that lets it interact easily with MySQL databases (you would likely have to install it), but I'm not totally sure in terms of other databases. I'm becoming a bigger fan of php for websites to be …

Member Avatar for Stefano Mtangoo
0
132
Member Avatar for zachabesh

Hey all, Working on a medium sized Tkinter app. I have it working fine, but I feel like the app isn't as clean as I would like it to be, namely because I have a million labels and different widgets and I can't figure out what to call them... For …

Member Avatar for bumsfeld
0
93
Member Avatar for penguin22

[url]http://www.google.com/search?q=flash+command+line+arguments[/url] Welcome to the interwebs. Use 'em.

Member Avatar for zachabesh
0
87
Member Avatar for zachabesh

Hey all, Here's my problem: php/mysql noob here. I have an admin section on the website, and I have successfully password protected all the php pages in that directory using sessions. I have included code like this on the top of each of my pages: [code=php]<?php include('login.php'); if (checkLogin() != …

Member Avatar for zachabesh
0
148
Member Avatar for Aiban

How's this for a solution: Instead of worrying about what email client your users are using, have python send the email for them, through an account that you set up! It's fairly easy to get python to send email if you have an email account with smtp. Your GUI would …

Member Avatar for Aiban
0
138
Member Avatar for Clueless86

You should really check out the tutorial on python.org. Anyway, since you're having trouble wrapping your head around try except, here's a basic outline that handles bad choice slightly differently [CODE=python]#a simple class for our user class Player: def __init__(self,name): self.day = 0 self.name = name def __str__(self): s = …

Member Avatar for jlm699
0
414
Member Avatar for bgk111

Okay, I quickly glanced over your code. It doesn't look like it works at all. Am I right? Note that subprocess.Popen only creates the instance, it doesn't run the command line. You need to use the methods communicate() or poll(). Once you get your command line to run, the python …

Member Avatar for bgk111
0
124
Member Avatar for Stefano Mtangoo

This sounds awesome, but it also sounds like an API would be useful here. If you have the API (not sure if one exists) for MSN/YAHOO then I think that's where you should start. If you post a link to the API here that would be pretty neat too.

Member Avatar for Stefano Mtangoo
0
109
Member Avatar for sravan953

Link directly to it. ie: somesite.com/myscript.py But make sure your print statements are "html" ie: print "<P> Hello shadowickman </p> " There are certain rules you have to follow for cgi scripts, they are mentioned earlier in this thread. I definitely recommend python for web development if you have been …

Member Avatar for sravan953
0
243
Member Avatar for freddiecool

This thread makes my head hurt. Do you need to store all the info about the cars in a python module? What about a csv? Also, if you're going to call a class in a module, that class has to be part of the module if you're not doing it …

Member Avatar for freddiecool
0
575
Member Avatar for gsingh2011

Hey there, The short answer is that you haven't looked hard enough. ;) I realize that you probably don't want to hear that, so here's a quick and dirty explanation. Most sites don't like computers logging themselves into their protected areas. For this reason, they have created security to check …

Member Avatar for zachabesh
0
1K
Member Avatar for dontgetit

Mmkay. The first step is determining what your input and output are. I believe the input is the cheques.data file, and your output is the XHTML that looks something like this: [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>All Cheques</title> <style type="text/css"> td.amount { …

Member Avatar for zachabesh
0
144
Member Avatar for Alex!

Or you could just read up on the behavior of the canvas widget. Honestly doesn't really sound like you need the canvas. Labels and Text widgets should do it.

Member Avatar for vegaseat
0
116
Member Avatar for sravan953

lol dude, because subprocess.call takes a list as it's first arg! [CODE=python]filename = 'song.mp3' myList = ['myprog.exe',filename] subprocess.call(myList)[/CODE] Definetly look up the subprocess module, there's a whole lot more you can pass to call() that will help you direct your output, etcetera. You may want to look into the Popen …

Member Avatar for zachabesh
0
111
Member Avatar for sneekula

Shameless promotion: [url]http://www.nudebeachfilms.org[/url] I use bluehost.com to host the site, and I put all sorts of other junk on it too, because as far as I can tell it's unlimited. Also unlimited subdirectories. But I pay for it. And as many of you know, you have to pay up front …

Member Avatar for zachabesh
0
202
Member Avatar for Clueless86

Are you making a game? If you have a variable Gold and you want to add 200 to it (I'm assuming the player just got off work), why not just say: [icode=python]Gold = Gold + 200[/icode] Too easy? Or get fancy, say you have another variable called job: [CODE=python]def get_pay(job): …

Member Avatar for shadwickman
0
313
Member Avatar for thenameisprayag

I haven't found the smtplib module to be super reliable, but here's what I use to send email: [CODE=python]def email(usertuple,sender,to,subject,msg): """Sends an email from a gmail account""" (login,pswd) = usertuple print 'Connecting...' mailServer = smtplib.SMTP("smtp.gmail.com", 0) print 'Initiating relationship...' mailServer.ehlo() print 'Encrypting...' mailServer.starttls() print 'Initiating encrypted relationship...' mailServer.ehlo() print 'Logging …

Member Avatar for jlm699
0
838
Member Avatar for pads_irl

you code confuse me too. Note this: [CODE=python]>>> range(11,12) [11] >>> for i in range(11,12): print i 11 [/CODE] You're only executing your first loop for when r = 11, ie 1 time only. Give us a little more code and some context. But yeah, no need for a loop …

Member Avatar for pads_irl
0
92
Member Avatar for Your_mum

Not really recommended, since you don't really always want to pause your code but I think you want this: [CODE=python]class Name: def __init__(self): self.name = raw_input("Name: ")[/CODE] However, I'd have to agree that snippsat's solution is a better written class, because if neccessary you could use it on names that …

Member Avatar for Your_mum
0
136
Member Avatar for foosion

code executes line by line, so with your code the label won't update until dosomething(x) is complete. Your dosomething function should theoretically call a callback everytime it finishes a block. urllib.urlretrieve sends a callback after every block for example. Since I'm assuming you wrote your own function, maybe this would …

Member Avatar for foosion
0
203
Member Avatar for rajasekhar1242

[QUOTE=sneekula;921987]Here is a Python output with an image: [code=python]# draw a flower with module turtle import turtle as tu tu.title('I call this one Flower') [/code] heh heh, that's awesome. The doc page for the turtle module: [url]http://docs.python.org/library/turtle.html[/url] My C++ teacher had made a similar thing for Beginning programming called "Athlete"

Member Avatar for zachabesh
0
4K
Member Avatar for hughesadam_87

Hey, I had a similar issue. I believe the easiest answer is to create a shared pylib and put your module in that folder. It's not wise to have multiple copies of modules, because when you change one, you end up having to change them all. So, have all your …

Member Avatar for hughesadam_87
0
128
Member Avatar for Rhijaen

You sounds like you've got it together, so the simple explanation is: -Google shutil.copytree. -Modify. -Execute. :) If you want a complete solution I can talk more about this, but I figured you might just want a poke in the right direction. os.walk is useful, but kinda tough to bend …

Member Avatar for shadwickman
0
136
Member Avatar for sravan953

Dude. Come on. You've posted in like 3 different threads about this very thing: [url]http://www.daniweb.com/forums/thread203590.html[/url] Search the string you get from the user for 'why.' There are several solutions in the linked thread.

Member Avatar for zachabesh
0
96
Member Avatar for Dan08
Member Avatar for Stefano Mtangoo
0
109
Member Avatar for Morika

count() will return the number of [B]non-overlapping[/B] instances. See this page: [url]http://docs.python.org/library/string.html[/url] I wrote a function a while back to find all occurrences of x in a larger string. The idea is that you step along the string looking at snippets the size of the word you are trying to …

Member Avatar for woooee
0
105
Member Avatar for dstar

Pop your log file open before you get the current ip and parse out the most recent ip logged. Then compare it with the current ip address. [CODE=python]if most_recent_ip != current_ip: print "Your IP changed!" else: pass[/CODE] Also, your last 3 lines don't really do much. ;)

Member Avatar for zachabesh
0
137
Member Avatar for wotthe2000

A good rule of thumb: Get your data (whether it be from a file, user input, etc...) and THEN do stuff to it. It looks like you're trying to open your input file and also write to your output at the same time. So, if booklist.txt looks like this: book1 …

Member Avatar for zachabesh
0
141
Member Avatar for zachabesh

Hey all, I'm working on a project combining a javascript bookmarklet and a php script that lets users mail the url of the site they are currently browsing to their email address. I had a PHP issue solved over in the PHP forum: [url]http://www.daniweb.com/forums/thread202375.html[/url] But now I have a new …

Member Avatar for codejoust
0
123
Member Avatar for denniskhor

I would use os.listdir, and shutil.move (or copy). Here's a useful function to sort by extension: [CODE=python]def filterbyext(filelist,ext): """Returns all files of type ext in filelist""" returnfiles = [] for item in filelist: x = item.split(".") try: #Take all files of THIS type if str(x[1]) == ext: returnfiles.append(item) except IndexError: …

Member Avatar for zachabesh
0
133

The End.