4,305 Posted Topics

Member Avatar for FengG

Looks like you have made nice progress with coding pygame. The pygame module has something called [B]sprites[/B] that, as far as I remember, are more suitable for what you have in mind.

Member Avatar for FengG
0
140
Member Avatar for GrimJack
Member Avatar for zyrus001

Thanks for letting the rest of us know! Most folks use protocol=-1 as the highest possible protocol.

Member Avatar for vegaseat
0
282
Member Avatar for wrobl1rt

If [B]remove('an', 'banana') --> 'bana'[/B] then this should be [B]remove('iss', 'Mississippi') --> 'Missippi'[/B] So you can use ... [code]def remove(sub, s): # replace first sub with empty string return s.replace(sub, "", 1) # test print( remove('an', 'banana') ) # --> bana print( remove('iss', 'Mississippi') ) # --> Missippi [/code] If …

Member Avatar for vegaseat
0
6K
Member Avatar for python123
Member Avatar for python123
0
244
Member Avatar for FengG

The culprit is screen.blit(background, (0,0)) I moved it out of the event loop, and rewrote your program just a little to reflect Python coding convention better ... [code=python]import pygame as pg def main(): # initialize pygame pg.init() screen = pg.display.set_mode((640, 480)) pg.display.set_caption('game') background = pg.Surface(screen.get_size()) background = background.convert() background.fill(pg.color.Color('yellow')) # …

Member Avatar for FengG
1
126
Member Avatar for PixelHead777

An entry in the Python26 manual: No one has made a Windows port of the curses module. On a Windows platform, try the Console module written by Fredrik Lundh. The Console module provides cursor-addressable text output, plus full support for mouse and keyboard input, and is available from [url]http://effbot.org/zone/console-index.htm[/url].

Member Avatar for PixelHead777
0
320
Member Avatar for Missy!

The Now Generation will blame his parents, so where did his parents go wrong?

Member Avatar for kalia247
-9
240
Member Avatar for Ri0o

Simply posting the same question with another meaningless title again is in rather poor taste. People have given you advice, so apply it and go from there. We will not do homework for you, since you are the one that has to learn something!

Member Avatar for Ri0o
-1
124
Member Avatar for sneek

Gribouillis hit it right. Another observation, the C version of a module, method or function is built-into the compiled interpreter itself (or in the form of a [B]dll[/B] or [B]pyd[/B] file). Python language versions are in the [B]Lib[/B] directory. I can only speak for the Windows version of Python here.

Member Avatar for pythopian
0
139
Member Avatar for shaan07

[B]from xml.sax.saxutils import XMLGenerator[/B] I have no experience with the XMLGenerator, but I know it is used to create xml files.

Member Avatar for pythopian
0
132
Member Avatar for lewashby

I agree with snippsat, don't tie yourself down with an outdated book and outdated custom modules. Pygame has come out for Python3, and will be around for hopefully more than just a few years. If you learn pygame programming directly, you have learned something worthwhile.

Member Avatar for vegaseat
0
102
Member Avatar for lewashby

LiveWires is a pretty well dated Python course that uses a module called games as a wrapper for PyGame. It is supposed to make the use of PyGame easier for the beginner. Looking over the module games.py, there is no init() method, unless there is a much newer version out.

Member Avatar for vegaseat
0
236
Member Avatar for Ri0o

Actually. your raw data file is tab delimited and easily converted into a list of lists. Once that is done you can simply access your specific data by index and looping through the list. The only special considerations are that the first line is a header and the last line …

Member Avatar for Ri0o
0
179
Member Avatar for Mathhax0r
Member Avatar for efecto

It can be as simple as this ... [code=python]import os import time # pick a file you have in the working directory filename = "beachball.jpg" # show file creation time print( time.ctime(os.path.getctime(filename)) ) [/code]

Member Avatar for efecto
0
248
Member Avatar for Mouche

Nice game, but like mawe says, your (PVC) 'player wins' detector does not work! Something to work on.

Member Avatar for vegaseat
0
1K
Member Avatar for vegaseat

This shows how to create, load and access a ListBox. BCX was used to create the original code which was then modified to work with the Dev C++ (really GCC/G++) compiler, compile as a Windows Application.

