761 Posted Topics

Member Avatar for leegeorg07

Sounds like you'd want to spawn two threads. One to constantly update mytime and another to wait on the user's input. Is that what you mean? I'm pretty sure vegaseat has provided a number of examples of spawning threads with subprocess, try searching the forum for some good examples

Member Avatar for leegeorg07
0
73
Member Avatar for zublacko

[QUOTE=zublacko;846010]Ok I have a while loop set but can you guys give me an example of a while loop that takes information, reads the more specific detail and then another specific detail? In my code I cant figure out how to make the loop search another line or sentence. All …

Member Avatar for jlm699
0
95
Member Avatar for zublacko

After you perform [icode]x = s.find("<img")[/icode] you will receive an index. Feed this index into the find function when looking for your closing parenthesis and it will give you the ending index. You can then use the two indexes to slice out the image source URL here's an example (off …

Member Avatar for jlm699
0
115
Member Avatar for harrykokil

[QUOTE=harrykokil;838851]how can i create 50 apples at different positions on screen without having to each time call the constructor 50 times? [/QUOTE] Just put the call to the Apple constructor within your for loop and randomize the values a bit... or use a linear approach to the values... or whatever …

Member Avatar for lllllIllIlllI
0
150
Member Avatar for mafarooqi

I think the function you may be looking for in Python is [icode]eval[/icode]. Or perhaps [icode]exec[/icode], or its variant [icode]execfile[/icode], which eliminate reading the files all together. [URL="http://docs.python.org/library/functions.html#eval"]Refer here[/URL] to information on these built-in functions. As far as how to open files within a for loop it could be something …

Member Avatar for mafarooqi
0
460
Member Avatar for mg0959

[QUOTE=mg0959;842048]Running it as a service works great!!! thanks for the help[/QUOTE] What did you do to get it running as a service?

Member Avatar for mg0959
0
160
Member Avatar for Malestryx

I notice that your condition 3 is missing a continue statement... To answer your question however, you should check to see if intWork is greater than 40 and if it is, calculate the overtime based on the number of hours over 40 that the employee worked.

Member Avatar for woooee
0
1K
Member Avatar for Hatz2619

[QUOTE=Hatz2619;841136] [CODE=python] try: salariesWage=open("PAY.txt", "w") salariesList.writelines(salaries) salariesWage.close() except(IOError): print "Error writing to file list" ... try: employeeWage=open("PAY.txt", "r") employeeList.readlines(salaries) employeeWage.close() except(IOError): print "Error writing to file list"[/CODE] [/QUOTE] Upon initial inspection I see that you're opening PAY.txt as salariesWage and then employeeWage but then trying to read/write as salariesList and …

Member Avatar for Hatz2619
0
925
Member Avatar for dmpop

[QUOTE=dmpop;841319]the script still doesn't work[/QUOTE] What doesn't work? If you are getting error messages please paste the traceback here.

Member Avatar for vegaseat
1
146
Member Avatar for miller4bears6

This code doesn't really do anything for me... can you explain the concept a little bit? When none of the menu choices do anything except for the 'new maze' bit. Printing shows the maze but neither solve nor "Remove v's" does anything whatsoever. I'm not getting errors though...

Member Avatar for jlm699
0
185
Member Avatar for toadzky

You're looking to remotely shutdown a linux server? Or to quit a python program? [icode]sys.exit(rtn_code)[/icode] can exit a python program... but I'm not sure if that's what you're looking for.

Member Avatar for vidaj
0
189
Member Avatar for pythonator

I don't understand... is there a question hidden within these cryptically edited posts?

Member Avatar for sneekula
0
48
Member Avatar for dgtvr

[URL="http://www.crummy.com/software/BeautifulSoup/"]Beautiful Soup[/URL]. If you search this forum there's plenty of examples using it, as well as the numerous other parsers out there.

Member Avatar for chaney44145
0
83
Member Avatar for tillaart36

