Communicate between Python and Node.js

2014-01-15 Thread Manish
I've been tasked to write a module that sends data from Django to a Node.js 
server running on the same machine. Some magic happens in node and I recv the 
results back, which are then rendered using Django templates. 

At first I thought to use the requests library to GET/POST data to node, but I 
googled around and it seems lots of people think TCP sockets are the way to go. 
I tried implementing my own using several examples I have found online. It 
*kind of* works. It seems like I get blocked while trying to receive data back 
in the recv() loop. I never reach the end. I'm not an expert in 
sockets/networking, but maybe I'm not wrong in guessing it is because of the 
non-blocking nature of Node.js ?

A Stackoverflow post helped a little more in figuring things out (though I'm 
not sure if I'm correct here). Right now, I'm failing during connect() - I get 
"Operation now in progress". 

So my question is, how can I get recv() to work properly so that data is 
seamlessly passed back and forth between my Python script and the node server. 
Am I taking the right approach? Is there any better way? 

Relevant scripts: 
1) http://bpaste.net/show/NI2z9RhbT3HVtLVWUKuq/ 
2) http://bpaste.net/show/YlulEZBTDE5KS5ZvSyET/

Thanks! 

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


Getting started with Python: The ultimate guide with Tips, Tools and Resources

2013-03-06 Thread Manish
Getting started with Python: Tips, Tools and Resources
http://lurnq.com/lesson/getting-started-with-python-tips-tools-and-resources/

This is a lesson I published on LurnQ which acts like a beginners guide. I have 
included various Books, MOOCs, Video Tutorials, Interactive tutorials, 
exercises which can get you started with Python. I have included my review 
along with some resources, which I have used while teaching Python myself. 

Any form of feedback is most welcome. Also, if I missed out on any good 
learning resource, do leave it as a comment. I will update the list. 

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


Getting started with Python: The ultimate list with Tips, Tools and Resources

2013-03-13 Thread Manish
Getting started with Python: The ultimate list with Tips, Tools and Resources
http://lurnq.com/lesson/Getting-started-with-Python-Tips-Tools-and-Resources/

Here is a lesson which includes a great set of resources including Books, 
MOOCs, Video Tutorials, Interactive tutorials, exercises which can get you 
started with Python. I have included my review along with some resources, which 
I have used while teaching Python myself. 

If I missed out some good book or resources, do leave the link as a comment so 
that I can update the list. 

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


Re: Python Processor

2009-08-26 Thread manish
Hi,

I am also wondering about how to implement a soft core reconfigurable
processor in a FPGA
which would directly execute the compiled python bytecode.

I am trying to understand the bytecode format but apart from
http://docs.python.org/library/dis.html
there is hardly any documentation on the python bytecodes.

Before going through the one of the existing VM implementations, i want to
know if there is there any informaition
available which elaborates on the structure of the bytecodes. Like details
regarding co_names, co_cellvars,
co_freevars, the concept of frames, global, local, objects, functions etc
with respect to the bytecode.


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


Re : Python Processor

2009-08-26 Thread manish
Hi,


Contrary to the ancient and, I believe, obsolete text in the
documentation,
 there is no 'python bytecode'. Dis is based on CPython bytecode.
 Jython uses Java bytecode. IronPython uses, I believe, Microsoft clr
bytecode. Object code compilers do not use bytecode.

 Before going through the one of the existing VM implementations, i
want to know if there is there any informaition
 available which elaborates on the structure of the bytecodes. Like
details regarding co_names, co_cellvars,
 co_freevars, the concept of frames, global, local, objects,
functions etc with respect to the bytecode.

 These are mostly version-specific Cpython implementation details.

 tjr

I agree, i am looking at a version-specific CPython implementation, or can
be PyPy even . I need some information
on the implementation of these interpreters which would help me visualize
how they can be mapped to hardware.

  It probably wouldn't help much.  CPython's performance problems
 come from excessive dictionary lookups, not from instruction decode.

   John Nagle

This is just for my personal interest so currently i am not looking at
performance - just be able to implement a basic core at first.
The idea is to then extend it and develop a self contained unit of
computation which can be reconfigured on the fly. So given enough
memory and I/Os the same module can behave differently depending on the
script loaded. One can either have a large monolithic cpu
running an OS of some sorts or smaller processors each executing their own
little scripts and communicating with each other.

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


