Feeding differeent data types to a class instance?

2010-03-13 Thread kuru
Hi

I have couple classes in the form of

class Vector:
  def __init__(self,x,y,z):
   self.x=x
   self.y=y
   self.z=z

This works fine for me. However I want to be able to provide a list,
tuple as well as individual arguments like below

myvec=Vector(1,2,3)

This works well


However I  also want to be able to do

vect=[1,2,3]

myvec=Vec(vect)

I want this class to accept multiple data types but process them as
they are same when the classs deals with the instances.

thanks


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


Re: Feeding differeent data types to a class instance?

2010-03-14 Thread kuru
Hi

Thank you so much for all these great suggestions. I will have time
today to try all these and see which one works best for me

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


Re: DreamPie - The Python shell you've always dreamed about!

2010-03-21 Thread kuru
Thanks for the shell. It is nice alternative , however I am not ready
to give up Ipython :)

If the code ends with a comment line your shell is giving an error.

Feature request: It would be nice to have numbered lines in the code
section, it makes it hard to find problem line
Feature request: Loading an actual Python file rather than copy
pasting

keep up the good work
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: building exe from script

2007-08-20 Thread Furkan KURU
you can embed py2exe in your program.


On 8/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Is there any solution for building exe file from python script
> something like bbfreeze.When user write some script in
> my program, it must compile script into exe without opening console
> ( cmd ).I'am working on Windows XP  SP2 and Python 2.5.
>
>
>
> Regards,
> Vedran
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


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


Re: how can I find out the process ids with a process name

2007-09-02 Thread Furkan KURU
the easiest but slowest way:

you can send output to a file

ps -ef |grep emacs > output_file

and then read the file content

(I believe there is a much better way)




On 9/2/07, herman <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to find out all the process id with the process name
> 'emacs'.
>
> In the shell, i can do this:
>
> $ ps -ef |grep emacs
> root 20731  8690  0 12:37 pts/200:00:09 emacs-snapshot-gtk
> root  25649 25357  0 13:55 pts/900:00:05 emacs-snapshot-gtk rtp.c
> root  26319 23926  0 14:06 pts/700:00:04 emacs-snapshot-gtk
> stressTestVideo.py
> root  26985 1  0 14:15 ?00:00:01 /usr/bin/emacs-snapshot-
> gtk
> root 27472 21066  0 14:23 pts/500:00:00 grep emacs
>
>
> and I can see the process id is 20731, 25649, etc, etc.
>
> But now I would like to do the programmically in my python script.
> I know I can use ' os.system(cmd)' to execute the command 'ps -ef |
> grep emacs', but how
> can I pipe the output of my 'ps -ef | grep emacs' to my python script
> and then run a regression expression with it to get the process Ids?
>
> Thank you.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


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


Re: Using python to create windows apps that everyone can use?

2007-09-17 Thread Furkan Kuru
have a look at wxpython and py2exe.

On 9/17/07, Tom Harding <[EMAIL PROTECTED]> wrote:
>
>  Hi guys, sorry to post another topic on this, as I am aware that it has
> already been posted a few times, but not with specifically what I am looking
> for. I want an app that makes a gui interface for python (similar to
> Microsoft visual studio or qt designer, not a code based one) and/or an app
> that can make this into a .exe that can be opened by any person on any
> computer without python installed.
>
>
>
> I would just love to do this in python and not C++, its so simple and
> logical.
>
>
>
> So basically, the easiest way to do that, please!
>
>
>
> Thanks,
>
>
>
> Tom Harding
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: calling the function of one class from another class

2007-09-22 Thread Furkan Kuru
On 9/22/07, Mridula Ramesh <[EMAIL PROTECTED]> wrote:
>
> hi.
>
> i currently have code structured like this:
>
> classA():
> > def __init__():
> >  ..
> >  ..
> >
> > def fnc1():
> > 
> > 
> >
> >
> > classB():
> >def __init__():
> > 
> > 
> > classA.fnc1()#this is where i get an error
> >
>
> TypeError: unbound method fnc1() must be called with classA instance as
> first argument (got nothing instead)
>
> when i do  fnc1(classA) i get:
>
> NameError: global name 'fnc1' is not defined
>
> am i violating some programming rule by trying to call fnc1 in classB? i
> am only now learning OO alongside python, so i'm not sure! also, can someone
> please tell me where to go for more articles on the classes and functions
> and calling them from other places?
>
> thanks a lot!
>
> mridula.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

