[Tutorial] PyQT with Qt Designer


Quote: Originally Posted by coldDeath Nice I didn't realise it would be GPLed on Windows, that was Qts only bad point (IMHO). That's the main reason why I was looking into GTK, which has no such restriction. Roll on PyQt 4
Posted On: Friday 28th of December 2012 05:25:22 AM Total Views:  215
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Re: wx module?

False alarm, found it, sorry...
VIEWS ON THIS POST

68

Posted on:

Monday 5th November 2012
View Replies!

Re: How to destroy a Frame with condition

En Wed, 27 Jun 2007 01:39:22 -0300, senthil arasu escribi: > In my code logic I need to check the frame existence and then destroy a > frame. > I dont know how to code this condition. > In Python tutorials what i reffered, "if "condition given only for > integers(like if x>0 > > I need some one to help me. > > This is my condition > > If iframe==NULL//if frame not available > iframe.destroy() That does not look like Python code - and in any case, it does not make much sense. If iframe is NULL you can't call a method on it. In Python, usually the symbol None is used when you want to say "nothing" (like NULL, null, or nil in another languages). But unlike other languages, None is an actual object - a singleton, there exist exactly one instance of it, that is, all references to None along the whole program refer to the same and unique object. To test is something is None or anything else, you use the "is" operator. It tests object identity (whether both operands are in fact the same thing). Your code above (reversed) would be: if iframe is not None: iframe.destroy() This will call the destroy() method of iframe, only when iframe is not the None object itself. -- Gabriel Genellina
VIEWS ON THIS POST

55

Posted on:

Monday 5th November 2012
View Replies!

Parsing a file with iterators

On Fri, 17 Oct 2008 11:42:05 -0400, Luis Zarrabeitia wrote: > I need to parse a file, text file. The format is something like that: > > TYPE1 metadata > data line 1 > data line 2 > ... > data line N > TYPE2 metadata > data line 1 > ... > TYPE3 metadata > ... > [\t] > because when the parser iterates over the input, it can't know that it > finished processing the section until it reads the next "TYPE" line > (actually, until it reads the first line that it cannot parse, which if > everything went well, should be the 'TYPE'), but once it reads it, it is > no longer available to the outer loop. I wouldn't like to leak the > internals of the parsers to the outside. > > What could I do > (to the curious: the format is a dialect of the E00 used in GIS) Group the lines before processing and feed each group to the right parser: import sys from itertools import groupby, imap from operator import itemgetter def parse_a(metadata, lines): print 'parser a', metadata for line in lines: print 'a', line def parse_b(metadata, lines): print 'parser b', metadata for line in lines: print 'b', line def parse_c(metadata, lines): print 'parser c', metadata for line in lines: print 'c', line def test_for_type(line): return line.startswith('TYPE') def parse(lines): def tag(): type_line = None for line in lines: if test_for_type(line): type_line = line else: yield (type_line, line) type2parser = {'TYPE1': parse_a, 'TYPE2': parse_b, 'TYPE3': parse_c } for type_line, group in groupby(tag(), itemgetter(0)): type_id, metadata = type_line.split(' ', 1) type2parser[type_id](metadata, imap(itemgetter(1), group)) def main(): parse(sys.stdin)
VIEWS ON THIS POST

64

Posted on:

Wednesday 7th November 2012
View Replies!

smart quotes

Can anyone tell me how to get rid of smart quotes in html using Python I've tried variations on stuff = string.replace(stuff, "\", "\""), but to no avail, presumably because they're not standard ASCII.
VIEWS ON THIS POST

48

Posted on:

Wednesday 7th November 2012
View Replies!

giving imp.load_module not a real file, HOW?

I am running into a problem with the python interpreter's internals. For some reason imp.load_module insists on getting a real open file as the second parameter. I have not able to fool it with stringIO or overloaded file objects. So now I have two questions: 1) why does load_module insist on a real file 2) is there a way around it that does not involve (say) tempfile Paul
VIEWS ON THIS POST

178

Posted on:

Wednesday 7th November 2012
View Replies!

Creating Installer or Executable in Python

I have a small project which has around 10 .py files and I run this project using command line arguments. I have to distribute this project to somebody. I was wondering how can I make an executable or some kind of installer, so that end user doesn't need to compile and worry if he/ she has Python installed or not Every help is greatly appreciated.
VIEWS ON THIS POST

73

Posted on:

Wednesday 7th November 2012
View Replies!

Module python-magic on/for Windows - UPDATE: WORKING & HowTo!!!

Thank you, again, Michael, for all your help many months ago. I *FINALLY* got a HowTo done up; please see http://wiki.python.org/moin/HowTo/FileMagic I've also emailed Mr. Hupp to see if he'll re-post the SWIG version; he's working on a newer binding ...
VIEWS ON THIS POST

102

Posted on:

Saturday 10th November 2012
View Replies!

Re: Given a string - execute a function by the same name

python@bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > ...
VIEWS ON THIS POST

102

Posted on:

Sunday 11th November 2012
View Replies!

clearing text on canvas

hi i am new to tkinter and would like some help with canvas i am doing validation of contents of a folder and need to show the ok/error messages on a canvas resultdisplay =Canvas(...) errmessage="error!" okmessage="dir validation ok!" if dirvalidate ...
VIEWS ON THIS POST

59

Posted on:

Monday 26th November 2012
View Replies!

Re: help displaying pdf thru client/server

On Wed, 19 Dec 2007 13:50:10 -0600, Larry Bates wrote: >PaulS wrote: >> Connecting to a Linux server from XP pc using a telnet program, I run a >> report and convert it to a pdf document(using Reportlab) which ...
VIEWS ON THIS POST

93

Posted on:

Monday 26th November 2012
View Replies!

Python-URL! - weekly Python news and links (Dec 18)

QOTW: "XML. Almost as good as plain text for grepping." - Joe Mason "Where there's IP, there's a way." - Kyler Laird, on network programming Linked lists, deques, and iteration over a mutating container: http://groups.google.com/group/comp....7de91323d9e23/ Containers should compare themselves using ...
VIEWS ON THIS POST

46

Posted on:

Monday 26th November 2012
View Replies!

Pythonic way to add method alias in subclass

I thought of several ways to add another name for a method in a subclass ... #alias.py class Foo(object): def nod(self): print "nodding" class Bar(Foo): def __init__(self): self.agree = self.nod class Bar2(Foo): agree = Foo.nod class Bar3(Foo): def agree(self): Foo.nod(self) ...
VIEWS ON THIS POST

60

Posted on:

Monday 26th November 2012
View Replies!

Block comments

Tomorrow is block comment day. I want them to nest. I think the reason that they don't routinely nest is that it's a lot of trouble to code. Two questions: 1) Given a start and end location (line position and ...
VIEWS ON THIS POST

55

Posted on:

Monday 26th November 2012
View Replies!

ANN: Chandler 0.7.3

The Chandler Project is pleased to announce the 0.7.3 release of Chandler Desktop! Chandler Desktop is an open source, standards-based personal information manager (PIM) built around small group collaboration and a core set of information management workflows modeled on Inbox ...
VIEWS ON THIS POST

45

Posted on:

Monday 26th November 2012
View Replies!

Re: which configparse?

Martin Marcher wrote: > > > On 12/6/07, Neal Becker wrote: >> configparse looks like what I want, but it seems last commit was >2years >> ago. >> >> What is the best choice > > that seems ...
VIEWS ON THIS POST

51

Posted on:

Monday 26th November 2012
View Replies!

Detecting mod_rewrite via CGI

I am using an Apache webserver with mod_rewrite and the cgi module. Is there a way to do the following that isn't completely evil ######## def mod_rewrite_enabled(): try: file = open(os.path.join(os.environ['DOCUMENT_ROOT'], '.htaccess')) except: return False for line in file: ...
VIEWS ON THIS POST

65

Posted on:

Monday 26th November 2012
View Replies!

=?ISO-8859-1?Q?Hi_I_am_anuusha_21years_of_student..._find_your_love?==?ISO-8859-1?Q?r_here_www.loverguru.blogspot.com?=

Hi I am anuusha 21years of student... find your lover here www.loverguru.blogspot.com...
VIEWS ON THIS POST

109

Posted on:

Monday 26th November 2012
View Replies!

Writing event handler for dropdown list in python

I am new to python, Can someone help me with writing event handler for a dropdown list in python. i have one function to create dropdown list in a file def dropdown_options(self,title,options,name,value = None): ret = "\n
VIEWS ON THIS POST

53

Posted on:

Monday 26th November 2012
View Replies!

how to resize a window with a specific name with python-xlib

The python-xlib documentation is confusing for me..and the examples are too few :-( I need simply to resize a window (named "firefox" for example), but before I need the window's id, how can i obtain this id
VIEWS ON THIS POST

75

Posted on:

Monday 26th November 2012
View Replies!

how to figure out if python was used as a cgi script

hi, is there a way to figure out which scripting language was used in a cgi. I used to watch extensions (i.e. py, pl, asp or php) nowadays i hardly see any extensions and really it is hard to find ...
VIEWS ON THIS POST

62

Posted on:

Monday 26th November 2012
View Replies!

Google's tolerance of spam

On 13 Nov, 23:03, Ben Finney wrote: > > Their messages are an abuse of Google Groups's terms of service, and > Google will likely act on complaints that include a *full* copy of the > offending message. Unless ...
VIEWS ON THIS POST

83

Posted on:

Monday 26th November 2012
View Replies!

CodeInvestigator version 0.6.0 released.

CodeInvestigator version 0.6.0 was released on November 8. This version adds support for input() and raw_input() functions. The main changes: * The 'Details' button on the file selection screen gives access to statistics, stdin and stdout for the running program. ...
VIEWS ON THIS POST

46

Posted on:

Monday 26th November 2012
View Replies!

help

i am working o my first real program, a strategy game when i ran a part of it and it said invalid syn tak and hilighted the colon on line 15 hers the code (Toggle Plain Text) import random,pickle,easygui level=1 money=1000 lives=10 class War: def __init__(self,numsol,tysol,posol,strengh,risk): self.numsol=numsol self.tysol=tysol self.level=level self.money=money self.lives=lives self.posol=posol self.strengh=strengh self.risk=risk def Save: pickle.dump(War,open("savedata.p","wb")) easygui.msgbox("your data has been saved") def Load: class War=pickle.load(open("savedata.p","rb")) easygui.msgbox("game has been loaded level: %l money: %m lives: %d" %l level %m money %d lives) import random,pickle,easygui level=1 money=1000 lives=10 class War: def __init__(self,numsol,tysol,posol,strengh,risk): self.numsol=numsol self.tysol=tysol self.level=level self.money=money self.lives=lives self.posol=posol self.strengh=strengh self.risk=risk def Save: pickle.dump(War,open("savedata.p","wb")) easygui.msgbox("your data has been saved") def Load: class War=pickle.load(open("savedata.p","rb")) easygui.msgbox("game has been loaded level: %l money: %m lives: %d" %l level %m money %d lives)
VIEWS ON THIS POST

72

Posted on:

Tuesday 27th November 2012
View Replies!

how to create a .exe file from a python script

hello i have written a small python script, which includes matplotlib,tkinter and numpy. How can i create a installation file which bundles all the above 3 and my script and python itself. I tried py2exe , it gives me a error "invalid syntax (test1.py) " I am using windows 7 i want to do this so that the persons who receives this .exe file need not install python in their computer
VIEWS ON THIS POST

60

Posted on:

Tuesday 27th November 2012
View Replies!

need help with this grade calculator program PLZ!!

Quote: Originally Posted by titaniumdecoy Since you don't seem to get it... You're clever = What you think it means Your cleaver = Your large knife oh gotcha yea i didn't even notice the spelling mistake
VIEWS ON THIS POST

111

Posted on:

Tuesday 27th November 2012
View Replies!

lists indexes - beginner

Every C I know, which predates C89, handles the offset automatically by multiplying by type size. Admittedly, I've only been using it since 1980.
VIEWS ON THIS POST

76

Posted on:

Tuesday 27th November 2012
View Replies!

Need help adding a loop to restart program

So, I can't seem to get any loop to work in with this program to calculate average test scores. This is for a lab i need to finish by tomorrow so I need urgent help haha. so far this is what I have; (Toggle Plain Text) score = 0 totalScores = 0 averageScores = 0 students = raw_input("How many students took the test") students = int(students) for counter in range( students ): score = input("Enter a score") totalScores = score + totalScores averageScores = totalScores/students print"The average test score is:",averageScores score = 0 totalScores = 0 averageScores = 0 students = raw_input("How many students took the test") students = int(students) for counter in range( students ): score = input("Enter a score") totalScores = score + totalScores averageScores = totalScores/students print"The average test score is:",averageScores
VIEWS ON THIS POST

119

Posted on:

Tuesday 27th November 2012
View Replies!

Quadratic Formula in Python

But don't be fooled by what "%si" is doing... I'm not sure if it's clicked yet, but it's nothing magical. It's saying "replace %s with one of the variables, and print it next to the letter 'i'". So print "%si"%("Aaron"), will output "Aaroni", for example. Nothing to do with complex numbers really. Just a trick, that's all.
VIEWS ON THIS POST

38

Posted on:

Tuesday 27th November 2012
View Replies!

Arithmetic By Percentage

That's the OP's call. He said "short", not "looks short." Abstraction has its uses. As a means of programmer productivity at the expense of performance, I think this one has already failed.
VIEWS ON THIS POST

42

Posted on:

Tuesday 27th November 2012
View Replies!

The Demise of lambda, map, filter and reduce

But, on the other hand: (Toggle Plain Text) [i * i for i in l if i % 2 == 0] [i * i for i in l if i % 2 == 0]
VIEWS ON THIS POST

53

Posted on:

Tuesday 27th November 2012
View Replies!

Hard understanding part of tutorial

http://ibiblio.org/obp/thinkCS/pytho...h/chap09.htm#4 I am doing this tutorial, but when it comes to the exercise in this part 9.4 I'm stuck, I do not understand the high and low thing, what does he mean with that Quote: To generate a random number between 0.0 and an upper bound like high, multiply x by high. As an exercise, generate a random number between low and high.
VIEWS ON THIS POST

90

Posted on:

Tuesday 27th November 2012
View Replies!

GIL and concurrency challenges in Python

Interesting article on what is probably the single biggest drawback to using python. http://www.jeffknupp.com/blog/2012/0...rdest-problem/ Even without efficient parallelism, its better than perl
VIEWS ON THIS POST

46

Posted on:

Wednesday 28th November 2012
View Replies!

alternative for eval?

The function eval() in Python breaks very easily when used to convert a string into a number. you need to do is input a value with a leading zero. Any idea why So if you have code like: x=input("Please enter a number: ") val=eval(x) print(x) And you run it with a value of: 015 It fails and issues: SyntaxError: invalid token What's a good way to ensure no error (without trimming leading zeros).
VIEWS ON THIS POST

49

Posted on:

Wednesday 28th November 2012
View Replies!

pygame help!

this my code (Toggle Plain Text) import pygame.sprite import os.path import os, sys import pygame from pygame.locals import * if not pygame.font: print 'Warning, fonts disabled' if not pygame.mixer: print 'Warning, sound disabled' def load_image(name, colorkey = None): fullname = os.path.join('data', name) try: image = pygame.image.load(fullname) except pygame.error, message: print 'Cannot load image:', name raise SystemExit, message image = image.convert() if colorkey is not None: if colorkey is -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, RLEACCEL) return image, image.get_rect() def load_sound(name): class NoneSound: def play(self): pass if not pygame.mixer: return NoneSound() fullname = os.path.join('data', name) try: sound = pygame.mixer.Sound(fullname) except pygame.error, message: print 'Cannot load sound:', wav raise SystemExit, message return sound class Fist(pygame.sprite.Sprite): """moves a clenched fist on the screen, following the mouse""" def __init__(self): pygame.sprite.Sprite.__init__(self) #call Sprite initializer self.image, self.rect = load_image('fist.bmp, -1') self.punching = 0 def update(self): "move the fist based on the mouse pisition" pos = pygame.mouse.get_pos() self.rect.midtop = pos if self.punching: self.rect.move_ip(5, 10) def punch(self, target): "returns true if the fist collides with the target" if not self.punching: self.punching = 1 hitbox = self.rect.Inflate(-5, -5) return hitbox.colliderect(target.rect) def unpunch(self): "called to pull the fist back" self.punching = 0 class Chimp(pygame.sprite.Sprite): """moves a monkey critter acreoss the screen. it can spin the monkey when it is punched.""" def __init__(self): pygame.sprite.Sprite.__init__(self) #call Sprite initializer self.image, self.rect = load_image('chimp.bmp, -1') screen = pygame.display.get_surface() self.area = screen.get_rect() self.rect.topleft = 10, 10 self.move = 9 self.dizzy = 0 def update(self): "walk or spin, depending on the monkeys state" if self.dizzy: self._spin() else: self._walk() def _walk(self): "move the monkey across the screen, and turn at the ends" newpos = self.rect.move((self.move, 0)) if not self.area.contains(newpos): if self.rect.left < self.area.left or\ self.rect.right > self.area.right: #error self.move = -self.move newpos = self.rect.move((self.move, 0)) self.image = pygame.transform.flip(self.image, 1, 0) self.rect = newpos def _spin(self): "spin the monkey image" center = self.rect.center self.dizzy += 12 if self.dizzy >= 360: self.dizzy = 0 self.image = self.original else: rotate = pygame.transform.rotate self.image = rotate(self.original, self.dizzy) self.rect = self.image.get_rect(center = center) def punched(self): "this will cause the monkey to start spinning" if not self.dizzy: self.dizzy = 1 self.original = self.image pygame.init() screen = pygame.display.set_mode((468, 60)) pygame.display.set_caption('Monkey Fever') pygame.mouse.set_visible(0) background = pygame.Surface(screen,get_size()) background = background.convert() background.fill((250, 250, 250)) if pygame.font: font = pygame.font.Font(None, 36) text = font.render("Pummel The Chimp, And Win $$$", 1, (10, 10, 10)) textpos = text.get_rect(centerx = background.get_width()/2) background.blit(text, textpos) screen.blit(background, (0, 0)) pygame.display.flip() whiff_sound = load_sound('whiff.wav') punch_sound = load_sound('punch.wav') chimp = Chimp() fist = Fist() allsprites = pygame.sprite.RenderPlain((fist, chimp)) clock = pygame.time.Clock() while 1: clock.tick(60) for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return elif event.type == MOUSEBUTTONDOWN: if fist.punch(chimp): punch_sound.play() #punch chimp.punched() else: whiff_sound.play() #miss elif event.type == MOUSEBUTTONUP: fist.unpunch() allsprites.update() screen.blit(background, (0, 0)) allsprites.draw(screen) pygame.display.flip() #error import pygame.sprite import os.path import os, sys import pygame from pygame.locals import * if not pygame.font: print 'Warning, fonts disabled' if not pygame.mixer: print 'Warning, sound disabled' def load_image(name, colorkey = None): fullname = os.path.join('data', name) try: image = pygame.image.load(fullname) except pygame.error, message: print 'Cannot load image:', name raise SystemExit, message image = image.convert() if colorkey is not None: if colorkey is -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, RLEACCEL) return image, image.get_rect() def load_sound(name): class NoneSound: def play(self): pass if not pygame.mixer: return NoneSound() fullname = os.path.join('data', name) try: sound = pygame.mixer.Sound(fullname) except pygame.error, message: print 'Cannot load sound:', wav raise SystemExit, message return sound class Fist(pygame.sprite.Sprite): """moves a clenched fist on the screen, following the mouse""" def __init__(self): pygame.sprite.Sprite.__init__(self) #call Sprite initializer self.image, self.rect = load_image('fist.bmp, -1') self.punching = 0 def update(self): "move the fist based on the mouse pisition" pos = pygame.mouse.get_pos() self.rect.midtop = pos if self.punching: self.rect.move_ip(5, 10) def punch(self, target): "returns true if the fist collides with the target" if not self.punching: self.punching = 1 hitbox = self.rect.Inflate(-5, -5) return hitbox.colliderect(target.rect) def unpunch(self): "called to pull the fist back" self.punching = 0 class Chimp(pygame.sprite.Sprite): """moves a monkey critter acreoss the screen. it can spin the monkey when it is punched.""" def __init__(self): pygame.sprite.Sprite.__init__(self) #call Sprite initializer self.image, self.rect = load_image('chimp.bmp, -1') screen = pygame.display.get_surface() self.area = screen.get_rect() self.rect.topleft = 10, 10 self.move = 9 self.dizzy = 0 def update(self): "walk or spin, depending on the monkeys state" if self.dizzy: self._spin() else: self._walk() def _walk(self): "move the monkey across the screen, and turn at the ends" newpos = self.rect.move((self.move, 0)) if not self.area.contains(newpos): if self.rect.left < self.area.left or\ self.rect.right > self.area.right: #error self.move = -self.move newpos = self.rect.move((self.move, 0)) self.image = pygame.transform.flip(self.image, 1, 0) self.rect = newpos def _spin(self): "spin the monkey image" center = self.rect.center self.dizzy += 12 if self.dizzy >= 360: self.dizzy = 0 self.image = self.original else: rotate = pygame.transform.rotate self.image = rotate(self.original, self.dizzy) self.rect = self.image.get_rect(center = center) def punched(self): "this will cause the monkey to start spinning" if not self.dizzy: self.dizzy = 1 self.original = self.image pygame.init() screen = pygame.display.set_mode((468, 60)) pygame.display.set_caption('Monkey Fever') pygame.mouse.set_visible(0) background = pygame.Surface(screen,get_size()) background = background.convert() background.fill((250, 250, 250)) if pygame.font: font = pygame.font.Font(None, 36) text = font.render("Pummel The Chimp, And Win $$$", 1, (10, 10, 10)) textpos = text.get_rect(centerx = background.get_width()/2) background.blit(text, textpos) screen.blit(background, (0, 0)) pygame.display.flip() whiff_sound = load_sound('whiff.wav') punch_sound = load_sound('punch.wav') chimp = Chimp() fist = Fist() allsprites = pygame.sprite.RenderPlain((fist, chimp)) clock = pygame.time.Clock() while 1: clock.tick(60) for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return elif event.type == MOUSEBUTTONDOWN: if fist.punch(chimp): punch_sound.play() #punch chimp.punched() else: whiff_sound.play() #miss elif event.type == MOUSEBUTTONUP: fist.unpunch() allsprites.update() screen.blit(background, (0, 0)) allsprites.draw(screen) pygame.display.flip() #error
VIEWS ON THIS POST

107

Posted on:

Wednesday 28th November 2012
View Replies!

Complete new needs help with code

I'm new here. Hi . I'm just learning python and I'm stumped trying to get this to work. Python Syntax (Toggle Plain Text) print "How old are you",age = raw_input (36)print "how tall are you",height = raw_input (6)print "How much do you weigh",weight = raw_input (200)print "So, you are %r old, %r tall, and %r heavy." %(age, height, weight) print "How old are you", age = raw_input (36) print "how tall are you", height = raw_input (6) print "How much do you weigh", weight = raw_input (200) print "So, you are %r old, %r tall, and %r heavy." %(age, height, weight)
VIEWS ON THIS POST

64

Posted on:

Wednesday 28th November 2012
View Replies!

Calculate CRC32 checksums (like SFVs)

(Toggle Plain Text) import binascii def getCRC(filename): filedata = open(filename).read() return binascii.crc32(filedata) import binascii def getCRC(filename): filedata = open(filename).read() return binascii.crc32(filedata)
VIEWS ON THIS POST

65

Posted on:

Wednesday 28th November 2012
View Replies!

Are nested lists indestructable?

I am trying to create a program that involves writing a whole bunch of lists with information of its specific topic then grouping them together. Normally I would use a hash but they don't really let you create a whole bunch of variables that can be withdrawn later. So my problem is when I nest them together, based on a random factor I want to delete so many of them from the back, but nothing I write seems to work I can see doing all this with a whole bunch of if: loops but I know there has to be some easier way here is my program(at least the part that pertains to it) (PS. all the importing and preperations are done I simply didn't print it) a=randint(6,11) aa=['name', 'att', 'def', 1] ab=['name', 'att', 'def', 1] ac=['name', 'att', 'def', 1] ad=['name', 'att', 'def', 1] ae=['name', 'att', 'def', 1] af=['name', 'att', 'def', 1] ag=['name', 'att', 'def', 1] ah=['name', 'att', 'def', 1] ai=['name', 'att', 'def', 1] aj=['name', 'att', 'def', 1] abspirlist=[aa,ab,ac,ad,ae,af,ag,ah,ai,aj] del abspirlist[a:] shuffle(abspirlist)
VIEWS ON THIS POST