Please verify!!

2012-02-23 Thread Manish Sharma
Hi I am new to python language. On my first day, somebody told me that
if any python script file is opened with any editor except python
editor, the file is corrupted. Some spacing or indentation is changed
and script stops working. I was opening the script file in Windows
using Notepad++ but I didn't save anything and closed it. Still it was
suggested to never open the python file in any other editor.

Can anybody please verify this? Can opening a python script in any
editor other than python editor corrupt the script? Did anybody ever
face such type of issue or its just misunderstanding of the concept.

I hope this group is the best place to ask this. Please reply !

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


Re: Please verify!!

2012-02-23 Thread Manish Sharma
Hi All,

Thanks a ton for your replies!

Still my question is what if I open the file and dont make any changes to
it and close it again? Can it be possible just by doing these steps add
indentation to lines? I am not changing the file prefrences to open it
always with notepad++. Opening it once only.

On Fri, Feb 24, 2012 at 6:08 AM, Jason Friedman  wrote:

> > Hi I am new to python language. On my first day, somebody told me that
> > if any python script file is opened with any editor except python
> > editor, the file is corrupted. Some spacing or indentation is changed
> > and script stops working. I was opening the script file in Windows
> > using Notepad++ but I didn't save anything and closed it. Still it was
> > suggested to never open the python file in any other editor.
>
> It is possible that the OP is not aware of that Python is space
> sensitive, unlike most(?) programming languages.
>
> for i in range(5):
>print("Hello.")
>print("Goodbye.")
>
> will not run because the indentation (leading spaces) on the third
> line is incorrect.  It must instead line up with the second line.
>
> A single tab is equivalent to a single space as far as Python is
> concerned, but your eyes will report a difference and editors that
> substitute one for the other can cause, after saving, code that was
> formerly working to not work (and, I suppose, the reverse).
>
> Make sure to read the tutorial at http://python.org (which is
> unfortunately down at this moment
> (http://www.downforeveryoneorjustme.com/python.org)).
>



-- 
-
Thanks & Regards
Manish Kumar
| Mob: +91-9911635906 |
manish2...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Unable to remove setup of 3.9.5 from Windows 10

2021-06-19 Thread Manish Jain
Hello Team,

I have installed the Python 3.9.5 and trying to remove from the PC through
the Uninstall Program (All Possible ways - Through Control Panel or
Uninstall Python executable)

It just outputs saying Uninstall Successfully but nothing happening (Still
listed in Programs List) and even not allowing me to install again.

Please let me know if there is any alternate resolution

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


problem using logging module in python

2006-06-06 Thread Manish Marathe
Python Experts every where!!

I am having a problem using the logging utility in Python using the
logging module from the std. lib. I have written a class SPFLogger
which actually should be creating a new logger if one already does not
exist. I have given the class I wrote in the end. The problem I 
am facing is:

I am creating 2/3 object of this class SPFLogger in 2/3 other classes
of mine having different logger name and the handler they will be
using. Although the logs are going in a single file which means the
logging.getLogger(name) function is getting the same logger which was
created earlier and not creating a new logger with new handler.
Eventhough the logs are going in a single file the loggers names used
are different  which I am passing as an argument.

So for example if I do this first in the init method of class A:

obj1 = SPFLogger ("A", "A.log")
logger1 = obj.getLogger()
logger1.info("Message A") > Goes in A.log with logger name A

now class A calls class B so in the init method of class B I have:

obj2 = SPFLogger ("B", "B.log")
logger2 = obj.getLogger()
logger2.info("Message B") > still goes in A.log with logger name B ..

Is there something that needs to be done to handle this? Below is the code for SPFLogger class


-- Manish MaratheSpikeSource, Inc.http://developer.spikesource.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Killing a thread

2006-06-09 Thread Manish Marathe
Hello,

I am creating threads using my self defined class which inherits the
threading.Thread class. I want to know how can I kill the threads which
are being created by the object of my self defined class.

Thanks
-- Manish MaratheSpikeSource, Inc.http://developer.spikesource.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Killing a thread

2006-06-09 Thread Manish Marathe
On 6/9/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
Manish Marathe wrote:> I am creating threads using my self defined class which inherits the> threading.Thread class. I want to know how can I kill the threads which> are being created by the object of my self defined class.
you cannot kill a thread "from the outside"; you have to design yourthread tasks so they can kill themselves, when asked to do that.
Thanks for the reply. So can  a thread listen to an event i.e. can we send an event to the thread indicating to kill itself.
Thanks-- Manish MaratheSpikeSource, Inc.http://developer.spikesource.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Help needed to install ZOracleDA

2007-05-21 Thread Manish Kumar
Hi All,

 

How can I install ZOracleDA on Red Hat Linux machine? 

 

Configuration of my system is as below:

Zope-2.7

Python-2.3.5

Oracle-9i

 

I have tried to install ZOracleDA but installable needed
rh-7.1-python-1.5.2-dco2.so file which is not present in Binaries directory.

 

Any help from you people is appreciable.

 

 

Regards,

Manish Kumar


"Legal Disclaimer: This electronic message and all contents contain information 
from Cybage Software Private Limited which may be privileged, confidential, or 
otherwise protected from disclosure. The information is intended to be for the 
addressee(s) only. If you are not an addressee, any disclosure, copy, 
distribution, or use of the contents of this message is strictly prohibited. If 
you have received this electronic message in error please notify the sender by 
reply e-mail to and destroy the original message and all copies. Cybage has 
taken every reasonable precaution to minimize the risk of malicious content in 
the mail, but is not liable for any damage you may sustain as a result of any 
malicious content in this e-mail. You should carry out your own malicious 
content checks before opening the e-mail or attachment."
www.cybage.com 


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

Needs help to install ZOracleDA

2007-05-21 Thread Manish Kumar

Hi All, 

How can I install ZOracleDA on Red Hat Linux machine? 
Configuration of my system is as below:

Zope-2.7
Python-2.3.5
Oracle-9i

I have tried to install ZOracleDA but installable needed
rh-7.1-python-1.5.2-dco2.so file which is not present in Binaries directory.

Any help from you people is appreciable.
 

Regards,
Manish Kumar



"Legal Disclaimer: This electronic message and all contents contain information 
from Cybage Software Private Limited which may be privileged, confidential, or 
otherwise protected from disclosure. The information is intended to be for the 
addressee(s) only. If you are not an addressee, any disclosure, copy, 
distribution, or use of the contents of this message is strictly prohibited. If 
you have received this electronic message in error please notify the sender by 
reply e-mail to and destroy the original message and all copies. Cybage has 
taken every reasonable precaution to minimize the risk of malicious content in 
the mail, but is not liable for any damage you may sustain as a result of any 
malicious content in this e-mail. You should carry out your own malicious 
content checks before opening the e-mail or attachment."
www.cybage.com 


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


Needs help to install ZOracleDA

2007-05-21 Thread Manish Kumar
Hi All, 

 

How can I install ZOracleDA on Red Hat Linux machine? 

Configuration of my system is as below:

 

Zope-2.7

Python-2.3.5

Oracle-9i

 

I have tried to install ZOracleDA but installable needed
rh-7.1-python-1.5.2-dco2.so file which is not present in Binaries directory.

 

Any help from you people is appreciable.

 

 

Regards,

Manish Kumar

 


"Legal Disclaimer: This electronic message and all contents contain information 
from Cybage Software Private Limited which may be privileged, confidential, or 
otherwise protected from disclosure. The information is intended to be for the 
addressee(s) only. If you are not an addressee, any disclosure, copy, 
distribution, or use of the contents of this message is strictly prohibited. If 
you have received this electronic message in error please notify the sender by 
reply e-mail to and destroy the original message and all copies. Cybage has 
taken every reasonable precaution to minimize the risk of malicious content in 
the mail, but is not liable for any damage you may sustain as a result of any 
malicious content in this e-mail. You should carry out your own malicious 
content checks before opening the e-mail or attachment."
www.cybage.com 


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

Re: Exceptions and unicode messages

2007-03-21 Thread manish kurup

Hey anybody please tell me...
How we can get the properties of a file in python

On 3/21/07, Tuomas <[EMAIL PROTECTED]> wrote:


This works:
>>> raise StandardError(u'Wrong type')
Traceback (most recent call last):
   File "", line 1, in ?
StandardError: Wrong type

but don't in Finnish:
>>> raise StandardError(u'Väärä tyyppi')
Traceback (most recent call last):
   File "", line 1, in ?
StandardError>>>
>>>

Any solution in Python?

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

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

Re: "return" in def

2008-12-28 Thread Manish Sinha

Roger wrote:

Hi Everyone,

First I want to thank everyone that posts to this group.  I read it
daily and always learn something new even if I never feel like I have
anything to contribute but my questions.
  
Same here, I always read the news, but hardly post anything since am not 
very much expert in Python.

Even when I'm not explicitly returning something I like to add
"return" because it's a good additional visual marker for me to see
where a method definition ends especially in cases where I may use a
nested method.
  
I would personally prefer to use a comment for return rather than giving 
an explicit return statement.

e.g.
# return from function

--
Manish Sinha

Personal Blog: http://www.manishsinha.info
Tech Blog: http://manishtech.wordpress.com
OpenPGP Key: 99E6658F

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


Re: deleting a method

2009-01-04 Thread Manish Sinha

Filip Gruszczyński wrote:

I am trying to delete a method from a class. It's easy to delete other
attributes, but when I try:

  

class A:


... def foo():
... pass
...
  

a = A()
del a.foo



I get

Traceback (most recent call last):
  File "", line 1, in 
AttributeError: A instance has no attribute 'foo'

Why is it so and how may still delete it?

  

Sounds crazy

If you want to delete a function, create lambda functions though am not 
sure whether it can be deleted or not.


--
Manish Sinha

Personal Blog: http://www.manishsinha.info
Tech Blog: http://manishtech.wordpress.com
OpenPGP Key: 99E6658F

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


Undefined symbol PyUnicodeUCS2_DecodeUTF8

2009-04-03 Thread Manish Jain


Hi all,

I am using Gnome on FreeBSD 7.1. A few days back, my gnome crashed and I 
have had to spend over 4 days recovering my gnome environment. Pretty 
much everything is okay now except for a few python-dependent 
applications (alacarte, for instance), which exit immediately with the 
following error message :



 Traceback (most recent call last):
  File "/usr/local/bin/alacarte", line 22, in 
from Alacarte.MainWindow import MainWindow
  File "/usr/local/lib/python2.5/site-packages/Alacarte/MainWindow.py", line 19, in 

import gtk, gtk.glade, gmenu, gobject, gio
  File "/usr/local/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py", line 38, in 

import gobject as _gobject
  File "/usr/local/lib/python2.5/site-packages/gtk-2.0/gobject/__init__.py", line 33, 
in 
from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "/usr/local/lib/python2.5/site-packages/gtk-2.0/glib/__init__.py", line 30, in 

from glib._glib import *
ImportError: /usr/local/lib/python2.5/site-packages/gtk-2.0/glib/_glib.so: Undefined 
symbol "PyUnicodeUCS2_DecodeUTF8"

[1]+  Exit 1  alacarte



I have searched google/yahoo for any help without luck. I have rebuilt 
all python and gtk2 ports from scratch but the error continues.


Can anybody please point out the source and/or remedy for the problem ? 
I am using the python25 port.


--

Thank you and Regards
Manish Jain
invalid.poin...@gmail.com
+91-99830-62246

NB : Laast year I kudn't spell Software Engineer. Now I are won.
--
http://mail.python.org/mailman/listinfo/python-list


TypeError: send() argument 1 must be string or read-only buffer, not int

2005-02-17 Thread Manish Gupta (BBS)
Hello
 invoking something like following -
  sock.send(100)
 generates the following error -
  TypeError: send() argument 1 must be string or read-only buffer, 
not int

 how can I work around this? I wish to write
 msg-length on a stream socket.
 thanks in advance.
 manish
--
http://mail.python.org/mailman/listinfo/python-list


Using variable in storbinary function of ftpilb module

2008-10-15 Thread Arya, Manish Kumar
Hi,

  I am new to python.

I have written a simple code to upload a file via ftp to remote server

-
import sys
import ftplib
host=sys.argv[1]
username=sys.argv[2]
passwd=sys.argv[3]
filename=sys.argv[4]

print host,username,passwd

ftp = ftplib.FTP(host,username,passwd)
fd=open(filename,'rb')
ftp.storbinary('STOR filename',fd)
---

I am passing file name in cmd line arg. but I have no idea how to use 
"filename" variable value in ftp.storbinary('STOR filename',fd) ?




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


Exception Handling

2006-01-11 Thread Manish Kumar (WT01 - Software Products & OSS)

Hi,

We have some modules of our project implemented in python and some in C.
We use shared library objects to access C functions from python.

We need to catch the exceptions like segmentation fault occurring in the
C module in python and print the complete stack.

We tried 1) signal.signal(SIGSEGV, handler_function)   
2)  try:
call to C functions through shared object
except:
traceback.print_exc(file=sys.stdout)
We got this.
1) But it hangs the process.