you should create an instance of ClassA:

a = ClassA()
a.fnc1()

or if you want a static function you should declare the method as static

classA():
def __init__():
 ..
 ..
@staticmethod
def fnc1():


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

Re: Noob questions about Python

2007-10-17 Thread Furkan Kuru
li.reverse() does not return a list it just changes the list li.

val = 00110 is evaluated in base 8 try without leading 0s



On 10/17/07, Ixiaus <[EMAIL PROTECTED]> wrote:
>
> I have recently (today) just started learning/playing with Python. So
> far I am excited and impressed (coming from PHP background).
>
> I have a few questions regarding Python behavior...
>
> val = 'string'
> li = list(val)
> print li.reverse()
>
> returns nothing, but,
>
> val = 'string'
> li = list(val)
> li.reverse()
> print li
>
> returns what I want. Why does Python do that?
>
> Also I have been playing around with Binary math and noticed that
> Python treats:
>
> val = 00110
>
> as the integer 72 instead of returning 00110, why does Python do that?
> (and how can I get around it?)
>
> Grateful for any replies!
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: recording sound with python

2007-11-09 Thread Furkan Kuru
try pymedia

On Nov 9, 2007 3:57 AM, jesse j <[EMAIL PROTECTED]> wrote:

> Hello Everyone,
>
> I'm new to python.  I have worked through some tutorials and played around
> with the language a little bit but I'm stuck.
>
> I want to know how I can make python run a program.  More specifically, I
> want to get python to work with SOX to record a sound through the
> microphone, save the sound and then play the sound by typing one command
> into a linux terminal (UBUNTU).
>
> Can someone give me some hints on how this can be done?
>
> Thank You.
>
> jessej
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

embedded python in c++ packaging

2008-02-07 Thread Furkan Kuru
Hello,

I have been developing an application in C++ that embeds Python interpreter.
It takes advantage of too many modules from Python.
When I want to package this application, I need to add too many files (.pyc)
from Python/lib folder together with Python25.dll.
Is there a way to pack these .pyc files to a zip file and redirect
Python25.dll to that zip file?

Thanks in advance.

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

Re: embedded python in c++ packaging

2008-02-07 Thread Furkan Kuru
I do not have access to my development machine right now.
but is it enough adding just a simple line at the top of my main python file
'sys.path.append("modules.zip")' before importing any other modules?

On 2/7/08, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> En Thu, 07 Feb 2008 16:18:57 -0200, Joshua Kugler <[EMAIL PROTECTED]>
> escribió:
> > Furkan Kuru wrote:
> >>
> >> I have been developing an application in C++ that embeds Python
> >> interpreter. It takes advantage of too many modules from Python.
> >> When I want to package this application, I need to add too many files
> >> (.pyc) from Python/lib folder together with Python25.dll.
> >> Is there a way to pack these .pyc files to a zip file and redirect
> >> Python25.dll to that zip file?
> >
> > That is effectively what py2exe does with the modules required by the
> > main
> > application.  It takes all the required modules and puts them in a
> > library.zip file.  You might take a look at how it does it.
>
> Using py2exe has an additional advantage, it recursively scans all modules
> looking for dependencies.
> Once you know the required set of modules, you can bundle them in a .zip
> file and add its full path into sys.path (the absolute path including
> filename and .zip extension). Python does look into the .zip searching for
> modules.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: embedded python in c++ packaging

2008-03-25 Thread Furkan Kuru
Sorry for long delay,

I've tried below code (Setting pythonpath environment variable)
and then initialize python interpreter but the embedded python interpreter
did not get the newly assigned PYTHONPATH.
I ve looked at the sys.path in python code (that is run by the embedded
interpreter) and it behaved according to older pythonpath.

Setting environment variable seemed to be correct.
Does py_initialize run in another thread so it starts before setting the
environment var?

// add custom plib.zip archive to pythonpath

if(!::getenv("PYTHONPATH"))

{

::putenv("PYTHONPATH=.;.\\plib.zip");

}

else ::putenv("PYTHONPATH=%PYTHONPATH%;.\\plib.zip");

std::cout << "PYTHONPath Set to: " << ::getenv("PYTHONPATH") << std::endl <<
"And Again: ";