61

Posted on:

Wednesday 28th November 2012
View Replies!

Python IDE

I'm on a seemingly eternal quest for a good and free python IDE. My criteria:Syntax Highlighting Autocompletion/tooltips Integrated and user-friendly debugger Integrated shell that can be restarted independently of the editor I've used IDLE, Pywin, Py (part of wxPython), DrPython and SPE. I like SPE, but the debugger is the powerful but (to me, at least) unwieldy winpdb and the shell can't be restarted without closing the editor. Also, the integrated Pychecker doesn't seem to work on my system. Any recommendations , DrPython does all of the above. What don't you like about it You have to install a few plug-ins (download and install from within DrPython). , Quote: Have you used it Indeed I have. I do almost all of my C++ development on it, and keep up to date with relevant updates concerning it. Half of the features you mentioned there are KatePart specific, and were not requested as features required in the IDE... Quote: Originally Posted by Silvanus Autocompletion/tooltips Nope. Quote: Originally Posted by Silvanus Integrated and user-friendly debugger Quote: Originally Posted by iignatus Debugger Check. What Where Show me where the Python debugger is.. last time I checked, KDevelop can only make use of valgrind or gdb with C++. Quote: Integrated shell that can be restarted independently of the editor If you mean Python shell, then no. KDevelop does embed a KonsolePart that can, obviously, be used independantly of the editor (Menu->Run->`konsole`), but Konsole is a terminal, not a Python shell. , Quote: Integrated python shell right there, no I think he's talking about graphical shells like PyCrust/IDLE. Thats what it sounds like, at least.
VIEWS ON THIS POST

