1,175 Posted Topics

Member Avatar for StMark

Read the docs of Python3: [url]http://docs.python.org/3.1/whatsnew/3.0.html?highlight=callable[/url] [QUOTE]Removed callable(). Instead of callable(f) you can use hasattr(f, '__call__'). The operator.isCallable() function is also gone.[/QUOTE] You can run this program to check what you have available: [code=python]# print all builtin functions/methods # do a case insensitive sort then print ... print( '\n'.join(sorted(dir(__builtins__), key=str.lower)) …

Member Avatar for StMark
0
214
Member Avatar for Darkangelchick

Here is an example using the module pygame: [code=python]# experiments with module pygame # free from: http://www.pygame.org/ # load, display and move an image import pygame as pg # initialize pygame pg.init() # pick an image you have (.bmp .jpg .png .gif) # if the image file is not in …

Member Avatar for shadwickman
0
150
Member Avatar for Mushy-pea
Member Avatar for sravan953

If Sound Recorder has a command-line option, then you can send the arguments along to start it etc.

Member Avatar for Stefano Mtangoo
0
128
Member Avatar for sneekula

Does anyone know a good internet site where I can 'park' my Python code? Easy download, upload, and search.

Member Avatar for zachabesh
0
203
Member Avatar for tomtetlaw

You need to use one of the GUI toolkits for the 2 frames to respond to each other.

Member Avatar for shadwickman
0
133
Member Avatar for flipjoebanana

Salem has a very good point, it would be very confusing to the user to show ***** that does not match the password string in length.

Member Avatar for vegaseat
0
155
Member Avatar for bladelord76

Your carlist is a list of instances of the class carType. To compare the car's name you have to use the instance.name as shown here: [code=python]class carType: def __init__(self, name, brand, price): self.name = name self.brand = brand self.price = price carlist = [ carType("Viper", "Dodge", 80000), carType("Mustang", "Ford", 25000), …

Member Avatar for bladelord76
0
179
Member Avatar for tomtetlaw

List values are accessed by their index. Dictionary values are accessed by their key. To allow for high speed key searches, the keys are in a hash order. So a dictionary sorted alphabetically by it's keys would make no sense and would defeat the whole dictionary idea. The best you …

Member Avatar for scru
0
110
Member Avatar for sab786
Member Avatar for rajasekhar1242

Here is a Python output with an image: [code=python]# draw a flower with module turtle import turtle as tu tu.title('I call this one Flower') # values for speed are 'fastest' (no delay), 'fast', (delay 5ms), # 'normal' (delay 10ms), 'slow' (delay 15ms), and 'slowest' (delay 20ms) tu.speed('fastest') #turtle.color((.3,.5,.3)) tu.color('red') tu.width(2) …

Member Avatar for zachabesh
0
4K
Member Avatar for artemis_f

You can use Hide() and Show() as explained here: [code=python]# create two frames with wxFrame, only one is showing import wx class Frame1(wx.Frame): def __init__(self, parent, mytitle): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle) self.SetBackgroundColour("green") # pass frame1 to frame2 as instance self self.frame2 = Frame2(None, 'Frame1', self) # create input widgets self.button1 …

Member Avatar for artemis_f
0
208
Member Avatar for Arrorn

I would use module subprocess: [code=python]# os.system() does not allow the Python program # to run in the background, whereas subprocess does import subprocess # remove "arg1", "arg2" if you don't have any command line args subprocess.call(["C:/Python25/Python.exe", "Skripta.py", "arg1", "arg2"]) [/code]

Member Avatar for Arrorn
0
109
Member Avatar for sravan953

Look through your code and test print some of your variables to see what is going on. Create a word list then something like this will work: [code]s = 'he said why' word_list = s.split() n = 0 for word in word_list: if word[0] == 'w': print word_list[n] n += …

Member Avatar for zachabesh
0
96
Member Avatar for pluring
Member Avatar for Morika
Member Avatar for zachabesh

Like snippsat so wisely said, [B]"do not change a list that your are iterating over"[/B] this will upset the indexing of the list during the iteration process. snippsat also recommended to iterate over a copy of mylist: [code=python]mylist = ['bunnies', 'apples', 'animals', 'fruit', 'amsterdam'] mylist_copy = list(mylist) # or mylist[:] …

Member Avatar for zachabesh
0
92
Member Avatar for Morika

This would give you the sum of digits: [code=python]def sum_digits(n): total = 0 for digit in str(n): total += int(digit) return total [/code]Now expand this function so you multiply int(digit) with each other. Notice that I didn't use 'sum' because sum() is a Python function.