system("echo %PYTHONPATH%");

Py_Initialize();



Regards,

On Fri, Feb 8, 2008 at 2:08 AM, Bronner, Gregory <[EMAIL PROTECTED]>
wrote:

>  I've done this the rather old-fashioned way.
>
> Basically, what I do is:
>
> Step 1:
>
> Embed Python:
>   if(!::getenv("PYTHONHOME"))
>   {
>  ::putenv("PYTHONHOME=");
>   }
>   if(!::getenv("PYTHONPATH"))
>   {
>  ::putenv("PYTHONPATH=.");
>   }
>
>   Py_SetProgramName("leaktester");
>   Py_InitializeEx(0);
>   init_memoryhoginterface();  // This initializes your SWIG module
>   PyRun_SimpleString("print 'HELLO FROM PYTHON'");  //<--- OR you can do
> something else here like run a file
>
>
> Step 2:
> Extend python to talk back to your C++ code.
> I use one giant SWIG module (see init function above)
>
> SWIG allows you to finely control what you expose to python, so you don't
> wind up exposing the whole C++ API.
>
>
>
>
>
>
>
>
>
>  --
> *From:* Furkan Kuru [mailto:[EMAIL PROTECTED]
> *Sent:* Thursday, February 07, 2008 6:06 PM
> *To:* python-list@python.org
> *Subject:* Re: embedded python in c++ packaging
>
>   I do not have access to my development machine right now.
> but is it enough adding just a simple line at the top of my main python
> file 'sys.path.append("modules.zip")' before importing any other modules?
>
> On 2/7/08, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> >
> > En Thu, 07 Feb 2008 16:18:57 -0200, Joshua Kugler <[EMAIL PROTECTED]>
> > escribió:
> > > Furkan Kuru wrote:
> > >>
> > >> I have been developing an application in C++ that embeds Python
> > >> interpreter. It takes advantage of too many modules from Python.
> > >> When I want to package this application, I need to add too many files
> > >> (.pyc) from Python/lib folder together with Python25.dll.
> > >> Is there a way to pack these .pyc files to a zip file and redirect
> > >> Python25.dll to that zip file?
> > >
> > > That is effectively what py2exe does with the modules required by the
> > > main
> > > application.  It takes all the required modules and puts them in a
> > > library.zip file.  You might take a look at how it does it.
> >
> > Using py2exe has an additional advantage, it recursively scans all
> > modules
> > looking for dependencies.
> > Once you know the required set of modules, you can bundle them in a .zip
> > file and add its full path into sys.path (the absolute path including
> > filename and .zip extension). Python does look into the .zip searching
> > for
> > modules.
> >
> > --
> > Gabriel Genellina
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
>
> --
> Furkan Kuru
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - This message is intended only for the personal and
> confidential use of the designated recipient(s) named above. If you are not
> the intended recipient of this message you are hereby notified that any
> review, dissemination, distribution or copying of this message is strictly
> prohibited. This communication is for information purposes only and should
> not be regarded as an offer to sell or as a solicitation of an offer to buy
> any financial product, an official confirmation of any transaction, or as an
> official statement of Lehman Brothers. Email transmission cannot be
> guaranteed to be secure or error-free. Therefore, we do not represent that
> this information is complete or accurate and it should not be relied upon as
> such. All information is subject to change without notice.  IRS
> Circular 230 Disclosure: Please be advised that any discussion of U.S. tax
> matters contained within this communication (including any attachments) is
> not intended or written to be used and cannot be used for the purpose of (i)
> avoiding U.S. tax related penalties or (ii) promoting, marketing or
> recommending to another party any transaction or matter addressed herein.




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

Re: Inheritance question

2008-03-25 Thread Furkan Kuru
a = super(Foo, self).getid()
should be
a = super(FooSon, self).getid()


On Tue, Mar 25, 2008 at 2:34 PM, Tzury Bar Yochay <[EMAIL PROTECTED]>
wrote:

> > Rather than use Foo.bar(), use this syntax to call methods of the
> > super class:
> >
> > super(ParentClass, self).method()
>
> Hi Jeff,
> here is the nw version which cause an error
>
> class Foo(object):
>def __init__(self):
>self.id = 1
>
>def getid(self):
>return self.id
>
> class FooSon(Foo):
>def __init__(self):
>Foo.__init__(self)
>self.id = 2
>
>def getid(self):
>a = super(Foo, self).getid()
>b = self.id
>return '%d.%d' % (a,b)
>
>
> FooSon().getid()
>
>
> Traceback (most recent call last):
>  File "a.py", line 19, in 
>FooSon().getid()
>  File "a.py", line 14, in getid
>a = super(Foo, self).getid()
> AttributeError: 'super' object has no attribute 'getid'
>  --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: Inheritance question

2008-03-25 Thread Furkan Kuru
In the derived class init you set self.id to 2 so
when you call getid method it just returns self.id which is now 2.
you can use another variable name.

On Tue, Mar 25, 2008 at 1:44 PM, Tzury Bar Yochay <[EMAIL PROTECTED]>
wrote:

> given two classes:
>
> class Foo(object):
>def __init__(self):
>self.id = 1
>
>def getid(self):
>return self.id
>
> class FooSon(Foo):
>def __init__(self):
>Foo.__init__(self)
>self.id = 2
>
>def getid(self):
>a = Foo.getid()
>b = self.id
>return '%d.%d' % (a,b)
>
> While my intention is to get 1.2 I get 2.2
> I would like to know what would be the right way to yield the expected
> results
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: My python interpreter became mad !

2008-03-25 Thread Furkan Kuru
Most probably X-Spam added itself to your path.
you should look at your PATH and PYTHONPATH environment variables.

On Tue, Mar 25, 2008 at 1:40 PM, John Machin <[EMAIL PROTECTED]> wrote:

> On Mar 25, 10:05 pm, Benjamin Watine <[EMAIL PROTECTED]> wrote:
> > Yes, my python interpreter seems to became mad ; or may be it's me ! :)
> >
> > I'm trying to use re module to match text with regular expression. In a
> > first time, all works right. But since yesterday, I have a very strange
> > behaviour :
> >
> > $ python2.4
> > Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
> > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> >  >>> import re
> > X-Spam-Flag: YES
> > X-Spam-Checker-Version: SpamAssassin 3.1.7-deb (2006-10-05) on
> w3hosting.org
> > X-Spam-Level: **
> > X-Spam-Status: Yes, score=22.2 required=5.0 tests=MISSING_HB_SEP,
> >  MISSING_HEADERS,MISSING_SUBJECT,RAZOR2_CF_RANGE_51_100,
> >
> > RAZOR2_CF_RANGE_E8_51_100,RAZOR2_CHECK,TO_CC_NONE,UNPARSEABLE_RELAY,
> >
> > URIBL_AB_SURBL,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_SBL,URIBL_SC_SURBL,
> >  URIBL_WS_SURBL autolearn=failed version=3.1.7-deb
> >
> > Traceback (most recent call last):
> >File "", line 1, in ?
> >File "/etc/postfix/re.py", line 19, in ?
> >  m = re.match('(Spam)', mail)
> > AttributeError: 'module' object has no attribute 'match'
> >  >>>
> >
> > What's the hell ?? I'm just importing the re module.
>
> No you're not importing *the* re module. You're importing *an* re
> module, the first one that is found. In this case: your own re.py.
> Rename it.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: Creating dynamic objects with dynamic constructor args

2008-03-25 Thread Furkan Kuru
you can call a function with arglist like this:

def dummy(a, b, c):
print a + b, c

args = [1, 2, "hello"]
dummy(*args)

On Tue, Mar 25, 2008 at 5:38 PM, <[EMAIL PROTECTED]> wrote:

> I'd like to create objects on the fly from a pointer to the class
> using:  instance = klass()  But I need to be able to pass in variables
> to the __init__ method.  I can recover the arguments using the
> inspect.argspec, but how do I call __init__ with a list of arguments
> and have them unpacked to the argument list rather than passed as a
> single object?
>
> ie. class T:
>def __init__(self, foo, bar):
>self.foo = foo
>self.bar = bar
>
> argspec = inspect.argspec(T.__init__)
> args = (1, 2)
>
> ??? how do you call T(args)?
>
> Thanks.
> Greg
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

embedded python pythonpath

2008-03-25 Thread Furkan Kuru
Hello,
It is somehow related with c++ and python.

I've tried below code (Setting pythonpath environment variable)
and then initialize python interpreter but the embedded python interpreter
did not get the newly assigned PYTHONPATH.
I ve looked at the sys.path in python code (that is run by the embedded
interpreter) and it behaved according to older pythonpath.

Setting environment variable seemed to be correct.
Does py_initialize run in another thread so it starts before setting the
environment var?

// add custom plib.zip archive to pythonpath

if(!::getenv("PYTHONPATH"))

{

::putenv(
"PYTHONPATH=.;.\\plib.zip");

}

else ::putenv("PYTHONPATH=%PYTHONPATH%;.\\plib.zip");

std::cout <<
"PYTHONPath Set to: " << ::getenv("PYTHONPATH") << std::endl << "And Again:
";

system("echo %PYTHONPATH%");

Py_Initialize();

Sorry for asking it twice.

Regards,



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

Re: My python interpreter became mad !

2008-03-25 Thread Furkan Kuru
Ok, you're right.

but I did not give it a chance "not trying python interpreter in another
directory"
so if we assume the problem exists in every directory, it has something to
do with  pythonpath.
you can try setting pythonpath to some directory and put a re.py there and
try from any directory starting your interpreter and importing re.



On 3/25/08, John Machin <[EMAIL PROTECTED]> wrote:
>
> Furkan Kuru top-posted:
> > Most probably X-Spam added itself to your path.
>
> What is "X-Spam"? Added itself to Benjamin's path [not mine] in such a
> fashion that it is invoked when one does "import re"?
>
> > you should look at your PATH and PYTHONPATH environment variables.
>
> Most *IM*probably. Read the traceback:
> """
> >  >File "/etc/postfix/re.py", line 19, in ?
> >  >  m = re.match('(Spam)', mail)
> >  > AttributeError: 'module' object has no attribute 'match'
> """
>
> This is a classic case of a script (which does not guard against side
> effects (like spewing out gibberish) when imported instead of being
> executed) being given the same name as a Python-included module and
> being executed in the current directory and hence ends up importing
> itself.
>
> >
> > On Tue, Mar 25, 2008 at 1:40 PM, John Machin <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > On Mar 25, 10:05 pm, Benjamin Watine <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >  > Yes, my python interpreter seems to became mad ; or may be it's
> > me ! :)
> >  >
> >  > I'm trying to use re module to match text with regular
> > expression. In a
> >  > first time, all works right. But since yesterday, I have a very
> > strange
> >  > behaviour :
> >  >
> >  > $ python2.4
> >  > Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
> >  > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
> >  > Type "help", "copyright", "credits" or "license" for more
> > information.
> >  >  >>> import re
> >  > X-Spam-Flag: YES
>
> [snip]
>
> >  > Traceback (most recent call last):
> >  >File "", line 1, in ?
> >  >File "/etc/postfix/re.py", line 19, in ?
> >  >  m = re.match('(Spam)', mail)
> >  > AttributeError: 'module' object has no attribute 'match'
> >  >  >>>
> >  >
> >  > What's the hell ?? I'm just importing the re module.
> >
> > No you're not importing *the* re module. You're importing *an* re
> > module, the first one that is found. In this case: your own re.py.
> > Rename it.
> >
>
>


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