Member Avatar for lashatt2
0
1K
Member Avatar for zyrus001

In line [B]print cipher.encrypt(lines)[/B] are you sure all the characters are printable? BTW, Python relies on indentations, please keep them constant.

Member Avatar for mn_kthompson
0
556
Member Avatar for pdxwebdev

[QUOTE=pdxwebdev;1032220][CODE] def doKey(e): print(e.widget.get("1.0","end")) root= Tk() root.title('yada') txta = Text(root, width=40, height=10) txta.bind("<Key>", doKey) txta.pack(side=LEFT) root.mainloop() [/CODE] Pressing a key in this text area will always output the string prior to your pressing the key. Am I missing something?[/QUOTE]You could use [B]txta.bind("<KeyRelease>", doKey) [/B]

Member Avatar for pdxwebdev
0
144
Member Avatar for BattlingMaxo

The closest Python module that I can think of is visual Python (VPython), a free download from [url]http://vpython.org[/url]. Also take a look at some examples at: [url]http://wiki.aims.ac.za/mediawiki/index.php/Vpython:Getting_Started#Basics[/url]

Member Avatar for vegaseat
0
95
Member Avatar for masterofpuppets

Take a look at: [url]http://www.daniweb.com/forums/showthread.php?p=1032475#post1032475[/url]

Member Avatar for masterofpuppets
0
961
Member Avatar for kenmeck03
Member Avatar for Zaffron

What do you think it should print? Here is a typical class example ... [code=python]class MyName: def __init__(self, name): self.name = name def print_name(self): print "Hi, I am", self.name def __str__(self): """overloads str() and hence print applied to instance""" return "My name is %s" % self.name name = 'bob' mm …

Member Avatar for vegaseat
0
75
Member Avatar for lewashby

In function(x) x is the outside argument passed to the function. In x.function() x is the namespace of the module or instance used. You better read up on functions! See ... [url]http://www.swaroopch.com/notes/Python_en:Functions[/url]

Member Avatar for masterofpuppets
0
161
Member Avatar for CaptainMack

All is relative! If you count the time since the [B]big bang[/B], then 3 years is almost nothing.

Member Avatar for sneekula
-2
235
Member Avatar for trahrey

I am glad the OP didn't ask for a particular hand.:) This thread is starting to get funny and belongs into the Geek's Lounge! Just in case ... [QUOTE]Directions 1 the act of directing; management; supervision 2 [usually pl.] instructions for doing, operating, using, preparing, etc. 3 an authoritative order …

Member Avatar for sneekula
-5
227
Member Avatar for AutoPython

[QUOTE=AutoPython;1030006]I can't find a compiler to compile version 3 Python scripts to .exe. All the compilers I see are all for Python 2.[/QUOTE]Just a clarification: The software you are talking about does not compile, but forms a packet of your compiled byte code, all the needed modules, and the Python …

Member Avatar for vegaseat
0
188
Member Avatar for thehivetyrant

Here is a simple example that just erases and redraws the shape ... [code=python]# exploring module pygame # draw a white circle on a black screen and move it # by erasing and redrawing the circle within a set time delay import pygame as pg # (r, g, b) tuple …

Member Avatar for vegaseat
0
8K
Member Avatar for P3run

Let's hope that the code you are showing is not exactly like in the tutorial. There are some major mistakes in your code. Also, please do not use tabs for indentations! In most editors tabs come out as 8 spaces and make the code look rather messy. I don't even …

Member Avatar for snippsat
0
130
Member Avatar for python.noob

Please make your title a bit more specific the next time around.:) If you are a beginner with GUI programming, stick with Tkinter to get used to the basics of how to set up a GUI, and then move to something with fancier widget as you need them. A lot …

Member Avatar for vegaseat
0
139
Member Avatar for nerdagent
Member Avatar for jay 11

Schmidt's statement that a Netbook running with Google OS expected by 2010 is another eyebrow raiser.

Member Avatar for vegaseat
0
255
Member Avatar for mishu5770l