[QUOTE=tillaart36;790853]It should iterate as (x, y) [/QUOTE] You just have your x and y mixed up: [code=python] >>> def printGrid(w,h): ... for y in xrange(h): ... for x in xrange(w): ... print '%d,%d' % (x,y), ... print ... >>> printGrid(w=7,h=6) 0,0 1,0 2,0 3,0 4,0 5,0 6,0 0,1 1,1 2,1 …

Member Avatar for tillaart36
0
247
Member Avatar for breatheasier

You could use the python debugger to put a break statement I guess? I'm not terribly versed in using it, but from my limited exposure I know that you can put break statements and step through loops, etc. just like most other debuggers. In order to use it you have …

Member Avatar for breatheasier
0
179
Member Avatar for LateNiteTippin

[QUOTE=LateNiteTippin;835806]I'm very new to python, so this is very basic. I'm using the same basis i used on an add row program, which is probably why it comes up adding a row. When i read it back to myself, it seems to make sense. Thanks in advance for any help. …

Member Avatar for LateNiteTippin
0
2K
Member Avatar for srk619

[QUOTE=Gribouillis;836181]google is your friend [url]http://commons.wikimedia.org/wiki/File:Dragon_curve.png[/url][/QUOTE] Wow. I love that db replaced the text within that hyperlink with a smiley. I'm sorry this post isn't on topic but I just wanted to get that out there. Hey, and the link still works! EDIT: kette = chain laenge = length zeichne = …

Member Avatar for srk619
0
98
Member Avatar for tschafer204

Please provide the current state of your code and the problems that you are currently having. Please be specific and show us the exact portion of code that is broken and any error messages that you receive. Do not forget to [URL="http://www.daniweb.com/forums/announcement114-3.html"]wrap your code[/URL] in code tags to preserve formatting. …

Member Avatar for jlm699
0
934
Member Avatar for pythonnewbie1

[QUOTE=pythonnewbie1;835916][code=python] #creating a Class # class wpoMath(object): """This is a Math object""" #main program wpoMath1=wpoMath() wpoMath1.talk() def _init_(self,wpoMath): print "I am wpoMath object" self.name = wpoMath print wpoMath1.wpoMath def _str_(self): print "Hi, I'm, wpoMath, "\n" self._wpoMath=wpoMath def get_wpoMath(self): return self._wpoMath def _init_(self, plus): self.plus = plus def _str_(self): doubled = …

Member Avatar for jlm699
0
227
Member Avatar for tomtetlaw

This might be the easiest thing to do: [code=python] fh = open('myfile.txt') for each_line in fh: print each_line.strip().replace(':', '|') fh.close() [/code] That'll iterate line by line through the file and print out each line only replacing all occurences of ':' with '|'... You could alternately use methods read(), readline(), or …

Member Avatar for tomtetlaw
0
114
Member Avatar for JeyC

[url=http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files]Here's some documentation[/url] on the file object and associated methods.

Member Avatar for Arrorn
0
135
Member Avatar for jessica2009

You've got numerous indentation errors in your code as vegas seat mentioned... first off, fix your lines 2-5 above, as they need to be at the same indentation level as your first if statement... Then work from there, as you've got a LOT of work to do to get this …

Member Avatar for woooee
0
139
Member Avatar for lilkid

Also please post code using code tags, as it preserves the formatting and highlights reserved words (such as file). This will increase the chance that other forum members will read your post and be more willing to help. Use code tags like this: [noparse][code=python] #You code goes here [/code][/noparse]

Member Avatar for lilkid
0
128
Member Avatar for Darkangelchick

[QUOTE=Darkangelchick;823323]does anyone know if it's possible to make this using Tkinter?[/QUOTE] Yes, it is. Coming up with a design for the game board (colors, sizes, etc.) might be the hardest part. We can help you once you get started if you get stuck on anything, just don't forget to post …

Member Avatar for woooee
0
650
Member Avatar for amarmasic21