Re: embedded python pythonpath

2008-03-25 Thread Furkan Kuru
Actually, I do not want any .py or .pyc files around my executable.
(including userdict, sys, site etc)
I want to have just single zip file for all python files.

I had a look at py2exe source codes but could not figure out how it just
looks into a zip file.

So maybe I have to compile the svn version of python.


On 3/26/08, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>
> Furkan Kuru  gmail.com> writes:
>
> > I've tried below code (Setting pythonpath environment variable)
> > and then initialize python interpreter but the embedded python
> interpreter
> did not get the newly assigned PYTHONPATH.
> > I ve looked at the sys.path in python code (that is run by the embedded
> interpreter) and it behaved according to older pythonpath.
>
> Note that you don't HAVE to set the environment variable PYTHONPATH, there
> are
> other ways to get directories listed in sys.path - and that is what really
> counts.
> The simplest way is to just write code to insert the desired directories
> in
> front of sys.path, after the call to Py_Initialize. The only problem is
> that
> some modules (like site and sitecustomize) are searched and executed
> before
> your code has a chance to modify sys.path - I hope it's not a problem for
> you.
>
> > Setting environment variable seemed to be correct.
> > Does py_initialize run in another thread so it starts before setting the
> environment var?
>
> I could reproduce the problem with a smaller code (using C, not C++).
> Testing
> with Python 2.5.1 doesn't work (that means, it ignores the new setting for
> PYTHONPATH). Testing with current Python trunk (from svn) *does* work. I
> don't
> know if this is a bug that has been fixed, or it works that way because
> the
> svn version is not the default installation and then searches for things
> in a
> different way.
>
> #include 
>
> int main(int argc, char *argv[])
> {
> putenv("PYTHONPATH=C:\\TEMP\\MF");
> system("set PYTHONPATH");
> printf("Py_GETENV(PYTHONPATH)=%s\n", Py_GETENV("PYTHONPATH"));
>
> Py_Initialize();
> PyRun_SimpleString("import sys\nprint sys.path");
> Py_Finalize();
> return 0;
> }
>
> I compiled twice with these commands:
> cl -MD -Ic:\apps\python25\include test.c c:\apps\python25
> \Libs\Python25.lib /Fetest25.exe
> cl -MD -Ic:\apps\python\trunk\PC -Ic:\apps\python\trunk\include test.c
> c:\apps\python\trunk\PCbuild\Python26.lib /Fetest26.exe
>
> Python25.dll and Python26.dll both were copied into the current directory.
>
> test25.exe:
> PYTHONPATH=C:\TEMP\MF
> Py_GETENV(PYTHONPATH)=C:\TEMP\MF
> ['C:\\Apps\\Python25\\lib\\site-packages\\setuptools-0.6c5-
> py2.5.egg', 'C:\\Apps\\Python25\\lib\\site-packages\\
> simplejson-1.7.1-py2.5-win32.egg',
> ... many directories, not including C:\TEMP\MF ... ]
>
> test26.exe:
> PYTHONPATH=C:\TEMP\MF
> Py_GETENV(PYTHONPATH)=C:\TEMP\MF
> 'import site' failed; use -v for traceback
> ['C:\\TEMP\\MF', 'C:\\TEMP\\python26.zip', '', 'C:\\TEMP']
>
> I don't understand how the test program, compiled for 2.5.1, could
> actually
> locate the Python directory. (It's not in my PATH, it's not the default
> install directory, and I deleted the HKLM\Software\Python\PythonCore\2.5
> registry key).
>
> --
> Gabriel Genellina
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: Filtering a Python list to uniques

