4,305 Posted Topics

Member Avatar for corolaron

Take the string and spell it in reverse. Compare the two strings, if they match you got a palindrome. Now show us some code!

Member Avatar for gkmishr1
0
2K
Member Avatar for grahhh

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]

Member Avatar for paddy3118
0
187
Member Avatar for Pretorak
Member Avatar for robgxxx
0
2K
Member Avatar for jrcagle

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.

Member Avatar for vegaseat
0
124
Member Avatar for davidjhay

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 …

Member Avatar for davidjhay
0
142
Member Avatar for Salem

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.

Member Avatar for Lardmeister
0
139
Member Avatar for The Dude

[quote=iamthwee;428472]What is a segway?[/quote]A single axle two wheeled thingy powered by an electric motor. Doesn't everybody have one?

Member Avatar for Lardmeister
0
79
Member Avatar for ufwt
Member Avatar for vegaseat
0
177
Member Avatar for >shadow<
Member Avatar for Serunson
0
2K
Member Avatar for Dave Sinkula

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 …

Member Avatar for Lardmeister
0
153
Member Avatar for murschech

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 …

Member Avatar for bdj
0
594
Member Avatar for kaze139

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

Member Avatar for jrcagle
0
137
Member Avatar for The Dude

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 …

Member Avatar for hbk619
1
125
Member Avatar for The Dude

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!

Member Avatar for Ancient Dragon
0
251
Member Avatar for Lardmeister

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

Member Avatar for Lardmeister
0
94
Member Avatar for php111

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 …

Member Avatar for vegaseat
0
182
Member Avatar for bergy_nj

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]

Member Avatar for bergy_nj
0
116
Member Avatar for rubyMOLIVER

On behalf of the moderators at Daniweb let me be the first to welcome you!

Member Avatar for vegaseat
0
7
Member Avatar for flaerpen
Member Avatar for wandie

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 …

Member Avatar for vegaseat
0
255
Member Avatar for flaerpen

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 …

Member Avatar for flaerpen
0
11K
Member Avatar for katharnakh
Member Avatar for StrikerX11
0
359
Member Avatar for shadrakni
Member Avatar for ~s.o.s~
1
360
Member Avatar for bm1167

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 …

Member Avatar for vegaseat
0
102
Member Avatar for Dark_Omen

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.

Member Avatar for jeanlazarou
0
287
Member Avatar for aasi007onfire

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]

Member Avatar for praneeth_gunda
0
121
Member Avatar for ThePATRIOT
Member Avatar for fredzik

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.

Member Avatar for fredzik
0
305
Member Avatar for shanenin
Member Avatar for vegaseat
0
180
Member Avatar for erlkz

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.

Member Avatar for vegaseat
0
93
Member Avatar for olufunkky

What is the original code and what have you added to it? The way it is now, it does not make much sense.

Member Avatar for olufunkky
0
152
Member Avatar for Lardmeister

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 …

Member Avatar for vegaseat
0
1K
Member Avatar for bklstheman

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 …

Member Avatar for iamthwee
0
122
Member Avatar for Matt Tacular

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.

Member Avatar for vegaseat
0
288
Member Avatar for Zorbie

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 …

Member Avatar for StrikerX11
0
159
Member Avatar for olufunkky

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 …

Member Avatar for olufunkky
0
259
Member Avatar for iamthwee

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.

Member Avatar for Ene Uran
0
697
Member Avatar for FoX_

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!

Member Avatar for NetByte
0
123
Member Avatar for asatrujesus

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

Member Avatar for gamingfan1993
0
495
Member Avatar for fredzik

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

Member Avatar for fredzik
1
137
Member Avatar for ongxizhe

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 …

Member Avatar for ongxizhe
0
380
Member Avatar for EnderX

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]

Member Avatar for Aia
0
156
Member Avatar for Matt Tacular

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!

Member Avatar for Salem
0
149
Member Avatar for 65dos

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 …

Member Avatar for vegaseat
0
131
Member Avatar for raleman

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 …

Member Avatar for vegaseat
0
164
Member Avatar for Mouche

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 …

Member Avatar for arsham
0
141
Member Avatar for fredzik

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.

Member Avatar for fredzik
0
126
Member Avatar for Blujacker

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

Member Avatar for Blujacker
0
197
Member Avatar for pyarticles
Member Avatar for bumsfeld

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

Member Avatar for vegaseat
0
2K

The End.