761 Posted Topics
Re: [QUOTE=Lingson;944773]2.2**2 resulting 4.840000000000001 which we all know that is incorrect.[/QUOTE] Why is that incorrect? [URL="http://www.google.com/search?q=2.2^2"]http://www.google.com/search?q=2.2^2[/URL] | |
Re: [QUOTE=evstevemd;941569]sqlite3.OperationalError: near "?": syntax error File "f:\Hosanna\CodeBase\PyCodeBase\sqlite_on_test.py", line 26, in <module> test.CreateNewTable("testing") File "f:\Hosanna\CodeBase\PyCodeBase\sqlite_on_test.py", line 12, in CreateNewTable self.cur.execute("CREATE TABLE IF NOT EXISTS ?(id INTEGER, name TEXT)", (tablename, ))[/QUOTE] Yup, that's a syntax error in the SQL command. Read up on SQL syntax [URL="http://www.1keydata.com/sql/sql-syntax.html"]here[/URL]. | |
Re: Is there a question here? Also, do you not need to perform a [icode]conn.commit()[/icode] in sqlite after transactions? I know that for postgres it's a req | |
Re: As far as asking the user for input use either raw_input or input depending on your version of Python. Then the conversion is simple math. Just google "1 kilometer to miles" and it will give you the conversion rate. | |
Re: [QUOTE=blah32;943676]I am new to regular expressions, but I do not get why this is not working : [CODE] import re inputstr = "HI\n//asgwrg\nasdg" re.sub("\/\/(.*)(\n)", "\n", inputstr) [/CODE] I am trying to substitute everything between "//" and newline with newline. Can someone tell me whats wrong? I am using python 3.1[/QUOTE] … | |
Re: [QUOTE=smoore;943889]What if I would like to change the file's privileges after i have already initialized the variable?[/QUOTE] You basically have two options: 1) Close the file handle and reopen (you can use the file handles member [icode]name[/icode] if you don't want to hard code it): [code=python] >>> fh = open('some.file', … | |
Re: That means you haven't installed/setup the module correctly. Why don't you try going to the source website and see if there are instructions for setup. | |
Re: You'll need to actually write to your file handle [icode]txtfile[/icode] by using [icode]txtfile.write( text )[/icode]. | |
Re: [QUOTE=Aiban;941655]goto musicback2[/QUOTE] I was just talking with a co-worker yesterday about BASIC. He mentioned that people should learn it simply to demonstrate how NOT to write code... heh Anyway, to call a function you would do this: [code=python] >>> def musicback2(): ... print 'Hey this is the music back 2 … | |
Re: Did this just start or has it happened always? It almost sounds like you may have inadvertently borked your Python install. I'd suggest a clean install. | |
Re: [QUOTE=fleem;942953]I've been unable to get to it for the last hour or so.[/QUOTE] This is a great site to keep in mind when you're posed with this question in the future... [URL="www.downforeveryoneorjustme.com"]www.downforeveryoneorjustme.com[/URL] | |
Re: If you were to [icode]split[/icode] the users input into a list you can use list indexing to call out each word individually. Here's an example: [code=python] >>> act_in = "punch Alice in the face" >>> act_in_parts = act_in.split() >>> action = act_in_parts[0] >>> target = act_in_parts[1] >>> action 'punch' >>> … | |
Re: Is there any possibility that the page your browser is displaying is a cached version and hasn't updated to notify you of the user's deletion? Try clearing ff's cache and then fetching the page again. | |
Re: I'm thinking you should just be "adding" the lists together instead of appending a list onto a list... if you know what I mean. Like this: [code=python] import re def test(): a = "<this is> <a> test" b = re.split("(<|>)", a) c = [] for item in b: c += … | |
Re: [QUOTE=willygstyle;942439] [CODE=python] #open inventory and add contents to contents list newfile = open("inventory.txt", "rt") for item in newfile: ## Use strip here to remove the newlines that you're reading in contents.append(item.strip()) newfile.close() [/CODE][/QUOTE] You're right... it's important to remember that when reading files, each line has a newline on the … | |
Re: For one thing, don't name your list "list", as that's a reserved word in Python (try [icode]list('12345')[/icode]), same thing with file... But that modification won't help you. I'm assuming you've got a new version of Python installed, as the method you're using will only work in earlier versions of python. … | |
Re: 1. What is the "vs solution" ? 2. How are you performing your "build and clean" ? 3. What isn't creating the .exe ? | |
Re: [QUOTE=funfullson;939501]Thank dears.So I have to chose one between wxpython and pygtk...your mean that pygtk is better to learn? and another question.to use a database I learned sql language and there is not basic differences between mysql, sqlite and etc. [/QUOTE] You don't need to choose one, you can learn them … | |
Re: [QUOTE=leanne86;932873]...[/QUOTE] What does your pstat code look like? Do you know if it's still in a valid directory that apache can get to ? | |
Re: In windows use [icode]tasklist[/icode], and in linux us [icode]ps[/icode]. In either case, you'll need to search/grep out your process's name to see if it's running | |
Re: [QUOTE=Dixtosa;940080]udp or tcp?[/QUOTE] UDP is an "unreliable" transfer protocol, ie if a packet is dropped or lost, it doesn't care. This is for high-demand but low-expectation connections (think streaming video: you don't care if you miss a frame or two because you can still see the entire video). TCP is … | |
Re: [QUOTE=shaun.b;940982]it just shows a load of {}. [CODE]firstRec = True for fields in parser: if firstRec: fieldNames = fields firstRec = False else: dicts.append({}) for i,f in enumerate(fields): dicts[-1][fieldNames[i]] = f[/CODE][/QUOTE] In your code, you are iterating over the contents of parser. You ignore the first line, then set firstRec … | |
Re: You could do something along the lines of this: [code=python] # Open our input (hosts) file file_in = open(filename) # Open a temporary output file file_out = open(fileoutname, 'w') # host_found will tell us if we found the line define host { host_found = False # Now iterate over each … | |
Re: [QUOTE=LW00;940118]'os.system(pathToBatFile)' [/QUOTE] Is your pathToBatFile an absolute or relative path? | |
Re: I believe [icode]sys.stdout.flush()[/icode] is what you're looking for. Those stdio handles are just like open file handles | |
Re: What implementation of sql? There are different modules to use depending on whether it's postgresql, mysql, etc... | |
Re: Use [icode]os.system("RD /s folderName")[/icode] or subprocess.Popen depending on your python install | |
Re: The AttributeError is telling you that the instance of X lacks Y. If you study your error message: [QUOTE]background = pygame.image.load(bif).covert() AttributeError: 'pygame.Surface' object has no attribute 'covert'[/QUOTE] It first gives you the line of code for context, then the actual error (AttributeError). So it says the pygame.Surface object does … | |
Re: sys.stdin is an "always open" file handle to the stdin and likewise sys.stdout. To use them, import sys. | |
Re: [QUOTE=you2;932195] Logs snippet below: ==========LOGS============== a:CPU [ 85%]: asdf asd 123 xyz A: Ts 23086, Netvalue 3286, someothervalues 3456 abc abc xyz xyz a:CPU [ 75%]: asdf asd 123 xyz A: Ts 24088, Netvalue 3266, someothervalues 6576 ======End of Logs ===========[/QUOTE] Will your logs always have a: A: on the … | |
Re: You would use string formatting to insert the value of the variable in the string you're using to execute grep like so: [code] variable = 123 s = subprocess.Popen("grep -w %s Data.txt" % variable) [/code] Here's the documentation on [URL="http://docs.python.org/library/stdtypes.html#string-formatting-operations"]string formatting[/URL]. | |
Re: Use tortoise's [URL="http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/apc.html"]command line stuff[/URL] | |
Re: [QUOTE=JasonHippy;938309]would it be worth using a variable to catch whatever value is returned by the system.os [/QUOTE] Nah, os.system just returns the return value. You'd be better off using a subprocess and read the STDOUT pipe... Additionally, you could add a " > filename.txt" to the end of your command, … | |
Re: py2exe.org is where you should be looking. I'm sure they'd love the help if you're willing to volunteer. | |
Re: [QUOTE=penguin22;935602]When i try to build a visual studio solution it does not want to build[/QUOTE] Why not? | |
![]() | Re: [QUOTE=sravan953;936229][I][B]#1 doubt:[/B][/I] Why do I have to specify 'self' while defining the function? I usually don't do it if the function isn't in a class, then why if it is in a class? [/QUOTE] LOLWUT? [ICODE]myThread[/ICODE] is a class, so naturally you should be specifying self... I don't really understand … |
Re: Explain what's wrong or else nobody can help you. [URL="http://docs.python.org/library/urllib.html#urllib.urlretrieve"]Here's the documentation[/URL] on urlretrieve. | |
Re: In that case you can simply open a csv file and read it like a text file. Additionally there is a csvreader module in python, but I find it's simpler to just open the file as text and do your own splitting/processing. And to get the user's input you'd use … | |
Re: In windows command line: [icode]start mailto:<email_addy>@<domain>[/icode] will open the default mail client and create a new message to <email_addy>@<domain>. So simply pop that into os.system or subprocess or whatever your method of choice is, and that will take care of a windows platform machine. I know there's something similar on … | |
Re: What version of python are you using? Did it work before and stop or just never work at all? Are any other built-in functions working? As a replacement you could use this: [code=python] def callable_(obj): if "__call()__" in dir(obj): return True else: return False [/code] That should provide the same … | |
Re: [QUOTE=Clueless86;934684]This is coming along nicely. Next to do is: Set HP for player based on Level. Set Cargo for ships to a max level. Make a Black Market for selling of illegal items. Make Quest Side Missions. Finally, Set the players level to an EP system for points between levels. … | |
Re: If you roll your own dialog box instead of using the standard offerings you can put anything you'd like on it... | |
Re: If the python program quits with an error the return code is 1. If it successfully runs the return code is 0. You can alternately specify your own return codes using sys.exit(return_code_value) at specific exit points of your code. | |
Re: evstevemd; are you aware of [URL="http://www.digsby.com"]Digsby[/URL]? Digsby is a multi-protocol messaging/email consolidation client. As far as I'm aware, the program is designed in Python and wxPython; however I know they have certain elements (like the login window) that are designed in C++ and SWIG wrapped (this was a recent change … | |
![]() | Re: The only problem here being that a free web hosting service most likely isn't going to allow you to upload python scripts to their servers. ![]() |
Re: [QUOTE=gsingh2011;926292]The only code I have are exact examples from online, and none of them work so it would much quicker to get a working version from someone rather than take the code from a random website.[/QUOTE] Here's a better approach: provide us the code that you tried on your system. … | |
Re: [QUOTE=bgk111;928752][CODE] print(command) cursor.execute(command) db.commit cursor.close() db.close()[/CODE][/QUOTE] Can you give us some example output from the [ICODE]print(command)[/ICODE] trace code? It could be as simple as a missing quote or an improper tablename. Also, where is tablename even coming from? I don't see it in your code anywhere. | |
Re: If you were using an older version of python and working in the wx GUI toolkit I would suggest using a simple dialog box and giving it the directive [icode]ShowModal()[/icode], which makes it the only window with focus. No other parent window can be accessed until the dialog box has … | |
![]() | Re: The equivalent device in python is slicing: [code=python] >>> my_text = 'Rajesh Kumar' >>> my_text[3:] 'esh Kumar' >>> my_text[1:2] 'a' >>> [/code] This example is analogous to the example on [URL="http://www.roseindia.net/java/beginners/SubstringExample.shtml"]this page[/URL], which gives example usage of Java substring. |
Re: [QUOTE=evstevemd;931198]what is the best way to go? XML or Pickle? or Anything else?[/QUOTE] Pickle. XML is way too much overhead for such a simple task. |
The End.