I think Python is a OO and lite version of matlab

2006-12-07 Thread Allen
Does anyone agree with me?
If you have used Matlab, welcome to discuss it.

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: I think Python is a OO and lite version of matlab

2006-12-08 Thread Allen

> Sure, and earth is a heavy version of a basketball. If all you have is
> a hammer...
>

It is not make sense to compare earth and basketball.
I think Python introduced many idea of matlab.

If you have used matlab, you will say that they are very very similar,
except that matlab was born years earlier and is used mainly in the
area
of matrix calculation.

I do not mean Python shall feel ashamed for it. We will be pleased that
Python 
does absorb many successful ideas of computer languages.

-- 
http://mail.python.org/mailman/listinfo/python-list


Set PyObject value from C extension

2007-06-11 Thread Allen
I have the PyObject pointers, and want to set different type of values
to them.

For example,

INT8 nValue1 = 0;
INT16 nValue2 = 1;
FLOAT32 fValue = 1.0f;

PyObject* var1 <= nValue1
PyObject* var2 <= nValue2
PyObject* var3 <= nValue3

How to do it?

Regards,
Allen Chen

-- 
http://mail.python.org/mailman/listinfo/python-list

How can I parse False from c extension?

2007-06-12 Thread Allen
>From python command, I call C extension method
>>> import PyRPC
>>> PyRPC.addBool(False)

In C extension, I know parse integer value like this:
PyArg_ParseTuple(args, "i", &nValue);

But, how can I parse the False value?

Regards,
Allen Chen

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How can I parse False from c extension?

2007-06-12 Thread Allen
On 6 12 ,   5 21 , "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Tue, 12 Jun 2007 05:07:13 -0300, Allen <[EMAIL PROTECTED]>
> escribió:
>
> >> From python command, I call C extension method
> >>>> import PyRPC
> >>>> PyRPC.addBool(False)
>
> > In C extension, I know parse integer value like this:
> > PyArg_ParseTuple(args, "i", &nValue);
>
> > But, how can I parse the False value?
>
> Parse them as integers, with False==0 and True==1.
>
> --
> Gabriel Genellina

Thanks!
It does work.

-- 
http://mail.python.org/mailman/listinfo/python-list

In C extension .pyd, sizeof INT64 = 4?

2007-06-12 Thread Allen
My C extension works wrong, and debug it, found that sizeof (INT64) =
4, not 8.
I compile on Windows XP platform.
Please tell me how to fix it to support INT64?
Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-12 Thread Allen
On 6 12 ,   6 03 , Allen <[EMAIL PROTECTED]> wrote:
> My C extension works wrong, and debug it, found that sizeof (INT64) =
> 4, not 8.
> I compile on Windows XP platform.
> Please tell me how to fix it to support INT64?
> Thanks.

I find it is strange. In an exe win32 console project, sizeof(INT64) =
8.

My code is just like this:

/* my.h header file */

#ifdef __cplusplus
extern "C" {
#endif

static PyObject* method(PyObject* self, PyObject *args);

#idef __cplusplus
}
#endif

/* my.cpp source file */
PyObject* method(PyObject* self, PyObject *args)
{
   INT64 nValue; /* LINE_HERE */
   INT32 nRet;
   nRet = DoSomeCOperations(nValue);
   return PyBuildValue("i", nRet);
}

If I changed INT64 nValue to be static INT64 nValue at LINE_HERE, it
is ok.
Why?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-12 Thread Allen
On 6 12 ,   8 08 , "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Tue, 12 Jun 2007 08:39:43 -0300, Allen <[EMAIL PROTECTED]>
> escribió:
>
> > PyObject* method(PyObject* self, PyObject *args)
> > {
> >INT64 nValue; /* LINE_HERE */
> >INT32 nRet;
> >nRet = DoSomeCOperations(nValue);
> >return PyBuildValue("i", nRet);
> > }
>
> > If I changed INT64 nValue to be static INT64 nValue at LINE_HERE, it
> > is ok.
> > Why?
>
> I don't know, but I don't see either where Python is involved... you don't
> use any argument and the returned Python object is not an INT64...
>
> --
> Gabriel Genellina

The problem is obviously compiler involved.
But I don't know why the sizeof INT64 is changed to be 4.

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-12 Thread Allen
On 6 13 ,   4 06 , "Martin v. Lo"wis" <[EMAIL PROTECTED]> wrote:
> Allen schrieb:
>
> > My C extension works wrong, and debug it, found that sizeof (INT64) =
> > 4, not 8.
> > I compile on Windows XP platform.
> > Please tell me how to fix it to support INT64?
>
> What *is* INT64? It's not a builtin type of standard C, it isn't
> defined by Microsoft C, and it isn't predefined by Python.
>
> So it must be something that you have defined, and apparently
> incorrectly. How did you define it?
>
> Regards,
> Martin

Thanks for your reply.

I defined in this way:

#ifndef WIN32
typedef long long   INT64;
#else
typedef __int64 INT64;
#endif

I feel it strange that when I use INT64 as local variable, it will run
error.
When I change the local variable to be static or global, it will be
ok.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-12 Thread Allen
On 6 13 ,   9 00 , Allen <[EMAIL PROTECTED]> wrote:
> On 6 13 ,   4 06 , "Martin v. Lo"wis" <[EMAIL PROTECTED]> wrote:
>
> > Allen schrieb:
>
> > > My C extension works wrong, and debug it, found that sizeof (INT64) =
> > > 4, not 8.
> > > I compile on Windows XP platform.
> > > Please tell me how to fix it to support INT64?
>
> > What *is* INT64? It's not a builtin type of standard C, it isn't
> > defined by Microsoft C, and it isn't predefined by Python.
>
> > So it must be something that you have defined, and apparently
> > incorrectly. How did you define it?
>
> > Regards,
> > Martin
>
> Thanks for your reply.
>
> I defined in this way:
>
> #ifndef WIN32
> typedef long long   INT64;
> #else
> typedef __int64 INT64;
> #endif
>
> I feel it strange that when I use INT64 as local variable, it will run
> error.
> When I change the local variable to be static or global, it will be
> ok.

I feel very very sorry.
It is my fault.
I used INT64 and initialize its value from PyArg_ParseTuple.
The code is PyArg_ParseTuple(args, "l", &nValue).
It should be PyArg_ParseTuple(args, "L", &nValue).

Thanks all of you.

Regars,
Allen Chen

-- 
http://mail.python.org/mailman/listinfo/python-list


How to format a string from an array?

2007-06-13 Thread Allen
a = range(256)
I want to output the formated string to be:
00 01 02 03 04 05 06 07   08 09 0a 0b 0c 0d 0e 0f
10 11 12 13 14 15 16 17   18 19 1a 1b 1c 1d 1e 1f

f0 f1 f2 f3 f4 f5 6 f7   f8 f9 fa fb fc fd fe ff

How to do it?

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-13 Thread Allen
On 6 13 ,   11 55 , "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > I used INT64 and initialize its value from PyArg_ParseTuple.
> > The code is PyArg_ParseTuple(args, "l", &nValue).
> > It should be PyArg_ParseTuple(args, "L", &nValue).
>
> That's still incorrect. For the L format flag, use PY_LONG_LONG,
> not your own INT64 type. More generally: always use the type
> documented in
>
> http://docs.python.org/api/arg-parsing.html
>
> Regards,
> Martin

PY_LONG_LONG is decleared as __int64 on windows. There is no
difference.

Regards,
Allen Chen

-- 
http://mail.python.org/mailman/listinfo/python-list

Is there any way to catch expections when call python method in C++

2007-06-13 Thread Allen
I use try catch, but cannot catch the execeptions of execution python
method.

PYCALL_API void PyCall(const char * pszModule, const char * pszFunc,
void * pArg)
{
if (pszModule == NULL || pszFunc == NULL)
{
return;
}

Py_Initialize();

PyObject * pModule = NULL;
PyObject * pFunc   = NULL;

try {

pModule = PyImport_ImportModule(pszModule);
pFunc   = PyObject_GetAttrString(pModule, pszFunc);

PyEval_CallObject(pFunc, (PyObject*)pArg);
} catch (...) {
   fprintf(stderr, "Error: call python method failed");
}

Py_Finalize();
}

Can I catch it from C++? Thank you.

Regards,
Allen Chen

-- 
http://mail.python.org/mailman/listinfo/python-list

[email protected]

2009-02-20 Thread Allen
I am using Python with cx_oracle to load an excel spreadsheet into an
Oracle table. There are lots of text on the spreadsheet that have "&"
in them which I want to keep in the table. But inserting those text
will fail. Is there a work around for this? I can filter out the
failed insert statements and in SQLPLUS set define off  to run those
statements, but it would be nice to insert "&" directly in PYTHON.

Allen
--
http://mail.python.org/mailman/listinfo/python-list


How to distribute C/C++ python extension module on Linux?

2008-12-05 Thread Allen
I have build an extension module PyRPC.so (why not be libPyRPC.so?).
The PyRPC.so uses API in libRPCPacker.so.
How to distribute the PyRPC.so?

I just put PyRPC.so and libRPCPacker.so in the same folder.
And under this folder, run python.
It tells PyRPC module cannot find a method in libRPCPacker.so.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zipping python modules

2008-06-17 Thread Allen

Larry Bates wrote:

Brian Vanderburg II wrote:
I've installed Python 2.5 on MSW and it works.  I'm preparing it to 
run from a thumb drive so I can run applications by dropping them onto 
the python.exe or from command line/etc.  It works but the size is 
quite large.  I've compressed most of the executables with UPX even 
the dlls under site-packages, but is there a way I could compress the 
top-level 'lib' directory into a python.zip instead so save some 
space, and do I need the 'test' directory (which is about 10MB itself)?


Brian Vanderburg II


With thumb drives now being 2-4Gb what possible need would there be to 
worry about 10Mb?  Remember by zipping things you are trading 
performance for size as well.


-Larry


My python 'portable' version is about 150 MB (wxPython, PyQT, and a few 
others), but I'm going to purchase one of those nice pocket hard drives 
with plenty of space :)  I did remove the *.pyo files for the install 
for now and just let the scripts use the *.pyc, and most of the test 
suites which I assume are use only when building/testing the extensions 
so I probably won't need at runtime hopefully.


Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Save turtle state?

2008-06-17 Thread Allen
I'm using the turtle module in Python.  Is there a way to save the turle 
state at any moment for recursive algorithms to easily return the turtle 
to an earlier point for another branch/etc?


Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Re: Ternary operator alternative in Ptyhon

2008-06-18 Thread Allen

kretik wrote:
I'm sure this is a popular one, but after Googling for a while I 
couldn't figure out how to pull this off.