Member Avatar for vegaseat
0
91
Member Avatar for Hiroshe
Member Avatar for mascot
1
140
Member Avatar for denniskhor
Member Avatar for zachabesh
0
452
Member Avatar for sneekula

Ever since I got my Ubuntu notebook computer, I can't fail to notice how fast it starts up (and shuts down) compared to my Windows Vista notebook. Other than the system itself, the virus program seems to take more and more time as it checks for seemingly millions of possible …

Member Avatar for vegaseat
0
230
Member Avatar for Flyin dagger

[QUOTE=joshSCH;805477]... When Ronald Reagan took office, the economy was in an arguably worse state than it is now. However, his strives to limit government, and leave the private sector alone helped us to recover, and enjoy the prosperities of the 90s. Obama plans to do the very opposite... Hmmm.... I …

Member Avatar for Aia
0
783
Member Avatar for Your_mum

Oh I see, you want the instance name be the name of the person. That will not be a good idea, because identifiers in Python don't allow spaces. A dictionary, where the name is the key and the value is a ( home, mobile, email ) tuple or list will …

Member Avatar for leegeorg07
0
575
Member Avatar for MosaicFuneral

I like[B] nutella[/B], a chocolaty hazelnut spread, sort of like a much improved peanut butter.

Member Avatar for jephthah
0
392
Member Avatar for amrith92

[QUOTE=Himaloy;903106]It does not exist when you think about something very deeply than a image can be born on your mind,and then people see this "GHOST" okay then we can say it exists but only in peoples mind :)[/QUOTE]IMHO, you are right on! If you see too many ghosts, you are …

Member Avatar for jephthah
1
347
Member Avatar for xgmx
Member Avatar for ndeniche

[QUOTE=debasisdas;411140]if you have brain go for it. else other options are open for you.[/QUOTE]I agree, if you have the brain, she/he doesn't need much of it.

Member Avatar for ditz
0
1K
Member Avatar for leegeorg07

Are you using tabs for indents? They are screwed up! I normally don't even bother with code that has obvious signs of tabs. Do not use 'dict' as identifier, it is the name of a Python function. Also, test your list, the punctuation marks are still attached: [code=python]test = "Hello, …

Member Avatar for leegeorg07
0
193
Member Avatar for Your_mum
Member Avatar for Your_mum
0
91
Member Avatar for BigTurtle

Corrected your code a little and it works just fine: [code=python]''' TextFileDisp00.py ''' import wx import codecs #------------------- class TextFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, -1, mytitle, mysize) self.menubar = wx.MenuBar() self.file = wx.Menu() self.SetMenuBar(self.menubar) self.menubar.Append(self.file,'&File') self.openitem = self.file.Append(wx.ID_ANY,'&Open') self.Bind(wx.EVT_MENU,self.openevent,self.openitem) self.runitem = self.file.Append(wx.ID_ANY,'&Run') self.Bind(wx.EVT_MENU,self.runevent,self.runitem) self.exititem = self.file.Append(wx.ID_ANY,'E&xit') self.Bind(wx.EVT_MENU,self.exitevent,self.exititem) …

Member Avatar for BigTurtle
0
947
Member Avatar for mbox_96

Since parallel is supposed to be a package, check if there is a file __init__.py in folder C:\\Python26\\Lib\\site-packages\\parallel

Member Avatar for Stefano Mtangoo
0
137
Member Avatar for tomtetlaw

Variables in Python are officially names/identifiers (keys in a dictionary) of object references. I still like to refer to them with the old fashioned name variables, this way other folks know what we are talking about.

Member Avatar for sneekula
0
129
Member Avatar for sravan953

If you use the Windows OS: [code=python]# get the character of a key pressed (no return key needed) # works only in the command window and with Windows OS # msvcrt.dll is the MS C library containing most standard C functions from msvcrt import getch print "press a char key …

Member Avatar for scru
0
493
Member Avatar for scru

With James Bond the Brits have a leg up 'gainst the Yanks. Also, let's not forget the legendary Benny Hill. However when it comes to wars, the Yanks have beat the Brits by a mile.

Member Avatar for jbennet
0
333
Member Avatar for sravan953

Microsoft's msvcrt.dll is a dynamic link library, look here for some of its contents: [url]http://msdn.microsoft.com/en-us/library/ms235446(VS.80).aspx[/url]

Member Avatar for vegaseat
0
131
Member Avatar for hughesadam_87

