761 Posted Topics

Member Avatar for Lingson

[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]

Member Avatar for Lingson
0
143
Member Avatar for Stefano Mtangoo

[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].

Member Avatar for Stefano Mtangoo
0
3K
Member Avatar for Stefano Mtangoo

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

Member Avatar for Stefano Mtangoo
0
152
Member Avatar for Missy_poo

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.

Member Avatar for Stefano Mtangoo
0
104
Member Avatar for blah32

[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] …

Member Avatar for jlm699
0
90
Member Avatar for smoore

[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', …

Member Avatar for jlm699
0
149
Member Avatar for Furtano

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.

Member Avatar for leegao
0
1K
Member Avatar for SuperMetroid

You'll need to actually write to your file handle [icode]txtfile[/icode] by using [icode]txtfile.write( text )[/icode].

Member Avatar for SuperMetroid
0
157
Member Avatar for Aiban

[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 …

Member Avatar for shadwickman
0
256
Member Avatar for SuperMetroid

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.

Member Avatar for SuperMetroid
0
377
Member Avatar for fleem

[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]

Member Avatar for vegaseat
0
129
Member Avatar for Zebibyte

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' >>> …

Member Avatar for Zebibyte
0
110
Member Avatar for znice

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.

Member Avatar for znice
0
118
Member Avatar for Zetlin

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 += …

Member Avatar for Zetlin
0
126
Member Avatar for willygstyle

[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 …

Member Avatar for willygstyle
0
129
Member Avatar for smoore

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. …

Member Avatar for smoore
0
244
Member Avatar for penguin22

1. What is the "vs solution" ? 2. How are you performing your "build and clean" ? 3. What isn't creating the .exe ?

Member Avatar for jlm699
0
144
Member Avatar for funfullson

[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 …

Member Avatar for funfullson
0
142
Member Avatar for leanne86

[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 ?

Member Avatar for jlm699
0
192
Member Avatar for denniskhor

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

Member Avatar for jlm699
0
124
Member Avatar for Dixtosa

[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 …

Member Avatar for leegao
0
85
Member Avatar for shaun.b

[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 …

Member Avatar for woooee
0
449
Member Avatar for ms_kichu

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 …

Member Avatar for woooee
0
115
Member Avatar for LW00

[QUOTE=LW00;940118]'os.system(pathToBatFile)' [/QUOTE] Is your pathToBatFile an absolute or relative path?

Member Avatar for LW00
0
112
Member Avatar for tdeck

I believe [icode]sys.stdout.flush()[/icode] is what you're looking for. Those stdio handles are just like open file handles

Member Avatar for jlm699
0
151
Member Avatar for mishra59
Re: Hi

What implementation of sql? There are different modules to use depending on whether it's postgresql, mysql, etc...

Member Avatar for zachabesh
0
66
Member Avatar for penguin22

Use [icode]os.system("RD /s folderName")[/icode] or subprocess.Popen depending on your python install

Member Avatar for jlm699
0
112
Member Avatar for SuperMetroid

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 …

Member Avatar for fallopiano
0
1K
Member Avatar for tdeck

sys.stdin is an "always open" file handle to the stdin and likewise sys.stdout. To use them, import sys.

Member Avatar for jlm699
0
107
Member Avatar for you2

[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 …

Member Avatar for you2
0
191
Member Avatar for dieg0s

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].

Member Avatar for jlm699
0
7K
Member Avatar for penguin22

Use tortoise's [URL="http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/apc.html"]command line stuff[/URL]

Member Avatar for jlm699
0
48
Member Avatar for penguin22

[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, …

Member Avatar for JasonHippy
0
141
Member Avatar for southafrica1

py2exe.org is where you should be looking. I'm sure they'd love the help if you're willing to volunteer.

Member Avatar for southafrica1
0
175
Member Avatar for penguin22

[QUOTE=penguin22;935602]When i try to build a visual studio solution it does not want to build[/QUOTE] Why not?

Member Avatar for penguin22
0
158
Member Avatar for sravan953

[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 …

Member Avatar for Stefano Mtangoo
0
225
Member Avatar for Dixtosa

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.

Member Avatar for Dixtosa
0
156
Member Avatar for catcit

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 …

Member Avatar for sab786
0
121
Member Avatar for Aiban

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 …

Member Avatar for Aiban
0
139
Member Avatar for StMark

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 …

Member Avatar for StMark
0
214
Member Avatar for Clueless86

[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. …

Member Avatar for jlm699
0
414
Member Avatar for jcmeyer

If you roll your own dialog box instead of using the standard offerings you can put anything you'd like on it...

Member Avatar for jcmeyer
0
102
Member Avatar for sab73

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.

Member Avatar for sab73
0
107
Member Avatar for Stefano Mtangoo

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 …

Member Avatar for Stefano Mtangoo
0
110
Member Avatar for sravan953

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.

Member Avatar for sravan953
0
243
Member Avatar for gsingh2011

[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. …

Member Avatar for zachabesh
0
1K
Member Avatar for bgk111

[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.

Member Avatar for bgk111
0
144
Member Avatar for Aiban

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 …

Member Avatar for snippsat
0
108
Member Avatar for sravan953

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.

Member Avatar for jlm699
0
330
Member Avatar for Stefano Mtangoo

[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.

Member Avatar for Stefano Mtangoo
0
87

The End.