On Sun, Dec 6, 2009 at 10:47 PM, Dr. Phillip M. Feldman <
pfeld...@verizon.net> wrote:
>
> I wrote a handy-dandy function (see below) called "strip_pairs" for
> stripping
> matching pairs of characters from the beginning and end of a string. This
> function works, but I would like to be able to i
On Wed, Dec 9, 2009 at 9:06 AM, Wanderer wrote:
> Found another strange bug (Strange to me, anyway). int(0.8 * 10.0) =
> 7. Had to change the code to int(0.8 * 10.0 + 0.0001).
>
>
http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm
Floating point math is not precise; if
On Wed, Dec 9, 2009 at 10:21 PM, Frank Millman wrote:
> Wanderer wrote:
>
> >I have a wxPython program which does some calculations and displays
> > the results. During these calculations if I click the mouse inside the
> > dialog the program locks up. If I leave the dialog alone the process
> >
On Thu, Dec 10, 2009 at 6:01 AM, Frank Millman wrote:
> > Another approach is to use wnd.CaptureMouse() on a particular control
> > which
> > doesn't really respond to anything. Just be sure to ReleaseMouse() later
> > and
> > follow the instructions in the docs about capturing that cancel-captur
On Mon, Dec 14, 2009 at 6:14 PM, W. eWatson wrote:
> I think Python is capable of executing a compiled C or FORTRAN program, and
> maybe even getting some parameters passed back. Does anyone have a example
> of how this might be done? I'm running under Win XP Pro.
>
import subprocess
proc = subp
On Sun, Dec 20, 2009 at 3:05 AM, Victor Subervi wrote:
> Of course, I can pass the page name as a parameter, but that's not elegant.
>
That is precisely what it is in fact-- elegant; it is non-elegant to have
magical behavior where what 'imports' something somehow changes or
determines how that s
On Sun, Dec 20, 2009 at 11:01 AM, Victor Subervi wrote:
> If you want a piece of code to have a variable number of differing
>> behaviors, that's something you can handle in many elegant ways. That's
>> something inheritance is good for, with a core default behavior represented
>> in one class and
On Mon, Dec 21, 2009 at 9:22 AM, Simon Moses wrote:
> hi,
>
> i am new to python but have programming experience in few other languages.
> i am trying to start with python 2.6 or 3.0. my requirement is accessing
> database (mysql and/or postgresql) and web development.
>
> what all i should insta
On Mon, Dec 21, 2009 at 8:23 AM, logan tag wrote:
> It should be interesting to add new funcionality to "copytree" function
> into a "shutil.py" module?, I mean...I have developed a very silly function
> "copytree" with a different fourth argument. I have modified the "ignore"
> parameter to "tar
On Mon, Dec 21, 2009 at 9:41 AM, Denis Doria wrote:
> All examples that I saw with property didn't show a way to do it in
> the __init__. Just to clarify, I don't want to check if the parameter
> is an int, or something like that, I want to know if the parameter do
> not use more than X chars; an
On Mon, Dec 21, 2009 at 10:34 AM, Simon Moses wrote:
>
> to code a web page which connects to a database and displays some rows, what
> minimum software and libraries i should install?
>
> python 2.6, mysql 5.0, apache 2.2 and Django? thats enough?
Depending on your requirements, you might not n
On Mon, Dec 21, 2009 at 11:09 AM, Simon Moses wrote:
> so python 2.6, mysql 5.0, apache 2.2, mod_wsgi,
> MySQL-python-1.2.2.win32-py2.6 and Django should be sufficient for my
> requirement.
I don't know for certain; you're asking a bit too much specific detail here :)
Just go to http://docs.djan
On Mon, Dec 21, 2009 at 1:51 PM, W. eWatson wrote:
> Lie Ryan wrote:
>>
>> On 12/22/2009 6:39 AM, W. eWatson wrote:
>>>
>>> Wow, did I get a bad result. I hit Ctrl-P, I think instead of Alt-P, and
>>> a little window came up showing it was about to print hundreds of pages.
>>> I can canceled it, b
On Mon, Dec 21, 2009 at 2:57 PM, W. eWatson wrote:
> This has got to be some sort of IDLE issue then.
Huh? How do you figure?
> When I run a simple
> program. If I open this program in the IDLE editor:
> #import math
> print "hello, math world."
> print cos(0.5)
> print sin(0.8)
>
> then I get
>
On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle
wrote:
> #spawn a pool of threads, and pass them queue instance
> for i in range(5):
> t = ThreadUrl(queue,i)
> t.setDaemon(True)
> t.start()
>
> #populate queue with data
> for host in hosts:
> queue.put(host)
This is indented over o
On Mon, Dec 21, 2009 at 3:24 PM, Stephen Hansen wrote:
> This is indented over one indentation level too much. You want it to
> be at the same level as the for above. Here, its at the same level
> with "t" -- meaning this entire loop gets repeated five times.
Err, "thi
On Mon, Dec 21, 2009 at 3:31 PM, Boris Epel wrote:
> Hi! Please help with the problem:
> send over TCPIP data packet organized as 6 bytes of identifier,
> integer (LSB) and length of following binary data, binary data
> the clear part: create socket, connect it, use send, close socket
> the uncle
On Fri, Dec 25, 2009 at 8:00 PM, Dave Angel wrote:
> Dotan Barak wrote:
>>>
>>> Recover the exception, and examine the tuple of args or the message
>>> string.
>>> >>> try:
>>> ... eval("my_number < 10", {"__builtins__":None}, {})
>>> ... except NameError,e:
>>> ... print e.args
On Sat, Dec 26, 2009 at 4:34 AM, Michael Fötsch wrote:
> To explain, "().__class__.__base__.__subclasses__()" gives you a list of
> all object-derived classes, i.e., of *all* classes that exist in the
> surrounding program. If you can find just one class that allows you to do
> something subtle o
Jonathan Hartley writes:
> These
are non-technical users, so I'd rather send them a single executable
> that 'just works',
[break]
rather than asking them to install Python and then
> coach them through running a script - they would HATE that as a
> solution.
>
Whoa... How can you go from
On Sun, Dec 27, 2009 at 4:42 PM, Dan Sommers wrote:
> On Sun, 27 Dec 2009 19:07:12 -0500, python wrote:
>
> > Hans,
> >
> >> Unfortunately, Windows is not a respectable OS. Unlike Unix, it allows
> >> two processes to bind to the same port. The theory is that this somehow
> >> allows the two proc
On Sun, Dec 27, 2009 at 8:54 PM, W. eWatson wrote:
> That's fine, but I'd like to start with two dates as strings, as
> "1961/06/16 04:35:25" and "1973/01/18 03:45:50"
>
> How do I get the strings into a shape that will accommodate a difference?
>
> For example,
> t1=datetime.datetime.strptime("2
On Mon, Dec 28, 2009 at 3:54 PM, Joel Davis wrote:
> I'm just curious if anyone knows of a way to get the variable name of
> a reference passed to the function.
>
> Put another way, in the example:
>
> def MyFunc ( varPassed ):
> print varPassed;
>
> MyFunc(nwVar)
>
> how would I get the str
On Tue, Dec 29, 2009 at 8:17 AM, Joel Davis wrote:
> did set the tone and I think I've been more than a little tolerant on
> this. Someone posts a question, responds back with a "n/m I found the
> solution, here it is" and his response is essentially to berate them,
> telling them how crappy their
On Tue, Dec 29, 2009 at 7:21 AM, M.-A. Lemburg wrote:
> If you want a more human readable, relative format use Age():
>
> >>> Age(bree, nat)
> 0x2b99c6e37ef0>
>
> i.e. 8 years, 4 months, 29 days, 49 minutes, 35 seconds.
>
That is... awesome. I use mx.DateTime all the time, and never knew about
On Thu, Dec 31, 2009 at 8:09 AM, Victor Subervi wrote:
> Hi;
> I have this code:
>
> sql = 'describe %s %s;' % (optionsStore, option)
> print sql
> cursor.execute(sql)
> descr = cursor.fetchone()
> if len(descr) is not None:
>
> Python complains:
>
> *TypeEr
On Thu, Dec 31, 2009 at 8:54 AM, Wells wrote:
> Sorry, this is totally basic, but my Google-fu is failing:
>
> I have a variable foo. I want to instantiate a class based on its
> value- how can I do this?
It sort of depends on where these classes are. If they're in the current
namespace/module,
On Thu, Dec 31, 2009 at 11:42 AM, Tom Machinski wrote:
> On Thu, Dec 31, 2009 at 1:54 AM, Peter Otten <__pete...@web.de> wrote:
> > Somewhat related in 2.6 there's the next() built-in which accepts a
> default
> > value. You can provide a sentinel and test for that instead of using
> > try...excep
On Thu, Dec 31, 2009 at 12:18 PM, Phlip wrote:
> The point is I need to augment that layer's exceptions with extra
> information that I know about that layer.
>
>
I would take advantage of the fact that exceptions are real, full-blown
objects, and not just treat them as something that holds a str
On Fri, Jan 1, 2010 at 5:36 PM, Peng Yu wrote:
> >> Otherwise, could some python expert explain to me why exception is
> >> widely used for error handling in python? Is it because the efficiency
> >> is not the primary goal of python?
> >
> > Correct; programmer efficiency is a more important goa
On Mon, Jan 4, 2010 at 9:28 AM, Victor Subervi wrote:
> Hi;
> I have this code snippet:
>
> sql '''create table if not exists %sCustomerData (
>
You left out the actual assignment operator.
--S
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Jan 7, 2010 at 8:44 AM, Phlip wrote:
> On Jan 7, 5:36 am, Stefan Behnel wrote:
>
> > Well, then note that there are tons of ways to generate XML with Python,
> > including the one I pointed you to.
>
> from lxml.html import builder as E
>xml = E.foo()
>
> All I want is ""
On Sat, Jan 9, 2010 at 7:15 AM, Victor Subervi wrote:
> On Sat, Jan 9, 2010 at 9:35 AM, Steve Holden wrote:
>
>> But we are now in the realm of theory as far as you are concerned, since
>> you have already stated several times that you aren't interested in
>> correcting your design until after yo
On Mon, Jan 11, 2010 at 12:02 PM, Jeremy wrote:
> Your guess is correct. I had forgotten that I was using that
> function.
>
> I am using the re.sub command to remove trailing whitespace from lines
> in a text file. The commands I use are copied below. If you have any
> suggestions on how they
On Fri, Jan 15, 2010 at 10:13 PM, D'Arcy J.M. Cain wrote:
> Damn! I missed the @invalid.com in the address. I'm not sure why I
> just didn't do this before but @invalid.com just went into my
> blacklist.
>
> Does anyone else think that that behaviour is just rude, not to mention
> in violation
On Sun, Jan 17, 2010 at 5:25 PM, Jive Dadson wrote:
> I just found another module that broke when I went to 2.6. Gnuplot.
> Apparently one of its routines has a parameter named "with." That used to
> be okay, and now it's not.
>
> Once I get everything to work under 2.6, I am using it forever o
On Sun, Jan 17, 2010 at 4:45 PM, Alf P. Steinbach wrote:
> Steven: on a personal note, earlier when I saw you (I think it was you)
> using the "Norwegian Parrot" example I thought it referred to me because
> that was the only sense I could make of it, it followed right after some
> discussion we
On Mon, Jan 18, 2010 at 7:43 AM, superpollo wrote:
> #!/usr/bin/env python
> data = "seq=123"
> name , value = data.split("=")
> print name
> print value
> if not name == "seq":
>print "DOES NOT PRINT OF COURSE..."
> if name is not "seq":
>print "WTF! WHY DOES IT PRINT?"
>
Because name r
On Mon, Jan 18, 2010 at 8:07 AM, Kit wrote:
> Hello Everyone, I am not sure if I have posted this question in a
> correct board. Can anyone please teach me:
>
> What is a list compression in Python?
>
> Would you mind give me some list compression examples?
>
Do you mean list *comprehension*? If
On Tue, Jan 19, 2010 at 7:30 AM, Gerald Britton wrote:
[snip]
> mystring = '\n'.join( line for line in lines if depending on line> )
>
Note, this is not a list comprehension, but a generator comprehension.
A list comprehension is used to build, in one sweep, a list and return it.
A generator c
On Tue, Jan 19, 2010 at 9:00 AM, Robert Somerville <
rsomervi...@sjgeophysics.com> wrote:
> Hi;
>
Hi, why did you post this three times?
> i am having trouble trying to sort the rows of a 2 dimensional array by the
> values in the first column .. does anybody know how or have an example of
> ho
On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious wrote:
> I am using Python 3, getting an error from SQLite:
>
> sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless
> you use a text_factory that can interpret 8-bit bytestrings (like
> text_factory = str). It is highly recommended that
On Tue, Jan 19, 2010 at 8:16 PM, Gnarlodious wrote:
> Well, Python 3 is supposed to be all Unicode by default. I shouldn't
> even need to say
> # coding:UTF-8
>
> And, the file is saved as Unicode.
>
> There are many mentions of this error found by Google, but none seen
> to clearly say what the
On Tue, Jan 19, 2010 at 10:39 PM, Rainer Grimm wrote:
> Hallo,
> you can also look at list comprehension as syntactic sugar for the
> functions map and filter. The two functions from the functional world
> can be expressed in a comprehensive way with list comprehension.
> >>> [x**2 for x in range
On Tue, Jan 19, 2010 at 11:32 PM, Stephen Hansen wrote:
>
> I really don't think you can call comprehensions as mere syntactic sugar,
>
Err, I misspoke.
I don't really think you can call comprehensions mere syntactic sugar /for
map and filter/.
It IS mere syntactic sugar for
On Wed, Jan 20, 2010 at 7:19 AM, Victor Subervi wrote:
> Hi;
> I think I finally have an interesting problem for y'all. I need to import a
> script from a lower dir, forcing me to change dirs:
>
Don't do that. If you must, then the correct way to do it is to adjust your
sys.path and not change di
On Thu, Jan 21, 2010 at 6:23 AM, Gnarlodious wrote:
> This works! However I end up saying:
>
> d['Server'].Config.BaseURL
>
> to get the data, when I should be saying:
>
> Server.Config.BaseURL
That's the thing: you should not actually be saying that.
d['Server'].Config.BaseURL is precisely wh
On Sat, Jan 23, 2010 at 12:57 PM, thinke365 wrote:
> def sort_by_list(E1, E2):
>print len(E1), len(E2)
>return len(list(E1)) > len(list(E2))
>
> l.sort(cmp=sort_by_list)
>
The cmp function is defined as returning one of three values, -1, 0 and 1.
You are returning true or false, so thin
On Mon, Jan 25, 2010 at 9:31 AM, Steve Howell wrote:
> Another way of looking at it is that you would need to have 250 or so
> lists in memory at the same time before the extra pointer was even
> costing you kilobytes of memory. My consumer laptop has 3027908k of
> memory.
>
Umm, I think the is
On Tue, Jan 26, 2010 at 10:23 PM, Paul Rubin wrote:
> Steven D'Aprano writes:
> > print as a function is more consistent and more convenient than print as
> > a statement.
>
> Convenience is subjective, but the 3.x 'print' behavior is definitely
> inconsistent (i.e. different from 2.x).
This is
On Wed, Jan 27, 2010 at 6:06 PM, Rotwang wrote:
> But suppose I replace the line
> self.data = [[0]]*2
>
> with
>
> self.data = [[0] for c in xrange(2)]
>
The first line does not do what you think it does: it doesn't make a copy of
that internal [0]. Python almost never implicitly copies any
On Fri, Jan 29, 2010 at 8:37 AM, Alan Harris-Reid <
aharrisr...@googlemail.com> wrote:
> Hi,
>
> I am creating a web application (using Python 3.1 and CherryPy 3.2) where a
> SQLite connection and cursor object are created using the following code
> (simplified from the original):
>
> class MainSi
On Sat, Jan 30, 2010 at 8:58 AM, tanix wrote:
> The very idea of using a number of blanks to identify your block level
> is as insane as it gets. First of all, combinations of blanks and tabs,
> depending on how your ide is setup to expand tabs, may get you bugs,
> you'd never imagine in your wil
>
> Anyways, maybe I got off to a bad start, but I'm a bit leery of the
> language. In my estimation it's trying to be 'too clever by half', and
> this coming from a veteran bash/perl programmer. I mean, free form is
> one thing, but too much of a good thing can be harmful to your
> programming hea
On Mon, Oct 5, 2009 at 4:54 PM, Stef Mientki wrote:
> hello,
>
> I want to handle datetime vars in a general way, so I use the default
> time-format,
> so I can use the standard cinversion procedures.
>
Personally, I love mx.DateTime; its the best date/time library around. But,
Python's built in
>
> I really can't quite fathom why you'd want to use something so low-level as
>> time.mktime... or just about anything in the time module :)
>>
> I didn't know anything better,
> but (forgive me if I'm wrong) I find mx almost as low-level :
> >>> mx.DateTime.strptime('01-01-53',"%d-%m-%y")
>
> w
On Wed, Oct 7, 2009 at 2:31 AM, Ryan wrote:
> Next time python comes across
>
> from PyQt4 import QtGui
>
> it would have to re-import the class, which seems a waste of cycles
> that could accumulate.
Python only imports modules once. The next time Python comes across that, it
looks in sys.modu
On Wed, Oct 7, 2009 at 1:59 AM, Ken Elkabany wrote:
> Hello,
>
> I am hoping to get feedback for a new, commercial platform that
> targets the python programming language and its users. The product is
> currently in a closed-beta and will be free for at least a couple
> months. After reviewing th
On Fri, Oct 9, 2009 at 7:13 AM, Victor Subervi wrote:
> Hmm. I didn't bother to look at the "comparison post". The indenting looks
> right to me. I reread my post and I believe my question is straight-forward.
> The crux of the issue is my sentence at the bottom. I believe that details
> what my o
On Fri, Oct 9, 2009 at 10:02 AM, Victor Subervi wrote:
> Hi;
> I have the following code:
>
> elif table[0] == 't': # This is a store subtype table
> bits = string.split(table, '0')
> sst.append(bits[2])
> sstp.append(bits[1])
> subtypes = dict(zip(sstp, sst))
>
> When I pr
Changing the line:
> subtypes = dict(zip(sstp, sst))
> to:
> subtypes = dict(zip(sst, sstp))
> as I believe Stephen misread it to be causes the zip operation to return:
> [('doctors', 'prescriptions'), ('patient', 'prescriptions')]
> an
On Fri, Oct 9, 2009 at 11:04 AM, Victor Subervi wrote:
> So, because the results in sstp were duplicates ( ['prescriptions',
> 'prescriptions'] ) it only returned one result in the dict(zip()) statement.
> Weird. Bug or feature? ;)
> Thanks,
> V
Feature.
zip() returned two results, but dictiona
>
> I use "while True"-loops often, and intend to continue doing this
> "while True", but I'm curious to know: how widespread is the
> injunction against such loops?
The injunction is nonexistent (save perhaps in people coming from another
language who insist that Python just /must/ have a "prope
On Sat, Oct 10, 2009 at 4:36 PM, Stef Mientki wrote:
> hello,
>
> I always thought code in a module was only executed once,
> but doesn't seem to be true.
>
This is one of the reasons why that whole big mess of a ton separate scripts
that all call each-other and are sometimes imported and sometim
gt;> this is the resulting output:
>>
>> B [3]
>> B [3, 3]
>> C [3, 3]
>>
>> Why is the B.py executed twice ?
B.py is the entry point of the program and it is known internally as
__main__. There is no record of a B.py.
If you really must import objects from the main module you can do it like
this.
from __main__ import *
--
Stephen Fairchild
--
http://mail.python.org/mailman/listinfo/python-list
path.split(a)[1] ) [0]
>
> #import myself as 'ME'
> ME = __import__ ( X )
>
> # run some code in myself
> ME.functional_code ()
>
> # prevent that the code below is executed,
> # ( for the second time )
> # if this file is used as a script
> sy
On Sun, Oct 11, 2009 at 4:46 PM, aditya shukla
wrote:
> Hello Guy's
>
> I am using python 2.6 on windows 7 and MySQLdb to make connections to the
> database.The issue here is that I am not able to insert from the python
> script to the database.When I run the same query in mysql query brower then
g, language
>
>
> traceback
>
> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning:
> the sets module is deprecated
> from sets import ImmutableSet
>
> cp1252 en_US
>
> Thanks
>
> Aditya
>
>
>
>
>
>
>
>
>
>
>
>
>
>
--
Stephen Hansen
Development
Advanced Prepress Technology
shan...@advpubtech.com
(818) 748-9282
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Oct 11, 2009 at 8:56 PM, Dennis Lee Bieber wrote:
> On Sun, 11 Oct 2009 17:00:42 -0700, Stephen Hansen
> declaimed the following in
> gmane.comp.python.general: >
> > Otherwise, the only thing anyone will be able to do is guess wildly.
> Which
>
On Mon, Oct 12, 2009 at 4:15 PM, Stef Mientki wrote:
> Hierarchical choices are done on todays knowledge, tomorrow we might have
> different views and want/need to arrange things in another way.
> An otter may become a reptile ;-)
> So from the human viewpoint the following should be possible (and
On Mon, Oct 12, 2009 at 11:33 AM, Victor Subervi wrote:
> for row in data:
> i += 1
> total = 0
> quantity = form.getfirst('order_' + str(i), '')
> if quantity != '':
> sql = 'select * from products p join %s c on p.ID=c.ID where
> c.ID=%s;' % (client, str(i))
>
On Tue, Oct 13, 2009 at 2:17 PM, Peng Yu wrote:
> Hi,
>
> The following code does not run because range() does not accept a big
> number. Is there a way to make the code work. I'm wondering if there
> is a way to write a for-loop in python similar to that of C style.
>
> for(int i = 0; i < a_big_
s two
things. It states what is to be returned by the generator's next() method
and it also defines g as a function that returns a generator.
--
Stephen Fairchild
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Oct 14, 2009 at 1:37 PM, Laszlo Nagy wrote:
>
> Andre Engels schrieb:
>>
>>>
>>> None, True, False, NotImplemented are guaranteed to be singletons, all
>> builtin types and exceptions can be considered as singletons, too.
>>
>>
> I thought that different mutable objects always have differ
On Wed, Oct 14, 2009 at 4:19 PM, Chris Rebert wrote:
> Although I have no idea how it is that `id({}) == id({})` as a prior
> posted showed; FWIW, I can't manage to reproduce that outcome.
>
With Python 2.5.1 on MacOS X, I can; it looks like there's an optimization
in there where its 'saving' di
On Thu, Oct 15, 2009 at 8:02 AM, Peng Yu wrote:
> Suppose I have classes 'A', 'B', 'C', 'D'. The definition of these
> classes are long enough so that I have to put each class in a separate
> module 'mA', 'mB', 'mC', 'mD', which are in packages 'pA', 'pB', 'pC',
> 'pD', respectively. And there
On Thu, Oct 15, 2009 at 4:43 PM, Stef Mientki wrote:
> hello,
>
> By writing the following unicode string (I hope it can be send on this
> mailing list)
>
> Bücken
>
> to a file
>
>fh.write ( line )
>
> I get the following error:
>
> UnicodeEncodeError: 'ascii' codec can't encode character
On Fri, Oct 16, 2009 at 2:02 AM, Bearophile wrote:
> Terry Reedy:
> >2. iterator protocol is intentionally simple.<
>
> Slice syntax is already available for lists, tuples, strings, arrays,
> numpy, etc, so adding it to iterators too doesn't look like adding
> that large amount of information to t
On Fri, Oct 16, 2009 at 5:22 AM, Duncan Booth
wrote:
> Chris Rebert wrote:
>
> > Essentially, file iterators are dumb and don't keep track of where in
> > the file the next line starts,
>
[snip]
>
> Nothing 'dumb' or 'smart' about it: it is simply that a file object is
> already an iterator. Tr
On Fri, Oct 16, 2009 at 8:39 AM, Alan G Isaac wrote:
> I expected this to be fixed in Python 3:
>
> sum(['ab','cd'],'')
>>> Traceback (most recent call last):
> File "", line 1, in
> TypeError: sum() can't sum strings [use ''.join(seq) instead]
>
> Of course it is not a good way to join s
On Fri, Oct 16, 2009 at 9:24 AM, Harald Kraemer wrote:
> Stephen Hansen wrote:
> Nothing 'dumb' or 'smart' about it: it is simply that a file object is
>
>> already an iterator. Trying to create an iterator from an existing
>>> iterator
>>> i
On Fri, Oct 16, 2009 at 9:59 AM, Tim Chase wrote:
> Stephen Hansen wrote:
>
>> Why doesn't duck typing apply to `sum`?
>>>
>>
>> Because it would be so hideously slow and inefficient that it'd be way too
>> easy a way for people to program so
The script below uploads files to a web server. Currently it
overwrites a file if it already exists. I'm instead trying to rename
the old file with an appended date/timestamp before the new file is
uploaded. I *think* I have the idea down but it's not be implemented
in the script correctly. Any hin
Instead, use a compatible character encoding. Note the explicit conversion.
fh.write(line.encode('utf-8'))
Alternatively, you can write sixteen bit unicode directly to a file:
import codecs
f = codecs.open('unicodetest.txt', mode='w', encoding='utf-16&
> This isn't working because the else: is dangling. And I think your logic is
> flawed (I might be wrong of course) because you rename the *existing* file
> instead of giving the new one a new data.
>
> Thus e.g. a link to the file (if it's a webserver) will suddenly deliver a
> different file. I d
red in your database, and
you should be able to use it in Delphi too I believe? Its been years since I
used delphi, but. At the point where there's a barrier between 'your' stuff
and 'other stuff', you convert from unicode into an encoding-- if you must.
Anyways. That's just ho
On Fri, Oct 16, 2009 at 6:02 PM, Kee Nethery wrote:
>
> On Oct 16, 2009, at 5:49 PM, Stephen Hansen wrote:
>
>> On Fri, Oct 16, 2009 at 5:07 PM, Stef Mientki
>> wrote:
>>
>
> snip
>
>> The thing is, I'd be VERY surprised (neigh, shocked!) if Excel
> This isn't working because the else: is dangling. And I think your logic is
> flawed (I might be wrong of course) because you rename the *existing* file
> instead of giving the new one a new data.
>
> Thus e.g. a link to the file (if it's a webserver) will suddenly deliver a
> different file. I d
> Clearly, the os.path.isfile() is never returning true, because once it does,
> you'll get a string error on the next line. You need
>
> fn = basename + "." + str(count)
>
> or something similar.
>
> Anyway, isfile() needs a complete path, there's no way it can guess what
> directory you plan
On Sat, Oct 17, 2009 at 10:22 PM, StarWing wrote:
> okay, I think somethings dowhile is useful, but why python didn't
> have it?
>
> in lisp, we can (while (progn ))
> and in all other language we have do...while.
> but in python, we only can:
> cond = 1
> while cond:
>cond = 0
>.
On Tue, Oct 20, 2009 at 7:41 PM, David Sfiligoi wrote:
> So normally I would open a connection and instentiate a cursor for my
> queries once at a global level(like find out if the current date is >
> than the last task date). Then go in an infinite loop that wait for data
> to arrive in the queu
or "license" for more information.
>>>>> import md5
>>>>> pass = md5.new()
>> File "", line 1
>> pass = md5.new()
>> ^
>> SyntaxError: invalid syntax
>
> pass is a keyword, as in:
>
> def f ():
>
On Wed, Oct 21, 2009 at 10:04 PM, Dieter Maurer wrote:
> Steven D'Aprano writes on 20 Oct
> 2009 05:35:18 GMT:
> > As far as I'm concerned, asking for help on homework without being honest
> > up-front about it and making an effort first, is cheating by breaking the
> > social contract. Anyone w
On Thu, Oct 22, 2009 at 8:12 PM, rh0dium wrote:
> In my case the args that it dumps them into a black hold is simply not
> true. I want an unknown set of args and kwargs to simply be forwarded
> onto init. So what's the problem with this??
>
There is no problem with doing that-- the deprecatio
On Thu, Oct 22, 2009 at 9:09 PM, Stephen Hansen wrote:
> >>> class myclass(object):
> ... def __new__(cls, *args, **kwargs):
> ... print args
> ... print kwargs
> ... self = object.__new__(cls)
> ... return self
On Fri, Oct 23, 2009 at 5:19 PM, kj wrote:
> I like Python a lot, and in fact I'm doing most of my scripting in
> Python these days, but one thing that I absolutely *DETEST*
> about Python is that it does allow an internal function to modify
> variables in the enclosing local scope. This
On Fri, Oct 23, 2009 at 7:31 PM, Peng Yu wrote:
> For example, the long string is 'abcabc' and the given string is
> 'abc', then 'abc' appears 2 times in 'abcabc'. Currently, I am calling
> 'find()' multiple times to figure out how many times a given string
> appears in a long string. I'm wonderi
On Fri, Oct 30, 2009 at 9:01 AM, AK Eric wrote:
> Should we start talking about how you can add stuff to __builtin__ and
> then it really is exposed to everything? (right, unless I'm missing
> some other Python idiom?) Again, *not advocating* in standard
> practice, but I think it's important to
On Thu, Nov 12, 2009 at 8:10 PM, r wrote:
> On Nov 12, 7:44 pm, Steven D'Aprano cybersource.com.au> wrote
> > Oh, but those hundreds of thousands of man-hours lost to bugs caused by
> > assignment-as-an-expression is nothing compared to the dozens of man-
> > minutes saved by having one fewer li
On Tue, Nov 17, 2009 at 10:15 AM, r wrote:
> On Nov 17, 9:28 am, Jonathan Saxton wrote:
>
> > And if I ever find the genius who had the brilliant idea of using = to
> mean assignment then I have a particularly nasty dungeon reserved just for
> him. Also a foul-smelling leech-infested swamp for
601 - 700 of 1209 matches
Mail list logo