would be a better way to do this? (aside from checking arg
values and types, I know...)
Ran OK for me, python 2.4.1 on Windows 7
Iain
--
http://mail.python.org/mailman/listinfo/python-list
A common one used to be expecting .sort() to return, rather than mutate (as it
does). Same with .reverse() - sorted and reversed have this covered, not sure
how common a gotcha it is any more.
Iain
On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka wrote:
Greetings,
I'm going
On May 25, 2:44 pm, ad adsquai...@gmail.com wrote:
On May 25, 4:06 am, Ulrich Eckhardt ulrich.eckha...@dominolaser.com
wrote:
ad wrote:
Please review the code pasted below. I am wondering what other ways
there are of performing the same tasks.
On a unix system, you would call find
.
Chris Angelico
I did not know this. Very useful!
Iain
--
http://mail.python.org/mailman/listinfo/python-list
New submission from Iain Henderson the_i...@mac.com:
The documentation here: http://docs.python.org/library/stdtypes.html
indicates that and operates as such
{if x:
return x
else:
return y}
to be a logical conjugation it should function as
{if x:
if y:
return True
return
:
dostuff()
i.e. check columns is not empty and then check if the last item
startswith 's'.
(a) I don't know if the order of resolution is predicated left-to-
right in the language spec of if it's an implementation detail
(b) columns[-1].startswith('s') would be better
Iain
--
http://mail.python.org
On Oct 28, 2:35 pm, Iain King iaink...@gmail.com wrote:
...
(a) I don't know if the order of resolution is predicated left-to-
right in the language spec of if it's an implementation detail
(b) columns[-1].startswith('s') would be better
...
Ignore (b), I didn't read the original message
On Apr 29, 10:38 am, Daniel Fetchinson fetchin...@googlemail.com
wrote:
| Any idea how I can replace words in a html file? Meaning only the
| content will get replace while the html tags, javascript, css are
| remain untouch.
|
| I'm not sure what you tried and what you haven't but
string (smallest
Levenshtein distance?).
Iain
--
http://mail.python.org/mailman/listinfo/python-list
),
('attr4', 4)):
class1.__setattr__(attr, value)
and to get a bit crunchy, with this your specific example can be
written:
for i in xrange(1, 5):
class1.__setattr__('attr%d' % i, i)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
()) is type(list()). Or, to
let the interpreter tell you why (1,2,3) [1,2,3]:
tuple list
True
Iain
--
http://mail.python.org/mailman/listinfo/python-list
. For
example:
if foo in ('some', 'random', 'strings'):
draw.text((10,30), WHICH IS WHITE, font=font)
draw.line([(70,25), (85,25), (105,45)])
I've no idea what the performance difference is; I've always assumed
it's negligible.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
+= direction.vy
Iain
--
http://mail.python.org/mailman/listinfo/python-list
or fobarbazyyyquuux?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On 21 Jan 2010, at 00:11, Gabriel Genellina wrote:
En Wed, 20 Jan 2010 19:45:44 -0300, Iain Barnett iainsp...@gmail.com
escribió:
Would anyone know if it's possible to install psycopg2-2.0.13 with
python3.1.1 (or similar)?I can install it with python2.6 with no problems,
but obviously
:
^
SyntaxError: invalid syntax
I can install it with python2.6 with no problems, but obviously I'd prefer to
use the latest version. My system is OSX10.6, and I'm new to Python.
Any help is much appreciated.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
)
else:
output.append(subs[tokens[piece]])
return ''.join(output)
token_replace(fooxxxbazyyyquuux, [(quuux, foo), (foo, bar),
(baz, quux)])
'barxxxquuxyyyfoo'
I'm sure someone could whittle that down to a handful of list comps...
Iain
--
http
On Jan 18, 12:41 pm, Iain King iaink...@gmail.com wrote:
On Jan 18, 10:21 am, superpollo ute...@esempio.net wrote:
superpollo ha scritto:
hi.
what is the most pythonic way to substitute substrings?
eg: i want to apply:
foo -- bar
baz -- quux
quuux -- foo
so
= fooxxxbazyyyquuux
re.subn(pattern, repl, s)
Winner! :)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 18, 4:26 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
On Mon, 18 Jan 2010 06:23:44 -0800, Iain King wrote:
On Jan 18, 2:17 pm, Adi Eyal a...@digitaltrowel.com wrote:
[...]
Using regular expressions the answer is short (and sweet)
mapping = {
foo : bar
break
return ishex
---cut---
Can someone help me get further along please?
Thanks.
better would be:
def ishex(s):
for c in s:
if c not in string.hexdigits:
return False
return True
Iain
--
http://mail.python.org/mailman/listinfo/python-list
', 'a', 'list', 'containing', 'the', 'resulting',
'substrings.\n']
Iain
--
http://mail.python.org/mailman/listinfo/python-list
else:
d[key] = value
or
try:
d[key] += value
except KeyError:
d[key] = value
I find both to be easily readable (and the similarity between the two
blocks is obvious and, to me at least, pleasing).
Iain
--
http://mail.python.org/mailman/listinfo/python-list
construct a plausible situation where it wouldn't be that
bad...
Anyway, I'm ambivalently on the fence.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
.
You're not just yanking the OP's chain???
That would be cruel. I mean the guy has enough problems already...
Sorry, there is no 'twice' builtin. I think what you are looking for
is:
def twice(n):
return return n
Iain
--
http://mail.python.org/mailman/listinfo/python-list
Hi All,
I'm writing a system tray application for windows, and the app needs
to poll a remote site at a pre-defined interval, and then process any
data returned.
The GUI needs to remain responsive as this goes on, so the polling
needs to be done in the background. I've been looking into Twisted
print nucleotides, seq[-76]
last_part = line.rstrip()[-76 : ]
You all mean: seq[:-76] , right? (assuming you've already stripped
any junk off the end of the string)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 6, 11:34 am, MRAB pyt...@mrabarnett.plus.com wrote:
Iain King wrote:
print nucleotides, seq[-76]
last_part = line.rstrip()[-76 : ]
You all mean: seq[:-76] , right? (assuming you've already stripped
any junk off the end of the string)
The OP said cut out the last
itself, or the output of factory_function?
Not only that - does 'return inner' return the function inner or the
result of function inner?
How does ruby pass a function as an object?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
what you can't have, can you?
[Holds breath while awaiting counter-example... :]
~Ethan~
The convention being detailed in PEP8: http://www.python.org/dev/peps/pep-0008/
basically, anything in ALL_CAPS is a constant, assuming you follow
those style guidelines.
Iain
--
http://mail.python.org
Iain Wade iw...@optusnet.com.au added the comment:
d'oh, I should have checked HEAD before submitting the bug.
I am running 2.5.1 on OSX, the fix seems to be in 2.5.2 and above.
Thanks, and sorry for wasting your time.
--
status: open - closed
New submission from Iain Wade iw...@optusnet.com.au:
Test vectors are in the following draft rfc:
http://tools.ietf.org/html/draft-nystrom-smime-hmac-sha
The problem is that hmac.py has a hard-coded block size of 64, while
SHA-384 and SHA-512 have a 128-byte block size.
Suggested fix
(assuming you've imported os):
print len(os.path.splitext(x)[0])
Iain
--
http://mail.python.org/mailman/listinfo/python-list
but not efficient. Better:
s = .join((x for x in s.split( ) if x))
Note that this will strip leading and trailing spaces.
Or you can use regexps:
import re
s = re.sub( {2,}, , s)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
and stop iteration when it's done, and rename it to par to keep
the OP happy and you should get something like what he initially
requests (I think):
total = 0
for score in par(f, data):
total += score
Iain
--
http://mail.python.org/mailman/listinfo/python-list
, but I'd read the whole
thing if you can.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 7, 1:44 pm, Tim Chase python.l...@tim.thechases.com wrote:
f = urllib.urlopen(http://www.google.com;)
s = f.read()
It is working, but it's returning the source of the page. Is there anyway I
can get almost a screen capture of the page?
This is the job of a browser -- to render
following pieces of code?
a = lambda x: x+2
def a(x):
return x+2
Iain
--
http://mail.python.org/mailman/listinfo/python-list
log, but I
couldn't find the answer to something: has any change been made to
how tabs and spaces are used as indentation? Can they still be
(inadvisably) mixed in one file? Or, more extremely, has one or the
other been abolished?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 3, 10:16 am, [EMAIL PROTECTED] wrote:
On Dec 3, 12:53 am, Bryan Olson [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
This message is not about the meaningless computer printout called
More importantly, it's not about Python. I'm setting follow-ups to
talk.politics.
] = []
array[x1].append(Hi)
array[x2]
['Hi']
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 25, 11:29 am, Iain King [EMAIL PROTECTED] wrote:
On Nov 17, 7:41 pm, Tim Chase [EMAIL PROTECTED] wrote:
It doesn't matter as none of this is valid Python. In Python you have to
write
array[x1] = False
array[x2] = False
Uh...not so much...
a = [1,2,3,4,5]
x1
://msdn.microsoft.com/en-us/library/ms526130(EXCHG.10).aspx
Looks like you want TimeLastModified
Iain
--
http://mail.python.org/mailman/listinfo/python-list
Perhaps the parent should open the pipe for reading, before calling
TroublesomeFunction. If the parent then dies, the child will get a broken
pipe signal, which by default should kill it.
Yeah, that seems to work well, I think. Thanks for the help! I also
realised the child process was
On Nov 8, 10:00 am, Iain [EMAIL PROTECTED] wrote:
On Nov 7, 4:42 pm, Lawrence D'Oliveiro [EMAIL PROTECTED]
central.gen.new_zealand wrote:
In message
[EMAIL PROTECTED], Iain
wrote:
Can someone give me some pointers as to how I might create some sort
of blocking device file or named
On Nov 7, 4:42 pm, Lawrence D'Oliveiro [EMAIL PROTECTED]
central.gen.new_zealand wrote:
In message
[EMAIL PROTECTED], Iain
wrote:
Can someone give me some pointers as to how I might create some sort
of blocking device file or named pipe ...
mkfifo /path/to/named/pipe
Thanks.
I did
thing, but I think I'm getting caught by
its blocking behaviour on open so as soon as I try to open the named
pipe (whether for reading or writing) my script just hangs.
Any help would be appreciated.
Cheers
Iain
--
http://mail.python.org/mailman/listinfo/python-list
In Emacs, using run-python,
import urllib
urllib.urlopen('http://www.google.com/')
results in this traceback:
Traceback (most recent call last):
File stdin, line 1, in module
File /usr/lib/python2.5/urllib.py, line 82, in urlopen
return opener.open(url)
Iain MacKay [EMAIL PROTECTED] added the comment:
Knowing that the large read provokes the problem enables one to write
this simple workaround by subclassing IMAP4 without patching the library:
maxRead = 100
class MySSL (imaplib.IMAP4_SSL):
def read (self, n):
#print ..Attempting
On Aug 27, 2:40 pm, ssecorp [EMAIL PROTECTED] wrote:
dict.update({a:1}) SETS the dict item a 's value to 1.
i want to increase it by 1. isnt that possible in an easy way? I
should use a tuple for this?
dict[a] += 1
Iain
--
http://mail.python.org/mailman/listinfo/python-list
, and the consumer exit before the producer makes
item 2.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
= wx.BoxSizer(wx.VERTICAL)
sz.Add(grid, 0, wx.ALL|wx.EXPAND, 5)
panel.SetSizer(sz)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
of Programming:
Any sufficiently complicated C or Fortran program contains an ad-hoc,
informally-specified bug-ridden slow implementation of half of Common
Lisp.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
the situation just doesn't work?
Just checking...
Iain
--
http://mail.python.org/mailman/listinfo/python-list
it into the language get smaller every time you
fire up your keyboard. Nice work.
Iain
p.s. am looking forward to your post whining about the invalid reasons
your PEP got rejected, in the slim hope you actually write one.
--
http://mail.python.org/mailman/listinfo/python-list
:
new_off_list.append(x)
off_list = new_off_list
generation += 1
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 25, 1:46 pm, Iain King [EMAIL PROTECTED] wrote:
On Jul 25, 10:57 am, Suresh Pillai [EMAIL PROTECTED] wrote:
I am performing simulations on networks (graphs). I have a question on
speed of execution (assuming very ample memory for now). I simplify the
details of my simulation
at the 'for') as a second loop, with the
goes_on function now returning a value based on the calculation
(rather than the calculation itself as I had it). Performance should
be similar.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
of times you have to loop over the
list increases. (1) always loops over the full list, but with each
successive iteration (2) and (3) are looping over smaller and smaller
lists. In the end this adds up, with (1) becoming slower than (2),
even though it starts out quicker.
Iain
--
http
/mel.html
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 19, 8:56 am, Stefan Behnel [EMAIL PROTECTED] wrote:
Iain King wrote:
Well, if you're looking for a list of excellent 3rd party Python
libraries, then I can give you the ones I like and use a lot:
[...]
BeautifulSoup : for real-world (i.e. not-at-all-recommendation-
compliant) HTML
the ones I like and use a lot:
wxPython : powerful GUI library which generates native look
feel
PIL : Imaging Library - if you need to manipulate bitmaps
pyGame :SDL for python
BeautifulSoup : for real-world (i.e. not-at-all-recommendation-
compliant) HTML processing
Iain
On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote:
Here's a simple way to do it with a minimum amount of loopiness (don't
forget to use 'try-except' or 'with' in real life):
f = open(item1.txt)
for preline in f:
if Item 1 in preline:
print preline,
for goodline in f:
On Jul 10, 4:54 pm, Iain King [EMAIL PROTECTED] wrote:
On Jul 10, 2:45 pm, jstrick [EMAIL PROTECTED] wrote:
Here's a simple way to do it with a minimum amount of loopiness (don't
forget to use 'try-except' or 'with' in real life):
f = open(item1.txt)
for preline in f:
if Item 1
a .py file in windows explorer. Right click it-Open With-
Choose Program...
Now find your python.exe file (should be in c:\python24), select it,
and tick the box that says Always use the selected program
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 7, 10:18 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
On Mon, 07 Jul 2008 01:03:10 -0700, norseman [EMAIL PROTECTED]
declaimed the following in comp.lang.python:
Normal file I/O sequence:
fp = open(target, 'wb')
fp.seek(-1, 2)
fp.write(record)
Except it
._connection.Properties(Jet OLEDB:Max Locks Per File).Value
= MAX_LOCKS
rs = win32com.client.Dispatch(r'ADODB.Recordset')
N.B. I'm writing tools software for a 3rd party app which uses an
Access db as it's output format, so I'm locked in. No way to switch
to SQL server.
Thanks both!
Iain
--
http
dbmaxlocksperfile,15000
Can I do this in win32com? I've been using ADO, not DAO, but I have
to confess to not knowing exactly what the difference is. I set up my
recordset thusly:
rs = win32com.client.Dispatch(r'ADODB.Recordset')
can I jigger it to increase it's max locks?
Iain
--
http
On Jul 2, 3:29 pm, Tim Golden [EMAIL PROTECTED] wrote:
Iain King wrote:
Hi. I'm using the win32 module to access an Access database, but I'm
running into the File Sharing lock count as
inhttp://support.microsoft.com/kb/815281
The solution I'd like to use is the one where you can
Hi,
I am new to python. I have been having trouble using the MysqlDB. I
get an error pointing from the line
cursor.execute(UPDATE article SET title = %s, text = %s WHERE id =
%u, (self.title, self.text, self.id))
Here is the error:
line 56, in save
cursor.execute(UPDATE article SET title
(i.e. 0 = no stars, 1 = half a star, 2 =
1 star, etc). Then you just need to divide by 2 at the end.
stars = round(star_sum/num_raters, 0) / 2.0
Iain
--
http://mail.python.org/mailman/listinfo/python-list
('vcdcflx006\\Flex
\\Sites\\*\\')]
I tend to use / instead of \\ as a folder seperator, it should work
for you (I think):
cities = [(os.path.basename(x), '') for x in glob('//vcdcflx006/Flex/
Sites/*')]
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On May 23, 3:35 am, Charles Hixson [EMAIL PROTECTED] wrote:
On Thursday 22 May 2008 13:30:07 Nick Craig-Wood wrote:
...
From Armstrong's book: The expression Pattern = Expression causes
Expression to be evaluated and the result matched against Pattern. The
match either succeeds or
On May 22, 1:14 am, bukzor [EMAIL PROTECTED] wrote:
On May 21, 3:28 pm, Dave Parker [EMAIL PROTECTED] wrote:
On May 21, 4:21 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
Which is exactly what the python decimal module does.
Thank you (and Jerry Hill) for pointing that out. If I want
On May 14, 9:37 pm, David C. Ullrich [EMAIL PROTECTED] wrote:
In article
[EMAIL PROTECTED],
Iain King [EMAIL PROTECTED] wrote:
Hi. I have a modal dialog whcih has a Browse... button which pops
up a file selector. This all works fine, but the first thing the user
has to do when
On May 14, 4:29 pm, Tim Golden [EMAIL PROTECTED] wrote:
Iain King wrote:
I'm manipulating an MS Access db via ADODB with win32com.client. I
want to rename a field within a table, but I don't know how to. I
assume there is a line of SQL which will do it, but nothing I've tried
(from
= win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=dbfile.mdb;'
connection.Open(DSN)
connection.Execute(ALTER TABLE tablename CHANGE from to) #this sql
doesn't work
connection.Close()
Anyone know how to get this to work?
Iain
--
http://mail.python.org/mailman
?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] wrote:
Iain King wrote:
Hi. I have a modal dialog whcih has a Browse... button which pops
up a file selector. This all works fine, but the first thing the user
has to do when they open the dialog is select a file, so I would like
On May 13, 2:43 pm, Iain King [EMAIL PROTECTED] wrote:
On May 13, 2:20 pm, Larry Bates [EMAIL PROTECTED] wrote:
Iain King wrote:
Hi. I have a modal dialog whcih has a Browse... button which pops
up a file selector. This all works fine, but the first thing the user
has to do when
is? And is there
anything about doing it this way which could be detrimental?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
to the sizer has the listbox as a parent.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
To be or not to be,
that is the question). Unless you can guarantee they won't, you'll
need to write (or rather use) a parser that understands the syntax.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 17, 9:27 am, Iain King [EMAIL PROTECTED] wrote:
On Mar 17, 6:56 am, Dan Bishop [EMAIL PROTECTED] wrote:
On Mar 17, 1:15 am, Girish [EMAIL PROTECTED] wrote:
I have a string a = ['xyz', 'abc'].. I would like to convert it to a
list with elements 'xyz' and 'abc'. Is there any simple
to be
strong on polynomial fitting, but not, apparently, on trig functions) and I
wondered if any one here had recommendations?
Something that implemented IEEE 1057 , or similar, would be perfect.
TIA
Iain
--
http://mail.python.org/mailman/listinfo/python-list
Thanks folks - I'll have a think about both of these options.
--
http://mail.python.org/mailman/listinfo/python-list
()
foo.test()
1
--
FTR, I won't be using this :) I do like this syntax though:
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def abs(self):
using self:
return math.sqrt(.x*.x + .y*.y + .z*.z)
Iain
--
http
On Nov 27, 12:03 pm, Duncan Booth [EMAIL PROTECTED]
wrote:
Iain King [EMAIL PROTECTED] wrote:
FTR, I won't be using this :) I do like this syntax though:
class Vector:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def abs(self
pythonic though :)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
):
lastUpdate = time.mktime(time.strptime(lastUpdate, %Y-%m-%d_%H:
%M))
runTimeStamp = time.mktime(time.strptime(runTimeStamp, %Y-%m-%d_
%H:%M))
return (runTimeStamp - lastUpdate) / ONEDAY = OLDNESS_THRESHOLD
if not isOld(auctionDate, currentTime):
checkForBid()
Iain
--
http
.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
di0rz` wrote:
hi,
I am looking for a python script to edit .torrent files
if anybody know one thx
Not sure exactly what you are looking for, but the original bittorrent
client is written in Python, so you could grab a copy of it and check
the code.
Iain
--
http://mail.python.org/mailman
= False
def pause():
global paused
paused = True
while paused:
time.sleep(1)
def onWakeUpButton(): #bind this to button
global paused
paused = False
Iain
--
http://mail.python.org/mailman/listinfo/python-list
of
the image work itself - it processes the index file, and then generates
a batch file. The batch file is a lot of calls to irfanview /append.
I've yet to find a tiff irfanview can't open.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
). This might be your problem
when reading the tags, too.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
/software_phil.html
• What Languages to Hate, Xah Lee, 2002
http://xahlee.org/UnixResource_dir/writ/language_to_hate.html
Xah
[EMAIL PROTECTED]
∑ http://xahlee.org/
I'm confused - I thought Xah Lee loved Perl? Now he's bashing it?
Huh?
Iain
--
http://mail.python.org/mailman/listinfo/python
file_path', and see
if it's creating it correctly. Your for loop looks fine, assuming that
file_path is a list of filenames.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
feel quite
confortable
with the intuition... can anyone think of a more solid argumentation ?
Why not use the supplied shuffle method?
random.shuffle(x)
or check out this thread:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/766f4dcc92ff6545?tvc=2q=shuffle
Iain
[EMAIL PROTECTED] wrote:
Iain, thanks - very helpful.
Really I'm trying to write a simulation program that goes through a
number of objects that are linked to one another and does calculations
at each object. The calculations might be backwards or fowards (i.e.
starting at the supply
was for
passing simple functions as arguments, and of these map and filter must
have made up a majority (and then I'd guess TKinter would be next).
List comprehensions replace map and filter, so...
I wouldn't put it as explosively as he has, but I find a lambda less
clear than a def too.
Iain
1 - 100 of 176 matches
Mail list logo