What do you need help with? Do you know how to define a class yet? Here's some [url=http://docs.python.org/tutorial/classes.html]documentation[/url].

Member Avatar for woooee
0
152
Member Avatar for lakhan.p

What exactly do you need explained? Also, in stead of [python] you should be using code tags. To get language-specific syntax highlighting use it like this: [noparse][code=python] # Code in here [/code][/noparse]

Member Avatar for woooee
0
83
Member Avatar for karenmaye

Karen, Please use code tags when posting code, or else it will become unreadable as it has above. To use the code tags, wrap your code like this: [noparse][code=python] # Code inside here [/code][/noparse] This will turn on syntax highlighting and preserve your indentation. Also, forum members are [b]much[/b] more …

Member Avatar for sneekula
0
2K
Member Avatar for JeyC

You can use a regular expression to grab the number of differences... please ask if there's anything you don't understand. [code=python] >>> import re >>> # my_file_handler = open( 'myfile.txt' ) >>> # my_file_lines = my_file_handler.readlines() >>> # Here's the contents of my_file_lines after a readlines() >>> # my_file_lines = …

Member Avatar for JeyC
0
121
Member Avatar for alicem

[QUOTE=alicem;826881]Thank you, however I'm using Python 2.6.1... is there a different way to do it using that?[/QUOTE] Maybe try this.. pretty much same principal as 3.0 : [code=python]fh = open('myfile.txt', 'rb') while True: try: fh.read(1) except: pass [/code]

Member Avatar for jlm699
0
6K
Member Avatar for siddhant3s

I don't believe that there is a way to ensure Python is un-reverse engineer-able... Meaning that even Python byte code programs can be translated back to source code if someone were dedicated enough to do it. That being said, I used to be a C++ programmer until I discovered Python. …

Member Avatar for sneekula
0
773
Member Avatar for shakeel.ahmad

Please use code tags when posting any type of code [noparse][code=syntax] # Code goes here [/code][/noparse] syntax can be replaced with any code that is supported by DaniWeb like: python, php, etc.

Member Avatar for jlm699
0
189
Member Avatar for leegeorg07
Member Avatar for leegeorg07
0
119
Member Avatar for chris99

I would highly suggest reinstalling and making sure you install under admin for everything.

Member Avatar for jlm699
0
725
Member Avatar for super zach

Remove an item from a list: [code=python]>>> B = [12,24,36,48,60,72] >>> B.remove(24) >>> B.remove(48) >>> B.remove(72) >>> B [12, 36, 60] >>> [/code]

Member Avatar for Max721
0
323
Member Avatar for mahela007

I find that best practice is to always use [icode]strip()[/icode] on lines that I read in from files. This gets rid of all leading and trailing white-space (tabs, spaces, newlines, etc.) Also, here's a rewrite of your code... I removed the tabs and replaced them with spaces and also stripped …

Member Avatar for Gribouillis
0
118
Member Avatar for patelmitul

[QUOTE=patelmitul;822211] [CODE=python] import os, glob path = 'd:\del' for my_file in glob.glob( os.path.join(path, '*.jpg') ): (dirName, fileName) = os.path.split(my_file) (fileBaseName, fileExtension) = os.path.splitext(fileName) print fileBaseName[/CODE] [/QUOTE] Are you getting errors? You don't need to import os.path, as you can simply use os.path after importing os... Also, you aren't using the …

Member Avatar for Gribouillis
0
378
Member Avatar for mahela007

[icode]f.seek(0)[/icode] will always return to the beginning of a file as well. If you print out the value of [icode]beginning[/icode] in the code snippet above, you'll likely find that it is an integer == 0.

Member Avatar for mahela007
0
104
Member Avatar for MaxManus

Not sure exactly what you're asking... but you could make a list of tuples list: [code=python] my_list = [ (0,0), (0,1), (1,1), (1,2) ] [/code] ? Is that what you're asking?

Member Avatar for MaxManus
0
174
Member Avatar for pythononmac