63

Posted on:

Wednesday 28th November 2012
View Replies!

While And Random Problem [solved]

G'day all I am working my way through a book called "Python programming for absolute beginners" (I have very little programming experience) and at the end of one chapter you are asked to write a simple coin toss programme that tosses a coin 100 times and prints the result of each toss either as "heads" or "tails" using a while loop. I can get the random to work without the loop but I can't get it working properly using the loop, each toss is exactly the same (eg 100 instances of "heads"), though randomly it will change to the other and every time I run the programme for some time it will generate that. Here is the code: (Toggle Plain Text) # Coin Toss programme # Flips 100 coins and reports heads or tails # Stuart Graham 10/12/04 import random coin = random.randrange(2) count = 0 toss = int(raw_input("enter number of tosses ")) while (count < toss): * *if (coin == 0): * *print "heads", coin *else: #(coin == 1) * *print "tails", coin *count += 1 # Coin Toss programme # Flips 100 coins and reports heads or tails # Stuart Graham 10/12/04 import random coin = random.randrange(2) count = 0 toss = int(raw_input("enter number of tosses ")) while (count < toss): * *if (coin == 0): * *print "heads", coin *else: #(coin == 1) * *print "tails", coin *count += 1
VIEWS ON THIS POST

147

Posted on:

Wednesday 28th November 2012
View Replies!

