Wheres the code?
Are you using the 'EVT_DATE_CHANGED' to catch the date?
Cheers and Happy coding
Wheres the code?
Are you using the 'EVT_DATE_CHANGED' to catch the date?
Cheers and Happy coding
I never said to compare it with if..elif..else.
Cheers and Happy coding
list1 = []
for y in range(50):
for x in range(50):
list1.append((x, y))
print list1
Cheers and Happy coding
I think it's easy as making a case and a for loop and testing them.
Cheers and Happy coding
Like:
os.system('program.exe | argument')
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
???
A guess... :)
class foobar():
def __init__(self, foo, bar): # constructor
self.foo = foo
self.bar = bar
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
I would do like this for your example, it shows the 'mean' when you just press enter with no input.
def getlist():
lst = []
x = None
while x != '':
x = raw_input('Your number:')
if x:
lst.append(int(x))
return lst
def mean(l):
return float(sum(l))/len(l)
a = mean(getlist())
print a
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
You can run the listening function on an asynchronized thread.
from functools import wraps
from threading import Thread
def async(func):
@wraps(func)
def async_func(*args, **kwargs):
func_handler = Thread(target=func, args=args, kwargs=kwargs)
func_handler.start()
return func_handler
return async_func
@async
def listener():
print "Initializing Listener..."
Listener.Listen(server_ip, int(server_port))
os.system("cls")
print "Server IP: %s" % server_ip + ":" + server_port
print "Level Name: %s" % level_name
print "Public IP: %s" % public_ip
print "-------------------------------------------"
os.system("pause")
Cheers and Happy coding
I guess you must go for 16 bits for the mixed mode and use Unicode.
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.
Wheres the checksum?
Cheers and Happy coding
EDIT:
How about this?
data = '\x02' + '1T025.0F00R1000000000000000' + '\x8B' + '\x03'
See the snippet that vegaseat told.
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
A hint that makes a huge difference in another project was doing like this.
...
diff = ImageChops.difference(im1,im2)
n = diff.load()
GRAY = (25, 25, 25)
RED = (255,0,0)
BLACK = (0,0,0)
for x in range(0, res[0], 2): #every other pixel for speed
for y in range(0, res[1], 2):
if n[x,y] > GRAY:
n[x,y] = RED
else:
n[x,y] = BLACK
...
I know it doesn't look that better, and in my case and more variables, but it helped, you can try it.
Cheers and Happy coding
I would like to help, but I'm not understanding now mate.
Cheers and Happy coding
Happy coding mate.
Case solved. You can close the thread.
Can't you separate it by channels (RGB) and treat the data on those channels.
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')