2008-03-25 Thread Furkan Kuru
set(lstone)
works fine in python 2.5.1

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]
>>> set(lstone)
set([1, 2, 3, 4, 5, 6])



On 3/26/08, kellygreer1 <[EMAIL PROTECTED]> wrote:
>
> What is the best way to filter a Python list to its unique members?
> I tried some method using Set but got some "unhashable" error.
>
> lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]
> # how do i reduce this to
> lsttwo = [ 1, 2, 3, 4, 5, 6 ]
>
> Is there a page on this in the Python in a Nutshell or the Python
> Cookbook?
> Did I miss something?
>
> Kelly Greer
> [EMAIL PROTECTED]
> change nospam to yahoo
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: My python interpreter became mad !

2008-03-25 Thread Furkan Kuru
On 3/26/08, John Machin <[EMAIL PROTECTED]> wrote:
>
>
> > but I did not give it a chance "not trying python interpreter in another
> > directory"
>
> I don't understand that sentence.


ok let me explain:
I did not think he/she/anyone would ask the question in the main thread
without trying the interpreter a few times starting it from different
directories.



> so if we assume the problem exists in every directory, it has something
> > to do with  pythonpath.
>
> Why would/should we assume that?



Because I, as an individual, would not ask this question without running
interpreter from different directories.
and I would look whether I created a py file with the exact same name of a
core module.