Heads or Tails

Here's the relevant part isolated: (Toggle Plain Text) counter = 1 if(counter > maximum): maximum = counter counter = 1 if(counter > maximum): maximum = counter, in a row assuming that the coin is unbiased, 0.5 to the power of X i think.. Where X is the number of times played, and 0.5 is the prob that you will win on the first game. X(E)Z X > 0 So if you play twice, it is 0.25, play three times and it is 0.125 etc My rather basic memory of stats is coming back to me. I always found it boring to be honest. The only time that I have ever used it in any capacity, in CS, is implementing simulation (used to randomly generate random people roaming each street in games like GTA, for example). And even then you are not actually calculating probability. You are generating a number and using that to generate an event, with events assigned depending on the number that you get. You can use it to control virtual rats through a series of virtual pipes, for example , an infinite number of times played would be interpreted as zero, in which case you would both have a 100% chance of winning, meaning that it is impossible, since 1+1 is 2 and you cant have that in probability the only truth would be that for each game you haze a 0.5 chance either way. By the way, I failed stats at college. I'm just using common sense, which doesnt work in stats, please take what I tell you with a pinch of salt.
VIEWS ON THIS POST

118

Posted on:

Friday 28th December 2012
View Replies!

Few questions about python/programming.

, I'm new to the whole programming scene and have been interested in doing this for a while. I started doing an online tutorial for python, I have a few questions. 1. How do I apply my python language to "real" programs, I only seem to be doing text based programs. Can python apply this to "real" programs, for example a program to do a scheduled task (windows does this in the control panel, but just for an example) 2. Whats the learning curve I have heard python is supposed to be easy, how long until i can start making said "real" programs, how much time per day/week should I spend programming, I may not have a lot of time once college starts (i'im asking for a reference or guide to how much can be done per day to still progress)
VIEWS ON THIS POST

