4,305 Posted Topics
Re: Take the string and spell it in reverse. Compare the two strings, if they match you got a palindrome. Now show us some code! | |
Re: Can you live with this? [code=python]""" [two spaces]6.0730000e+003[tab][one space]-9.2027000e+004[tab][two spaces]7.8891354e+01[tab]\r\n """ my_line = ' 6.0730000e+003\t -9.2027000e+004\t 7.8891354e+01\t\r\n' my_list = [eval(n) for n in my_line.split(None)] print my_list """ result --> [6073.0, -92027.0, 78.891354000000007] """ [/code] | |
Re: I don't have my Builder up anymore, but replace MB_OK with zero and see what happens. | |
Re: My totally uneducated guess is that the Python folks switched to an installer made for Vista. Vista has a whole set of rather childish security traps. | |
Re: Which version of PyScripter are you using? I have run into problems with wxPython code with earlier versions of PyScripter. Presently I am using the latest update (version 1.9.1.0). Pyscripter is still in beta mode, but seems to improve with every update. Get the latest update using Tools/Check Updates. Look … | |
Re: Sorry to say that, but it doesn't even look like a wig, it looks more like a leftover piece of carpeting. Ontopic, wo needs numbers or marks when you have DNA? Then of course, corrupt judges, politicians and the like would hardly leave DNA evidence behind. | |
Re: [quote=iamthwee;428472]What is a segway?[/quote]A single axle two wheeled thingy powered by an electric motor. Doesn't everybody have one? | |
Re: Looks and smells like spam! I let the members of the Python forum be the judge! | |
Re: My boss is the sweetest person, may she stay on vacation forever! | |
Re: The Department of Education does a swell job with only 5,000 employees. Just imagine what good of a job it could do with 5,000,000 employees! The [URL="http://en.wikipedia.org/wiki/No_Child_Left_Behind_Act"][U][COLOR=green]No Child Left Behind Act[/COLOR][/U][/URL] has made our public school system very creative when it comes to fudging the data as required. Finally some … | |
Re: A little blurb from Borland: [quote] 4. Using TD.EXE in a Windows DOS box ------------------------------------ The TD.PIF file included with the BC45 installation insures the proper settings for running the DOS based Turbo Debugger (TD.EXE) in a Windows DOS box. If need be, you can create this .PIF file using … | |
Re: Should be a thing of the past. In earlier years of computing, when 16bit operating systems were king, memory used to be addressed in segments/chunks of 64k (2**16). If you crossed one of those segments, you got a fault message. Python's memory manager shouldn't give you any problems like that! … | |
Re: Your fate to a large extend is the result of the will of other human beings. You may be born into a family of wealth or thiefs, into a messy war or dictatorship, into an area of religious extremists or enlightened well educated people. The list goes on and is … | |
Re: Love to put ketchup on my sunny side ups, together with a medium rare steak! Also a side of simmered mushrooms. Breakfast is my meal of the day! | |
Re: The easiest way is to extablish a temporary list of numeric values ... [code=python]mixed_list = [1, 0.5, 0, 3, 'a', 'z'] print max(mixed_list) # shows z, but would like it to be 3 number_list = [] for x in mixed_list: if type(x) in (int, float): number_list.append(x) print number_list print max(number_list) … | |
Re: Python or Ruby? I would say that Python has the better syntax, and is easier to read and understand. As you learn Python, take a look into simple C++ programming every now and then. There are quite a number of similarities to discover. I like this analogy: Learning Python is … | |
Re: The easiest way would be to simply slice your list ... [code=python]y = re.split('/+','http://www.mercury.tiser.com.au/blabla')[0:2] print y # ['http:', 'www.mercury.tiser.com.au'] [/code] | |
| |
Re: Don't wedge your for loops detween two function defines! Rewrite your code like this ... [code=python]import wx import wx.grid import getdata db = getdata.Eb_db() class MyFrame(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.grid_1 = wx.grid.Grid(self, -1, size=(1, 1)) self.__do_layout() # end wxGlade … | |
Re: Make sure you give it the correct size of the icon ... [code=python]from PIL import Image import ImageDraw im = Image.new("RGB", (500,500), "white") draw = ImageDraw.Draw(im) icon = Image.open("icon1.jpg") # get the correct size x, y = icon.size im.paste(icon, (0,0,x,y)) del draw im.save("test.jpg", "JPEG") # optional, show the saved image … | |
Re: Nice deduction there kath! Python does equate True with 1 and False with 0. | |
Re: Need a bit more info. Do you want to start the game from the server? | |
Re: Do all of us, including yourself, a favor and don't mix tabs and spaces for the 'all important' Python code indentations. Stick with spaces, since tabs depend on the editor settings. Most Python editors can be set to this feature. As for your date entry you could use something like … | |
Re: Just to let you know that I have been smitten by Ruby thanks to your ruby snippets. I downloaded the whole shmaltz including FxRuby from: [url]http://rubyforge.org/projects/fxruby[/url] I let you know how it works out. I like the syntax and am familiar with it from my Python days. | |
Re: A couple of excellent code snippets by Dave Sinkula on this very subject: Read an Integer from the User, Part 1 [URL]http://www.daniweb.com/code/snippet266.html[/URL] Read a Line of Text from the User [URL]http://www.daniweb.com/code/snippet278.html[/URL] Safe Version of gets() [URL]http://www.daniweb.com/code/snippet280.html[/URL] Read a Floating-Point Value from the User, Part 1 [URL]http://www.daniweb.com/code/snippet357.html[/URL] | |
Re: There is always: [URL]http://babelfish.altavista.com/[/URL] | |
Re: I don't know what editor or IDE you are using for writing your code. Colour highlighting is generally a function of the IDE and can be customized. | |
Re: Please start a new thread! Hijacking old threads is kind of rude. | |
Re: Take a look at the Python code snippet at: [URL]http://www.daniweb.com/code/snippet610.html[/URL] You are almost there, just add a few extra buttons and do the math. | |
Re: What is the original code and what have you added to it? The way it is now, it does not make much sense. | |
Re: In Python these kind of things are a lot easier than in C#. Here is a typical example ... [code=python]sentence = 'the dog barks' # create a list of words (default=whitespaces) words = sentence.split() # take a look print words # ['the', 'dog', 'barks'] # now reverse the list of … | |
Re: Not better, but cute, create your own display window with a Windows message box ... [code=c]// use a message box to display console output // compile as GUI #include <windows.h> #include <string.h> #include <stdlib.h> int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char output[1000]; char st[20]; int … ![]() | |
Re: With `from __future__ import division` I can see a problem in line `for i in range(2,(i2/2)):` you get a float from the division and range does not like floats. Change this line to `for i in range(2,(i2//2)):` Nice thinking here, have to see what Bumsfeld's timing comes up with. | |
Re: Not all modules are modulename.py files. Some of them are .pyc (Python bytecode) or .pyd (Python dll) )files. My best guess is that the module sys is written in C and is part of the Python24.dll/Python25.dll. If you run the Windows version of Python, this file is installed in the … | |
Re: Use the Python shell (with the ugly >>> prompts) only for simple testing of one liners. For programming use an editor or better an IDE like IDLE or DrPython. This will save the program as a .py file. Write the program in parts you can test out ... [code=python]# create … | |
![]() | Re: Python is not for everbody! If you are an entrenched traditional language (C, C++, Java, C#, Pascal) person, Python, because of its elegance, will be too confusing for you. |
Re: Read the first couple of posts in the "Starting Python" thread: [URL]http://www.daniweb.com/techtalkforums/thread20774.html[/URL] IDLE works well, DrPython is better, PyScripter has a few quirks, but is hot! | |
Re: Ideally you should have an application first and than find the best language to code it in. This in turn means you need to know the basics about a number of languages. I have used C, C++, C#, Delphi/Pascal and Python for some major projects. I keep looking at Ruby. … | |
Re: Changing the icon can be rather simple. If you want the icon to blend in with the title bar, you can use a blank icon with the matching background colour. I have created one for this example with LiquidIcon, my favorite icon program ... [code=python]# replace the Tkinter icon # … | |
Re: Java and Python are much alike, they both compile to virtual machine code (byte code) and then interpret this code to the specific CPU machine code. Java uses pretty much the same ugly syntax that C++ uses, so there isn't much gain there. Daniweb does have a Python forum, look … | |
Re: Dave Sinkula, a very talented C programmer, has given quite a bit of attention to this issue. Take a look at one or more of his code snippets at DaniWeb: [URL]http://www.daniweb.com/code/snippet266.html[/URL] | |
Re: You might have to add the line [code]using namespace std; [/code]or add a std:: before every cout and cin (etc). What are you using for a compiler? Sounds like the old Borland thingy! | |
Re: This is one way to hide and show widgets that share the same grid ... [code=python]# hide and show labels sharing the same grid import Tkinter as tk def show2(): label1.lower() label2.lift() def show1(): label2.lower() label1.lift() root = tk.Tk() button1 = tk.Button(root, text="Press to show label2", command=show2) button1.grid(row=0, column=0) button2 … | |
Re: Here is an example using a modern language like Python ... [code=python]def is_palindrome(phrase): """ take a phrase, convert to all lowercase letters, create a list of the characters (ignore punctuation marks and whitespaces) if it matches the reverse order, then it is a palindrome """ phrase_letters = [c for c … | |
![]() | Re: Nice, I would code it like that ... [code=python]def prime(x, myarray=[2,3]): for i in range(3, x, 2): if filter(lambda x: i % x, myarray) == myarray : myarray.append(i) return myarray prime_list = prime(15000) # check the first 10 primes print prime_list[:10] # check the last 10 primes print prime_list[-10:] [/code]This … |
Re: Notice that in this article place() does not work in the text widget, but you are shifting the entire Text widget partially out of the window. This way the window becomes a view into an area of the the text widget. Actually quite interesting. | |
Re: This will give the mouse position within the whole scrolled canvas ... [code=python]""" # -*- coding: cp1250 -*- """ # get coordinates of whole scrolled canvas import wx class Okno: def __init__(self,parent=None,id=wx.ID_ANY,title="Graf"): self.okno=wx.MDIChildFrame(parent,title="Graf",id=-1) self.okno.Maximize() self.okno.SetAutoLayout(True) self.okno.SetBackgroundColour("#FCFCFE") self.sizer = wx.FlexGridSizer(2,2,0,0) self.canvas = wx.ScrolledWindow(self.okno, id=wx.ID_ANY) self.canvas.EnableScrolling(True, True) self.canvas.SetScrollbars(20, 20, 1000/20, 1000/20) self.sizer.Add(self.canvas, … | |
Re: Thanks, looks like some interesting reading. | |
Re: A simple way would be to use wx.DisplaySize() as the size tuple of your frame ... [code=python]import wx class Frame1(wx.Frame): def __init__(self): """ create a frame, size is full display size, wx.DisplaySize() gives width, height tuple of display screen """ wx.Frame.__init__(self, None, wx.ID_ANY, 'Full display size', pos=(0, 0), size=wx.DisplaySize()) self.SetBackgroundColour('yellow') … |
The End.