1,175 Posted Topics

Member Avatar for El Duke

If there is no space in the rank or name you can do it this simple way: [code=python]mydata = """\ <Ranking: AA (John)> <Ranking: CA (Peter)> <Ranking: TA-A (Samantha)> """ rank_list = [] for line in mydata.split('\n'): print line, line.split() # testing if line: rank_list.append(line.split()[1]) print print rank_list """my result …

Member Avatar for vegaseat
0
139
Member Avatar for Scuppery

The recommended coding style for Python is: Do your imports Define your functions and/or classes Do the main code The bare minimum: Define your functions before you use them in your main code

Member Avatar for hondros
-2
2K
Member Avatar for ribot

Call for update() as shown below: [code]from tkinter import * class fb( Frame ): def fastbuttons( self ): b = Button(self) b.grid() self.update() print( b.winfo_ismapped() ) def __init__( self, master=None ): Frame.__init__( self, master ) self.grid( sticky='nsew' ) self.button = Button( self, text='Start', command=self.fastbuttons ) self.button.grid() if __name__ == '__main__': …

Member Avatar for ribot
0
110
Member Avatar for rajeshwari_ib
Member Avatar for sneekula
0
56
Member Avatar for baskar007

The module[B] threading[/B] is the higher level module and actually uses module [B]thread[/B], since that one has the lower level tasks. So one can assume that [B]threading[/B] is somewhat slower in speed, but nicer in syntax. Python3 adds another module called multiprocessing that can take advantage of multiple processsor machines.

Member Avatar for baskar007
0
83
Member Avatar for dinfadi

Here would be one way to accomplish this: [code=python]mylist = [ ['A', 60], ['B', 40], ['C', 90], ['B', 150], ['C', 230], ['A', 220] ] # convert to dictionary, put collision values into a list mydict = {} for sub in mylist: print sub # testing mydict.setdefault(sub[0], []).append(sub[1]) print print mydict …

Member Avatar for dinfadi
0
133
Member Avatar for ~s.o.s~

Could a counselor substitute for a mentor? Counselors are plentyful, mentors are in very short supply.

Member Avatar for alams
1
176
Member Avatar for mrnutty

[QUOTE=William Hemsworth;1072644]Yep, I've been forced to do VB in college, I really don't like it. One of my favourite languages is Flash Actionscript 2.0, its syntax is very similar to C++/Java, and it's extremely flexible and easy to use.[/QUOTE]There are entire hospital management systems written in vb, and sold for …

Member Avatar for ddanbe
0
247
Member Avatar for python.noob

[QUOTE=python.noob;1072569]snippsat.. Everybody is here with a question to be answered.. Google gives result for everything.. Then why people are answering and wasting their time??? Just can give the link to [url]www.google.com[/url].. I think you might not(matured) know the concept of a forum even though you are a member:S.. It is …

Member Avatar for vegaseat
0
161
Member Avatar for Ene Uran

A Turk got sore at his harem And thought of a scheme to scare them He caught him a mouse And let it loose in the house The chaos was called a "harem-scarem"

Member Avatar for chickenfarmer
0
359
Member Avatar for jwxie

Well, in Python just about anything is an object not just the typical OOP stuff. I assume that your instructor forgot about that and actualy means creating a class Student where each instance is a particular student.

Member Avatar for jwxie
0
111
Member Avatar for truekid

If you search DaniWeb, you will find a whole lot of similar requests about queues, stacks and html tag names. Looks like this homework has been given in the last few weeks to a bunch of folks. The Python manual describes the use of queues in detail. Your problem will …

Member Avatar for sneekula
0
106
Member Avatar for gangster88

You may also take a look at: [url]http://www.daniweb.com/forums/thread240778.html[/url]

Member Avatar for sneekula
0
597
Member Avatar for Musafir

There is a very similar thread at: [url]http://www.daniweb.com/forums/thread241913.html[/url]

Member Avatar for sneekula
0
393
Member Avatar for sneekula

I was trying to create a 3x3 list of lists, and came up with this surprising behaviour: [code]# creating a 2D list with an overloaded * operator mlist3 = [[0]*3]*3 print mlist3 # [[0, 0, 0], [0, 0, 0], [0, 0, 0]] mlist3[0][0] = 1 print mlist3 # [[1, 0, …

