Re: ctypes LoadLibrary search path

2011-08-05 Thread Santoso Wijaya
Nevermind. I figured it out (d'oh!). I had to append to `os.environ['PATH']`, not `sys.path`! ~/santa On Fri, Aug 5, 2011 at 2:13 PM, Santoso Wijaya wrote: > Hi, > > Can anyone enlighten me to the search path mechanism in ctypes' > LoadLibrary? I have a DLL th

ctypes LoadLibrary search path

2011-08-05 Thread Santoso Wijaya
Hi, Can anyone enlighten me to the search path mechanism in ctypes' LoadLibrary? I have a DLL that resides elsewhere that is not in any default search path. I tried adding the path to `sys.path` before attempting to load said DLL but I still get "WindowsError: [Error 126] The specified module coul

Re: py to exe converter

2011-03-21 Thread Santoso Wijaya
t; > Alan > > -- > On 21/03/2011 19:47, Santoso Wijaya wrote: > > There's also py2exe: http://www..py2exe.org/ <http://www.py2exe.org/> > > ~/santa > > > On Mon, Mar 21, 2011 at 11:06 AM, Alan Harris-Reid < > a...@baselinedata.co.uk&g

Re: py to exe converter

2011-03-21 Thread Santoso Wijaya
There's also py2exe: http://www.py2exe.org/ ~/santa On Mon, Mar 21, 2011 at 11:06 AM, Alan Harris-Reid wrote: > On 19:59, PATRICIA MEDINA wrote: > > I know there is a converter for python 2.x to executable file, but is > there one for python 3.x yet? > > > I use cx_Freeze without any problems

Re: Python 3.2 Debug build

2011-03-17 Thread Santoso Wijaya
Looks like something tripped over whitespaces in path names for svn tools. Try checking out a working copy from the hg repository? ~/santa On Thu, Mar 17, 2011 at 3:54 PM, Willis Cheung wrote: > Hi all, > > I'm trying to build the debug version of Python 3.2. I downloaded the py3k > folder fro

Re: Memory Usage of Strings

2011-03-16 Thread Santoso Wijaya
?? Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> L = [] >>> for i in xrange(10): ... L.append(str(i) * (1000 / len(str(i ... >>> sys.getsizeof(L) 824464 >>> L =

Re: possible to run a python script without installing python?

2011-03-16 Thread Santoso Wijaya
py2exe does this for you... ~/santa On Wed, Mar 16, 2011 at 8:02 AM, David Jackson wrote: > i need to run a python script on any arbitrary server and don't want to do > an actual installation. i figured i could do a clean install on my machine > and install whatever libraries would be needed,

Re: A Question on URLLIB

2011-03-14 Thread Santoso Wijaya
Well, have you run into any problem, expected or otherwise, yet? ~/santa On Mon, Mar 14, 2011 at 11:10 PM, joy99 wrote: > Dear Group, > I am trying to construct a web based crawler with Python and for that > I am using the URLLIB module, and by doing > import urllib and then trying with urlli

Re: Get Path of current Script

2011-03-14 Thread Santoso Wijaya
You can make it a required input with default values to sys.argv when you start the program. Parse the content of the file given by sys.argv, then cache it in some global module or pass it around as arguments... That said, if you still want to go the route of knowing where the current directory of

Re: Guido rethinking removal of cmp from sort method

2011-03-13 Thread Santoso Wijaya
I did not even realize such a change occurred in Python 3. I'm still currently blissful in Python 2 land. I'd be concerned about the impact in ported libraries (memory footprint? others?)... ~/santa On Sun, Mar 13, 2011 at 1:35 PM, Dave Abrahams wrote: > Steven D'Aprano pearwood.info> writes:

Re: Defining class attributes + inheritance

2011-03-08 Thread Santoso Wijaya
Remember the mantra, "Explitic is better than implicit." ;-) ~/santa On Tue, Mar 8, 2011 at 7:15 PM, Martin De Kauwe wrote: > On Mar 9, 12:53 pm, "Rhodri James" > wrote: > > On Wed, 09 Mar 2011 01:00:29 -, Martin De Kauwe > > > wrote: > > > > > class BaseClass(object): > > >def __ini

Re: Defining class attributes + inheritance

2011-03-08 Thread Santoso Wijaya
Here's how you do inheritance: C:\>python Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class BaseClass(object): ... def __init__(self, a, b, c, d): ... self.a = a ... self.b = b ...

Re: having both dynamic and static variables

2011-03-07 Thread Santoso Wijaya
Now you're just muddying the terminology! ~/santa On Mon, Mar 7, 2011 at 1:20 PM, Paul Rubin wrote: > Steven D'Aprano writes: > > but I call that a feature, not a bug. If you want an immutable constant, > > use a tuple, not a list. > > Nope: > >L = ([1,2],[3,4]) # tuple >L[0].append(

Re: having both dynamic and static variables

2011-03-05 Thread Santoso Wijaya
Shouldn't this go to python-ideas? Anyway, I'm partial to "static". ~/santa On Sat, Mar 5, 2011 at 8:33 PM, Westley Martínez wrote: > On Sat, 2011-03-05 at 18:37 -0800, John Nagle wrote: > > On 3/2/2011 9:27 PM, Steven D'Aprano wrote: > > > On Wed, 02 Mar 2011 19:45:16 -0800, Yingjie Lan wrot

Re: having both dynamic and static variables

2011-03-05 Thread Santoso Wijaya
A function object can get bound to a name, too: def foo(x): return x + 1 foo = lambda x: x - 1 assert foo(1) == 0 ~/santa On Sat, Mar 5, 2011 at 7:46 PM, Corey Richardson wrote: > On 03/05/2011 10:23 PM, MRAB wrote: > > Having a fixed binding could be useful elsewhere, for example, with

Re: Numerical representation

2011-03-04 Thread Santoso Wijaya
Have you taken a look at numpy? [1] It was written for exactly this kind of usage. ~/santa [1] http://numpy.scipy.org/ On Fri, Mar 4, 2011 at 2:32 PM, Jon Herman wrote: > Hello all, > > I am new to the Python language and writing a Runge-Kutta-Fellberg 7(8) > integrator in Python, which requi

Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Santoso Wijaya
GUI application is a whole other matter entirely. For that, you might want to look into cross-platform GUI toolkits with Python bindings. E.g., PyQT [1], wxPython [2], TkInter [3], etc. Python, after all, is just a cross-platform language. To do all those user-friendly bells and whistles, you'd nee

Re: having both dynamic and static variables

2011-03-04 Thread Santoso Wijaya
> > Declaring the *type* of such variables is a different matter I think (and > probably is not considered 'pythonic'; certainly it's a crude, if effective, > way of getting extra performance). I concur. Especially given performance is not a primary goal of Python to begin with, and--if such a bo

Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Santoso Wijaya
Django is excellent as a CMS builder (think blogs, articles websites), though it has many uses beyond that, as well. If, ultimately, you want client-side interactivity, however, you'd have to look into (perhaps in addition to Python--it can provide some of the backend logic for the website you want

Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Santoso Wijaya
First, learn the language. Second, browse a multitude of popular web frameworks written in Python, and try your hands on a few of them. I'd suggest looking into django, pyramid, webpy, ... (others will fill in). ~/santa On Fri, Mar 4, 2011 at 12:08 PM, ErichCart ErichCart wrote: > I am currentl

Re: import python module from C++ code

2011-03-04 Thread Santoso Wijaya
ri, Mar 4, 2011 at 9:14 AM, Arthur Mc Coy <1984docmc...@gmail.com>wrote: > Yes, I did. Here the link > http://docs.python.org/extending/extending.html#providing-a-c-api-for-an-extension-module > > It does not cover .py file embeding. So it is not my case. > > > On F

Re: import python module from C++ code

2011-03-04 Thread Santoso Wijaya
Have you read the doc [1] on extending/embedding Python? ~/santa [1] http://docs.python.org/extending/ On Fri, Mar 4, 2011 at 8:27 AM, Arthur Mc Coy <1984docmc...@gmail.com>wrote: > Hi all, > > > I have a C++ application. I have a .cpp file which is not a main > program, but a class where I wan

Re: making a class callable

2011-03-03 Thread Santoso Wijaya
Are you missing an import? import ohYeah f = ohYeah.foo('wow') ... ~/santa On Thu, Mar 3, 2011 at 5:45 PM, dude wrote: > I've been struggling with getting my class to behave the way I want > it. > > I have python module called ohYeah.py, defined as follows... > #File Begin > class foo: > >

Darwin build error with MacPorts Python 2.7.1 installed.

2011-03-02 Thread Santoso Wijaya
Hi, I recently tried to play around with the latest source for Python-2.7.1, and I came across this build error while trying to build a clean checkout (after `./configure`, of course): bash-3.2$ make ./Parser/asdl_c.py -h ./Include ./Parser/Python.asdl Traceback (most recent call last): File "/

Re: subclass urllib2

2011-02-28 Thread Santoso Wijaya
1. Why are you subclassing a module? 2. If you want to "mask" a module's version attribute, just do this: >>> import urllib2 >>> urllib2.__version__ = 'foo' >>> print urllib2.__version__ foo ~/santa On Mon, Feb 28, 2011 at 10:53 AM, monkeys paw wrote: > I'm trying to subclass u

Re: Dictionary with additional attributes

2011-02-22 Thread Santoso Wijaya
Instead of inheriting a dict, why not composing a dict into your "model" class, like: class Model(object): def __init__(self, *args, **kwargs): self._probabilities = defaultdict(lambda: defaultdict(float)) @property def features(self): # insert

Re: running Python code from external application

2011-02-22 Thread Santoso Wijaya
Sounds like an embedding job. Have you taken a look at this documentation ? ~/santa On Tue, Feb 22, 2011 at 4:30 AM, Nadav Chernin wrote: > Hello, > > I need to run Python code from external application. In this external > application i have 2 options to run:

Re: where to import

2011-02-17 Thread Santoso Wijaya
As a general rule, I group all my imports in the beginning of the module's source, even if it is only used a handful of times by a few functions. However, on such cases as the import is only needed by specific function(s) zero or once, then I do the import in the function itself. Importing argpars