On Thu, 03 Sep 2009 12:22:14 -0400, doug wrote:
> I am new to python, working by way through 'Core Python Programming'. I
> can find no description of using print with the built-in type for
> formatting. I think I have got some [most?] of it from Chun, google, and
> python.org. My comment is - it
On Fri, Sep 4, 2009 at 11:23 AM, Scott David
Daniels wrote:
> The Music Guy wrote:
>>
>> I have a peculiar problem that involves multiple inheritance and method
>> calling.
>>
>> I have a bunch of classes, one of which is called MyMixin and doesn't
>> inherit from anything. MyMixin expects that it
> def enable_recur(f):
> print f.func_code.co_names
> if 'recur' not in f.func_code.co_names:
> return f # do nothing on non-recursive functions
> c = Code.from_code(f.func_code)
> c.code[1:1] = [(LOAD_GLOBAL, f.__name__), (STORE_FAST, 'recur')]
> for i, (opcode, value)
On Sep 5, 1:51 am, Dero wrote:
> On Sep 5, 2:35 pm, "Mark Tolonen" wrote:
>
> > "DarkBlue" wrote in message
>
> >news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com...
>
> > >I am trying to get used to the new print() syntax prior to installing
> > > python 3.1:
...
> > Without
On Fri, 04 Sep 2009 22:51:39 -0700, Ken Newton wrote:
> On Fri, Sep 4, 2009 at 9:49 PM, Steven
> D'Aprano wrote: ...
>>
>>> The old discussion, the above link points to, shows that such a
>>> dot-accessible dict-like class is something that many people need and
>>> repeatedly implemet it (more or
Dear all,
I am writing an application in Python for an experiment in Experimental
Economics.
For those who do not know what this is: experimental economics uses
controlled, computerised lab experiments with real subjects, putting the
subject in a game mimicking the situation of interest and co
I have a text file and the first line provides the best score of a game. This
line has the following format :
Best score : 42
In order to update the score, I try to retrieve the score value.
In C, we would manage this with the following statement :
fscanf(foo_file, "Best score : %d", &score);
On Sat, Sep 5, 2009 at 3:13 AM, candide wrote:
> I have a text file and the first line provides the best score of a game. This
> line has the following format :
>
> Best score : 42
>
> In order to update the score, I try to retrieve the score value.
>
> In C, we would manage this with the followin
As I Understand it I Would just use a simple shared variable or perhaps data
wrote to a file to indicate busy or waiting and then use some kind of wait
function or no-op to simulate' then recheck
--
Sent via Cricket Mobile Email
--Original Message--
From: Paolo Crosetto
To:
Da
We are developing a turn-based strategy game in Python 2.6. One of the
features of this game is that several battles can be concurrently in
progress which each one having a *user-defined* turn-length.
So the problem here is coming up with a robust method of turn processing
which ensures all initia
On 5 Sep, 08:47, Steven D'Aprano wrote:
> How do you know?
After more than 10 years experience with scientific programming I just
do. When it comes to numerics I have a gut feeling for what is fast
and what is slow.
It's not difficult actually. You just have to imagine how often the
interpreter
On Sep 5, 12:06 am, Steven D'Aprano wrote:
> On Fri, 04 Sep 2009 06:36:59 -0700, Adam Skutt wrote:
> > Nope, preventing mutation of the objects themselves is not enough. You
> > also have to forbid variables from being rebound (pointed at another
> > object). Consider this simple example:
>
> > -
Alan G Isaac wrote:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
class MyError(Exception):
... def __init__(self, message):
... Exception.__init__(self)
... self.message = message
...
The Tutorial Committee for PyCon 2010 in Atlanta is now accepting proposals
for classes. This year will feature 2 days of classes prior to the
"official" conference. These classes are 3-hour long sessions concentrating
on specific Python packages or techniques and are taught by some of the
smarte
On 12:20 pm, alan.is...@gmail.com wrote:
Alan G Isaac wrote:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
class MyError(Exception):
... def __init__(self, message):
... Exception.__
In Ethan Furman
writes:
>I've seen a couple cool recipes implementing WORM* attributes if you
>wanted to ensure that your settings were not re-set.
>Steven D'Aprano wrote one with a class name of ConstantNamespace, you
>can search on that if you're interested. I'd include the code, but I
Leo 4.6.3 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106
Leo is a text editor, data organizer, project manager and much more. See:
http://webpages.charter.net/edreamleo/intro.html
Leo 4.6.3 fixes a significant caching bug in Leo 4.6.2.
Leo 4
On 9/5/2009 9:07 AM, exar...@twistedmatrix.com wrote:
You are using the deprecated practice.
Clearly not, or it would fail in Python 3,
which it does not.
Attributes are not scoped to a
particular class. There is only one "message" attribute on your
"MyError" instance. It does not belong just
In article ,
kiithsa...@gmail.com wrote:
>
>Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6
>but it might run on older python as well)
Why are you using ImageMagick instead of PIL?
--
Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/
"Look, it's
> Theorem provers
> such as OCaml (HOL, Coq), Mizar does math formalism as a foundation,
> also function as a generic computer language, but lacks abilities as a
> computer algebra system or math notation representation.
Isabelle's presentation layer is well integrated with LaTeX and you
can use
exar...@twistedmatrix.com wrote:
On 12:20 pm, alan.is...@gmail.com wrote:
I think you are missing my point.
I understand it is just a DeprecationWarning.
But **why** should I receive a deprecation warning
when I am **not** using the deprecated practice?
Since I am **not** using the deprecated
Martin P. Hellwig wrote:
Timothy Madden wrote:
Martin P. Hellwig wrote:
Timothy Madden wrote:
>>> conn = pyodbc.connect('DRIVER={PostgreSQL
Unicode};Servername=127.0.0.1;UID=pikantBlue;Database=pikantBlue')
Traceback (most recent call last):
File "", line 1, in
pyodbc.Error: ('0', '[0
Chris Rebert wrote:
On Sat, Sep 5, 2009 at 3:13 AM, candide wrote:
I have a text file and the first line provides the best score of a game. This
line has the following format :
Best score : 42
In order to update the score, I try to retrieve the score value.
In C, we would manage this with th
Paolo Crosetto wrote:
Dear all,
I am writing an application in Python for an experiment in Experimental
Economics.
For those who do not know what this is: experimental economics uses
controlled, computerised lab experiments with real subjects, putting the
subject in a game mimicking the sit
On 02:28 pm, alan.is...@gmail.com wrote:
I am not sure how best to deprecate dependence on the
Python 2.5 mistake, but this is not it. And I know at
least one important library that is affected.
I'll agree that it's not great. I certainly would have preferred it not
to have been done. It i
Adam Skutt wrote:
\
This is a side-effect of writing code that relies on global variables.
Global variables are generally a bad idea. Global constants are fine.
Nope, the variables don't have to be global to have this problem, they
just have to be shared:
>>> a = 3
>>> b = lambda x: x
Dear Terry,
thanks.
>
> As I understand your description, the server and each client will be a
> separate process on a separate machine (once deployed), so threads do
> not seem applicable. (For development, you can use separate processes on
> one machine communicating through sockets just as if
Martin v. Löwis a écrit :
Without having seen any details, I refuse to guess. Most likely, it is
a user mistake.
YES IT IS! Sorry for the inconvenience. I usually start from this
assumption. Yesterday this new student was really agressive, and I
assumed he was right!
Here's his mistake: wi
On Saturday 05 September 2009 12:07:59 Paolo Crosetto wrote:
8<---
>
> The problem I now face is to organise turns. Players, as in Scrabble, will
> play in turns. So far I have developed the server and ONE client, and
> cannot get my head round to - nor
There's something wonderfully clear about code like this:
# (1)
def spam(filename):
for line in file(filename):
do_something_with(line)
It is indeed pseudo-codely beautiful. But I gather that it is not
correct to do this, and that instead one should do something l
05-09-2009 Steven D'Aprano wrote:
On Fri, 04 Sep 2009 22:37:15 +0200, Jan Kaliszewski wrote:
Named tuples (which indeed are really very nice) are read-only, but the
approach they represent could (and IMHO should) be extended to some kind
of mutable objects.
[snip]
What sort of extensions di
Pascale Mourier wrote:
Martin v. Löwis a écrit :
Without having seen any details, I refuse to guess. Most likely, it is
a user mistake.
YES IT IS! Sorry for the inconvenience. I usually start from this
assumption. Yesterday this new student was really agressive, and I
assumed he was right!
kj wrote:
There's something wonderfully clear about code like this:
# (1)
def spam(filename):
for line in file(filename):
do_something_with(line)
It is indeed pseudo-codely beautiful. But I gather that it is not
correct to do this, and that instead one should do
candide wrote:
>In C, we would manage this with the following statement :
>
>fscanf(foo_file, "Best score : %d", &score);
>
>Does Python provide an equivalent ?
RTFM! :)
In the python 2.5 manual: Chapter 4.2.6 (search pattern 'scanf' on the
index tab of python25.chm)
There are some scanf-pat
kj wrote:
There's something wonderfully clear about code like this:
# (1)
def spam(filename):
for line in file(filename):
do_something_with(line)
It is indeed pseudo-codely beautiful. But I gather that it is not
correct to do this, and that instead one should do som
On Sat, Sep 5, 2009 at 8:00 AM, Terry Reedy wrote:
> Chris Rebert wrote:
>>
>> On Sat, Sep 5, 2009 at 3:13 AM, candide wrote:
>>>
>>> I have a text file and the first line provides the best score of a game.
>>> This
>>> line has the following format :
>>>
>>> Best score : 42
>>>
>>> In order to up
On Sep 5, 1:17 pm, Dave Angel wrote:
> kj wrote:
> > There's something wonderfully clear about code like this:
>
> > # (1)
> > def spam(filename):
> > for line in file(filename):
> > do_something_with(line)
>
> > It is indeed pseudo-codely beautiful. But I gather that
* MRAB (Sat, 05 Sep 2009 17:54:00 +0100)
> Pascale Mourier wrote:
> > Martin v. Löwis a écrit :
> >
> >> Without having seen any details, I refuse to guess. Most likely, it is
> >> a user mistake.
> >
> > YES IT IS! Sorry for the inconvenience. I usually start from this
> > assumption. Yesterday
HELP! So apparently after installing EPD 5.0 (a python 2.5 dist) aside
my main Python installation (2.6) I started getting this error.
-Pure virtual function call
Whenever I open up ActiveState Python, it gets this runtime error
under pythonwin.exe
Already uninstalled EPD but am still getting th
CPython uses reference counting, so an object is garbage collected as
soon as there are no references to it, but that's just an implementation
detail.
Other implementations, such as Jython and IronPython, don't use
reference counting, so you don't know when an object will be garbage
collected, wh
I'm trying to modify an app I wrote a few months ago, but now it dies
on startup (it worked before). The app loads the SQLite Media Monkey
database, and crashes on its first query (when I try to get the number
of podcasts). At the end of this post is a reduced version of the
problem (which produces
Günther Dietrich a écrit :
>
> RTFM! :)
>
> In the python 2.5 manual: Chapter 4.2.6 (search pattern 'scanf' on the
> index tab of python25.chm)
Correct !! For once ;) the Manual gives an inambiguous answer :
--
Simulating scanf() .-- Python does not currently have an equ
Pascale Mourier wrote:
>
>YES IT IS! Sorry for the inconvenience. I usually start from this
>assumption. Yesterday this new student was really agressive, and I
>assumed he was right!
>
>Here's his mistake: with Windows the name of the directory rooted at a
>drive name (say C:) is called 'C:\' n
On Sep 5, 11:29 am, Terry Reedy wrote:
>
> This is a pointless replacement for 'def b(x): return x+a'
And? That has nothing to do with anything I was saying whatsoever.
Point is: any mutable shared state is bad, and making objects
immutable isn't enough to remove all shared state, or even reduce
william tanksley wrote:
I'm trying to modify an app I wrote a few months ago, but now it dies
on startup (it worked before). The app loads the SQLite Media Monkey
database, and crashes on its first query (when I try to get the number
of podcasts). At the end of this post is a reduced version of t
william tanksley wrote:
> Oh, this is Python 2.5 on Windows.
New result: this works on Python 2.6. Obviously the SQLite format
changed between the two runs.
I'll call this "problem solved"; my app appears to run now.
-Wm
--
http://mail.python.org/mailman/listinfo/python-list
MRAB wrote:
> I wonder whether it's complaining about the "as count" part because
> "count" is the name of a function, although you do say that the same
> query works elsewhere.
Hey, good catch. Thanks; I'll change that. (It wasn't the problem, but
no doubt someday it could be.)
-Wm
--
http://m
I've filed a bug report:
http://bugs.python.org/issue6844
Sadly the Twisted developers apparently did not file
a bug report when they were bitten by this ...
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 5, 2:47 pm, Dennis Lee Bieber wrote:
(snip)
> > Finally, I was under the impression that Python closed filehandles
> > automatically when they were garbage-collected. (In fact (3)
> > suggests as much, since it does not include an implicit call to
> > fh.close.) If so, the difference betwe
I'm trying to efficiently "split" strings based on what substrings
they are made up of.
i have a set of strings that are comprised of known substrings.
For example, a, b, and c are substrings that are not identical to each
other, e.g.:
a = "0" * 5
b = "1" * 5
c = "2" * 5
Then my_string might be:
Hello,
I was wondering if there was something like Perl's "require" that allows
you to import a file whose name is specified at run-time. So far I've only
seen imports of modules that are put in the standard module include path.
I'm interested in three seperate problems:
1) being able to import
On Sep 4, 5:56 am, "Jan Kaliszewski" wrote:
> 04-09-2009 o 08:37:43 r wrote:
>
> > Why use a nested function when you already *in* main?
>
> I understand you name global scope as 'main'. But (independently
> of using the __main__ idiom and so on) it is still good idea not to
> place to much code
On Sat, Sep 5, 2009 at 3:23 PM, wrote:
> Hello,
>
> I was wondering if there was something like Perl's "require" that allows
> you to import a file whose name is specified at run-time. So far I've only
> seen imports of modules that are put in the standard module include path.
You'll need to use
On Sat, 05 Sep 2009 22:54:41 +0100, per wrote:
I'm trying to efficiently "split" strings based on what substrings
they are made up of.
i have a set of strings that are comprised of known substrings.
For example, a, b, and c are substrings that are not identical to each
other, e.g.:
a = "0" * 5
On Sep 5, 6:42 pm, "Rhodri James" wrote:
> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote:
> > I'm trying to efficiently "split" strings based on what substrings
> > they are made up of.
> > i have a set of strings that are comprised of known substrings.
> > For example, a, b, and c are substrings
On Sat, 05 Sep 2009 23:54:08 +0100, per wrote:
On Sep 5, 6:42 pm, "Rhodri James" wrote:
On Sat, 05 Sep 2009 22:54:41 +0100, per wrote:
> I'm trying to efficiently "split" strings based on what substrings
> they are made up of.
> i have a set of strings that are comprised of known substrings.
travis+ml-pyt...@subspacefield.org wrote:
> I'm interested in three seperate problems:
>
> 1) being able to import a file that isn't in the standard module include
> path
sys.path.insert(0, "/path/to/module"
module = __import__("module")
del sys.path[0]
Ideally this goes into a function, possib
On Sep 5, 7:07 pm, "Rhodri James" wrote:
> On Sat, 05 Sep 2009 23:54:08 +0100, per wrote:
> > On Sep 5, 6:42 pm, "Rhodri James" wrote:
> >> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote:
> >> > I'm trying to efficiently "split" strings based on what substrings
> >> > they are made up of.
> >> >
On Sat, 05 Sep 2009 14:09:57 -0700, Adam Skutt wrote:
>> Python does not have lambda objects. It has lambda expressions that
>> produce function objects identical except for .__name__ to the
>> equivalent def statement output.
>
> Sure sounds like python has lambda objects to me then... the fact
>
On Sat, 05 Sep 2009 16:14:02 +, kj wrote:
> Finally, I was under the impression that Python closed filehandles
> automatically when they were garbage-collected. (In fact (3) suggests
> as much, since it does not include an implicit call to fh.close.) If so,
> the difference between (1) and (3
On Sat, 05 Sep 2009 04:57:21 -0700, Adam Skutt wrote:
>> > so the fact "Foo" and "Bar" are immutable isn't enough to solve the
>> > problem.
>>
>> This is a side-effect of writing code that relies on global variables.
>> Global variables are generally a bad idea. Global constants are fine.
>
> No
On Sep 4, 6:01 am, The Music Guy wrote:
> I have a peculiar problem that involves multiple inheritance and method
> calling.
>
> I have a bunch of classes, one of which is called MyMixin and doesn't
> inherit from anything. MyMixin expects that it will be inherited along
> with one of several oth
On Sun, 06 Sep 2009 00:29:14 +0100, per wrote:
it's exactly the same problem, except there are no constraints on the
strings. so the problem is, like you say, matching the substrings
against the string x. in other words, finding out where x "aligns" to
the ordered substrings abc, and then dete
Hi all,
I have the following code
import smtplib
from email.mime.text import MIMEText
smtpserver = 'smtp.gmail.com'
AUTHREQUIRED = 1 # if you need to use SMTP AUTH set to 1
smtpuser = 'ad...@myhost.com' # for SMTP AUTH, set SMTP username
here
smtppass = '123456' # for
Hi,
I have released pyKook 0.0.4.
http://pypi.python.org/pypi/Kook/0.0.4
http://www.kuwata-lab.com/kook/
http://www.kuwata-lab.com/kook/pykook-users-guide.html
In this release, recipe syntax is changed (see below).
Overview
pyKook is a smart build tool similar to Make, Rake, Ant, or C
When a python package includes data files like templates or images,
what is the orthodox way of referring to these in code?
I'm working on an application installable through the Python package
index. Most of the app is just python code, but I use a few jinja2
templates. Today I realized that I'm
On Sep 4, 3:01 am, The Music Guy wrote:
> I have a peculiar problem that involves multiple inheritance and method
> calling.
>
> I have a bunch of classes, one of which is called MyMixin and doesn't
> inherit from anything. MyMixin expects that it will be inherited along
> with one of several oth
Matthew Wilson writes:
> Today I realized that I'm hardcoding paths in my app. They are
> relative paths based on os.getcwd(), but at some point, I'll be
> running scripts that use this code, these open(...) calls will fail.
The conventional solution to this is:
* Read configuration settings, w
In <02b2e6ca$0$17565$c3e8...@news.astraweb.com> Steven D'Aprano
writes:
>(3) For quick and dirty scripts, or programs that only use one or two
>files, relying on the VM to close the file is sufficient (although lazy
>in my opinion *wink*)
It's not a matter of laziness or industriousness, but
Ben Finney wrote:
Matthew Wilson writes:
Today I realized that I'm hardcoding paths in my app. They are
relative paths based on os.getcwd(), but at some point, I'll be
running scripts that use this code, these open(...) calls will fail.
The conventional solution to this is:
* Read c
Adam Skutt wrote:
On Sep 5, 11:29 am, Terry Reedy wrote:
This is a pointless replacement for 'def b(x): return x+a'
And? That has nothing to do with anything I was saying whatsoever.
Agreed. However, posts are read by newbies.
Posts that promote bad habits are fair game for comment.
Py
On 2009-09-05, Pascale Mourier wrote:
> Well, os.listdir('C:') instead of raising an exception, for
> some reason behaves like os.listdir('.').
Windows (and DOS) have worked like that for decades. A lone
drive letter always refers to the "current directory" on that
drive. It's been that way si
On Sep 5, 2:37 pm, kennyken747 wrote:
> HELP! So apparently after installing EPD 5.0 (a python 2.5 dist) aside
> my main Python installation (2.6) I started getting this error.
>
> -Pure virtual function call
>
> Whenever I open up ActiveState Python, it gets this runtime error
> under pythonwin.e
I got the same bug.
Traceback (most recent call last):
File "./script1.py", line 30, in
call(["python", "script2.py", "arg1"], stdout=sys.stdout, stderr=STDOUT)
File "/usr/lib/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python
I got the same bug.
Traceback (most recent call last):
File "./script1.py", line 30, in
call(["python", "script2.py", "arg1"], stdout=sys.stdout, stderr=STDOUT)
File "/usr/lib/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python
On Sun, 06 Sep 2009 01:51:50 +, kj wrote:
> In <02b2e6ca$0$17565$c3e8...@news.astraweb.com> Steven D'Aprano
> writes:
>
>>(3) For quick and dirty scripts, or programs that only use one or two
>>files, relying on the VM to close the file is sufficient (although lazy
>>in my opinion *wink*)
>
## python 2.6.2
from tkFileDialog import askopenfilename, askdirectory
def nowindow(function):
def windowless():
from Tkinter import Tk
Tk().withdraw()
return function()
return windowless
getfilename = nowindow(askopenfilename)
getdirectoryname = nowindow(askdirec
On Fri, 04 Sep 2009 15:28:10 -0700, Arnon Yaari wrote:
> Hello everyone.
> Perhaps I'm missing something, but I see several problems with the two
> hex-conversion function pairs that Python offers: 1. binascii.hexlify
> and binascii.unhexlify 2. bytes.fromhex and bytes.hex
>
> Problem #1:
> bytes
On Sat, Sep 5, 2009 at 6:51 PM, kj wrote:
> In <02b2e6ca$0$17565$c3e8...@news.astraweb.com> Steven D'Aprano <
> st...@remove-this-cybersource.com.au> writes:
>
> >(3) For quick and dirty scripts, or programs that only use one or two
> >files, relying on the VM to close the file is sufficient (alt
Steven D'Aprano wrote:
On Fri, 04 Sep 2009 06:36:59 -0700, Adam Skutt wrote:
Nope, preventing mutation of the objects themselves is not enough. You
also have to forbid variables from being rebound (pointed at another
object).
Right. What's needed for safe concurrency without global lock
80 matches
Mail list logo