Member Avatar for Mathhax0r
0
1K
Member Avatar for gangster88
Member Avatar for jaison2
0
155
Member Avatar for Stefano Mtangoo

Get one of the many Python Learning Books they usually have plenty of exercises.

Member Avatar for elasolova
0
184
Member Avatar for Ancient Dragon
Member Avatar for bobfromphilly
6
200
Member Avatar for saikeraku

You could do: [code=python]for c in "Hello World": print c , [/code]In Python2 the comma puts in a space and keeps it on the same line.

Member Avatar for pythopian
0
127
Member Avatar for ljvasil

It's always good to use a few test prints: [code]import operator OPERATORS = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.div, } class Stack(object): "Creates a stack to enter numbers or operators into" def __init__(self): self.storage = [0,0,0,0] self.sptn = -1 def push(self, item): self.sptn = self.sptn + 1 …

Member Avatar for vegaseat
0
619
Member Avatar for SpectateSwamp

Yeah, I have heard enough of my fellow students brag about the amount of disk space on their brand new notebooks. I have never bought anything but a used notebook computer, so I have to be happy with disk space they gave you a few years ago. Actually more than …

Member Avatar for Bob_180_Bob
0
218
Member Avatar for Kruptein

What do you mean with "WxGlade does not show value"? Is it WxGlade or your program you wrote using WxGlade? Just a note on the smart side of things. If you have a problem for others to look at and possible solve, it behooves you to supply as much needed …

Member Avatar for Kruptein
-1
167
Member Avatar for MosaicFuneral

[QUOTE=GrimJack;1038840]But have you seen this l[URL="http://www.daniweb.com/forums/thread235892.html"]ink[/URL]?[/QUOTE]Wow, recursion in action! Very geeky too!

Member Avatar for sneekula
5
302
Member Avatar for nevets04
Member Avatar for sneekula
0
166
Member Avatar for parsifal67

Ah, the pros and cons on posting on an old thread. If you are interested in a regex solution, I would start a new thread and put regex in the title.

Member Avatar for mitsuevo
0
257
Member Avatar for sneekula

A mother and son were walking through a cemetery, and passed by a headstone inscribed "Here lies a good lawyer and an honest man." The little boy read the headstone, looked up at his mother, and asked "Mommy, why did they bury two men there?"

Member Avatar for vegaseat
1
495
Member Avatar for tygerberg

Rugby could become a sport, if they ever show it on the tele in the US.

Member Avatar for GrimJack
0
180
Member Avatar for zandiago

In a number of cases the parents should be spanked for bringing their unruly kids to a nice restaurant, where you just sat down to enjoy a special meal.

Member Avatar for BestJewSinceJC
0
889
Member Avatar for Mouche

I found and played a pretty sophisticated Tic Tac Toe game written in Python at an earlier posting here: [URL]http://www.daniweb.com/techtalkforums/thread26658.html[/URL]

Member Avatar for vegaseat
0
1K
Member Avatar for sneekula

I am still rather new to the Linux OS and need some detailed advice on the installation of Python3.1 on my Ubuntu machine. Python3.1 is not in the Ubuntu package repository yet.

Member Avatar for pdxwebdev
0
1K
Member Avatar for lewashby

[QUOTE=Garrett85;1031820]How do you know when to use a function by wraping the content between parentheses "function(x) or through dot notation x.function() ? thanks.[/QUOTE]You are somewhat confused about functions.

Member Avatar for masterofpuppets
0
161
Member Avatar for CaptainMack

[QUOTE=CaptainMack;262238]Hi i am new to daniweb.com, i was looking around this website and i saw that i needed to register. I am 17 years old and im from Gibraltar, i am studying French Spanish and Computing. I am hoping that i could learn a lot from other members as at …

Member Avatar for sneekula
-2
235
Member Avatar for trahrey

[QUOTE=cplspls;1031571]Kindly go to the C++ forum.[/QUOTE]I went to the C++ forum, but nothing happened. :)

Member Avatar for sneekula
-5
227
Member Avatar for jephthah
Member Avatar for wotthe2000