88

Posted on:

Friday 28th December 2012
View Replies!

Beginers Python Tutorial

This is a tutorial I originaly wrote for the hackers.com forum... but since that forum was taken down for the better part of the year I'll bring the tutorial here... 1. Intro Now what is Python Well Python is a very powerful programming language that can be used for many things like Basic Adding to somewhat Complex Shell Programming and CGIs it is also very simple to learn, this is a good language to learn if you are new to programming. This tutorial is written for people who have never programmed before so dont expect to learn how to do any complex programs, Just Yet You can download Python at the link below: (Toggle Plain Text) http://www.python.org http://www.python.org
VIEWS ON THIS POST

70

Posted on:

Friday 28th December 2012
View Replies!

Need Help Cant Find Download

i need help b/c i cant find a download for python any where.
VIEWS ON THIS POST

94

Posted on:

Friday 28th December 2012
View Replies!

Keeping Window Open :\

K, I'm a complete noob when it comes to python. I have no experience in it what-so-ever. So you might be getting a lot of these posts from me... little lame things... Now, how do you keep a python window open When I do the print command, it doesn't stay open. Noobular, I know... but still. How
VIEWS ON THIS POST

86

Posted on:

Friday 28th December 2012
View Replies!

Python is where it starts.

Thanks
VIEWS ON THIS POST

