2,190 Posted Topics

Member Avatar for wolf29

You call executemany but only supply one value. What is the point of creating the tuple "tests" or "vuln" instead of supplying the fields directly to the insert statement. You should also open or create the SQLite db once at the top of the function before the for loop. As …

Member Avatar for wolf29
0
3K
Member Avatar for tony75

I would just add both directories to the PYTHONPATH variable in .bashrc. You can also add something like export PYTHONSTARTUP=$HOME/.pythonstartup to .bashrc to execute a given file when python starts. Edit: Sorry, I see now from the "7" and "xp" that you are probably using a windows OS, but am …

Member Avatar for woooee
0
294
Member Avatar for m_ishwar

An infinite loop as play_click is not changed within the while loop while(self.play_click==0): self.while_time() When testing it is a good idea to limit while loops ctr = 0 while self.play_click==0: self.while_time() ctr += 1 if ctr > 99: print "Counter limit exit from while loop" self.play_click=99

Member Avatar for m_ishwar
0
167
Member Avatar for floatingshed

That comes out to June 10th, 14 days off. There would be something like 28 leap years which is too far off to be a possibility. "41401,250002" comes back as May 9th at 6:00 AM (providing January 1, 1900 is correct). import datetime x=datetime.datetime(1900, 1, 1, 0, 0, 0) + …

Member Avatar for woooee
0
470
Member Avatar for tony75

It appears that user name or password are None as the program prints the message and then exits, but it should be sys.exit(0) instead of exit(0).

Member Avatar for kwheeles
0
248
Member Avatar for KatJ9

Always use complete names. The program is not looking in the directory that the file is located in. Also, you should be able to use a slash, /directory_name on any OS. ##------------------------------------------------------------- ## Assumes this code is now indented to run under the for() loop ##------------------------------------------------------------- folder_to_import = '/Location/DATA' l_files_to_import …

Member Avatar for KatJ9
0
480
Member Avatar for fatalaccidents