[QUOTE=Salem;899242]The maximum number of open files a process is allowed to have comes from the Operating System. ... [/QUOTE]That is not all of it. In Python you have constructs like: [code=python]for line in file(filename): # do something with line [/code]Here the closing of the file is left to the very …

Member Avatar for jlm699
0
1K
Member Avatar for sravan953

There are a number of GUI drag and drop builders. Boa Constructor: [url]http://www.daniweb.com/forums/post400296-107.html[/url] wxGlade: [url]http://www.daniweb.com/forums/post400189-106.html[/url]

Member Avatar for sneekula
0
2K
Member Avatar for reedie

Python has a module numpy that will make things easier. However, you can use a Python list of lists for a matrix as shown in this example: [code=python]# create a 2D matrix of zeros and populate it def make_list(size): """create a list of size number of zeros""" mylist = [] …

Member Avatar for sneekula
0
139
Member Avatar for MONODA

This might help: [code=python]# see also: http://www.daniweb.com/forums/post896314-177.html import math def fuzzyequals(a, b, delta=0.0000000001): """ returns true if a is between b-delta and b+delta used for comparison of floating point numbers a and b """ return abs(a-b) < delta # cosine of 90 degrees should be zero n = math.cos(math.radians(90)) #n …

Member Avatar for MONODA
0
306
Member Avatar for abhigyan91

A good part of coding in Python is to know what its modules are doing. The module datetime makes your life a lot simpler, it also flags down impossible dates: [code=python]# convert one date format to another # check the Python manual under strftime() # to get the % format …

Member Avatar for sneekula
0
108
Member Avatar for besktrap

The function exec() does not know where class Vent is coming from. You could try something like: exec(mystring, globals()) Now you are putzing around with the global dictionary, dangerous territory indeed!

Member Avatar for abhigyan91
0
12K
Member Avatar for rupeshpradhan

Since a list is a mutable object, it would still behave global if it is used as a function parameter/argument. To wit: [code=python]def add_element(mylist2): mylist2.append(33) return mylist2 mylist = [1,2,3,4] mylist3 = add_element(mylist) print(mylist) # [1, 2, 3, 4, 33] oops! print(mylist3) # [1, 2, 3, 4, 33] [/code]To prevent …

Member Avatar for shadwickman
0
154
Member Avatar for rustysynate
Member Avatar for rustysynate
0
156
Member Avatar for sravan953

[QUOTE=sravan953;896232]It doesn't work even though I run it in the DOS Console window! It just pops up and then closes....(even when I modified the code with the time module).. In IDLE, when I run it, it says "'module' not found"[/QUOTE]Works well on my Linux/Ubuntu computer. I code with the Geany …

Member Avatar for sneekula
0
2K
Member Avatar for firegenius

In order to make added text transparent you have to use the canvas approach. I left a working example here: [url]http://www.daniweb.com/forums/showpost.php?p=895637&postcount=20[/url]

Member Avatar for firegenius
0
4K
Member Avatar for andriod

Are you using the Python Shell (>>> prompts), or an editor like the IDLE editor?

Member Avatar for andriod
0
134
Member Avatar for Jintu

To read in a list of integers with a loop you have to create an empty list and append to it with each input. For instance: [code=python]# create a list of integers # note that input() gives a string in Python3 n_list = [] while True: n = int(input("Enter a …

Member Avatar for Jintu
0
406
Member Avatar for hughesadam_87

[QUOTE=shoemoodoshaloo;894965]Hey guys, I wrote a file the other day, which reads in data, adds a column, and then reads the data out to a specific file. I thought everything was working great, with all of your help; however, I am now running into another problem. The output data looks like …

Member Avatar for sneekula
0
89
Member Avatar for hughesadam_87

[QUOTE=jlm699;894108]You could maintain a list of open file handles like this: [code=python] open_files = [] for each_name in names_list: open_files.append(open(each_name + '.bed', 'w')) [/code] Then that list would be full of open file handles.[/QUOTE]A nice feature of this approach is that the index of the file handle in open_files is …

Member Avatar for hughesadam_87
0
101
Member Avatar for Mclovin

If you just want to replace certain extensions, you can use something like this: [code=python]file_list = [ 'list_nonunique1.py', 'Gene_read1.pyw', 'wx_psutil1.pyw', 'pa16names.txt', 'wxFrame_centerthings1.pyw', 'averagewords1.py', 'oneline.txt', 'tk_coinflip.pyw'] # replace extension .pyw with .py new_list= [] for fname in file_list: if '.pyw' in fname: fname = fname[:-3] + 'py' new_list.append(fname) print(fname) """ my …

Member Avatar for Mclovin
0
655

The End.