And this "simple" mistake had been pointed out by other guys.
The only other reason that came to my mind was this pythonpath.
( and I was dealing with it recently: you may have take a look at the thread
titled 'embedded pyton pythonpath' any answer is appreciated :p  )


> > you can try setting pythonpath to some directory and put a re.py there
> > and try from any directory starting your interpreter and importing re.
>
> and achieve the same result: importing the bogus re. What's your point?



yeah same result: bogus re. but from a different way: not user's re but
created by someone else in another directory.



>
> >
> >
> > On 3/25/08, *John Machin* <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Furkan Kuru top-posted:
> >  > Most probably X-Spam added itself to your path.
> >
> > What is "X-Spam"? Added itself to Benjamin's path [not mine] in such
> a
> > fashion that it is invoked when one does "import re"?
> >
> >  > you should look at your PATH and PYTHONPATH environment
> variables.
> >
> > Most *IM*probably. Read the traceback:
> > """
> >  >  >File "/etc/postfix/re.py", line 19, in ?
> >  >  >  m = re.match('(Spam)', mail)
> >  >  > AttributeError: 'module' object has no attribute 'match'
> > """
> >
> > This is a classic case of a script (which does not guard against
> side
> > effects (like spewing out gibberish) when imported instead of being
> > executed) being given the same name as a Python-included module and
> > being executed in the current directory and hence ends up importing
> > itself.
> >
> >  >
> >  > On Tue, Mar 25, 2008 at 1:40 PM, John Machin
> > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >  > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
> wrote:
> >  >
> >  > On Mar 25, 10:05 pm, Benjamin Watine <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>
> >  > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
> >  >  > Yes, my python interpreter seems to became mad ; or may be
> > it's
> >  > me ! :)
> >  >  >
> >  >  > I'm trying to use re module to match text with regular
> >  > expression. In a
> >  >  > first time, all works right. But since yesterday, I have a
> > very
> >  > strange
> >  >  > behaviour :
> >  >  >
> >  >  > $ python2.4
> >  >  > Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
> >  >  > [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on
> linux2
> >  >  > Type "help", "copyright", "credits" or "license" for more
> >  > information.
> >  >  >  >>> import re
> >  >  > X-Spam-Flag: YES
> >
> > [snip]
> >
> >  >  > Traceback (most recent call last):
> >  >  >File "", line 1, in ?
> >  >  >File "/etc/postfix/re.py", line 19, in ?
> >  >  >  m = re.match('(Spam)', mail)
> >  >  > AttributeError: 'module' object has no attribute 'match'
> >  >  >  >>>
> >  >  >
> >  >  > What's the hell ?? I'm just importing the re module.
> >  >
> >  > No you're not importing *the* re module. You're importing
> *an* re
> >  > module, the first one that is found. In this case: your own
> > re.py.
> >  > Rename it.
> >  >
> >
> >
> >
> >
> > --
> > Furkan Kuru
>
>


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

Re: embedded python pythonpath

2008-03-25 Thread Furkan Kuru
On 3/26/08, Gabriel Genellina <[EMAIL PROTECTED]> wrote:

> En Tue, 25 Mar 2008 20:38:39 -0300, Furkan Kuru <[EMAIL PROTECTED]>
> escribió:
>
> > Actually, I do not want any .py or .pyc files around my executable.
> > (including userdict, sys, site etc)
> > I want to have just single zip file for all python files.
>
> Putting all of them into pythonNN.zip (NN depending on the Python version
> in use) should be enough, but I've never tried it.


 I had already tried putting all of them into pythonNN.zip but I had to copy
it to the place
where sys.path points in my case it was windows\system32\python25.zip


> I had a look at py2exe source codes but could not figure out how it just
> > looks into a zip file.
>
> Standard Python already supports having zip files in sys.path (using the
> builtin zipimport module), you don't have to do anything special to enable
> that (apart from building with the required dependencies, like zlib, of
> course)



yes I know but I do not want "any" py or pyc file. I would still need
dict.pyc, sys.pyc, site.pyc etc. files for py_initialize.

> So maybe I have to compile the svn version of python.
>
> After renaming the directory where Python 2.5 were installed, my
> test25.exe program (the one compiled using Python 2.5.1) worked fine. So
> it looks like it is something with how the "python home" is searched.


Ok then changing or deleting pythonhome environment variable may fix the
problem?

thanks,

Anyway, as I said earlier, you don't have to play with PYTHONPATH; just
> add any required directory to sys.path at runtime.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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

Re: embedded python pythonpath

2008-03-26 Thread Furkan Kuru
On Wed, Mar 26, 2008 at 3:49 AM, Gabriel Genellina <[EMAIL PROTECTED]>
wrote:

> En Tue, 25 Mar 2008 22:22:41 -0300, Furkan Kuru <[EMAIL PROTECTED]>
> escribió:
>
> > On 3/26/08, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> >
> >> En Tue, 25 Mar 2008 20:38:39 -0300, Furkan Kuru <[EMAIL PROTECTED]>
> >> escribió:
> >>
> >> > Actually, I do not want any .py or .pyc files around my executable.
> >> > (including userdict, sys, site etc)
> >> > I want to have just single zip file for all python files.
> >>
> >> Putting all of them into pythonNN.zip (NN depending on the Python
> >> version
> >> in use) should be enough, but I've never tried it.
> >  I had already tried putting all of them into pythonNN.zip but I had to
> > copy it to the place
> > where sys.path points in my case it was windows\system32\python25.zip
>
> It should be in the same directory as python25.dll; you don't have to use
> windows\system32 if you copy python25.dll to your application directory.
>


I did not know that. Ok, I tried and it works!

Thank you,

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

Re: Filtering a Python list to uniques

2008-03-27 Thread Furkan Kuru
lstOne = [ 'A', 'B', 'C', 'C' ]
dct = {}
for item in lstOne:
if dct.has_key(item):
dct[item] += 1
else: dct[item] = 1

On Thu, Mar 27, 2008 at 10:51 PM, Kelly Greer <[EMAIL PROTECTED]> wrote:

> I'm in Python 2.4.4
>
> And it works for me in the Python Shell like you just
> did. Let me try another thing or two. I can't
> reproduce the unhashable error now. :(
>
> Can you help me with one more thing?
> If I have
> lstOne = [ 'A', 'B', 'C', 'C' ]
>
> # what is the easiest way to get
> # back a dictionary like this:
> dct = { 'A': 1, 'B': 1, 'C': 2 }
> # in other words counting the times a letter appears
> in the list.
>
> Thanks,
> Kelly
>
>
> --- Furkan Kuru <[EMAIL PROTECTED]> wrote:
>
> > set(lstone)
> > works fine in python 2.5.1
> >
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08)
> > [MSC v.1310 32 bit (Intel)]
> > on
> > win32
> > Type "help", "copyright", "credits" or "license" for
> > more information.
> > >>> lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]
> > >>> set(lstone)
> > set([1, 2, 3, 4, 5, 6])
> >
> >
> >
> > On 3/26/08, kellygreer1 <[EMAIL PROTECTED]>
> > wrote:
> > >
> > > What is the best way to filter a Python list to
> > its unique members?
> > > I tried some method using Set but got some
> > "unhashable" error.
> > >
> > > lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]
> > > # how do i reduce this to
> > > lsttwo = [ 1, 2, 3, 4, 5, 6 ]
> > >
> > > Is there a page on this in the Python in a
> > Nutshell or the Python
> > > Cookbook?
> > > Did I miss something?
> > >
> > > Kelly Greer
> > > [EMAIL PROTECTED]
> > > change nospam to yahoo
> > > --
> > >
> > http://mail.python.org/mailman/listinfo/python-list
> > >
> >
> >
> >
> > --
> > Furkan Kuru
> >
>
>
>
>
>  
> 
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>



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