2nd hit on Google [pyusb backend not accessible](http://stackoverflow.com/questions/5152133/pyusb-backend-not-accessible). You have to install an additional lib that pyusb depends on, and it's also on the [pyusb site](http://sourceforge.net/apps/trac/pyusb/) but the web site isn't real clear saying that you have to install one of the library dependencies. Please mark this as solved.

Member Avatar for fatalaccidents
0
1K
Member Avatar for Necrozze

A class is a prototype, i.e. it is only a potential object. class HelloWorld : def __init__(self): print("Hi") def talk(self ,name): self.nameA = name print("Hello", self.nameA) HW1=HelloWorld() ## calls the class or creates an actual instance HW2=HelloWorld() ## a second, separate instance HW1.talk("Name 1") HW2.talk("Name Two") print HW1.nameA print HW2.nameA

Member Avatar for Necrozze
0
304
Member Avatar for Ismatus3

> i wanted to use the subprocess module also but i couldn't know how to use it , and got this Error : WindowsError: [Error 2] Le fichier spécifié est introuvable We don't know what the statment was that produced the error so can not offer any help on how …

Member Avatar for woooee
0
313
Member Avatar for Varunkrishna

It is replacing every 'a" with "ein". A [tutorial on using a dictionary to map from English to Spanish](http://www.greenteapress.com/thinkpython/html/thinkpython012.html) ## CamelCase is reserved for classes in Python dic_word= { 'a':'ein', 'an':'eine', 'able':'KOmmen', 'about':'gegen', 'above':'Uber', 'absence':'Abwesenheit', 'absent':'abwesend', 'accent':'Betonung', 'accept':'akzeptieren', 'according':'nach', 'acquainted':'kennen', 'across':'uber' } for word in ["a", "able", "acquainted"]: print word, …

Member Avatar for Varunkrishna
0
1K
Member Avatar for harinath_2007

If the car is still in transit, we don't know what the speed is. If there is no traffice, it is faster. If there is a traffic jam it is slow. If the traffice is the same then the speed is the same. If the car has already arrived, it's …

Member Avatar for woooee
0
185
Member Avatar for vadimak

If someone enters a wrong user name, or password, or bc, nothing happens. It should be something along the lines of if Choice==2: username = "" while username != uname: username=raw_input("Login User name: ") This is definitely a list exercise IMHO and whould be much easier with dictionaries. The point …

Member Avatar for vadimak
0
545
Member Avatar for dp121307

We don't have the inherited class, EventHandler, and don't know what graphics tool kit you are using, so can not offer any assistance other than to say that you don't call the function "handle" anywhere in the code posted that I can see.

Member Avatar for dp121307
0
382
Member Avatar for Varunkrishna

For starters you will have to [load/open and read the file](http://www.freenetpages.co.uk/hp/alan.gauld/tutfiles.htm) Post back when you have this coded (whether it works or not) with a sample of input and the output you would like.

Member Avatar for woooee
0
2K
Member Avatar for Social_psych

No "/n". The data is there it's just on one r e a l l y long line. fp=open("data.txt", "a") fp.write(dependent_variables) fp.close() And it should be fp=open("data.txt", "a") ## do the input or calcs or whatever fp.write(dependent_variables) ## do more input and/or calcs fp.write(dependent_variables) ## at the end of the …

Member Avatar for Social_psych
0
223
Member Avatar for ggsr45

You have not declared log_size or log1_size anywhere and it appears the indentation is off under the while True, which is an infinite loop since you don't ever exit it. There is no reason from the code you posted to append to "packed" and then write each value from packed …

Member Avatar for ggsr45
0
373
Member Avatar for dp121307

When you call/instantiante the class you should be including a monitor value. Someone on Chapter 15 of the book "Object-Oriented Programming in Python" should know how to call a class. Time to go back and review the basics.

Member Avatar for dp121307
0
535
Member Avatar for robinlrandall

Not without code as the error is possibly in the HtmlEasyPrinting function call. HtmlEasyPrinting(name_of_print_object, parentWindow) http://wxpython.org/docs/api/wx.html.HtmlEasyPrinting-class.html which it appears you overwrote/replaced with a class of the same name but we can not tell without code. > HtmlEasyPrinting.PreviewText(self, self.GetHtmlText(text))

Member Avatar for robinlrandall
0
362
Member Avatar for die_windoze

If you are using a Linux system, then it should be /dev/ttyS0, etc. If it is a USB connection, try [PyUSB](http://sourceforge.net/apps/trac/pyusb/)

Member Avatar for die_windoze
0
302
Member Avatar for NiescierJ

use [canvas.create_image](http://effbot.org/tkinterbook/canvas.htm#canvas.Canvas.create_image-method) instead of configure, and then place whatever objects on top of it.

Member Avatar for vegaseat
0
14K
Member Avatar for lewisrs89

Take a look at "Function Arguments" and "The Return Statement" [Click Here](http://www.tutorialspoint.com/python/python_functions.htm) You can also Google for instance objects (also called instance variables) if you want to learn more about classes.

Member Avatar for woooee
0
220
Member Avatar for NiescierJ

GUI's have their own "sleep" type methods that should be used. However each GUI uses a different function name so it depends on the GUI toolkit you are using.

Member Avatar for NiescierJ
0
127
Member Avatar for Koljik

Python does have a goto add on [Click Here](http://entrian.com/goto/) but it was an April Fool's joke so I don't know if it works or not (and don't care as I will not be using it).

Member Avatar for Koljik
-1
240
Member Avatar for in_xx

To set the background from a list for example would be like the following, and you would use other input parameters in a similar manner, although I don't think I understood your question correctly. import wx class mainFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title,style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION) mainBox = wx.BoxSizer(wx.VERTICAL) …

Member Avatar for in_xx
0
159
Member Avatar for dusto

I agree that you are doing it the hard way. Note that dollars is multiplied by two after the print and the addition to total #get the ending limit days = int(raw_input('How manys days were worked? ')) total = 0 dollars = 0.02 #print table headings print('\nDays\tDollars') print('------------------------------') #print the …

Member Avatar for woooee
0
125
Member Avatar for laver68xo

Does the file have more than one taxon? In the example you posted there is only one so all of the solutions are for one only. Try this as a hint, although there are other ways to do it. handle = open(fname, "r") all_data = handle.read() print all_data.split("taxon")

Member Avatar for HiHe
0
204
Member Avatar for ddannieellee

Python does have os.linesep which is perhaps what the OP was referring to. In Python, "\n" will be converted to the proper end of record termination for the OS used.

Member Avatar for HiHe
0
318
Member Avatar for Ismatus3

I would suggest that you use a button instead of a label, which can execute a funtion when it is clicked. Also, the name "list" is already used by Python so you should not override it, although you never use the variable "list" in the code posted so the "list" …

Member Avatar for Ismatus3
0
295
Member Avatar for Ismatus3

event.x and event.y have to be within the boundaries of the label. An example using a canvas but similar to what you want try: import Tkinter as tk ## Python 2.x except ImportError: import tkinter as tk ## Python 3.x def point(event): x = event.x y = event.y print "x, …

Member Avatar for Ismatus3
0
229
Member Avatar for nexy

Once you get the value it is a normal variable and you can do anything with it that you can do to a normal variable. I would suggest that you consider putting everything under one class instead of here's a function, there's a class, here's another function, etc. try: import …

Member Avatar for nexy
0
3K
Member Avatar for asim.poptani

Please mark the the thread "Solved" so as to not waste other's time looking at an already solved thread.

Member Avatar for woooee
0
271
Member Avatar for gmorcan

There is a typo in get_average that you should be able to run down from the error messages, or at least begin to learn how. Using descriptive variable names would help you with this, as well as help us understand the program. Print the return from get_average and see if …

Member Avatar for woooee
0
265
Member Avatar for mkweska

For future reference, the error was eliminated because you added the plus signs. Also, include the entire error message in the future. print('Ok,'chara, print('Ok, '+ chara +

Member Avatar for Schol-R-LEA
0
219
Member Avatar for Rick345

It would be something like cipher = short_str.find(letter, cipher) if cipher > -1: print cipher + 1, else: print "_",

Member Avatar for Rick345
0
228
Member Avatar for tony75

First, remove punctuation (? , . etc). Next all words should be lower() case as an upper case word is different to the computer than a lower case word. To print use the dictionary's key as below, although this code does not do any of the other above suggestions data="""I …

Member Avatar for tony75
0
504
Member Avatar for jaison2

And it's not tough to do. [CODE]import Tkinter root = Tkinter.Tk() root.title('Canvas') canvas = Tkinter.Canvas(root, width=450, height=450) canvas.create_oval(100,50,150,100, fill='gray90') x = 125 y = 175 stick = canvas.create_line(x, y-75, x, y) diff_x = 25 stick_leg1 = canvas.create_line(x, y, x-diff_x, y+50) stick_leg2 = canvas.create_line(x, y, x+diff_x, y+50) y=145 stick_arm1 = canvas.create_line(x, …

Member Avatar for bumsfeld
0
10K
Member Avatar for vegaseat

Has anyone used the PIL fork [Pillow](https://pypi.python.org/pypi/Pillow) and is there any reason to change?

Member Avatar for vegaseat
3
4K
Member Avatar for Ismatus3

The best you can do AFAIK is to bind the canvas to a button click and get the coordinates. You then check to see if the click was within the boundaries of the image. If you bind the Canvas object to a button click that calls the function clicked, the …

Member Avatar for Ismatus3
0
6K
Member Avatar for krimgo

You append everything to converted as one list, i.e. you have to use a sub-list and append it each time the list breaks. eq= ['MPNRRRCKLSTAISTVATLAIASPCAYFLVYEPTASAKPAAKHYEFKQAASIADLPGEVLDAISQGLSQFGINL', 'MQLVDRVRGAVTGMSRRLVVGAVGAALVSGLVGAVGGTATAGAFSRPGLPVEYLQVPSPSMGRSELPGWLQA', 'GLVGLAGGAATAGAFSRPGLPVEYLQVPSPSMGRDIKVQFQSGGNNSPAVYLLDGLRAQDDYNGWDINTPAFEWACGKAGCQTYKWETFLTSELPQWLSANRAVKPTGSAAIGLSMAGSSAMILAAYHPQQFIYAGSLSALL'] polarity = { 'A': 0.000, 'R': 52.000, 'N': 3.380, 'D': 49.700, 'C': 1.480, 'Q': 3.530, 'E': 49.900, 'G': 0.000, 'H': 51.600, 'I': 0.130, …

Member Avatar for krimgo
0
346
Member Avatar for krystosan

names = nmls means let both point to the same block of memory, so both get updated. names = nmls[:] note the colon means names is now a copy (complete slice) of nmls. You can also use copy() and deepcopy() to get a copy of the list [Click Here](http://docs.python.org/2/library/copy.html) .

Member Avatar for Lardmeister
0
210
Member Avatar for josh.culley.31

1. ask for each value separately. Otherwise "Enter if done" returns a "need 2 values to unpack" error. 2. you can do something like what is in your program but it returns a string odom2, gallons = input("\nPlease enter odometer reading and gallons used (odometer gallons) [Enter if done]: ").split() …

Member Avatar for woooee
0
6K
Member Avatar for jeremywduncan

> I can't seem to get pickle.dumps (or f.write..tried that earlier) to save without saving over itself. f =open('pettycash.txt', 'wb') Instead of write mode, which creates a new file each time, open the file in append mode: see the example at [Click Here](http://www.freenetpages.co.uk/hp/alan.gauld/tutfiles.htm) where these lines are explained def logError(msg): …

Member Avatar for woooee
0
271
Member Avatar for tony75

You do not test for the password for the user so if any user's password is found it will return True. This works for me but again will accept any user's password (and note the added print statements to see what is happening). import crypt line="victim: HX9LLTdc/jiDE: 503:100:Iama Victim:/home/victim:/bin/sh" cryptPass …

Member Avatar for tony75
0
663
Member Avatar for krystosan

As Tony said getters and setters are not used in Python as it is inefficient to create a function just to change or return some variable when that can be done directly as the following example illustrates class Priority(): def __init__(self, priority): self.priority = priority Pr = Priority(1) print Pr.priority …

Member Avatar for woooee
0
240
Member Avatar for jeremywduncan

You have to set writeback=True for changes to be made to the db. Doug Hellmann has a nice write up [Click Here](http://doughellmann.com/2007/08/pymotw-shelve.html)

Member Avatar for woooee
0
216
Member Avatar for johnny0627

Your code can return one, two, or three values. The error occurs when less (or more) than three vaules are returned (i.e. dice1, dice2, dice3 and only two are returned from the function). Usually you would catch the return with a [tuple Click Here](http://www.tutorialspoint.com/python/python_tuples.htm) since you want to catch any …

Member Avatar for woooee
0
212
Member Avatar for james.lu.75491856

For starters, your recursive call has no exit point so could easily go beyond the length of the list isloopy(nextcownum,data,did) This doesn't happen because the 1: '0', 2: '4', 3: '1' is a repetitive loop if I read this correctly (3 goes back to 1), so if cownum in did: …

Member Avatar for woooee
0
591
Member Avatar for Fernando_1

What and where do you and to print. I don't see anything in the program that prints name, etc. See [Click Here](http://www.freenetpages.co.uk/hp/alan.gauld/tutfiles.htm) for more info on reading files. Instead, we generally use something like fp_in = open(file_name, "r") for record in fp_in: # do some stuff print record

Member Avatar for woooee
0
314
Member Avatar for woooee

The following code does the same lookups using a list and a dictionary. Lists are sequential in memory, meaning that the program has to get the offset for the beginning of the item it wants to use, go to that offset, compare to what it wants to find, and go …

Member Avatar for sepp2k
1
205
Member Avatar for dirtydit27

A hint from string import ascii_lowercase as letters print letters[-1:] print letters[-2:] print location=25 print letters[location:] location -= 1 print letters[location:]

Member Avatar for Lucaci Andrew
0
297

The End.