77

Posted on:

Friday 28th December 2012
View Replies!

from MID() in VB to Python?

do anyone know the equivalent of the function MID() in VB, for Python thx in advance...
VIEWS ON THIS POST

77

Posted on:

Friday 28th December 2012
View Replies!

Decrypt the password

Hi , Good morning, I'm doing a small application using python and mysql. I have encrypted the password using md5. but it is one way algorithm. It means it only encrypts the password but while we are retriving the password it should check the given plain text with the encrypted text but it is not possible in md5. Is there any other algorithm is there then please tell me. This is the sample code: import md5 password = md5(password) this encrypts the password. but it is not decrypts the password. Please help me.
VIEWS ON THIS POST

68

Posted on:

Friday 28th December 2012
View Replies!

Looking for opinions on structure for a group of encryption functions

I'm coding a group of functions that performs various historical encryption functions on a plaintext, and I'm wondering what structure would be best. The couple of options I'm tossing around are: a) making a class plaintext that contains these functions and performs them on the plaintext passed in. I would import this plaintext class from a module (probably called plaintext, cipher, something like that) b) skipping the class step and simply making a module that contains all the functions and just importing that module. I'm open to any other suggestions, too. I realize it's a pretty open-ended question, but I'm interested in your input.
VIEWS ON THIS POST