Let's say I have this initializer on a class:

def __init__(self, **params):

I'd like to short-circuit the assignment of class field values passed in 
this dictionary to something like this:


self.SomeField = \
params.has_key("mykey") ? params["mykey"] : None)

Obviously I know this is not actual Python syntax, but what would be the 
equivalent? I'm trying to avoid this, basically:


if params.has_key("mykey"):
self.SomeField = params["mykey"]
else:
self.SomeField = None

This is not a big deal of course, but I guess my main goal is to try and 
figure out of I'm not missing something more esoteric in the language 
that lets me do this.


Thanks in advance.


The syntax is a bit different, but:

result = (true_value if condition else false_value)

is how it is in Pytthon:

self.SomeField = (params['mykey'] if params.has_key('mykey') else None)



Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Adding functions to an existing instance

2008-06-26 Thread Allen
I need a way to add a method to an existing instance, but be as close as 
possible to normal instance methods.  Using 'new' module or such code as 
'def addfunc(...): def helper(...) .. setattr(...)' causes a cyclic 
reference which requires using 'gc.collect' to release the object.  Also 
'new' is deprecated.  I also made a helper that uses weakref, but the 
problem is when the object is gone, existing instance method object 
would not work:



f = myobject.function
myobject = None
f() <--- would not work if it holds weak ref to myobject


The best I can come up with is to create a parent class and try to 
simulate as best as possible.  The code below works with no cyclic 
references that would be cause by 'new.instancemethod' etc, and without 
the weakref as well.  Is there a simpler way of achieving the same 
without cyclic references?  I know this is 'monkey patching' but for a 
small project I'm working on it is useful to be able to add functions 
dynamically to one instance without adding it to another instance of the 
same class, etc.



class InstanceFunctionHelper(object):
class FunctionCaller(object):
def __init__(self, instance, func):
self.__instance = instance
self.__func = func

def __call__(self, *args, **kwargs):
return self.__func(self.__instance, *args, **kwargs)

def add_instance_function(self, func, name = None):
if name is None:
name = func.__name__

if hasattr(self, name):
delattr(self, name)

try:
self._instance_funcs[name] = func
except AttributeError:
self._instance_funcs = {name: func}

def __setattr__(self, name, value):
funcs = getattr(self, '_instance_funcs', None)
if funcs and name in funcs:
del funcs[name]

object.__setattr__(self, name, value)

def __delattr__(self, name):
funcs = getattr(self, '_instance_funcs', None)
if funcs and name in funcs:
del funcs[name]
else:
object.__delattr__(self, name)

def __getattr__(self, name):
if name == '_instance_funcs':
raise AttributeError

funcs = object.__getattribute__(self, '_instance_funcs')

if name in funcs:
return InstanceFunctionHelper.FunctionCaller(self, funcs[name])

raise AttributeError



x = 0
class Blah(InstanceFunctionHelper):
def __init__(self):
global x
x += 1
def __del__(self):
global x
x -= 1

def Action(self, value):
print self
print value

a = Blah()
a.add_instance_function(Action)
a.Action(5)
a = None
print x

--
http://mail.python.org/mailman/listinfo/python-list


Re: Adding functions to an existing instance

2008-06-26 Thread Allen

[EMAIL PROTECTED] wrote:

On 26 juin, 17:18, Allen <[EMAIL PROTECTED]> wrote:

I need a way to add a method to an existing instance, but be as close as
possible to normal instance methods.


def set_method(obj, func, name=None):
  if not name:
name = func.__name__
  setattr(obj, name, func.__get__(obj, type(obj)))

class Toto(object):
  pass

toto = Toto()

def titi(self):
  print self

set_method(toto, titi)



I tried that.  func.__get__(obj, type(obj)) creates a bound method and 
then sets an attribute to that, creating a cyclic reference.  toto 
contains a reference to the bound method, the bound method contains a 
reference to the instance toto.


However it does eliminate the need for FunctionCaller.  Instead of:

return InstanceFunctionHelper.FunctionCaller(self, funcs[name])

__getattr__(...) can just do:

return funcs[name].__get__(self, type(self))

to get the same behavior.

All of the extra __setattr__ and __delattr__ exist so that if the 
attribute is set after a function is set, it will delete the function so 
that later deleting the attribute will not make the function visible again.



Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite3 alternative option

2008-06-26 Thread Allen

Gandalf wrote:

Hi every one I'm looking for a good alternative db to replace sqlite

I'm using pySQlite3, And I tried to translate very big database from
Mysql to sqlite.
I generated through  PHP a python script that insert 200,000 records
to my sqlite db and took me more then 5 hours and managed to insert
only  100,000 records.
I have almost million records so I need a better solution.


thank you


I don't know if this will help, but using transactions dramatically 
speed things up.  I've only played around with inserting records from 
large CVS files in C++, but outside of a transaction it creates an 
automatic transaction every time an update is made and takes forever, 
but if all the updates are inserted into one transaction and committed 
as one, it is  substantially faster.



Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


PyPy questions

2008-06-30 Thread Allen
I read the website of some information about PyPy, and how a translator 
translates the RPython code to C/CLI/Java/etc to be compiled to a native 
executable or something like that.  Would it be possible, in PyPy, to 
write such an extension that could easily be compiled to native code 
from Python code?  Is this functionality planned in a future release of 
it?  Also, how is the source distributed (If I opt to use it I will end 
up compiling it on a system without an initial python install (a scratch 
linux system)), so does the source include the generated C code?


B. Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Manipulating bitsets in struct

2008-07-09 Thread Allen
I'm using Python to do some simple network programming, and found the 
struct module very useful for such things, but is there a way to easily 
manipulate bitsets such as a 16 bit word being split into 4 parts like 2 
bits, 1 bit, 4 bits, and 9 bits?


Perhaps something like:

struct.pack('!h(2:1:4:9)',2,0,1,100)


Brian Vanderburg II





--
http://mail.python.org/mailman/listinfo/python-list


Using two pythons in an application

2008-08-03 Thread Allen
I'm in the process of developing an application that will use Python for 
a scripting support.  In light of the upcoming changes to Python, I was 
wondering if it is possible to link to and use two different versions of 
 Python so that in the future, scripts could be migrated to the new 
version, and older scripts would still work as well.  If so are there 
any code examples of this.


Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using two pythons in an application

2008-08-03 Thread Allen

Larry Bates wrote:

Allen wrote:
I'm in the process of developing an application that will use Python 
for a scripting support.  In light of the upcoming changes to Python, 
I was wondering if it is possible to link to and use two different 
versions of  Python so that in the future, scripts could be migrated 
to the new version, and older scripts would still work as well.  If so 
are there any code examples of this.


Brian Vanderburg II


Unlike languages you pay for, Python has on real motivation to 
"obsolete" old versions of Python (e.g. to force you to pay of an 
upgrade).  You can still get version 1.5.2 of Python and it is MANY 
years old and most could consider quite obsolete.  I just would not 
worry about it and stick with 2.5/2.6 for development and begin looking 
at Python 3.0 so I can learn what's new and exciting.


-Larry


I agree.  I had wanted for scripts of the program to be able to use the 
new string format method that is only in py3k, but I'm currently looking 
into other template solutions.


Brian Vanderburg II
--
http://mail.python.org/mailman/listinfo/python-list


Re: I'm happy with Python 2.5

2011-02-27 Thread Bill Allen
On Sun, Feb 27, 2011 at 07:34, n00m  wrote:

> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
> (Intel)] on win32
>
> and Idon't move neither up nor down from it (the best & the fastest
> version)
> -- 


Trolls should also be happy...
-- 
http://mail.python.org/mailman/listinfo/python-list


Python SIG for Healthcare IT

2011-03-11 Thread Brad Allen
For those seeking to work with Python-based tools in the healthcare
IT industry, this SIG ("special interest group") can provide a forum to
discuss challenges and hopefully foster knowledge sharing and tools
development. Relevant topics include tools for working with healthcare
standard data formats, industry news items, professional development,
and success stories about Python and open source in the healthcare
industry. Along the way, this SIG page can be updated with links to
relevant projects and resources.

If this interests you, please join this discussion on the mailing list:

  http://mail.python.org/mailman/listinfo/healthcare

This is a new list, so it has no archives as of yet.

If you're attending PyCon today, please join us in a face to face meeting
at 1pm in the Hanover A open space room. As with all open space
meetings, all are welcome, including those with no healthcare IT
background interested in joining the industry.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyPad 2.7.1 (Update 2)

2011-05-14 Thread Bill Allen
Jon,

Looks very promising.  Seems to be an issue with interactive mode.  The
following code behaves as thus:

testvar=raw_input("enter value: ")
print testvar


When run, the prompt from raw_input does print to the output screen as:
enter value:


But when you tap in the lower window to enter the value for the input, the
app closes unexpected.  When I reopen it, what I was working on is still
present.

However, if I tap into the lower window and do this one line at a time from
the interactive prompt >>>, the above code works ok.

A problem?   Or am I missing something?

Anyway, I love this little Python app.   Been wanting something like this
for a long time.  I installed this on my iPhone running iOS 4.3.3 (8J2).

Congrats on a great app!

Bill Allen







<http://www.python.org>
<http://www.catb.org/%7Eesr/faqs/hacker-howto.html><http://taarc.rebelwolf.com>



On Thu, May 12, 2011 at 02:06, Jon D  wrote:

> Hi All,
>
> PyPad 2.7.1 Update 2 is now available on the AppStore. This is mainly
> a bug fix release addressing a number of issues with the interactive
> mode, but does also add some colour highlighting of output.
>
> PyPad is a port of the standard python code base to the iPad. It
> includes most of the standard python modules and can be used for
> testing small scripts or interactively for simple computation.
>
> Regards,
>
> Jon
> --
> http://mail.python.org/mailman/listinfo/python-announce-list
>
>Support the Python Software Foundation:
>http://www.python.org/psf/donations/
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abandoning Python

2011-05-21 Thread Bill Allen
You have ideas, a text editor, and a computer - best get to coding.   What's
stopping you?  You largely want Python, with modifications.   Join the
development team and help implement those changes, or fork your own flavor
and do what you wish.   Right?  You imagine it's an easy task, so get after
it.   Also, quit saying "give me".   I realize that was a troll post, but I
hear people say so many things like this about lots of things.   Sick of
it.  Shut up and do something constructive instead.   Contribute with
effort, rather than a lot of "wishlist" and "give me" talk.




On Sat, May 21, 2011 at 10:49, John J Lee  wrote:

