Forum: Python 22 Days Ago |
| Replies: 1 Views: 187 Read the last post of masterofpuppets to your other thread (http://www.daniweb.com/forums/thread235765.html) and you'll nearly have the answer...
Put his code in a function (pascrow), change the for... |
Forum: Python 24 Days Ago |
| Replies: 4 Views: 221 Oh yes, you've got another choice. Use your brain.
This assignment is fairly doable and, if you search this forum or others, you'll find plenty of ways to do it.
I'm afraid that your post shows... |
Forum: Python 24 Days Ago |
| Replies: 10 Views: 457 You can have a look at this to have an idea of web programming in python
http://webpython.codepoint.net/
and this
http://webpy.org/
I've never done web programming in python because norm in my... |
Forum: Python 34 Days Ago |
| Replies: 7 Views: 284 doing
x=Stuff
make of x an alias to the Stuff class.
Try this :
class Test:
def __init__(self):
self.a="a"
x=Test |
Forum: Python Oct 20th, 2009 |
| Replies: 4 Views: 205 you can use list comprehensions
g = "ThisIsATestt"
print [g[i:i+2] for i in range(0,len(g),2)] |
Forum: Python Oct 18th, 2009 |
| Replies: 8 Views: 292 I would add that exactly the same question was posted 2 days ago.
http://www.daniweb.com/forums/thread230626.html
It would be a good idea to search the forum before asking... |
Forum: Python Oct 17th, 2009 |
| Replies: 8 Views: 481 When I say end is excluded, i mean that :
for i in range(0, 10):
print i,
> 0 1 2 3 4 5 6 7 8 9
No 10 in the list.
range(0,10) = [ 0, 10 [ in the mathematical writing way
This means... |
Forum: Python Oct 16th, 2009 |
| Replies: 4 Views: 520 Totally agree with Gribouillis. This is not a good way of doing things. Many problems may occur.
You may use a dictionnary instead:
def myfunc(arg1, arg2):
d={'x':2, 'y':3, 'z':4}
... |
Forum: Python Oct 16th, 2009 |
| Replies: 8 Views: 481 My 2 cents...
1 - I prefer for loop than while ones when I can (less code to write and no infinite loops).
start = int(raw_input("Start at: "))
end = int(raw_input("End at: "))
count =... |
Forum: Python Oct 16th, 2009 |
| Replies: 13 Views: 365 As far as I know, this is some kind of standard behaviour.
Old languages [ troll] like C [ /troll] made difference between value and reference...
To have this behaviour in "non object" langage (in... |
Forum: Python Oct 16th, 2009 |
| Replies: 13 Views: 365 Sorry, I typed the wrong key... So...
Simply think that, when you assign a variable to another (say b=a), it is a reference assignment. If you change PART of b, you'll change a too. If you reassign... |
Forum: Python Oct 16th, 2009 |
| Replies: 13 Views: 365 I typed the wrong key...
So... Simply think that, when you assign a variable to another, it is a reference assignment. If you change PART of b, you'll change a too. But, if you reassign b, just... |
Forum: Python Oct 16th, 2009 |
| Replies: 13 Views: 365 This is what i meant.
Try this and think of what it means :
a=13
b=a
b=14
print a
a=[1,2,3]
b=a
b[1]=4 |
Forum: Python Oct 15th, 2009 |
| Replies: 9 Views: 484 Look at the buildin functions in the manual... you've got some parameters.
You just have to write :
print ('Enter quiz score %d: ' % i, end='') |
Forum: Python Oct 15th, 2009 |
| Replies: 3 Views: 197 Beware of the '\'. You should write
textfile = file('C:\\HourlyATC\\ATC101509\\10-15-09 to 10-21-09 ATC.txt','w') # \\ and 'w' |
Forum: Python Oct 15th, 2009 |
| Replies: 13 Views: 365 It points to the original variable.
This is true for all variables containing objects.
For a list, if you want to duplicate it, you have to do
mylist = [1,2,3,4]
a = mylist[:]
a[0]... |
Forum: Python Oct 15th, 2009 |
| Replies: 9 Views: 484 numQuiz = input("Enter the number of quizzes: ")
total = 0
for i in range(numQuiz):
print ('Enter quiz score %d: ' % i) #
# OR
print ('Enter quiz score ', str(i), ' : ')
... |
Forum: Python Oct 14th, 2009 |
| Replies: 12 Views: 541 You should run your program with pythonw.
This can be done in your command line or by renaming your .py file .pyw |
Forum: Python Oct 14th, 2009 |
| Replies: 7 Views: 318 __repr__ is not required as you are only sorting your objects.
I put it here just to introduce this way of printing objects.
If you have a complex object with some interesting fields to display,... |
Forum: Python Oct 12th, 2009 |
| Replies: 3 Views: 231 "Error connecting to MySQL..." is not the error you have, it is the error you defined, in your try - except block, hiding the mysql error message. So, to know what error you exactly have, you should... |
Forum: Python Oct 11th, 2009 |
| Replies: 7 Views: 294 Sorry but I don't understand what you mean.
What do you mean with "each POS variable is in a certain place" ?
If I use one variable, it contains the tenth values.
Instead of using POS1, you'll... |
Forum: Python Oct 11th, 2009 |
| Replies: 3 Views: 231 The question is : what error do you have ? |
Forum: Python Oct 11th, 2009 |
| Replies: 7 Views: 294 Why do you want to have vars named POSn.
I wouldn't do that...
Very complicated. It's far easier to have one list variable where you assign pos[n]
pos=[' ' for i in range(10)] # defines a list... |
Forum: Python Oct 11th, 2009 |
| Replies: 4 Views: 281 Sorry, I answered too fast :
zipFile.write(filedir+'/'+pathname, zipFile, compress_type=None)
zip is not defined in your program, so it refers to the builtdin function which has... |
Forum: Python Oct 10th, 2009 |
| Replies: 7 Views: 314 Maybe you're right... I didn't look at that very much but you have some
while True:
...
while True:
...
That i don't like very much... But in this case, i maybe wrong.... |
Forum: Python Oct 9th, 2009 |
| Replies: 7 Views: 314 I don't have time to test extensively your code but i'd begin by looking at loops.
I've seen a couple of while True...
How long do you stay in these loops ?
You should test and locate precisely... |
Forum: Python Oct 9th, 2009 |
| Replies: 4 Views: 281 I don't think so : zip.write waits for a file NAME and you pass a file OBJECT.
I think this may be done by using the second argument of zip.write :
zip.write(filename, arcname=None,... |
Forum: Python Oct 9th, 2009 |
| Replies: 5 Views: 228 But one quick point is that if the letter is not standard, weight is tested but not yet defined (this is the translation of your error message)
Why do you test the size to allow the input of the... |
Forum: Python Oct 9th, 2009 |
| Replies: 5 Views: 228 So please, go on, repost your code with appropriate tags around it |
Forum: Python Oct 9th, 2009 |
| Replies: 3 Views: 216 a fourth :
import re
st = "abcd123"
rdigit=re.compile("\d")
print rdigit.findall(st)
Which can be onelined :
import re |
Forum: Python Oct 8th, 2009 |
| Replies: 2 Views: 255 outfile = 'OUTPUT'
output = open(outfile, 'w')
for line in open('DATA'): # You don't need to open the file and load it in a list (bad for memory)
linelist = line.strip().split() # Strip will... |
Forum: Python Oct 8th, 2009 |
| Replies: 2 Views: 235 I think this one is better...
import re
testStrings=[ "POST at the start without the other word", "GET at the start without the other word", "GET first\nthen POST and more", "POST first\nthen GET... |
Forum: Python Oct 8th, 2009 |
| Replies: 1 Views: 196 [ ] is generaly used for indexing (see the list, tuple or dictionary chapters in the doc).
mylist=[ 1,2,3,4,5,6]
print mylist[ 3]
> 4
If you see strings like some kind of char tuple... |
Forum: Python Oct 7th, 2009 |
| Replies: 13 Views: 485 Here :
if "FCITC" in line:
noline+=1
The idea is to say :
when i see a line with FCITC in it, i increase the number (i named it noline but it may not be the best name... You can... |
Forum: Python Oct 6th, 2009 |
| Replies: 13 Views: 485 Are the fields separated with tabs, are their length fixed
I'd say fixed length
First (FCITC) is before 9th character
Limiting constraint is from 29th to 79 th
Contingency description is from... |
Forum: Python Oct 6th, 2009 |
| Replies: 13 Views: 485 My question is :
How do you recognise the elements you want to keep :
Why is this in red and black
#
FCITC TDF LODF <--------- Limiting constraint ---------> <--------- Contingency description... |
Forum: Python Oct 6th, 2009 |
| Replies: 5 Views: 436 Your "row" is inside the sql statement as a string !
You can do
c.execute("INSERT INTO a (first, last) VALUES (%s, %s)" % row) |
Forum: Python Oct 6th, 2009 |
| Replies: 13 Views: 485 I can't copy the text to test...
Is this to be a html file ? Are the <br /> tags or are they supposed to show CR.
Your BBCodes don't work...
How can you select one line if all your file seems to... |
Forum: Python Oct 6th, 2009 |
| Replies: 4 Views: 291 Have you tried to call
EffectIllusion.illusionRace.get()
I don't know what StringCol is and how you should use it but it certainly provides something like get() or getValue()... |
Forum: Python Oct 5th, 2009 |
| Replies: 4 Views: 291 First of all, rewrite your code with correct indent.
This is very significant in python and your code is very strangely indented (i'm surprised this works...)
class effectIllusion shouldn't be... |