You are almost there: [code=python]def isCMD(msgstrlist): for word in msgstrlist: if word[0].upper() == 'C': print word else: print "Not CMD message" msgstrlist = ['Ox', 'Dog', 'Cow', 'mouse', 'cat'] isCMD(msgstrlist) """ my result --> Not CMD message Not CMD message Cow Not CMD message cat """ [/code]Note: Looks like you are …

Member Avatar for bumsfeld
0
2K
Member Avatar for ahihihi...

Computers are definitely female, here are the male reasons: 1) Most men who have one don't understand them. 2) Amongst themselves they talk in an incomprehensible language at high speed. 3) You need to tell them every trivial thing you want from them. 4) All of a sudden they refuse …

Member Avatar for Lardmeister
1
225
Member Avatar for LinkMaster03

With wxPython code you can give py2exe an XML based manifest to force it to adopt the Windows XP theme.

Member Avatar for Stefano Mtangoo
0
583
Member Avatar for leegeorg07

Looks like one of the 638 web pages is not available. You should use a try/except trap for this case.

Member Avatar for ov3rcl0ck
0
207
Member Avatar for OneDreamCloser

Something like that might do. I avoided the use of float() until the end to keep time-stamp and port info from turning into floats: [code=python]raw_data = """\ 501 0 0.932 0.933 0.931 0.931 0.929 0.933 0.93 0.928 501 1 0.974 0.98 0.978 0.976 0.974 0.974 501 2 0.953 0.949 0.944 …

Member Avatar for OneDreamCloser
0
163
Member Avatar for chico2009

I made an attempt on user friendly data entry with just such a simple temperature converter program, see: [url]http://www.daniweb.com/forums/showthread.php?p=992595#post992595[/url]

Member Avatar for chico2009
0
186
Member Avatar for blueness25

And don't forget to use self to turn those functions into methods for the instance, like def moveup(self):

Member Avatar for blueness25
0
804
Member Avatar for racshot65

At first, I would adopt consistent indentations! Very important in Python. Most people use 4 spaces.

Member Avatar for jlm699
0
119
Member Avatar for etypaldo

As a beginner use for loops first, later on 'list comprehensions' become more natural.

Member Avatar for sneekula
0
165
Member Avatar for Friktion

[QUOTE=Friktion;991252]well ok i can go back to pygame then , thanks but first i whant to try the thing above !! EDIT: Dude thanks i tried that and it worked =) i really appreciate your help thanks again, and no im not using all the features only the wav playing …

Member Avatar for Friktion
0
256
Member Avatar for mahela007

To make more sense you should have written your class this way: [code=python]class Animal: def __init__(self, legs): self.legs = legs cow = Animal(4) chicken = Animal(2) octopus = Animal(8) # Bob is a pet chicken with 1 leg missing bob = Animal(1) print( octopus.legs ) # 8 print( chicken.legs ) …

Member Avatar for djidjadji
0
175
Member Avatar for AutoPython

Gribouillis is right, global constants have their place, but like he mentioned, make them stick out. One time when all upper case is appropriate.

Member Avatar for AutoPython
0
331
Member Avatar for i are smart

Works fine on my Ubuntu machine. I copied the Python25/26 source from the webpage and saved it as cTurtle.py in my working directory. The module has a number of demos built in that look great and work well. I used the IDLE IDE, my normal IDE DrPython bitched about a …

Member Avatar for sneekula
0
252
Member Avatar for chico2009

Like gerard4143 says, you have to make the print statement part of the function, since Tf is local to the function. The other option would be to return Tf to make it available outside the function: [code=python]#Convert C to F def Tc_to_Tf (): Tc = input ("What is the Celsius …

Member Avatar for chico2009
0
194
Member Avatar for Benderbrau

Nice, looks like Python3 has bit your fancy. Sooner or later we all have to follow your example.

Member Avatar for Gribouillis
0
161
Member Avatar for optikali

Simply call the dispatch(choice) function with your choice as argument: [code=python]#!/usr/bin/python def dispatch(choice): if choice == 'A': functionA() elif choice == 'B': functionB() elif choice == 'C': functionC() else: print "An Invalid Choice" def functionA(): print "WRONG!" def functionB(): print "CORRECT!" def functionC(): print "WRONG!" choice = raw_input ("A, B, …

Member Avatar for sneekula
0
190

The End.