> 
>
> I still like Python after using it for over a decade, but there are
> things I don't like.
>
> What are your favourite up-and-coming languages of the moment?
>
> Here's my wishlist (not really in any order):
>
>  * A widely used standard for (optional) interface declaration -- or
>   something better.  I want it to be easier to know what interface an
>   object has when reading code, and which objects provide that
>   interface.
>  * Lower memory usage and faster execution speed.  Yes, this has been a
>   price worth paying.  But I do want jam on it, please: give me a
>   language where I get most of Python's advantages but don't have to
>   pay it.
>  * Better support for writing correct programs in the form of better
>   support for things like non-imperative programming, DBC, etc. (with
>   the emphasis on "etc").
>  * Perhaps better built-in support for common tasks in common application
>   domains.  Concurrency, persistence, database queries come to mind.
>  * Better refactoring tools, better code analysis tools (lint, search,
>   etc.).
>  * An even larger user base, contributing more and better free and
>   commercial software.
>
> I'm prepared to compromise on the last one.  Obviously, it should do all
> that while preserving all the nice features of Python -- surely an easy
> task.
>
>
> John
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Python stopped installing packages

2019-01-29 Thread Hamish Allen
Hi,

Recently I’ve been trying to code a Discord bot in Python 3.6.2, then I 
realised that some features of discord.py were only available in Python 3.7+ 
(as seen here on the right near the top 
https://docs.python.org/3/library/asyncio.html), so I downloaded 3.7.2. After 
correctly changing the environmental variables to have Python 3.7.2 before 
Python 3.6.2, I tried installing (for installing I was using cmd ‘pip install 
discord.py’, I’m not aware of any other way to install packages) discord.py 
onto Python 3.7.2, but after a few seconds there would be a whole page of red 
error text (attached), then it would say successfully installed. I tried 
importing it in code, but it would return errors implying it was incorrectly 
installed. I asked one of my friends for some help. He suggested uninstalling 
Python 3.6.2 and 3.7.2 and reinstalling Python 3.7.2. I thought this was a 
pretty good idea so I did it. Discord.py still refuses to be installed. I tried 
installing some of the packages I had in 3.6.2, but they had the same sort of 
problem. I’ve tried running the installer to repair the files, but that didn’t 
work. I would appreciate if you could help me. I got discord.py from here: 
https://github.com/Rapptz/discord.py I’ve tried the 3 commands in the 
Installing section and I’ve tried pip install discord.py.

Thanks,
Hamish 
-- 
https://mail.python.org/mailman/listinfo/python-list


Restore a unified diff

2005-01-04 Thread Nick Allen
After using ndiff from difflib, the function restore
would return the sequence that generated the delta.  Unfortunately,
restore does not do the same for unified_diff.  I do not see any similar
function that is intended for unified_diff.  Does anyone know how to 
"restore" from a unified diff generated delta?

Thanks for all your help in advance.

Best Regards,
Nick


Nick Allen <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


A few SWIG/Python questions

2005-03-06 Thread Derek Allen
I'm using SWIG to generate glue code for my embedded/extended python app. 
There are a couple of very frustrating issues that I would like to see if 
anyone else has solutions for:

- Once I have created and initialized a module with SWIG I can call it by 
executing a python file with no problems. However I would like to be able to 
type in a single-line python function and have it execute from my module. 
One line cannot contain both "import _mypackage" and 
"_mypackage.DoFunction("hello")" (and even if it could it would be 
cumbersome). I cannot find a way to manually import (in code) the methods 
from my package prior to executing the single-line instruction. I can get 
the dictionary but that doesn't give me the methods. How do I do this?

- For some reason whatever name I give the module (via %module name) ends up 
with an underscore at its beginning - e.g., _name. I don't know why this is, 
and it was the source of some serious hair-pulling. Is there a way to turn 
this off (without recompiling the swig executable)?

- SWIG in general generates a TON of code for the glue module. Is there a 
way to reduce this?

- SWIG wraps everything with extern "C", which is unnecessary for my code 
and requires me to decorate functions unnecessarily. Is there a way to turn 
this off?

Thanks. 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: random.sample with large weighted sample-sets?

2014-02-16 Thread Charles Allen
How efficient does this thing need to be?

You can always just turn it into a two-dimensional sampling problem by
thinking of the data as a function f(x=item), generating a random x=xr
in [0,x], then generating a random y in [0,max(f(x))].  The xr is
accepted if 0 < y <= max(f(xr)), or rejected (and another attempt made) if
y > max(f(xr)).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-16 Thread Brad Allen
Here is an idea for improving Python official documentation:

Provide a tab-based interface for each entry, with the overview/summary
at the top-level, with a row of tabs underneath:
1. Official documentation, with commentary posted at the bottom
(ala Django documentation)
2. Examples wiki
3. Source code browser with a folding/docstring mode
4. Bugs/To-Do

Of course, building this would take a lot of work, and I'm not offering
to build it myself...I just find that something like this is what I've
been longing for.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-17 Thread Brad Allen

Rakotomandimby (R12y) wrote:
> On Sat, 16 Sep 2006 12:30:56 -0700, Robert Hicks wrote:
>
> > That said...the Python docs are open source. Just start going through
> > them and adding examples.
>
> ASPN (activestate) is a good place for examples...

Yes, but that requires a separate search and depends on an external
organization. Wouldn't it be great if relevant examples were a single
click away from official documentation on any given module?  Examples
could either come in via a wiki approach, or maybe in some cases from
the doctests, which would be nice to have alongside handy access to the
source code.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python getting some positive attention at digg.com

2006-09-17 Thread Brad Allen
This made it to the front page of digg.com yesterday, and is now up to
597 diggs. It has some discussion among folks who are trying to decide
which language to learn next...if any of you Pythonistas have digg
accounts, you might want to chime in.

http://digg.com/programming/Python_Programming_for_Beginners

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-17 Thread Brad Allen

Kay Schluehr wrote:

> Personally, I never found the Python docs particular bad. It is
> rewarding to write good documentation because documentation has
> different aspects i.e. introductory/tutorial, exhaustive/manual and
> design documentation aspects. Not to mention cookbook recipes.
>
> I also observe that the discussion about Python docs is very tool
> centered and my question to all the people who believe to improve the
> Python docs by converting old tuturials into Wikis is that: what are
> the precise requirements? Will an internet connection soon be necessary
> to know how the sys module works?

+1 that downloadability is an important requirement; wiki does not
preclude this
-1 on wiki as the only approach; wiki could be an adjunct to officially
managed docs

> Are there any thoughts about
> integrating 3rd party module/package documentation with the docs of the
> stdlib / tutorial / language ref etc.so that they finally find their
> logical place in the system ?

This could become a natural progression once a full-featured
documentation system is in place.

> Are there any intentions to create an
> informational PEP regarding documentation in any forseeable future or
> shall documentation projects continue to start in the wild?

Sounds like a great idea. We should probably do more brainstorming and
discussion about the particulars before someone spends a lot of time
writing a PEP. We could create a separate topic in this forum, titled
something like 'Ideas for a new PEP on Python.org documentation
structure, UI, and processes'.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythondocs.info : collaborative Python documentation project

2006-09-17 Thread Brad Allen

A.M. Kuchling wrote:
> However, this code isn't used at the moment because I have no idea
> what to do about version controlling the links.  Do we just use the
> current links whenever the HTML is generated?  Make a copy of the list
> and commit them into SVN, so the links cease to be updated but are
> consistent for a given version's docs?  It would be nice to figure out
> what to do.

That sounds like another good reason to handle the examples at
python.org, but it argues against a wiki approach for examples. Maybe
the examples should be part of the same SVN repository; if they are
implemented as doctests they can be validated before each new release.
On the other hand, that probably only works for very simple examples;
I've seen some extensive examples at in the Cookbook that might not fit
well into a doctest.

There could a separate tab for "Links" alongside tabs for
documentation, svn source, doctests, discussion, bugs/requests, wiki.
The links tab might have a disclaimer to the effect of "Your Mileage
May Vary", and each link might have  a date posted next to it. The
links might not all be examples; they could point to alternative tools,
related resources, more discussion -- whatever the community comes up
with. Eventually, someone would have to prune; the dates would help
with that. Also, if folks could rate the links, the best ones might
float to the top.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: does anybody earn a living programming in python?

2006-09-30 Thread Brad Allen
I'll attest that we have a shortage of Python developers in the Dallas
area; in the DFW Python user group (dfwpython.org) we occasionally
encounter local employers who have trouble finding local Python
developers who can take on new work. Most of the group members are
already employed, so the standard answer to the employer is to
recommend hiring experienced developers and train them in Python.
Unfortunately we've seen a few cases where the employer decided to
choose a different technology due to the lack of available Python
talent.  Hopefully this will abate as more programmers understand this
problem and become attracted to Python.

BTW, are some Python-specific job sites:

http://www.python.org/community/jobs/

http://blog.gmane.org/gmane.comp.python.jobs

http://python.jobmart.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon 2007: What talks/tutorials/panels do you want to see?

2006-09-30 Thread Brad Allen
This thread is for posting ideas and general brainstorming about what
kinds
of talks folks would be interested in seeing at PyCon 2007. The idea is
to
inspire volunteer speakers to propose talks that they might not
otherwise
realize would be popular, and to give PyCon organizers a whiff of fresh
community feedback.

So, what do you want to see? What will attract you to travel to PyCon?
Or for that matter, what does your boss need to see on the schedule
to allow you to expense the conference?

The deadline for talks proposals is October 31.

http://us.pycon.org/TX2007/CallForProposals

The deadline for tutorial proposals is November 15.

http://us.pycon.org/TX2007/CallForTutorials

Remember, tutorials are half-day events on the day prior to the main
PyCon days, and have a separate admission price. The tutorial teachers
do receive some financial compensation for their time and preparation.

Also, consider the possibility of panel discussions, which would
compete for time with normal talks but might not require the same
kind of speaker preparation or proposal. Who in the Python community
would you like to see in a panel discussion or "town-hall" style event?

Btw, there is also a wiki for consolidating ideas on talks:

http://us.pycon.org/TX2007/TalkIdeas

-- 
http://mail.python.org/mailman/listinfo/python-list


How can I obtain the exception object on a generlized except statement?

2007-06-10 Thread Chris Allen
I am confused on one aspect of exception handling.  If you specify the
exception object type to match in an except statement it is possible
to also obtain the exception object itself, but I can't figure out how
to get the exception object when I don't specify a match.

for example:

>>> try: urlopen('http://www.google.com')
>>> except socket.error, msg:
>>> print str(msg)

this works and I can do what I like with the exception object (msg).
but I can't do this with a simple except statment.

>>> except msg:

this won't work because it will think msg is the type to match

>>> except ,msg:

syntax error

>>> except *,msg:

syntax error

>>> except (),msg:

Hmm I didn't try that one before I started this post.  It doesn't give
me a syntax error.  I'll experiment.
Even if the above syntax works, is this the way to do this?  It seems
sort of funky.

How do I do this?  Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I obtain the exception object on a generlized except statement?

2007-06-10 Thread Chris Allen
Just what I was looking for thanks Diez and John.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [dfwPython] A Few More Forrester Survey Questions

2007-05-18 Thread Brad Allen
At 10:22 AM -0500 5/18/07, Jeff Rush wrote:
>I'm down to the wire here on answering the Forrester survey but am stumped on
>a few questions I hope someone can help me out with.
>
>1) What -existing- examples of the use of Python to create social
>web applications are there?  These include chat, collaboration,
>forum boards, and editable content pages, RSS feeds.
>
>I know I use a lot of these, but under pressure I'm not coming
>up with a lot of names.  Can you throw a few my way?

