15,175 Topics

Member Avatar for
Member Avatar for TrustyTony

Next quiz is posted as code snippet. It is quite interesting code. What it does? And where [B]in your system[/B] you already have this code? (in little different format) (If you have not follow tip in page [url]http://python.org/download/[/url])

Member Avatar for TrustyTony
0
225
Member Avatar for Tomashqooo

[CODE]tomashqooo@Tomashqooo:~$ python Python/tcrack.py File "Python/tcrack.py", line 86 ostring2 = ostring2' -c 'station' mon0' ^ SyntaxError: invalid syntax[/CODE] That`s my error message when ostring2 and station are string variabiles and ' -c ' and ' mon0' is text. Please help me what`s the problem here???

Member Avatar for Tomashqooo
0
72
Member Avatar for debasishgang7

Hi all, Here is mu scenario.I am trying to open multiple port on a compute. I am trying to make the code multi threaded.So here is my code: [CODE]import socket import thread from threading import * s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def handler(clientsock,addr): while 1: data = clientsock.recv(BUFSIZ) if not data: …

Member Avatar for debasishgang7
0
892
Member Avatar for codemonster

The following is a class from a search engine program that I'm working on (via a text book). I'm attempting to modify the following code so that it will count the number of occurrences a user's entry has from a source. My initial attempts was to create a new method …

Member Avatar for woooee
0
89
Member Avatar for petzoldt01

Decided I want to use python for web programming. I am a fan of Lighttpd, but when it came to python, just seemed like apache had some better options. I am currently setup with Apache2 and mod_python. I use VirtualHost site configurations to serve a few websites, and do per-site …

0
73
Member Avatar for Checkerboz

Okay so as a complete newbie... Currently I am at chapter 6 of a book called How to Think like a Computer Scientist ([URL="http://openbookproject.net/thinkcs/python/english2e/ch06.html"]http://openbookproject.net/thinkcs/python/english2e/ch06.html[/URL]) and I for some reason can't figure out this exercise: Make this doctest pass: [CODE]def print_digits(n): """ >>> print_digits(13789) 9 8 7 3 1 >>> print_digits(39874613) …

Member Avatar for Checkerboz
0
117
Member Avatar for Thropian

I have a command lets say [CODE]f(x): print x[/CODE] I want to create several buttons to print various numbers so I made a list of the objects to print when I tried to do [CODE]for x in thislist: bind_all(x,lambda:f(x))[/CODE] which bound the buttons properly but all the buttons print the …

Member Avatar for Thropian
0
74
Member Avatar for SasseMan

Hi! I want to make a python program that runs different simple command line scripts. Right now I use os.system which works fine for running the scripts, but the problem is that the scripts sometimes halt and wait for input from the user. So my question is, how do i …

Member Avatar for Gribouillis
0
149
Member Avatar for ankurvit

Hi, I'm looking to code the following problem in python. If (for example) dict={A:0.7,B:0.8,C:0.9,D:2.3,E:0.1,F:2.4} and so on.. (i have a big dictionary of A-Z something like this) I'm looking to find repeated substring in a string that has a dissimilarity of no longer than 0.5 (between highest and lowest). The …

Member Avatar for TrustyTony
0
193
Member Avatar for clyt

I want to obtain the data from .dat file which contains millions records (most of them are string) with 52 fields. I am trying to store the data into 52 lists. However, it is very slow Here is the code: import sys try: file= open("test.dat", "r") except IOError: print >> …

Member Avatar for clyt
0
131
Member Avatar for Tugnus

So I'm pretty lost in Python. My teacher doesn't explain the commands for Python so I'm really confused on how to write this. I have to write a green screen type program that takes a picture with a green background and replaces it with another picture by looking at the …

Member Avatar for Tech B
0
2K
Member Avatar for FALL3N

I am writing Python on my mac, and am trying to pipe the output from the Terminal to python.. I think this is achieved with os.popen?

Member Avatar for FALL3N
0
113
Member Avatar for Hawkwing

If I have a class variable being passed to a function, is there a way that I can get the class that the variable is from? [CODE]class someclass: def __init__(self): self.somevariable='somevalue' def somefunction(self): print('gotta get here') def someotherfunction(somevariable): somevariable.needparentclasshere.somefunction() myclass=someclass() someotherfunction(myclass.somevariable)#this needs to print 'gotta get here'[/CODE]

Member Avatar for woooee
0
161
Member Avatar for Thropian

Ok so I'm trying to get images to resize which I could do with Image.PhotoImage but now I'm using RGBA .png files so I have to use ImageTk.PhotoImage and I can't figure out how to resize them anymore any help on this kind of thing? I'm using python,tkinter

Member Avatar for Thropian
0
14K
Member Avatar for Kirielson

Hello, I'm having trouble running the CalcOpticalFlowPyrLK in Python. When I try doing the calculations for the Lucas Kanade code it will not compute the error I get is the following:[ICODE] File "****", line 63, in callback (currFeatures, status, track_error) = cv.CalcOpticalFlowPyrLK(old_image, new_image, old_pyramid, new_pyramid, old_features, (3,3), 1, (cv.CV_TERMCRIT_ITER, 10, …

0
175
Member Avatar for Caraka

Greetings I'm running in circes trying to accomplish something very simple. I have a csv file with multiple lines resembling: 0002345, 24, 5, 0.24 I need this format in my output file: '0002345', 24, 5 0.24 The first entry is a census meshblock code and the leading zeros are relevant …

Member Avatar for Caraka
0
863
Member Avatar for AnjaliThukral

I have windows xp operating system at my home with python 2.5 and same operating system with python 2.4 at my computer lab. While working in python IDLE suddenly this error message --socket error:connection refused-- pops up and then python IDLE does not work at all.To make it work again …

Member Avatar for vegaseat
-1
1K
Member Avatar for Sinnocence

I wasn't able to find the link describing how to solve this. When I try to compile my program with py2exe using python v2.6 at the end of the process I get a message saying The following modules appear to be missing ['ICCProfile','_grabscreen','_imaging_gif'] my setup script is just : from …

Member Avatar for snippsat
0
195
Member Avatar for vegaseat

One more application of the Python Image Library (PIL). This short code creates thumbnails from all JPEG files in the current folder. The thumbnail image file is prefixed with a T_ and saved to the same directory. The program checks for existing files with this prefix, so we don't create …

Member Avatar for thenate
1
2K
Member Avatar for jmark13

Hello again, So, I'm trying to work out a problem where there are 6 symbols in a string (A, B, 0, 1, [, ]). The brackets always have to face each other in the string but they can be nested. There are some rules, most of which I have down, …

Member Avatar for TrustyTony
0
138
Member Avatar for Petan Kl

Hello, I am wondering if there is an efficient way (other than for cycle) of solving following task: I need to multiply e.g. two matrices and at every point in the matrix there is an array. The two matrices shall be multiplied using matrix multiplication and when the elements of …

Member Avatar for Gribouillis
0
211
Member Avatar for FALL3N

ok, I'm sure the answer to this is very simple.. there may even be some component in the os package to do this... I want to do what the code underneath seems like it would do.. I understand it does not, and when I try to run the code, I …

Member Avatar for FALL3N
0
276
Member Avatar for FALL3N

hello all, I have a program, and in it, it eventually specifies 'aFolder' to be os.walk(path/to/folder) how do I obtain inifo such as the name or the path of the folder, is it then the temporary current working directory?

Member Avatar for snippsat
0
111
Member Avatar for jml101

Hello All, New to Python, I keep getting an indentation error after the if (yescheck == todcheck): line. Any suggestions? As far as my python knowledge goes, I've got it correctly aligned, but clearly not. Could some of you try running this, see if it goes? [code=python] import os yesfile …

Member Avatar for vegaseat
0
712
Member Avatar for TrustyTony

I thought to post some not quite so trivial as it looks quiz for Python, to test if your brain has Python installed OK ;) Try to figure out what interpreter answers (#? lines), then check with your Python interpreter of choice: [CODE]>>> a = list(range(10)) >>> a[1:1] #? >>> …

Member Avatar for TrustyTony
3
658
Member Avatar for Kirielson

Hello, I'm trying to run an object on Python with ROS. When I run the code with a variable inside the object: [CODE]class lk(old_image): ....then some code def main(args): rospy.init_node('lk', anonymous=True) old_image = lk(old_image) try: rospy.spin() except KeyboardInterrupt: print "Shutting down" #cv.DestroyAllWindows() [/CODE] [ICODE]Traceback (most recent call last): File "/home/aadejare/ros/omnisensor/nodes/lk.py", …

Member Avatar for griswolf
0
337
Member Avatar for hszforu

I started learning python3 some 3-4 days ago.My ultimate aim to learn this language is to design web apps(eg apps to automate account creations for seo etc.) For this i guess i will have to use django or turbogears for this, but now i came to know that django or …

Member Avatar for hszforu
0
189
Member Avatar for TrustyTony

There was little buggy version of Python base conversion around, so here quick hack for my own program, including test with random numbers to verify it.

Member Avatar for TrustyTony
0
917
Member Avatar for johanngomes

Hi people, i am in trouble with python quotes, see this: [CODE]string = "qwerty"[/CODE] when i do a print string it returns: [CODE]'qwerty'[/CODE] how do i replace this singles quotes to double quotes when the value of the variable is returned? there is a way? thanks in advance! ;)

Member Avatar for Schol-R-LEA
0
681
Member Avatar for TrustyTony

What modules come builtin with your Python? Let's exclude the internal _ starting ones for this question. You know those? Are you sure? Good, because I did not! (Hint WindowsXP and Python2.72 has 27 builtin modules) Here the answer in code [CODE]import sys print('\n'.join(n for n in sys.builtin_module_names if not …

Member Avatar for Gribouillis
0
301

The End.