2) It does not print the stack.

Can you please suggest some solutions ?

Thanks and Regards
Manish Kumar



The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.
 
www.wipro.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 28, Issue 191

2006-01-12 Thread Manish Kumar (WT01 - Software Products & OSS)

Hi,

It does not work. I had already tried this earlier.

Please suggest some other solutions.

Also, I would like to see the stack from where the exception started.

Thanks n regards,
Manish Kumar

On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED] wrote:
> Send Python-list mailing list submissions to
>   python-list@python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> Today's Topics:
> 
>1. Re: Exception Handling (Sheldon)
>2. Re: void * C array to a Numpy array using Swig (Jon)
>3. Re: flatten a level one list (Peter Otten)
>4. Re: Why keep identity-based equality comparison? (Paul Rubin)
>5. Re: flatten a level one list (Paul Rubin)
>6. How can I create a dict that sets a flag if it's been
>   modified ([EMAIL PROTECTED])
>7. Re: Python Scripts to logon to websites (Paul Rubin)
>8. Re: flatten a level one list ([EMAIL PROTECTED])
>9. Re: How can I create a dict that sets a flag if it's been
>   modified (Amit Khemka)
>   10. Re: How can I create a dict that sets a flag if it's been
>   modified (Paul Rubin)
>   11. Re: Unicode style in win32/PythonWin (Thomas Heller)
>   12. Re: Real-world use cases for map's None fill-in feature?
>   (Raymond Hettinger)
> email message attachment
> On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED]
> wrote:
> > Hi,
> > This is a non-trivial thing that you are trying to do. You can use some
> > of python's built-in exceptions, like RuntimeError or IOError and if so
> > then:
> > try:
> >call C
> > except IOError, e:
> > print e
> > 
> > But this will return and print only IOErrors if they occur.
> > 
> > You can define your own error handling using the function RAISE:
> > try:
> >   Call C
> > except:
> >   raise my_error.
> > 
> > A catch-all error is RuntimeError; try this first.
> > try:
> >  call C
> > except RuntimeError, r:
> >   print r
> > 
> > You can read up on it here:
> > http://docs.python.org/api/standardExceptions.html
> > 
> > 
> > Cheers,
> > Sheldon
> > 
> > 
> email message attachment
> On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED]
> wrote:
> > Krish,
> > 
> > In case you find a good solution, I am also looking for one!
> > 
> > For now I essentially use helper functions on the c side which wrap in
> > SWIG to return the data as a string in python. That string can then be
> > converted to a numpy array using the fromstring function. This is
> > inefficient as it does an unnecessary copy but avoids dependence on
> > numeric versus numarray etc. It uses the cstring thing in SWIG (see the
> > manual). The library I am wrapping does not have an image struct, but
> > returns the data into memory that the user has to malloc.
> > 
> > In the swig file I have something like this, which I've simplified to
> > try to get to the point. It assumes you have two c functions which take
> > a pointer to your struct as argument, the first returns the size of the
> > data (what to malloc), the second copies the data into your memory
> > where a pointer to the memory location was second arg.
> > 
> > Doubtless I've introduced typos below, but hopefully you get the idea?
> > 
> > Good luck,
> > 
> > Jon
> > ---
> > typedef struct
> > {
> > stuff/* I don't know or care what is in here */
> > } imagefilestruct;
> > 
> > %extend imagefilestruct {
> > 
> >  [... snip constructor destructor other functions etc]
> > 
> > %cstring_output_allocate_size( char ** s, int *slen, free(*$1))
> > get_data ;
> > 
> > void get_data(char **s, int *slen){
> >void * array;
> >size_t size;
> >size = libraryfunction_get_size(self);
> >array=malloc(size));
> >libraryfunc_get_data(self, array);
> >*slen = size;
> >*s = (char *) array;
> >}
> > }
> > 
> > 
> email message attachment
> On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED]
> wrote:
> > Tim Hochberg wrote:
> > 
> > > Here's one more that's quite fast using Psyco, but only aver