I believe youtube.com is written in Python...

Trac is a form of social collaboration for technical people working on
projects.

Obviously Plone is used for a multitude of social collaboration apps...


>2) How easy is it to install an application written in the language?
>How is the application deployed?
>
>I'm having some trouble understanding the difference between
>"deployment" and "installation".  I suspect those words may
>have a special meaning to Java developers (who designed the survey)
>or to Big Corporate IT developers.  Ideas?
>
>I can tell the story of distutils, python eggs and PyPI, and py2exe
>and py2mumble for the Mac -- is there more to the story than that?

py2app for Mac

There is also the drag & drop approach; many Python apps don't
require an installer but can run standalone, especially since many
operating systems already include a Python install by default.

>3) What is the value of the language to developers?
>
>Yeah, a very common, slippery question.  Toss me some good
>explanations of why  -you- value Python.  Readable, free,
>cross-platform, powerful.  What else?  I'll synthesize
>something out of everyone's answers.

Learn once, use everywhere: web apps, GUI apps, command line scripts,
systems integration glue, wrapping libraries from other languages,

Wide range of scale: from quick and dirty tasks to large complex systems.

Wide range of skill: accessible to beginners, but supports advanced
concepts experienced developers require.

Practical syntax which emphasizes elegance and clarity through minimalism

Dynamic language features allow high level and flexible design approach,
boosting productivity.

Robustness - bugs in Python itself are rare due to maturity from long
widespread use.

No IDE required: you go far with simple text editors, but good IDEs are
available.

Good community support due to widespread use and open source nature.

Great as glue language, due to flexible options for calling external binary
apps

Mature ecosystem of libraries, both cross platform and platform native,
and good options for accessing libraries in other languages.

Professional opportunities: Python is in production use in a lot of companies,
who realize it costs less than static languages and is more generally useful
than PHP or Ruby. The only real competitor is Perl, which can be difficult
to manage due to readability problems.


Downsides:
Poor multithreading support for the multiprocessor age (Kill GIL!)
None of the Python web frameworks receive widespread use ala RoR or PHP



-- 
http://mail.python.org/mailman/listinfo/python-list


Global package variable, is it possible?

2007-08-03 Thread Chris Allen
Hello fellow pythoneers.  I'm stumped on something, and I was hoping
maybe someone in here would have an elegant solution to my problem.
This is the first time I've played around with packages, so I'm
probably misunderstanding something here...

Here's what I'd like to do in my package.  I want my package to use a
configuration file, and what I'd like is for the config file to appear
magically in each module so I can just grab values from it without
having to load and parse the config file in each package module.  Not
quite understanding how the __init__.py file works, I expected it to
be as easy as just setting up the ConfigParser object and then I
figured (since a package is a module) that it would now be global to
my package and I could access it in my modules, but I was wrong...  I
don't want to have to pass it in to each module upon init, or anything
lame like that.  A main reason for this is that I'd like to be able to
reload the config file dynamically and have all my modules
automatically receive the new config.  There must be a way to do this,
but seeing how __init__.py's namespace is not available within the
package modules, I don't see a simple and elegant way to do this.
Does anybody have any suggestions?  Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global package variable, is it possible?

2007-08-03 Thread Chris Allen
> Hmm. So maybe something like this makes sense:
>
> __init__py:
> ###
> _default_cfg_file = 'config.conf'
>
> import configure
> def loadcfg(filename):
> configure.cfgfile = filename
> try:
> reload(pkg_module1)
> reload(pkg_module2)
> except NameError:
> pass
> cfg = loadcfg(_default_cfg_file)
>
> import pkg_module1
> import pkg_module2
> # EOF
>
> confgure.py:
> ###
> cfgfile = None
> def loadcfg()
> global cfgfile
> if not cfgfile:
> return None
> file = open(cfgfile)
> cfg = SafeConfigParser()
> cfg.readfp(file)
> return cfg
> # EOF
>
> pkg_module1:
> ###
> import configure
> cfg = configure.loadcfg()
> # EOF
>
> It's a little bit convoluted, but I think it solves most of my
> gripes.  Anybody have a better idea of how to do this?  Thanks again
> Fabio.

Ugh... I wasn't thinking... Of course this won't work either for the
same reasons above.  changing configure.cfgfile from __init__.py will
have no effect on the separate configure instances loaded in other
modules.  I still don't understand why python's __init__.py namespace
isn't global to all modules in the package.  Is this a feature, to
prevent sloppy code?  I think there are certain instances when it
would make sense.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global package variable, is it possible?

2007-08-03 Thread Chris Allen
On Aug 3, 11:16 am, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-03 at 17:51 +, Fabio Z Tessitore wrote:
> > Heve you tried to do something like:
>
> > # module configure.py
> > value1 = 10
> > value2 = 20
> > ...
>
> > # other module
> > from configure import *
>
> > # now I'm able to use value1 value2 etc.
> > var = value1 * value2
>
> Right idea, wrong execution. Note that the OP said "I'd like to be able
> to reload the config file dynamically and have all my modules
> automatically receive the new config."
>
> "from configure import *" will import the settings into the current
> namespace, and subsequent changes in the original namespace will, in
> general, not have any effect in the current namespace.
>
> This should do the trick:
>
> # module configure.py
> value1 = 10
> value2 = 20
> ...
>
> # other module
> import configure
>
> var = configure.value1 * configure.value2
>
> HTH,
>
> --
> Carsten Haesehttp://informixdb.sourceforge.net

It does help thanks.  Okay now after reading your post I really need
to do some experimenting.  I was under the impression when I wrote my
last post that changing an attribute in one modules instance in
__init__.py would not effect other modules.  Sorry, I'm relatively new
to python, and things like this are still sometimes "gotchas!" for me.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global package variable, is it possible?

2007-08-03 Thread Chris Allen
On Aug 3, 10:51 am, Fabio Z Tessitore <[EMAIL PROTECTED]>
wrote:
> Heve you tried to do something like:
>
> # module configure.py
> value1 = 10
> value2 = 20
> ...
>
> # other module
> from configure import *
>
> # now I'm able to use value1 value2 etc.
> var = value1 * value2
>
> bye


Thanks for the response Fabio.  I thought about this, but I don't
think this will work well in my situation either.  Take a look at the
following:

__init__py:
###
_default_cfgfile = 'config.conf'
from configure import *
cfg = loadcfg(_default_cfgfile)

import pkg_module1
import pkg_module2
# EOF


configure.py:

from ConfigParser import SafeConfigParser

def loadcfg(filename):
file = open(filename)
cfg = SafeConfigParser()
cfg.readfp(file)
return cfg
# EOF

pkg_module1:

_default_cfgfile = 'config.conf'
from configure import *
cfg = loadcfg(_default_cfgfile)
# EOF


One problem I see with this approach is that we must define the
configuration file in every module.  Alternatively a better approach
would be to only define the configuration file within configure.py,
however this also seems less than ideal.  I don't like it because I
believe something as important as the location of the package
configuration file, used by all modules, should defined in __init__
not tucked away in one of it's modules.

Another problem is that after the package is loaded and we want to
load in a new config file, what will happen?  With this approach we'll
have to reload every module the package uses for them to read the new
config.  And even then, how do we tell each module what the new config
file is?  If I did define the configuration file in configure.py then
I suppose what I could do is set a cfgfile variable in configure.py to
the new file location and reload all the modules.  If there is no
global package variables, then maybe this isn't so bad...

Hmm. So maybe something like this makes sense:

__init__py:
###
_default_cfg_file = 'config.conf'

import configure
def loadcfg(filename):
configure.cfgfile = filename
try:
reload(pkg_module1)
reload(pkg_module2)
except NameError:
pass
cfg = loadcfg(_default_cfg_file)

import pkg_module1
import pkg_module2
# EOF

confgure.py:
###
cfgfile = None
def loadcfg()
global cfgfile
if not cfgfile:
return None
file = open(cfgfile)
cfg = SafeConfigParser()
cfg.readfp(file)
return cfg
# EOF

pkg_module1:
###
import configure
cfg = configure.loadcfg()
# EOF

It's a little bit convoluted, but I think it solves most of my
gripes.  Anybody have a better idea of how to do this?  Thanks again
Fabio.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global package variable, is it possible?

2007-08-03 Thread Chris Allen
> Only for knowing more about modules: is there a way to dinamically reload
> an already imported module?
>
> bye
> Fabio

Yeah you can reload modules with the reload builtin function.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global package variable, is it possible?