Re: image recogniton?

2009-01-06 Thread Furkan Kuru
start with Python Image Library:
http://www.pythonware.com/products/pil/

On Tue, Jan 6, 2009 at 4:28 PM, Li Han  wrote:

> Hi! I know little about the computer image processing, and now I have
> a fancy problem which is how to read the time from the picture of a
> clock by programming ?  Is there anyone who can give me some
> suggestions?
> Thank!
> Li Han
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: convert pyc (python 2.4) to py

2009-11-03 Thread Furkan Kuru
There is an online service at http://www.depython.com converting pyc
files to py.
You can give it a try.
It does not have file size limit.

On Wed, Oct 21, 2009 at 8:58 PM, Chris Rebert  wrote:
> On Wed, Oct 21, 2009 at 11:35 AM, Peng Yu  wrote:
>> On Tue, Oct 20, 2009 at 4:42 PM, Diez B. Roggisch  
>> wrote:
>>> Peng Yu schrieb:
>>>>
>>>> I have a .pyc file generated by python 2.4. My current python is of
>>>> version 2.6. I'm wondering how to generate the corresponding .py file
>>>> from it.
>>>
>>> http://www.crazy-compilers.com/decompyle/
>>
>> Is there any free one?
>
> There's an older version of the software at:
> http://sourceforge.net/projects/decompyle/
> but it's not maintained like the service (just see the last-modified
> date on it) and you'll have to figure out how to use it by yourself.
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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