Re: Exception Handling

2006-01-12 Thread Manish Kumar (WT01 - Software Products & OSS)

I tried with this piece of code

def temp():

try:
print "In try"
libsummac.main1()
except RuntimeError, re:
print "caught" + re
except e:
print "caught" + e

I think the control is not coming to python code. The output of the
above is ..(In main1 before assignment -- this print is inside the C
function).


In try
In main1 before assignment
Segmentation fault

Can u give some solutions for this???

Thanks n Regards,
Manish Kumar

On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED] wrote:
> Send Python-list mailing list submissions to
>   python-list@python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>   [EMAIL PROTECTED]
> 
> You can reach the person managing the list at
>   [EMAIL PROTECTED]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
> Today's Topics:
> 
>1. Re: Exception Handling (Sheldon)
>2. Re: void * C array to a Numpy array using Swig (Jon)
>3. Re: flatten a level one list (Peter Otten)
>4. Re: Why keep identity-based equality comparison? (Paul Rubin)
>5. Re: flatten a level one list (Paul Rubin)
>6. How can I create a dict that sets a flag if it's been
>   modified ([EMAIL PROTECTED])
>7. Re: Python Scripts to logon to websites (Paul Rubin)
>8. Re: flatten a level one list ([EMAIL PROTECTED])
>9. Re: How can I create a dict that sets a flag if it's been
>   modified (Amit Khemka)
>   10. Re: How can I create a dict that sets a flag if it's been
>   modified (Paul Rubin)
>   11. Re: Unicode style in win32/PythonWin (Thomas Heller)
>   12. Re: Real-world use cases for map's None fill-in feature?
>   (Raymond Hettinger)
> email message attachment
> On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED]
> wrote:
> > Hi,
> > This is a non-trivial thing that you are trying to do. You can use some
> > of python's built-in exceptions, like RuntimeError or IOError and if so
> > then:
> > try:
> >call C
> > except IOError, e:
> > print e
> > 
> > But this will return and print only IOErrors if they occur.
> > 
> > You can define your own error handling using the function RAISE:
> > try:
> >   Call C
> > except:
> >   raise my_error.
> > 
> > A catch-all error is RuntimeError; try this first.
> > try:
> >  call C
> > except RuntimeError, r:
> >   print r
> > 
> > You can read up on it here:
> > http://docs.python.org/api/standardExceptions.html
> > 
> > 
> > Cheers,
> > Sheldon
> > 
> > 
> email message attachment
> On Thu, 2006-01-12 at 10:40 +0100, [EMAIL PROTECTED]
> wrote:
> > Krish,
> > 
> > In case you find a good solution, I am also looking for one!
> > 
> > For now I essentially use helper functions on the c side which wrap in
> > SWIG to return the data as a string in python. That string can then be
> > converted to a numpy array using the fromstring function. This is
> > inefficient as it does an unnecessary copy but avoids dependence on
> > numeric versus numarray etc. It uses the cstring thing in SWIG (see the
> > manual). The library I am wrapping does not have an image struct, but
> > returns the data into memory that the user has to malloc.
> > 
> > In the swig file I have something like this, which I've simplified to
> > try to get to the point. It assumes you have two c functions which take
> > a pointer to your struct as argument, the first returns the size of the
> > data (what to malloc), the second copies the data into your memory
> > where a pointer to the memory location was second arg.
> > 
> > Doubtless I've introduced typos below, but hopefully you get the idea?
> > 
> > Good luck,
> > 
> > Jon
> > ---
> > typedef struct
> > {
> > stuff/* I don't know or care what is in here */
> > } imagefilestruct;
> > 
> > %extend imagefilestruct {
> > 
> >  [... snip constructor destructor other functions etc]
> > 
> > %cstring_output_allocate_size( char ** s, int *slen, free(*$1))
> > get_data ;
> > 
> > void get_data(char **s, int *slen){
> >void * array;
> >size_t size;
> >size = libraryfunction_get_size(self);
> >array=malloc(size));
> >libraryfunc_get_data(self, array);
> >*slen = siz