2007-08-06 Thread Chris Allen
On Aug 6, 12:41 am, Bruno Desthuilliers  wrote:
> Chris Allen a écrit :
>
>
>
> > Hello fellow pythoneers.  I'm stumped on something, and I was hoping
> > maybe someone in here would have an elegant solution to my problem.
> > This is the first time I've played around with packages, so I'm
> > probably misunderstanding something here...
>
> > Here's what I'd like to do in my package.  I want my package to use a
> > configuration file, and what I'd like is for the config file to appear
> > magically in each module so I can just grab values from it without
> > having to load and parse the config file in each package module.  Not
> > quite understanding how the __init__.py file works, I expected it to
> > be as easy as just setting up the ConfigParser object and then I
> > figured (since a package is a module) that it would now be global to
> > my package and I could access it in my modules, but I was wrong...  I
> > don't want to have to pass it in to each module upon init, or anything
> > lame like that.  A main reason for this is that I'd like to be able to
> > reload the config file dynamically and have all my modules
> > automatically receive the new config.  There must be a way to do this,
> > but seeing how __init__.py's namespace is not available within the
> > package modules, I don't see a simple and elegant way to do this.
> > Does anybody have any suggestions?  Thanks!
>
> Hi Chris...
> I've read all the thread, and it seems that your problem is mostly to
> share a single dynamic state (the config) between several modules. So I
> do wonder: have you considered the use of the Singleton pattern (or one
> of it's variants...) ?

Thanks, I don't know anything about python singletons.  But I'll look
it up.

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Global package variable, is it possible?

2007-08-06 Thread Chris Allen
On Aug 6, 2:27 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> > I've read all the thread, and it seems that your problem is mostly
> > to share a single dynamic state (the config) between several
> > modules. So I do wonder: have you considered the use of the
> > Singleton pattern (or one of it's variants...) ?
>
> Python modules are effectively singletons. So the idiomatic way to do
> this is to create a module for configuration (perhaps named 'config'),
> import that into every other module that needs it, and use its
> attributes.
>
> --
>  \   "[On the Internet,] power and control will shift to those who |
>   `\   are actually contributing something useful rather than just |
> _o__) having lunch."  -- Douglas Adams |
> Ben Finney

Yes, that's what I ended up doing.  Which is creating a configure
module and then importing it into my modules that use it.  I did
something very similar to the code I posted above.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about a web server

2007-08-20 Thread Chris Allen
On Aug 20, 12:02 am, Frank Millman <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I have just started to dabble in writing my own web server.
>
> I googled for 'python web server', and this is the first hit -
>
>http://fragments.turtlemeat.com/pythonwebserver.php
>
> It has the source code for a simple web server, based on HTTPServer
> and BaseHTTPRequestHandler.
>
> It demonstrates the concepts of
>   - returning a static page
>   - constructing and returning a dynamic page
>   - sending a form with a POST method, and responding to the result
>
> I typed it in and ran it, and it 'just worked', with one exception.
>
> When responding to the initial request, it sends a 200 response,
> followed by a content-type header, followed by an html page. This
> works fine.
>
> When responding to the POST data received, it sends a 301 response, no
> headers, and then the html page.
>
> This works with a Firefox browser on Linux, but MSW IE6 displays 'the
> page cannot be displayed'.
>
> According to the notes, "You don't have to know much about the HTTP
> protocol at all. Except some basic that when the client request
> something it is a "GET", and when the client sends something it is in
> our case a POST. Some basic responce codes like 200 is OK for GET, and
> 404 is file not found, 301 is OK for a Post."
>
> I googled for 'http response code 301', and found that it is actually
> a redirection code. It seems that the notes are misleading.
>
> So I guess my questions are -
>   1. what is the correct response for a POST?
>  I think the answer is 200.
>  However, I assume the author is trying to demonstrate a
> particular technique.
>  Can anyone explain what that may be.
>   2. why does the above work with Firefox?
>
> TIA for any enlightenment.
>
> Frank Millman


Yes HTTP response code 200 does indicate a normal response.  What you
really need to look at to build an HTTP server is is the RFC for
HTTP.  It is HTTP 1.1 is RFC 2616 and you can view it here:
http://www.faqs.org/rfcs/rfc2616.html

That should get you on your way...



-- 
http://mail.python.org/mailman/listinfo/python-list


sys.argv is munging my command line options

2007-08-29 Thread Chris Allen
The command line syntax for my program is as follows:

action key=value key=value...

Where action is a required string (ie. 'backup', 'init', 'restore',
etc) and the program can accept one or more key value pairs.  I know
this syntax isn't standard, but I think it works great for my program
as each key can override an identically named field in a configuration
file, that way the user doesn't have to have two different syntaxes to
do the same thing.  I could do this with --key value, but key=value is
cleaner IMHO because it matches the config file syntax.

But I'm running into a problem with this which is that sys.argv splits
my key=value options.  I need to know the option associations, and
there's no way to know this by inspecting sys.argv.  Can I get access
to the command line string as python saw it before it split it into
sys.argv or is there another way?  Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sys.argv is munging my command line options

2007-08-29 Thread Chris Allen
Thanks for the reply. Oops...  I forget that I was calling the program
from a shell script, the shell script was responsible for goofing up
my command line options.  Solved.  Thanks again.


On Aug 29, 12:28 pm, Ant <[EMAIL PROTECTED]> wrote:
> On Aug 29, 8:11 pm, Chris Allen <[EMAIL PROTECTED]> wrote:
> ...
>
> > But I'm running into a problem with this which is that sys.argv splits
> > my key=value options.  I need to know the option associations, and
> > there's no way to know this by inspecting sys.argv.  Can I get access
> > to the command line string as python saw it before it split it into
> > sys.argv or is there another way?  Thanks.
>
> Could you show us some example code that demonstrates this? The
> following works as expected for me on win32:
>
> # test.py
> import sys
>
> for arg in sys.argv[1:]:
> print arg
>
> >From the command prompt:
>
> C:\0>test.py action key=value key=value
> action
> key=value
> key=value
>
> --
> Ant.


-- 
http://mail.python.org/mailman/listinfo/python-list


GREAT VIDEO! >> http://www.tbn.org/films/videos/To_Hell_And_Back.ram << Just click link to view the free video.......... May 22, 2005 7:37:11 pm

2007-09-05 Thread Allen Bryant
Allen and jessica
Bryant24--
Sent from my T-Mobile Sidekick®
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread Brad Allen
At 6:05 AM -0600 3/9/07, Jeff Rush wrote:
>Prior to PyCon I'd been thinking about some kind of campaign, service or
>documents, that I call "So you think you know Python...".  My initial idea was
>for use by Python programmers, who are honest with themselves, to have a way
>to measure their knowledge.

A interactive Python skills test could be useful, fun, and popular, 
if designed well.
There are a lot of Python programmers who are serious about honing 
their skills,
and enjoy doing so.

Building a good interactive test is a big project; I hope we can get community
buy-in and participation for this idea. I'll volunteer to be a tester, and to
help with brainstorming ideas for content.

At 6:05 AM -0600 3/9/07, Jeff Rush wrote:
>I've been carefully watching Crunchy, about which a talk was given at PyCon,
>for writing tutorials that, with its "doctests" feature, could be used to
>propose tests that pass and require a candidate to write an acceptable
>program.

Crunchy has great possibilities, especially if we can find a good way to use
it on the web instead of requiring a download to run locally. However,
there is an obvious security problem with giving web users access to a Python
interpreter on the web server.

When I discussed this problem with Michael Bernstein at PyCon he suggested
the idea of creating a "chroot jail" for each web session which could run
the Python interpreter in a secure sandbox. That might be easier than giving
each session a whole virtual server.

Are there any experienced sysadmins reading this who know of a practical way
solve this problem so we can have Crunchy tutorials on the web?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread Brad Allen
At 9:10 AM -0800 3/10/07, Michael Bernstein wrote:
>On Sat, 2007-03-10 at 10:01 -0600, Brad Allen wrote:
>
>>  When I discussed this problem with Michael Bernstein at PyCon he suggested
>>  the idea of creating a "chroot jail" for each web session which could run
>>  the Python interpreter in a secure sandbox. That might be easier than giving
>>  each session a whole virtual server.
>
>Note that this wasn't an original idea of mine, I got it from brief
>mentions associated with two existing interactive python-in-a-web-page
>implementations:
>
> Try Python: http://www.mired.org/home/mwm/try_python/
>
> TryPy: http://trac.pocoo.org/wiki/TryPy
>

Cool! The first link appears to work with Firefox and provides a real example
of using a Python interactive prompt via a non-local web interface.
Interestingly, it doesn't seem to use Crunchy, but instead uses TryPy.

Apparently you can't define classes or functions with TryPy, but I recall you
can using Crunchy. This is important for creating tutorials in which you
ask the student to define a class or function to solve a problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python in academics?

2007-11-01 Thread Charles Allen
sandipm:
> seeing posts from students on group. I am curious to know, Do they
> teach python in academic courses in universities?

Bruce Sherwood and Ruth Chabay have an introductory physics text that
uses python for getting students doing computer simulation and
visualization very "early" compared to most course sequences:

<http://www4.ncsu.edu/~rwchabay/mi/>

-- 
Charles Allen
-- 
http://mail.python.org/mailman/listinfo/python-list


package import

2008-02-05 Thread Sean Allen
ok, what am i doing wrong?

in current working directory i have:

t.py
sub/t1.py

t.py is:

import sub.t1

i get:

ImportError: No module named sub.t1

t.py is

import sub

i get:

ImportError: No module named sub.t1

--

i am obviously missing something really basic here.
have tried on multiple machines, linux and mac os x.

thanks in advance.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: package import

2008-02-06 Thread Sean Allen
Thanks. Found that 10 minutes after I sent.

On Feb 6, 2008, at 4:57 AM, Diez B. Roggisch wrote:

> Sean Allen wrote:
>
>> ok, what am i doing wrong?
>>
>> in current working directory i have:
>>
>> t.py
>> sub/t1.py
>>
>> t.py is:
>>
>> import sub.t1
>>
>> i get:
>>
>> ImportError: No module named sub.t1
>>
>> t.py is
>>
>> import sub
>>
>> i get:
>>
>> ImportError: No module named sub.t1
>>
>> --
>>
>> i am obviously missing something really basic here.
>> have tried on multiple machines, linux and mac os x.
>
> http://docs.python.org/tut/node8.html#SECTION00840
>
> Diez
> -- 
> http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Function Overloading and Python

2008-02-24 Thread Allen Peloquin
I have a personal project that has an elegant solution that requires
both true multiple inheritance of classes (which pretty much limits my
language choices to C++ and Python) and type-based function
overloading.

Now, while this makes it sound like I have to resign myself to C++,
which I am not a fan of writing, I have resisted thus far. Who wants
to manage their own memory? No, I have fallen in love with Python, and
so come asking for help.

I have a very large multiple inheritance tree that will be frequently
extended as my project goes on. Let us call these "type A" classes.

I also have a moderately sized single inheritance tree whose task is
to match sets of "type A" parameters in a function. Let us call these
"type B" classes. "Type Bs" have one function, which is extended with
each new child, and overloaded to match varying combinations of "Type
As." The reason for this is code-reuse and eventual matching with
common "type A" parents.

Now, what are my options in Python to dispatch unique code based on
the permutations of "type A" classes without code repetition?
Such as, where in C++...

class B
{
fun(A x, A y, A z)...
fun(A1 x, A y, A z)...
}

class B1
{
fun(A1 x, A y, A z)...
}

Such that any previous behavior is inherited, but behaves
polymorphically because of the single function name.

B1.fun(A(x), A(y), A(z)) == B.fun(A(x), A(y), A(z))
but
B1.fun(A1(x), A(y), A(z) != B.fun(A1(x), A(y), A(z))

Is there a data-structure solution or third party module that would
mimic this behavior?

PEP 3124 got my hopes up, but I was let down when it was deferred.

Thank you for your time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function Overloading and Python

2008-02-24 Thread Allen Peloquin
On Feb 24, 11:44 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Allen Peloquin wrote:
> > class B
> > {
> > fun(A x, A y, A z)...
> > fun(A1 x, A y, A z)...
> > }
>
> > class B1
> > {
> > fun(A1 x, A y, A z)...
> > }
>
> > Such that any previous behavior is inherited, but behaves
> > polymorphically because of the single function name.
>
> Try something like this:
>
> class B(object):
> def fun(x,y,z):
> if isinstance(x, A1):
> return self._fun(x,y,z)
> # ...
>
> def _fun(x,y,z):
> # ...
>
> class B1(B):
> def _fun(x,y,z):
> # ...
>
> Stefan

The problem is that I want to reuse the code of the parent classes
through inheritance, otherwise this would work fine.

I am aware that because of the dynamic typing of Python, there
currently is no type-based function overloading, so I'm looking for
alternate solutions to my design problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python Unable to create file

2008-03-02 Thread Sean Allen

On Mar 2, 2008, at 3:24 AM, kaush wrote:

> On Mar 1, 11:24 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Sat, 01 Mar 2008 22:47:02 -0800, kaush wrote:
>>> I am using Apache and mod_python to service POST/GET requests on MAC
>>> OS. My script tries to create a file
>>
>>> file = open(file_path, 'w')
>>
>>> This fails with the following error
>>
>>> EACCES
>>> Permission denied
>>
>>> What is missing?
>>
>> To state the ovious: the rights to create a file at `file_path`.   
>> Remember
>> that web servers usually have their own "user".
>>
>> Ciao,
>> Marc 'BlackJack' Rintsch
>
> Thanks Marc.
> In Apache what are the ways/directives to set the rights to a folder?

none. you set permissions via the operating system.

chmod would be the command from terminal you are looking for.

or you can do get info on the folder in question via the finder and  
set perms there.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urgent : How to do memory leaks detection in python ?

2008-03-17 Thread Sean Allen


On Mar 17, 2008, at 3:21 AM, Pradeep Rai wrote:


Thanks for your inputs !!!

I have installed python v 2.5 on my Linux machine and executing the  
tool again.


I would like to share the memory status( using free -m command )  
before and after the execution of the tool.


BEFORE EXECUTION


   total   used   free shared 
buffers cached
Mem:  1006148858  0   
8 92

-/+ buffers/cache: 46960
Swap: 2047  0   2047


AFTER EXECUTION
===
  total   used   free shared 
buffers cached
Mem:  1006940 66  0  
49846

-/+ buffers/cache: 44962
Swap: 2047  0   2047


I am unable to find out why 66 MB system memory is left after tool  
execution ? If python does not have memory leaks then where this  
memory is going ?





the free you are looking at is not a  good indication of 'actual  
memory available' in linux.


the number you are intersted is this one:


-/+ buffers/cache: 46960


vs


-/+ buffers/cache: 44962


before execution you had 960 available for use by applications
after execution you had 962 available.

here is one of many pages explaining memory under linux:

http://gentoo-wiki.com/FAQ_Linux_Memory_Management




-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Apache binary error?

2008-03-17 Thread Sean Allen

On Mar 17, 2008, at 10:55 AM, Michael Wieher wrote:

> have simple webpage running
>
> apache, mod_python
>
> the error is binary
> ...binary as in "every other" time I load the page, Firefox keeps  
> telling me I'm downloading a python script, and asks to open it in  
> WINE, which is really strange.
>
> then, alternately, it loads the page just fine.  any clues as to why  
> this is happening?
> -- 

for anything like mod_perl, mod_python etc the first thing i do when i  
get really weird errors
it move to having only one apache process for testing.

might want to start there.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What Programming Languages Should You Learn Next?

2008-03-19 Thread Sean Allen
> Haven't found that killer problem so far ...

for Haskell, check out HAppS. They have
some great web application stuff going on.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does the Python community really follow the philospy of "Community Matters?"

2009-02-02 Thread Craig Allen
I think what you have found is a remarkable characteristic of this
language.  Somehow, perhaps something to do with guido or python
itself, python has a very strong non-dogmatic streak.  It's a relief
really.  If I were to pose a "is python or its community really xyz?"
I would wonder about the "one best way to do something".  One of my
first posts here was about three different ways I had built
singletons. As a result of that I was given a better way, but no one
said any of the other ways were "non-pythonic", it was more, "if you
use option one, make sure of this, if you use option two, don't forget
that"...

As such, python programmers are not there for you to feel superior.
If you want a language for a feeling of community, then it hardly
matters what language you choose, and if you want a good language,
it's secondary if the community gives you that feeling (you should get
it from the language itself).  And since there IS a python community
to go to for help, python has that covered without worrying about it
or making it a language feature.  It may seems cold, instead of giving
warm fuzzies, people will help you with tangible problems, but we are
not starting a commune.  "Uses a langague with sense of community that
advocates  for their language over others" is never in a spec.


-craig
--
http://mail.python.org/mailman/listinfo/python-list


"Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
I must not be understanding something. This is a simple recursive
function that prints all HTML files in argv[1] as its scans the
directory's contents. Why do I get a RuntimeError for recursion depth
exceeded?

#!/usr/bin/env python

import os, sys

def main():
absToRel(sys.argv[1], sys.argv[2])

def absToRel(dir, root):
for filename in os.listdir(dir):
if os.path.isdir(filename):
absToRel(filename, root)
else:
if(filename.endswith("html") or filename.endswith("htm")):
print filename

if __name__ == "__main__":
main()
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
On Feb 17, 4:46 pm, Thomas Allen  wrote:
> I must not be understanding something. This is a simple recursive
> function that prints all HTML files in argv[1] as its scans the
> directory's contents. Why do I get a RuntimeError for recursion depth
> exceeded?
>
> #!/usr/bin/env python
>
> import os, sys
>
> def main():
>     absToRel(sys.argv[1], sys.argv[2])
>
> def absToRel(dir, root):
>     for filename in os.listdir(dir):
>         if os.path.isdir(filename):
>             absToRel(filename, root)
>         else:
>             if(filename.endswith("html") or filename.endswith("htm")):
>                 print filename
>
> if __name__ == "__main__":
>     main()

Please note that I'm not using os.walk(sys.argv[1]) because the
current depth of recursion is relevant to the transformation I'm
attempting. Basically, I'm transforming a live site to a local one and
the live site uses all absolute paths (not my decision...). I planned
on performing the replace like so for each line:

line.replace(root, "../" * depth)

So that a file in the top-level would simple remove all instances of
root, one level down would sub "../", etc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
On Feb 17, 5:31 pm, Peter Otten <[email protected]> wrote:
> Thomas Allen wrote:
> > I must not be understanding something. This is a simple recursive
> > function that prints all HTML files in argv[1] as its scans the
> > directory's contents. Why do I get a RuntimeError for recursion depth
> > exceeded?
>
> > #!/usr/bin/env python
>
> > import os, sys
>
> > def main():
> >     absToRel(sys.argv[1], sys.argv[2])
>
> > def absToRel(dir, root):
> >     for filename in os.listdir(dir):
>
>           filename = os.path.join(dir, filename)
>
> >         if os.path.isdir(filename):
> >             absToRel(filename, root)
> >         else:
> >             if(filename.endswith("html") or filename.endswith("htm")):
> >                 print filename
>
> > if __name__ == "__main__":
> >     main()
>
> Without the addition for a directory and a subdirectory of the same
> name, "dir/dir", os.listdir("dir") has "dir" (the child) in the result list
> which triggers an absToRel() call on "dir" (the parent) ad infinitum.
>
> Peter

I have two problems in this case:

1. I don't know how to reliably map the current filename to an
absolute path beyond the top-most directory because my method of doing
so would be to os.path.join(os.getcwd(), filename)

2. For some reason, only one folder in the directory gets marked as a
directory itself when there are about nine others in the top-most
directory. I don't even know where to begin to solve this one.

I'm sure the first is an easy answer, but what do I need to do to
solve the second?
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
On Feb 17, 6:05 pm, Peter Otten <[email protected]> wrote:
> Thomas Allen wrote:
> > On Feb 17, 5:31 pm, Peter Otten <[email protected]> wrote:
> >> Thomas Allen wrote:
> >> > I must not be understanding something. This is a simple recursive
> >> > function that prints all HTML files in argv[1] as its scans the
> >> > directory's contents. Why do I get a RuntimeError for recursion depth
> >> > exceeded?
>
> >> > #!/usr/bin/env python
>
> >> > import os, sys
>
> >> > def main():
> >> > absToRel(sys.argv[1], sys.argv[2])
>
> >> > def absToRel(dir, root):
> >> > for filename in os.listdir(dir):
>
> >> filename = os.path.join(dir, filename)
>
> >> > if os.path.isdir(filename):
> >> > absToRel(filename, root)
> >> > else:
> >> > if(filename.endswith("html") or filename.endswith("htm")):
> >> > print filename
>
> >> > if __name__ == "__main__":
> >> > main()
>
> >> Without the addition for a directory and a subdirectory of the same
> >> name, "dir/dir", os.listdir("dir") has "dir" (the child) in the result
> >> list which triggers an absToRel() call on "dir" (the parent) ad
> >> infinitum.
>
> >> Peter
>
> > I have two problems in this case:
>
> > 1. I don't know how to reliably map the current filename to an
> > absolute path beyond the top-most directory because my method of doing
> > so would be to os.path.join(os.getcwd(), filename)
>
> Don't make things more complicated than necessary. If you can do
> os.listdir(somedir) you can also do [os.path.join(somedir, fn) for fn in
> os.listdir(somedir)].
>
> > 2. For some reason, only one folder in the directory gets marked as a
> > directory itself when there are about nine others in the top-most
> > directory. I don't even know where to begin to solve this one.
>
> > I'm sure the first is an easy answer, but what do I need to do to
> > solve the second?
>
> If you solve the first properly the second might magically disappear. This
> is what my crystal ball tells me because there is no code in sight...
>
> Peter

I'm referring to the same code, but with a print:

for file in os.listdir(dir):
if os.path.isdir(file):
print "D", file

in place of the internal call to absToRel...and only one line prints
such a message. I mean, if I can't trust my OS or its Python
implementation (on a Windows box) to recognize a directory, I'm
wasting everyone's time here.

In any case, is this the best way to go about the problem in general?
Or is there already a way to recursively walk a directory, aware of
the current depth?

Thanks,
Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
On Feb 17, 7:05 pm, Christian Heimes  wrote:
> Thomas Allen wrote:
> > I'm referring to the same code, but with a print:
>
> > for file in os.listdir(dir):
> >     if os.path.isdir(file):
> >         print "D", file
>
> > in place of the internal call to absToRel...and only one line prints
> > such a message. I mean, if I can't trust my OS or its Python
> > implementation (on a Windows box) to recognize a directory, I'm
> > wasting everyone's time here.
>
> You are under a wrong assumption. You think os.listdir() returns a list
> of absolute path elements. In fact it returns just a list of names. You
> have to os.path.join(dir, file) to get an absolute path.
>
> Anyway stop reinventing the wheel and use os.walk() as I already
> explained. You can easily spot the depth with "directory.count(os.sep)".
>  os.path.normpath() helps you to sanitize the path before counting the
> number of os.sep.
>
> Christian

If you'd read the messages in this thread you'd understand why I'm not
using os.walk(): I'm not using it because I need my code to be aware
of the current recursion depth so that the correct number of "../" are
substituted in.

Also, somebody mentioned wget -R...did you mean wget -r? In any case,
I have all of these files locally already and am trying to replace
absolute paths with relative ones so that a colleague can present some
website content at a location with no internet.

Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-17 Thread Thomas Allen
On Feb 17, 9:08 pm, Christian Heimes  wrote:
> Thomas Allen wrote:
> > If you'd read the messages in this thread you'd understand why I'm not
> > using os.walk(): I'm not using it because I need my code to be aware
> > of the current recursion depth so that the correct number of "../" are
> > substituted in.
>
> I'm well aware of your messages and your requirements. However you
> didn't either read or understand what I was trying to tell you. You
> don't need to know the recursion depths in order to find the correct
> number of "../".
>
> base = os.path.normpath(base)
> baselevel = root.count(os.sep)
>
> for root, dirs, files in os.walk(base):
>     level = root.count(os.sep) - baselevel
>     offset = level * "../"
>     ...
>
> See?
>
> Christian

Very clever (and now seemingly obvious)! That certainly is one way to
measure directory depth; I hadn't thought of counting the separator.
Sorry that I misunderstood what you meant there.

Thanks,
Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-18 Thread Thomas Allen
On Feb 18, 4:51 am, alex23  wrote:
> On Feb 18, 7:34 pm, [email protected] wrote:
>
> > Yeah, but wget -r -k will do that bit of it, too.
>
> Wow, nice, I don't know why I never noticed that. Cheers!

Hm...doesn't do that over here. I thought it may have been because of
absolute links (not to site root), but it even leaves things like . Does it work for you guys?
--
http://mail.python.org/mailman/listinfo/python-list


Re: "Maximum recursion depth exceeded"...why?

2009-02-19 Thread Thomas Allen
On Feb 18, 10:15 pm, [email protected] wrote:
> Thomas Allen  wrote:
> > On Feb 18, 4:51 am, alex23  wrote:
> > > On Feb 18, 7:34 pm, [email protected] wrote:
>
> > > > Yeah, but wget -r -k will do that bit of it, too.
>
> > > Wow, nice, I don't know why I never noticed that. Cheers!
>
> > Hm...doesn't do that over here. I thought it may have been because of
> > absolute links (not to site root), but it even leaves things like  > href="/">. Does it work for you guys?
>
> It works for me.  The sample pages I just tested on it don't use
> any href="/" links, but my 'href="/about.html"' got properly
> converted to 'href="../about.html"'.  (On the other hand my '/contact.html'
> got converted to a full external URL...but that's apparently because the
> contact.html file doesn't actually exist :)
>
> --RDM

Thanks for the help everyone. The idea of counting the slashes was the
linchpin of this little script, and with a little trial and error, I
successfully generated a local copy of the site. I don't think my
colleague knows what went into this, but he seemed appreciative :^)

Thomas
--
http://mail.python.org/mailman/listinfo/python-list


FTP libs for Python?

2009-02-20 Thread Thomas Allen
I'm interested in writing a script to ease deployment of minor changes
on some websites here, and it would involve some SFTP transfers. Do
you know of good alternatives to ftplib, which is relatively low-
level?

Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: FTP libs for Python?

2009-02-20 Thread Thomas Allen
On Feb 20, 9:45 am, coldpizza  wrote:
> Why don't you just use Curl? It does a dozen of protocols including
> SFTP. And if the command line version is not enough for you then there
> are Python bindings for Curl.

I'm actually hoping to eventually package these tools using py2exe for
some co-workers, which is why I'm not looking to Unix utilities

On Feb 20, 9:48 am, Mike Kent  wrote:
> I use Fabric (http://www.nongnu.org/fab/) as my Python-based
> deployment tool, but it uses ssh/scp, not sftp.

I'm looking at Paramiko right now which I saw some people
recommending, as SSH utils are required as well

Thomas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Threading and tkinter

2009-02-20 Thread Craig Allen

> The statement
>
>     x=x+1
>
> (which, by the way, should stylistically be written
>
>     x = x + 1
>

yes I was wondering what "x=x+1" meant until you translated it... oh,
"x = x + 1" of course! I thought to myself.

Oh wait no I'm sarcastic.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Emacs vs. Eclipse vs. Vim

2008-12-01 Thread Craig Allen
I would never tell someone what editor to use in the same way I
wouldn't tell someone what religion to believe in.  Which is to say, I
would tell my kids or other trusting soul... I used emacs for years, I
was eventually convinced to start using nedit, which is quite nice.
For an IDE, which I need for GUI debugging more than all the other
sometimes-nice bells and whistles, I use WingIDE and have found it
pretty cool but not free.  In terms of using it, it's much like any
IDE these days and I think learning one is a good platform for
learning how IDEs tend to work in general, at least until something
genuinely different comes along in that space.

I would say a beginner willing to face a learning curve should make
sure they know how to edit their project outside of the IDE,
understand something about how the IDE makes their project, and so on.
--
http://mail.python.org/mailman/listinfo/python-list


Re: HELP!...Google SketchUp needs a Python API

2008-12-02 Thread Craig Allen
> Just remember thought that if you threat Python like a
> hammer, suddenly everything will look like a bail.
>

don't you mean if you use Python like a pitchfork?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Confused about class relationships

2008-12-02 Thread Craig Allen
what you have is a totally acceptable factory system.  Not sure why
you are using a generator, but that's another matter.

I agree with the previous replies regarding inheritance... this is not
a case for inheritance.  You could, however, have Bar be a borg with
the Bar factory built in as a class method to the Bar class itself if
you want the whole job done by one component.  Questions to lead to or
away from that: will Engine every create things besides Bars?
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to modify a program while it's running?

2008-12-16 Thread Craig Allen
On Dec 16, 10:25 am, Joe Strout  wrote:
> Here's my situation: I'm making an AIM bot, but the AIM server will
> get annoyed if you log in too frequently (and then lock you out for a
> while).  So my usual build-a-little, test-a-little methodology doesn't
> work too well.
>
> So I'd like to restructure my app so that it can stay running and stay
> logged in, yet I can still update and reload at least most of the
> code.  But I'm not sure what's the best way to do this.  Should I move
> the reloadable code into its own module, and then when I give my bot a
> "reload" command, have it call reload on that module?  Will that work,
> and is there a better way?
>
> Thanks,
> - Joe

yes you want reload.  Design the high level part that knows how to log
in to be able to reload the stuff that changes.  My guess is that is
the best way, though I wouldn't be surprised if there are other
solutions.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-12-16 Thread Craig Allen
On Dec 14, 6:38 pm, cm_gui  wrote:
> hahaha, do you know how much money they are spending on hardware to
> make
> youtube.com fast???
>
> > By the way... I know of a very slow Python site called YouTube.com. In
> > fact, it is so slow that nobody ever uses it.

less than they'd spend to implement it in C
--
http://mail.python.org/mailman/listinfo/python-list


Re: I always wonder ...

2008-12-24 Thread Craig Allen
this is one of the most subtle trolls I've ever read.

you sir, are a master!


On Dec 22, 7:53 am, [email protected] wrote:
> ... shouldn't people who spend all their time trolling be doing something
> else: studying, working, writing patches which solve the problems they
> perceive to exist in the troll subject?  Is there some online troll game
> running where the players earn points for generating responses to their
> posts?
>
> --
> Skip Montanaro - [email protected] -http://smontanaro.dyndns.org/

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6, GUI not working on vista?

2008-10-09 Thread Craig Allen
as a 20 year observer of microsoft, I have to say this is not amazing
at all... and I do not mean that as a random put down of Microsoft.
Microsoft often develops things in response to demand... but they
don't always fit in their system well, and thus are not really used in
the spirit of the demand... meanwhile, bullet items are added to many
a software box and magazine review.

I would not presume to know more that Microsoft about that as a
business practice, but as an engineering practice, it speaks for
itself.
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDE Question

2008-10-15 Thread Craig Allen
it's commercial, but I like WingIDE enough to recommend... I run it on
Linux and Mac and it works well.

-craig


On Oct 15, 7:19 am, "Steve Phillips" <[EMAIL PROTECTED]> wrote:
> Hi All,
> I am just wondering what seems to be the most popular IDE. The reason
> I ask is I am currently at war with myself when it comes to IDE's. It
> seems like every one I find and try out has something in it that
> others don't and viceversa. I am in search for the perfect IDE and
> after many months of searching, I always come back to IDLE to do what
> I need to do. I want to use Komodo badly but the one issue I have with
> that is sometimes the auto-complete works and other times it doesn't.
> Even if I carbon copy a script.
>
> Thanks in advance,
> Steve P

--
http://mail.python.org/mailman/listinfo/python-list


Proposal for thread-safe Tkinter

2008-10-23 Thread Allen Taylor
I was given the task of upgrading a Python/Tkinter GUI application to the 
latest versions of Python and Tk. After a while, I realized that the 
application had not been written in a thread-safe manner. Multiple threads 
would simply use the Tk object directly. The application apparently ran fine 
(i.e., didn't crash!) using older versions of Python (2.2) and Tk (8.3), but it 
started to have serious problems (i.e., crashing) after using the latest 
versions.
 
The problem is that there isn't enough budget to fix the whole application. So, 
I invested a bit of time to develop mtTkinter, a thread-safe version of 
Tkinter. Importing mtTkinter actually modifies the original Tkinter in such a 
way to make it thread-safe, recognizing and diverting out-of-thread calls to 
the Tk object creation thread via a queue and an 'after' event. I think it 
works quite well, requiring basically no changes to the application other than 
to import mtTkinter instead of (or in addition to) Tkinter. Even packages that 
use Tkinter (e.g., Pmw) benefit.
 
I would like to contribute this module (single file, about 160 lines) to the 
Python community, but I don't know how. I'm new to Python and am not initiated 
in the deep Pythonic developer world. Can someone give me some pointers? Many 
thanks.
 
Allen B. Taylor
MDA
9445 Airport Road
Brampton, ON  L6S 4J3
905-790-2800 ext. 4350
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: dictionary

2008-10-24 Thread Craig Allen
when I was a baby programmer even vendors didn't have documentation to
throw out... we just viewed the dissassembeled opcodes to find out how
things worked... we never did find out much but I could make the speak
click, and we were happy with it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to examine the inheritance of a class?

2008-10-24 Thread Craig Allen
>
> Developer. NOT User.

I go around and around on this issue, and have ended up considering
anyone using my code a user, and if it's a library or class system,
likely that user is a programmer.  I don't really think there is a
strong distinction... more and more users can do sophisticated
configuration which while not like what we do professionally as
software engineers... is not fundamentally different that programming,
making the distinction arbitrary.

I think the issue here for the term "user" is that there are many
kinds of user, many ways they can customize the system, and the
programmer/developer is just one kind of user.  No?
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to examine the inheritance of a class?

2008-10-24 Thread Craig Allen

> Thank you, Chris.  Class.__bases__ is exactly what I wanted to see.
> And I thought I had tried isinstance(), and found it lacking -- but I
> just tried it again, and it does what I hoped it would do.

While isinstance is no doubt the proper way to access this
information, you may have run into problems because that isinstance
and ducktyping do not always work well together... because having a
particular interface does not mean you inherited that interface.
Checking __bases__ will not solve the problem either though, so best
to use isinstance if you can and document what you do well enough to
help people avoid breaking the assumptions of your system.

not that you didn't know that... but I thought it was worth saying
because I, at least, more and more do meta-class style techniques
which unfortunately do not play well with certain methods of checking
type.

-cba



--
http://mail.python.org/mailman/listinfo/python-list


Re: Structures

2008-11-03 Thread Craig Allen
>
> Care to say more about what they are, not what they're like?
>

I'm not the OP and I may be biased by C++, I can imagine the
complaints when I say, classes are just structures with function
members for working on the structure.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON WORKING WITH PERL ??

2008-11-03 Thread Craig Allen
> article:http://www.linuxjournal.com/article/3882

interesting read, thanks
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON WORKING WITH PERL ??

2008-11-03 Thread Craig Allen
> article:http://www.linuxjournal.com/article/3882

even if it is by Eric Raymond
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the instance reference of an object

2008-11-04 Thread Craig Allen
>
> If the assert statement fails (and it does), then no copy was made and
> Python is not call-by-value.
>
> So Python is not call-by-value, and it's not call-by-reference, so ...
> either Python doesn't exist, or it uses a different calling convention.
>

coming from C/C++ Python seemed to me call by reference, for the
pragmatic reason you said, modificaitons to function arguments do
affect the variable in the caller.  The confusing part of this then
comes when immutable objects are passed in. You still get a reference,
but rather than complaining if you change the value of that parameter
at might happen if immutible was "const" and the code was const-
correct. Honestly I understand how this can change the callBy paradigm
I don't see it that way (though I've duly remembers call-by-sharing
and call-by-object) for communication purposes).  I see it as a factor
of the way variable names are rebound, that is, the "quirk" I remember
is not about how entities are passed to functions, but the quirk of
how python deals with modifications to "immutibles".

That is, python lets you change object references pointing to
immutibles, which looks like changing the value referenced,  by
rebinding.

So is that objectionable?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the instance reference of an object

2008-11-04 Thread Craig Allen
On Nov 4, 11:06 am, Joe Strout <[EMAIL PROTECTED]> wrote:
> On Nov 4, 2008, at 7:42 AM, Craig Allen wrote:
>
> > coming from C/C++ Python seemed to me call by reference, for the
> > pragmatic reason you said, modificaitons to function arguments do
> > affect the variable in the caller.  The confusing part of this then
> > comes when immutable objects are passed in.
>
> Yes, you stepped in the wrong direction right away and led yourself  
> into a morass of contradictions.
>
> The correct way to look at it is that a Python reference is like a C++  
> pointer.  C++ pointers are passed by value (unless you add & to  
...
> I'd be very interested in hearing whether, as a C/C++ user, the above  
> explanation is clear and makes sense to you.
>

joe, yes, it makes perfect sense. In my defense my priority was
figuring out what was going on in terms of what happens passing in
various types of arguments, rather than what things are called. Also,
as a C/C++ programmer my perspective is that the program is the
interpreter, and so I try to think what the interpreter is doing.
This is ke because after 15 years of statically linked languages (no
one calls them this any more due to dynamically linked libraries) you
get used to things evaporating at compile time, the name "x" for a
variable has no status as a real entity at run time. It is a name
through which you communicate with the compiler only, the compiler has
no need to represent it in the runtime program.  I think a lot of this
language history is based on terminology that does not have to
consider this name as a real entity at runtime.

When you consider the status of the entity "x" in "x=1" in python, it
is a pointer, and python looks like pass by value.

The need for a different name comes from the fact that using pointers
ubiquitously like this leads to behavior much more like pass by
reference.

I'm open to pass-by-sharing, or pass-by-object, but neither is
perticularly intuitive, not as obvious in meaning as pass-by-val or
pass-by-reference (or call-by-xxx). I suppose I'd like pass-by-name as
more a description, as "name" to me has a similar sense to pointer, at
least in a language that preserves the name as a runtime entitity
(making C/C++ languages which compile away names).

What happens in python is clear to me, I think I understand what the
program, CPython is doing... the language still needs to settle.

Thanks for the reply, it does help me find a better way to discuss
what I understand about python and calling mechanics in general.

cheers,
craig
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the instance reference of an object

2008-11-12 Thread Craig Allen

> arguably even older than that to Lisp.
>

Firstly, thanks to those that have responded to my part in this
debate, I have found it very informative and interesting as I have the
entire thread.  However, with regard to comments that I led myself
astray, I want to reiterate the one thing I find determinably
important in this... I did not go astray because I did not fret what
the words meant and try to draw anything from that. I learned exactly
what would happen when I passed arguments different ways, and I
learned that well and accurately. Then I mused what to call it all. At
no time was I astray because I think to really be astray would be to
have a misunderstanding on what happens, not on what we call what
happens.

but I will concede that trying to use call-by-name is not a viable
idea as it's yet another term that is already taken. I did not think
too hard what the distinction is, and as far as I know it's as good a
candidate for what we call it as anything else, but I certainly don't
want to fight for the term.  Whatever we call the passing semantics
and methods in Python... it will not change what I understand about
what happens with certain kinds of calls vs others.

cheers.
--
http://mail.python.org/mailman/listinfo/python-list


Re: duck-type-checking?

2008-11-13 Thread Craig Allen
> This is better achived, not by littering the functional code unit with
> numerous assertions that obscure the normal function of the code, but
> rather by employing comprehensive unit tests *separate from* the code
> unit.

that doesn't seem to work too well when shipping a library for someone
else to use... we don't have access to the caller's code that needs to
be checked.  I suppose if the intent is to have a true assert, that
does nothing in shipped code, then you can argue that testing
addresses some of the issues, but one, not all of them, specifically,
not the part where the problem is ably reported, and two, I don't
think we can assume assert meant that sort of assert macro in C which
compiles away in release versions.

Asserts also do not litter code, they communicate the assumptions of
the code.  I like the idea of a general duck-type assertion and would
probably use that, especially since I also have arguments which can be
multiple objects, each with their own interface but similar meaning...
i.e. lower level file objects can be passed in, or my higher level
abstraction of the same file.
--
http://mail.python.org/mailman/listinfo/python-list


Re: duck-type-checking?

2008-11-13 Thread Craig Allen

> since both are equally informative when it comes to tracing the faulty
> assignment.
>

steve, they are not equally informative, the assertion is designed to
fire earlier in the process, and therefore before much mischief and
corruption can be done compared to later, when you happen to hit the
missing attribute.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-17 Thread Craig Allen
> >> * Do all objects have values? (Ignore the Python
> >>  docs if necessary.)
>
> > If one allows null values, I am current thinking yes.
>
> I don't see a difference between a "null value"
> and not having a value.
>

I think the difference is concrete... an uninitialized variable in C
has no value, I'd say, because the value it will have is
indeterminate, it will be whatever happens to be sitting at that
location in memory, inconsistent.  If that variable is initialized to
some value representing "none", like NULL, then it has a consistent
value of "none".  There is no way to have an uninitialized variable in
python, so they are always consistently set, so they always have
values.

?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding the instance reference of an object

2008-11-19 Thread Craig Allen
I've just come to the conclusion it's not possible to call functions
in python, to do so is undefined and indeterminate, like dividing by
zero.  Henceforth no calling functions for me as clearly it's the
devil's playground.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Opening for Python Programmer at Newport Beach

2009-03-03 Thread Craig Allen
On Mar 3, 10:17 am, Cool Dude  wrote:
> Hello ,
> This is Aniket from Techclique, a New Jersey based software
> development and IT consulting firm providing top quality technical and
> software professionals on a permanent and contractual basis to
> Government and commercial customer including fortune 500 companies and
> most of states and federal governments. I am contacting you to see if
> you are comfortable to the skills mentioned below, please forward
> resume to this e-mail address [email protected]
>
> Python Programmer (someone with industry knowledge/asset mgt)
> Location: Newport Beach, CA (Need Local)
> Duration: 6+ months
> Note: Communication MUST be perfect!, Plus submit with 3 professional
> references
>
> Python programming skills (with web development and dynamically
> generated charts/plots in particular) and working knowledge of Linux/
> UNIX Shell Scripts and SQL.
> Knowledge of Python integration with C/C++ - a definite plus.
>
> Qualifications/Requirements
> * 3+ years of Python programming on Linux/Unix platform; recent (2007)
> required
need programmer to write bot that doesn't multipost... please submit
three references so I can check to see if you've ever multiposted on
usenet.

> * Programming skills building forms, lay-outs, charts, and graphing
> required
> * Designing, coding, and testing web based applications preferred.
> * Strong organizational, oral and written communications skills
> * High energy/self starter with the ability to work independently
> within the firm*s demanding and highly focused environment
>
> Thanks & Regards,
> Aniket
> Techclique Inc.
> Jersey City, NJ
> Email: [email protected]
> Yahoo IM : [email protected]
> Contact No : 732-357-3844

--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >