nge(n):
> print >>f, random.randint(0, sys.maxint)
> f.close()
>
> What's using so much memory?
> What 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
On May 25, 2:44 pm, ad wrote:
> On May 25, 4:06 am, Ulrich Eckhardt
> 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" with according arguments and then
makes for easier maintenance, especially when you append
> array/list elements.
>
> Chris Angelico
I did not know this. Very useful!
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 28, 2:35 pm, Iain King 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
st)?
>
It's equivalent to:
if columns:
if columns[-1][0] == s:
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 impleme
On Apr 29, 10:38 am, Daniel Fetchinson
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 as a first tr
ld use the __setattr__ method:
for attr, value in (
('attr1', 1),
('attr2', 2),
('attr3', 3),
('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
sses in that zip code, and then finding whatever one of those
address strings most closely resembles your address string (smallest
Levenshtein distance?).
Iain
--
http://mail.python.org/mailman/listinfo/python-list
Possibly related: type(tuple()) 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
scussion.
I tend to use tuples unless using a list makes it easier to read. 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
On 21 Jan 2010, at 00:11, Gabriel Genellina wrote:
> En Wed, 20 Jan 2010 19:45:44 -0300, Iain Barnett
> 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,
&
ndsen
>
> --http://www.wilbertberendsen.nl/
> "You must be the change you wish to see in the world."
> -- Mahatma Gandhi
Sorting it isn't the right solution: easier to hold the subs as tuple
pairs and by doing so let the user specify order. Think of the
following subs:
"fooxx" -> "baz"
"oxxx" -> "bar"
does the user want "bazxbazyyyquuux" or "fobarbazyyyquuux"?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
bject):
def __init__(self, vx=0, vy=0):
self.vx = vx
self.vy = vy
up = Direction(0, -1)
down = Direction(0, 1)
left = Direction(-1, 0)
right = Direction(1, 0)
def move(direction):
spaceship.x += direction.vx
spaceship.y += direction.vy
Iain
--
http://mail.python.org/mailman/listinfo/python-list
cept Warning, w:
^
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
On Jan 18, 4:26 pm, Steven D'Aprano wrote:
> On Mon, 18 Jan 2010 06:23:44 -0800, Iain King wrote:
> > On Jan 18, 2:17 pm, Adi Eyal wrote:
> [...]
> >> Using regular expressions the answer is short (and sweet)
>
> >> mapping = {
> >>
uot;,
> "baz" : "quux",
> "quuux" : "foo"
>
> }
>
> pattern = "(%s)" % "|".join(mapping.keys())
> repl = lambda x : mapping.get(x.group(1), x.group(1))
> s = "fooxxxbazyyyquuux"
> re.subn(pattern, repl, s)
Winner! :)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
On Jan 18, 12:41 pm, Iain King wrote:
> On Jan 18, 10:21 am, superpollo wrote:
>
>
>
> > superpollo ha scritto:
>
> > > hi.
>
> > > what is the most pythonic way to substitute substrings?
>
> > > eg: i want to apply:
>
> > >
;.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://mail.python.org/mailman/listinfo/python-list
hex = True
> else:
> ishex = False
> 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
n,\nreturning a list
containing th
e resulting substrings.\n']
>>> re.split(" ", a)
['split(pattern,', 'string,', 'maxsplit=0)\n', '', '', '', 'Split',
'the', 'sour
ce', 'string', 'by', 'the', 'occurrences', 'of', 'the', 'pattern,\n',
'', '', ''
, 'returning', 'a', 'list', 'containing', 'the', 'resulting',
'substrings.\n']
Iain
--
http://mail.python.org/mailman/listinfo/python-list
instead of
altering a current one, and depending on that use either:
if key in d:
d[key] += value
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
certainly an error, and having the
warning is not a bad idea.
However, I assume you can get past the else by raising an exception,
so the idea becomes a little muddled - do you warn when there is no
break and no explicit raise caught outside the loop? What about an
implicit exception? I would guess that code intentionally using an
implicit exception to break out of a for loop is in need of a warning
(and the author in need of the application of a lart), but I'm sure
you could 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
gt; def twice(n):
> return twice(n)
>
> would work, but I get this really long error message.
>
> > 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 a
On Aug 6, 11:34 am, MRAB 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 o
> 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
We don't even
> > get a compiler warning!
>
> That's quite different, actually. Python doesn't claim to have
> constants! Can't misinterpret what you can't have, can you?
>
> [Holds breath while awaiting counter-example... :]
>
> ~Ethan~
The convent
gt; But back on topic... "r" has missed the point. It's not that a=b is hard
> to understand because b is a poor name. The example could have been:
>
> def factory_function():
> magic = time.time() # or whatever
> def inner():
> return magic
> return inner
>
> my_function = factory_function
>
> It's still ambiguous. Does the programmer intend my_function to become
> factory_function 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
ot;?
import os
root, ext = os.path.splitext(x)
print len(root)
or in one line (assuming you've imported os):
print len(os.path.splitext(x)[0])
Iain
--
http://mail.python.org/mailman/listinfo/python-list
pace, you can:
while " " in s:
s = s.replace(" ", " ")
readable 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
t; min(Timer('map(f, data)', setup).repeat(repeat=5, number=3))
> 74.999755859375
> >>> min(Timer('pmap(f, data)', setup).repeat(repeat=5, number=3))
>
> 20.490942001342773
>
> --
> Steven
I was going to write something like this, but you'
ail -f' is on page 39, 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 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 the source HTML. A
ference between the outcome
of the two following pieces of code?
a = lambda x: x+2
def a(x):
return x+2
Iain
--
http://mail.python.org/mailman/listinfo/python-list
ooked through the What's New and the change 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.pol
ssage object, that would be helpful.
>
> Please mail back for further information.
> Thanks in advance,
> Venu.
This looks like the API for the Message object:
http://msdn.microsoft.com/en-us/library/ms526130(EXCHG.10).aspx
Looks like you want TimeLastModified
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
r False (or any immutable), but are not if setting to
immutables, which could give you some real head-scratching bugs if you
were unaware of the difference - the first version assigns the same
object to both names:
>>> array[x1] = array[x2] = []
>>> array[x1].append("Hi")
>>> array[x2]
['Hi']
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 co
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
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 pi
tried the FIFO 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 "", line 1, in
File "/usr/lib/python2.5/urllib.py", line 82, in urlopen
return opener.open(url)
File "/usr/
done += 1
> if num_done == num_tasks:
> queue.put(None)
> break
Are you sure you want to put the final exit code in the consumer?
Shouldn't the producer place a None on the queue when it knows it's
finished? The way you have it, the producer could make 1 item, it
could get consumed, and the consumer exit before the producer makes
item 2.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
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) # this is a spacer
sz.Add(label2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
output.SetSizer(sz)
sz = wx.GridSizer(rows=2, cols=1, hgap=5, vgap=5)
sz.Add(input, 0, wx.ALIGN_LEFT)
sz.Add(output, 0, wx.ALIGN_RIGHT)
grid.SetSizer(sz)
sz = 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
what I have read.
>
It's Greenspun's Tenth Rule 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
rofessional of some sort? Man, I can't even imagine
> working in an environment with people like you. I guess I'm pretty
> lucky to work with real professionals who don't play petty little
> games like the one you played here -- and are still playing. Go ahead,
> have the last word, loser -- then get lost.
You understand this is usenet, right? Where we can all read the
entire thread? So trying to spin the situation just doesn't work?
Just checking...
Iain
--
http://mail.python.org/mailman/listinfo/python-list
27;t
comprehending). The most irritating thing is that I like the idea of
being able to use '.x = 10' type notation (and have been for a long
time), but the person arguing for it is an insufferable buffoon who's
too dense to understand a cogent argument, never mind make one. So
gre
he number 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.
code at the
begining; basically starting 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
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
st:
if goes_on(x):
on_list.append(x)
else:
new_off_list.append(x)
off_list = new_off_list
generation += 1
Iain
--
http://mail.python.org/mailman/listinfo/python-list
a Real Programmer:
http://www.pbm.com/~lindahl/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-wo
ke 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
--
http://mail.python.org/mailman/listinfo/python-list
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 re
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
not 2.5)
>
> How do I make it so that the script runs?
find 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
oftware 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://mail.python.org/mailman/listinfo/python-list
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 so
ngine.SetOption 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
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 titl
, I couldn't find a
> solution that did what I'm discussing above.)
>
> - Jeff
I know a ton of people have already replied with list comprehensions,
but I figured I'd chime in with one that also strips out the path of
your folders for you (since I'm not sure how you are managing that
just now)
cities = [(os.path.basename(x), '') for x in glob('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
tr(whole)+'.'+str(frac))
>
> Mmmm⦠In-N-Out Burgers⦠Please reply if you've got a better solution.
It'd be easier just to do the whole thing with ints. Represents your
stars by counting half-stars (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
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 succ
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
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 whi
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 fil
ient
connection = 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 thi
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 se
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 th
g do
something as soon as it's been shown?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
What is? And is there
anything about doing it this way which could be detrimental?
Iain
--
http://mail.python.org/mailman/listinfo/python-list
; Thanks,
> Soren
Without your code can only really guess, but I'd check that the new
panel you are trying to add to the sizer has the listbox as a parent.
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']"..
', ')]
This will fall over if xyz or abc include any of the characters your
stripping/splitting on (e.g if xyz is actually "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
Thanks folks - I'll have a think about both of these options.
--
http://mail.python.org/mailman/listinfo/python-list
(they seem 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
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 =
rgs, **kwargs)
for varname in delete:
del(g[varname])
return t
class Test(object):
x = 1
@noself
def test(self):
print x
>>> foo = Test()
>>> 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://mail.python.org/mailman/listinfo/python-list
the
> KHz.
>
> There are probably other more Pythonic ways...
>
I always use:
state = 1 - state
for toggles. I doubt it's much more pythonic though :)
Iain
--
http://mail.python.org/mailman/listinfo/python-list
imeStamp, "%Y-%m-%d_
%H:%M"))
return (runTimeStamp - lastUpdate) / ONEDAY >= OLDNESS_THRESHOLD
if not isOld(auctionDate, currentTime):
checkForBid()
Iain
--
http://mail.python.org/mailman/listinfo/python-list
and set a status bar to the total found, or whatever else you
want to do.
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.or
f wake_up_key_pressed:
paused = False
or with a gui:
paused = 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
open image with wxPython
except:
fail
Right now my program to compile multipage tiffs no longer does any 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
e
> end of things, so any kind suggestions would be most welcome.
>
> By the way, I believe the offending string contains a German umlaut, at least
> in one
> of the cases.
>
>
To get the MP3's name, use os.path.basename (I'm guessing that's what
your split() is for?)
Looking at the mutagen tutorial, most of the tags are lists of unicode
strings, so you might want to try audio["title"] = [unicode(name)],
instead of audio["title"] = unicode(name). This might be your problem
when reading the tags, too.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
.org/Periodic_dosage_dir/_p/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
txt" using the str function. Meaning that the FOR
> LOOP is not working correctly.
After your 'file_path =' line, try adding a 'print 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
://groups.google.com/group/comp.lang.python/browse_thread/thread/766f4dcc92ff6545?tvc=2&q=shuffle
Iain
--
http://mail.python.org/mailman/listinfo/python-list
[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.
>
if c.upstream != self:
c.setUpstream(self)
class Supply(Component):
pass
etc.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
uess 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
> regards
> Steve
> --
> Steve Holden +44 150 684 7255 +1 800 494 3119
> Holden We
s.path.split (so it should be fairly
compatible):
def split(path):
h,t = os.path.split(path)
if h == path:
return [h]
else:
return split(h) + [t]
You could throw in os.path.splitdrive and os.path.splitunc, if you
wanted to be really complete.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
lement inside p. It gives
> you a new sublist containing one element from p. You then append a
> column to that sublist. Then, since you do nothing more with that
> sublist, YOU THROW IT AWAY.
>
> Try doing:
>
> p[j] = p[j].append(col)
>
No, this doesn't work. append is an in-place operation, and you'll end
up setting p[j] to it's return, which is None.
Iain
--
http://mail.python.org/mailman/listinfo/python-list
of course the empty list),
which is then appended to, but is not stored anywhere. If you want to
insert str(col) then use p.insert
Iain
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 174 matches
Mail list logo