45

Posted on:

Friday 28th December 2012
View Replies!

Redirecting Console Output

I need to redirect all console output (including error messages) to a log file. There are several reasons why I would have to go out of my way to change each print statement to a call to a function. It would be much easier if there's some support in the sys library for just that
VIEWS ON THIS POST

78

Posted on:

Friday 28th December 2012
View Replies!

New to Functions

Hi. This is my first program with the use of functions. Could I get some opinions Could it be improved at all (Toggle Plain Text) #By Snipertomcat #Area Calculator w/ menu interface def menu_options(): #Getting all the def's squared away print "Welcome to Area-Calc." print "Options:" print " 'p' print options" print " 'r' calculate area of a rectangle " print " 's' calculate area of a square " print " 'c' calculate area of a circle " print " 'q' quit the program" def area_rec(width,height): return width*height def area_square(num): return num*num def area_circle(radius): return 3.14 * radius **2 menu_options() #Program starts here choice = "p" while choice != "q": if choice == "r": w = input("Rectangle width: ") h = input("Rectangle hight: ") print "The area is: ",area_rec(w,h) elif choice == "s": squarenum = input("Square length: ") print "The area is: ", area_square(squarenum) elif choice == "c": rad = input("Radius: ") print "The area is: ", area_circle(rad) choice = raw_input("Option: ") #By Snipertomcat #Area Calculator w/ menu interface def menu_options(): #Getting all the def's squared away print "Welcome to Area-Calc." print "Options:" print " 'p' print options" print " 'r' calculate area of a rectangle " print " 's' calculate area of a square " print " 'c' calculate area of a circle " print " 'q' quit the program" def area_rec(width,height): return width*height def area_square(num): return num*num def area_circle(radius): return 3.14 * radius **2 menu_options() #Program starts here choice = "p" while choice != "q": if choice == "r": w = input("Rectangle width: ") h = input("Rectangle hight: ") print "The area is: ",area_rec(w,h) elif choice == "s": squarenum = input("Square length: ") print "The area is: ", area_square(squarenum) elif choice == "c": rad = input("Radius: ") print "The area is: ", area_circle(rad) choice = raw_input("Option: ")
VIEWS ON THIS POST

229

Posted on:

Friday 28th December 2012
View Replies!