The other option is ... [code=python]import random list1 = ["1", "2", "3"] string1 = random.choice(list1) string2 = """\ Random Number is %s""" % string1 print(string2) [/code]... this makes the output more visual in your code.

Member Avatar for vegaseat
0
106
Member Avatar for mms6

Can you give us a simplified example what strA and strB would look like? Also, have you checked this: [url]http://biopython.org/wiki/Main_Page[/url]

Member Avatar for AutoPython
0
103
Member Avatar for nizbit

You can use this little function ... [code=python]def extract(text, sub1, sub2): """ extract a substring from text between first occurances of substrings sub1 and sub2 """ return text.split(sub1, 1)[-1].split(sub2, 1)[0] str1 = "<a href='http://www.google.com'>more stuff here</a>" str2 = extract(str1, "='", "'>") print( str1 ) print( str2 ) # http://www.google.com [/code]

Member Avatar for vegaseat
0
279
Member Avatar for rackster992

The best way to learn any computer language is to experiment with the concepts of the language, and if you are stuck, search the manuals and ask question on a language forum like this.

Member Avatar for dcghelp
0
1K
Member Avatar for Yeen

[QUOTE=pspwxp fan;1028792]Heheh, i could say i'm good at Python even though this is the first time i'm seeing its code! :D[/QUOTE]I keep telling folks that C++ and Python have much in common, by design the Python syntax is much easier on the eye. If you just want to toggle between …

Member Avatar for pspwxp fan
0
101
Member Avatar for Ancient Dragon
Member Avatar for vegaseat
0
23
Member Avatar for mms6

Can be as simple as this ... [code=python]strA = 'B' print(strA in 'ABCD') [/code]

Member Avatar for mms6
0
89
Member Avatar for scrace89

These two lines: ______________ = _______________("Enter the filename : ") file = ________(filename, __________) should be: filename = raw_input("Enter the filename : ") file = open(filename, "r") Picking [B]file[/B] as a variable name is a little unfortunate, since [B]file[/B] is a function name in Python2.

Member Avatar for vegaseat
0
384
Member Avatar for nevets04

Good effort, but super-long variable names and tab indentations make this code hard to fathom. Please avoid tab indentations as they translate into 8 spaces here in the DaniWeb code field. The standard that most folks are accustomed to is 4 space indentations for Python. Again, the general coding guide …

Member Avatar for nevets04
-2
311
Member Avatar for rush_ik52

To run the stopwatch in the background, you need to check out the Python module threading.

Member Avatar for snippsat
0
824
Member Avatar for bdesc100

You need to add these 2 lines to the beginning of your program code ... [code=python]import sys sys.path.append('/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages') [/code]

Member Avatar for vegaseat
0
4K
Member Avatar for mms6

I am a little lost. Would this be a correct statement? [QUOTE]str1 and str2 should contain one of [B]A T G C[/B] and form a combination of [B]AT[/B] or [B]TA[/B] and [B]CG[/B] or [B]GC[/B][/QUOTE] If that's the case then this should do ... [code=python]def is_base_pair(str1, str2): s = str1 + …

Member Avatar for vegaseat
0
132
Member Avatar for msaenz

Just a note: dictionaries keep their keys in a hash order to speed up searches. If you want to keep the entry order you can just use a list of (key, value) tuples which you can also sort if need be.

Member Avatar for vegaseat
0
167
Member Avatar for bol0gna

Can you give us a [B]short[/B] example what your data file looks like and what you want to extract?

Member Avatar for bol0gna
0
354
Member Avatar for Gribouillis
Member Avatar for thehivetyrant
Member Avatar for vnproduktionz

Here is a simple introduction: [url]http://en.wikipedia.org/wiki/Python_programming_language[/url] Swaroop C.H. has rewritten his excellent beginning Python tutorial/book for Python3: [url]http://www.swaroopch.com/notes/Python_en:Table_of_Contents[/url] More advanced: "Dive Into Python" Mark Pilgrim's free online book, novice to pro, updated constantly. [url]http://www.diveintopython.org[/url] rewritten for Python3 (check appendix A for 2to3 differences) [url]http://diveintopython3.org/[/url] Also "Think like a Python Programmer" …

Member Avatar for vegaseat
0
130

The End.