[QUOTE=pythononmac;818565]I have put # -*- coding: utf-8 -*- on the top of the script [/QUOTE] If you remove that line from the top of your script does it change the result? Also, have you tried utf-16 ?

Member Avatar for pythononmac
0
684
Member Avatar for besktrap

Here's a class example... [code=python]>>> class car(object): ... def __init__(self, make='Any', model='Something', year='Unknown'): ... self.make = make ... self.model = model ... self.year = year ... def __repr__(self): ... return 'Hello, I am a %s %s %s' % (self.year, self.make, self.model) ... >>> my_car = car('Ford', 'Focus', '2008') >>> your_car …

Member Avatar for besktrap
0
145
Member Avatar for MK12

Until py2exe works with Python 3 you're out of luck... if you can get your users to install Python 3 then all they have to do is double click on the script to run it...

Member Avatar for MK12
0
106
Member Avatar for lakhan.p

First of all, you should use code tags like such: [noparse][code=python] # Code goes in here [/code][/noparse] Which would've given you the following: [code=python]if param[0:4]<>'ini=': print ' %s ini='%sys.argv[0] sys.exit(1) inifile=param[4:][/code] Now, to answer your question: First we check that the first 4 characters of param are "not equal" to …

Member Avatar for jlm699
0
102
Member Avatar for Norbert X

[QUOTE=Norbert X;817803]I need help with my homework :( but no one's replying. [note: this comment was just to move this thread back to the top of the list][/QUOTE] This isn't a place to come and have your homework done for you. Forum-goers here typically don't just give out solutions to …

Member Avatar for jlm699
0
149
Member Avatar for breatheasier

Here's how to open a file and parse the contents as per your example: [code=python] def main(): """ test_data.txt contents (minus leading tabs): 2.825 1.00697992588 2.875 0.952989176901 2.925 0.91428970229 2.975 0.890110513425 3.025 0.879731596138 3.075 0.959217137445 3.125 1.07391392796 3.175 1.04874407027 3.225 0.857693793906 """ # We can keep track of our data …

Member Avatar for Gribouillis
0
153
Member Avatar for Norbert X

What do you mean by "play" ? Are you wanting to have an image pop up in a window or are you talking about playing a video file?

Member Avatar for Norbert X
0
125
Member Avatar for g_e_young

[QUOTE=g_e_young;815957]file_list ends up with the final value from data, rather than a string of all values in the file [/QUOTE] On every iteration you're simply over-writing the value of file_list. The proper way to use a list is: [code=python] my_list = [] for line in my_file: my_list.append( line ) [/code] …

Member Avatar for g_e_young
0
128
Member Avatar for toadzky

Why reinvent the wheel? Python has a text wrapping module [url=http://docs.python.org/library/textwrap.html]built right in[/url]

Member Avatar for scru
0
158
Member Avatar for wccarithers

[QUOTE=wccarithers;815738]I am using psycopg2 to read from one database table and insert these into another table. I get a format error when the value I am trying to insert has a space in it. The condensed code looks like: cursor.execute("""INSERT INTO table (column1, column2) VALUES ('start finish','now later')""") I'm a …

Member Avatar for jlm699
0
2K
Member Avatar for kanodi

My thoughts: Traverse the grid from top-to-bottom, and left-to-right (ie, just like reading a book). On each character, make a list of *this letter concatenated with every surrounding letter (for this example we'll start at the left or due west position and progress counter-clockwise, ie: [code=concept] grid = """ ashfghj …

Member Avatar for kanodi
0
190
Member Avatar for ChrisP_Buffalo

I assume that re-ordering is due to the way that dictionaries are stored in memory... in order to provide faster searching and indexing dictionaries are stored in a special way... much unlike lists and tuples, which retain their order.... Example: [code=python] >>> d = {'cat':'purr', 'dog':'woof', 'aardvark':'?', 'chocolate rain':'feel the …

Member Avatar for ChrisP_Buffalo
0
163

The End.