Like this?
for item in fenceLines:
print item
or
for i in range(len(fenceLines)):
print fenceLines[i]
Cheers and Happy coding
Like this?
for item in fenceLines:
print item
or
for i in range(len(fenceLines)):
print fenceLines[i]
Cheers and Happy coding
An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.
Cheers and Happy coding
It depends a lot of the application, and all of that.
But maybe a simple http server or json server in a peer to peer configuration should serve the task pretty good.
I''ve never tried xmlrpc servers, since I never felt the need to.
Cheers and Happy coding
relevant_weeks = [['[11', " '05/10/2009'", " '06/10/2009'", " '07/10/2009'", " '08/10/2009'", " '09/10/2009']", ''],
['[10', " '28/09/2009'", " '29/09/2009'", " '30/09/2009'", " '01/10/2009'", " '02/10/2009']", ''],
['[27', " '25/01/2010'", " '26/01/2010'", " '27/01/2010'", " '28/01/2010'", " '29/01/2010']", '']]
relevant_days = ['TUES', 'TUES', 'THURS', 'WED', 'THURS', 'MON', 'WED', 'THURS', 'WED', 'TUES', 'MON', 'WED', 'MON', 'WED', 'THURS', 'FRI', 'THURS']
days_reference = [['0', ' MON', ' TUES', ' WED', ' THURS', ' FRI']]
days_reference = [item.strip() for item in days_reference[0]] # cleaning the list
for i in range(len(relevant_weeks)):
print relevant_weeks[i][days_reference.index(relevant_days[i])]
Cheers and Happy coding
Seems fun but I don't understand.
Can you explain?
Cheers and Happy coding
else:
infos = [item for item in fields[i] if item]
f_out.write('%s,%s,%s\n' % (pre, infos[0], infos[1]))
This is for lines like: ,,,"bonapartei","Highland Tinamou"
it extracts the two fields and writes them together with the prefix, that is get by lines like: ,,"Tinamus",,
Cheers and Happy coding
Like this mate:
list1 = ['a', 'b', 'c']
for i in range(len(list1)):
open('file%s.txt' % i, 'w').write(list1[i])
Cheers and Happy coding
import re
data = 'LUBS5200M01/SMR 1/02<S1> wks 2-11,"((10 11 12 13 14 15 16 17 18 19) (34))",2'
data = data.split(',')[1]
match = re.findall(r'\(\d+\)', data)
print match[0][1:-1]
Cheers and Happy coding
That means that you have a typo, or your reference list is somenthing like:
reference_list = '1, 2, 3, 4'
and for that:
reference_list = [int(item.strip()) for item in reference_list.split(',')]
Cheers and Happy coding
f_in = open('mixorder.csv')
fields = []
for line in f_in.readlines():
fields.append([item.strip('\n') for item in line.split(',')])
f_in.close()
f_out = open('order.csv', 'w')
for i in range(len(fields)):
if fields[i][0] != '':
f_out.write('ORDRE ' + fields[i][0] + ',,\n')
elif fields[i][1] != '':
f_out.write('Family ' + fields[i][1] + ',,\n')
elif fields[i][2] != '':
pre = fields[i][2]
else:
infos = [item for item in fields[i] if item]
f_out.write('%s,%s,%s\n' % (pre, infos[0], infos[1]))
f_out.close()
Cheers and Happy coding
EDIT: I didn't saw your posted solution tonyjv.
Hint:
list1 = [4, 3, 1, 3, 2, 1]
list2 = [[0, '0800', 'MON'],
[1, '0830', 'MON'],
[2, '0900', 'MON'],
[3, '0930', 'MON'],
[4, '1000', 'MON']]
for i in range(len(list1)):
for item in list2:
if item[0] == list1[i]:
print item
Cheers and Happy coding
The error message you receive helps who is trying to help you. Try to post it next time.
But, since your error is easy, here it goes:
def lvl():
x = random.randint(100,1000)
tfile = open("text.txt", 'w')
tfile.write(str(x))
input("")
Cheers and Happy coding.
Whats your line 6?
And shouldn't you have
lstn.recv(1)
Cheers and Happy coding
One hint.
import time
date = 19980224
print time.strptime(date, '%Y%m%d')
date = 19982402
print time.strptime(date, '%Y%m%d')
Cheers and Happy coding
??? Something is wrong here.
Can you show code to what you do?
You can't receive or send data through a socket if you properly closed it.
Cheers and Happy coding
Going from the root as as folder python,
python\Objects\intobject.c
Cheers and Happy coding
Like this?
f_in = open('ids.txt')
for line in f_in.readlines():
print line
pos = 0
for run in range(line.count('ID=')):
pos = line.index('ID=', pos) + 3
print line[pos:pos + 4]
Cheers and Happy coding
Some code to see what you have done so far so we can guide you?
Cheers and Happy coding.
Why not?
top10 = [
[[u'abcde', u'fghij'], [1]],
[[u'abcde', u'fghij'], [2]],
[[u'abcde', u'fghij'], [3]],
[[u'abcde', u'fghij'], [4]],
[[u'abcde', u'fghij'], [5]]]
top10 = [[[str(a), str(b)], x] for [a, b], x in top10]
for item in top10:
print item
Output:
[['abcde', 'fghij'], [1]]
[['abcde', 'fghij'], [2]]
[['abcde', 'fghij'], [3]]
[['abcde', 'fghij'], [4]]
[['abcde', 'fghij'], [5]]
Cheers and Happy coding
I did nothing to the code mate, I just showed you a part of your code where within 5 lines you call two different things to the 'same' variable.
Cheers and Happy coding
Has nothing to do with putting 'self.' on front of everything, but at least being coinsistent on the variables. Look here:
def onAction(self, event):
disc_value = self.discountinput.GetValue().strip()
if all(x in "0123456789.+-" for x in disc_value):
value = round(float(disc_value), 2)
else:
discountinput.ChangeValue("number only")
Is it discountinput, or the discountinput from the class (self.discountinput)?
When you declare a class yes define attributes to the class by wirting them as 'self.'.
If you don't declare them as attributes you may not call them as attributes.
Cheers and Happy coding
Happy coding mate.
Case solved. You can close the thread.
Change also your line 21 mate.
Cheers and Happy coding.
You must use
self.cursor = db.cursor()
Then the LoginDld will have the cursor attribute, replace on all cursor declarations on the logiDlg and try again.
Cheers and Happy coding
You can declare the cursor as:
self.cursor = db.cursor()
and call it as:
login = LoginDlg()
login.cursor.execute('sql statement')
The connection is available till you do a db.close() I believe, but I never used MySQL.
Post some code, it should be easy to try to correct.
Cheers and Happy coding
A example:
print item.lower()
Cheers and Happy coding
Why the use of break or continue for the purpose??
Cheers and Happy coding
This simple solution will work for all files on the current dir.
import os
filelist = os.listdir('')
for files in filelist:
basename, ext = os.path.splitext(files)
if ext == '.kml':
f_output = open('%s-errors.txt' % basename, 'w')
f_output.write('whatever you want')
f_output.close()
Cheers and Happy coding
And how are you implementing it?
Doesn't this work?
from login import LoginDlg
I think that definatelly it's a bad version installed.
Try to redownload and install the proper ones.
Cheers and Happy coding
You must understand the question and logics first.
And as lrh9 said, and very good, you declare classes and define their functions.
class rectangle():
def __init__(self, coords, sizex, sizey):
self._startx, self._starty = coords
self._sizex = sizex
self._sizey = sizey
def getBottomright(self):
print '(%s, %s)' % (self._startx + self._sizex, self._starty + self._sizey)
def move(self, pos):
self._startx, self._starty = pos
def resize(self, width, height):
self._sizex = width
self._sizey = height
def __str__(self):
return '((%s, %s), (%s, %s))' % (self._startx, self._starty, self._startx + self._sizex, self._starty + self._sizey)
r = rectangle((2, 3), 5, 6)
print str(r)
"""'((2, 3), (7, 9))'"""
r.move((5, 5))
print str(r)
"""'((5, 5), (10, 11))'"""
r.resize(1,1)
print str(r)
"""'((5, 5), (6, 6))'"""
r.getBottomright()
"""(6, 6)"""
Cheers and Happy coding.
Some code and a clear explanation of the problem you have would help.
Cheers and Happy coding
Mate, I believe that all you need to do, it's to use my example of timer, and use it to call the function to voice, instead of the threading being the voice function, the thread will calll the object voice after that time.
Hope is clear enough.
Cheers and Happy coding.
It was a tip as I said, and you can read the lines individually as he does now.
And your code still uses my 60 GB+ RAM stick. :)
A tip:
for line in in_file.readlines():
Cheers and Happy coding
It's a typo. Your missing a d here.
elif option == 2:
remove[B]d[/B]Expence = removeExpence(totalBudget)
totalBudget = totalBudget + removedExpence
printOptions()
option = input("What would you like to do? ")
The 'blit' loads a image object to the window surface.
In your example 'blit' loads the 'background' image to the window starting at cordinates 0 in x and 0 in y.
screen.blit(background, (0, 0))
The second 'blit' loads the 'sprite' image to the screen, with a fixed cordinate of 100 in 'y', and uses a variable 'x' to define the cordinate on x, that is incremented by 10 every cycle.
screen.blit(sprite, (x, 100))
x += 10
Hope it helps,
Cheers and Happy coding
If i understood correctly:
initial_date = '9/14/1990'
initial_month, initial_day, initial_year = initial_date.split('/')
final_date = '9/17/1990'
final_month, final_day, final_year = final_date.split('/')
f_in = open('stations_temp.csv').readlines()
f_out = open('filtered_stations_temp.csv', 'w')
f_out.write(f_in[0])
for i in range(1, len(f_in)):
station, date, max_temp, min_temp = f_in[i].split(',')
month, day, year = date.split('/')
if initial_month <= month <= final_month and \
initial_day <= day <= final_day and \
initial_year <= year <= final_year:
f_out.write(f_in[i])
f_out.close()
Cheers and Happy coding
I don't get the previous link.
May you take a look here, fell free to ask, or PM with sugestions.
Texts K-Nearest Neighbor (KNN) using the Euclidean algorithm
Something like this.
name = []
ordertotal = []
for i in range(loopController):
name.append(raw_input("Who's order"))
order = input("How much was the order")
ordertotal.append(order + shippingCharge)
for i in range(loopController):
print name[i], ordertotal[i]
Hope it helps.
def voice(x):
print x
v = threading.Timer(50, voice)
v.start()
Cheers and Happy codings
Create function to voice users and run the function using the timer, instead of passing commands to the timer function.
I don't know if it is this function but this should work.
from scipy.special import kv
Happy coding
It works with your file again. :)
f_in = open('blocks.txt').read()
f_out = open('output.csv', 'w')
f_out.write('AC\tID\tFA\tOS\tSF\tBS\tGE\n')
blocks = [x for x in f_in.split('//') if x]
for item in blocks:
infos = [x for x in item.split('\n') if x and x != 'XX']
AC = ''
ID = ''
FA = ''
OS = ''
SF = ''
BS = ''
GE = ''
for field in infos:
if field.startswith('AC'):
AC += ' ' + field[3:]
elif field.startswith('ID'):
ID += ' ' + field[3:]
elif field.startswith('FA'):
FA += ' ' + field[3:]
elif field.startswith('OS'):
OS += ' ' + field[3:]
elif field.startswith('SF'):
SF += ' ' + field[3:]
elif field.startswith('BS'):
BS += ' ' + field[3:]
elif field.startswith('GE'):
GE += ' ' + field[3:]
f_out.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % (AC, ID, FA, OS, SF, BS, GE))
f_out.close()
Cheers and Happy coding
Your welcome.
You can mark as solved,
Cheers and Happy coding