Re: Hardlink sub-directories and files

2011-08-08 Thread Alexander Gattin
Hello,

On Tue, Aug 02, 2011 at 02:32:54AM -0700, loial
wrote:
> This works fine for files, but the directory
> also contains sub- directories (which themselves
> contain files and sub-directories).  However I
> do not think it is possible to hard link
> directories ?

On some Unices it is, as I heard. But in general,
it's not always possible to even hardlink to an
ordinary file:
1) across filesystem boundary
2) on GRSEC system, if you don't own the original
   file

-- 
WBR,
xrgtn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython and TK

2011-08-08 Thread ln4
azrael wrote:

> Today I found a quote from Guido.
> 
> wxPython is the best and most mature cross-platform GUI toolkit, given a
> number of constraints. The only reason wxPython isn't the standard Python
> GUI toolkit is that Tkinter was there first. -- Guido van Rossum
> 
> OK, now. Isn't it maybe time to throw out TK once and for all? Python is
> missing one of the most important aspects of todays IT industry. GUI
> development native library (I mean a serious one).
> 
> If I would have gotten a dollar for every time I talked to someone in a
> company about why they dont use python for their products and I was served
> the answer "Well it kind of sucks in GUI development", I would be a
> millionaire.

This quote from guido is perhaps from many, many years ago. I don't like 
wxpython so much. There is a much better solution available: using PyQt. Qt 
libraries are cross platform too, mature code and very fast. Including lots 
of tools for development without typing all the graphics code.
Taco
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Segmentation Fault on exit

2011-08-08 Thread Ulrich Eckhardt
Vipul Raheja wrote:
> I have wrapped a library from C++ to Python using SWIG. But when I
> import it in Python, I am able to work fine with it, but it gives a
> segmentation fault while exiting.

1. Use a debugger
Run python with "gdb python", import the module and exit. The debugger 
should then show you where the segmentation fault occurs, even though that 
code isn't necessarily the code that is at fault itself.

2. Reduce the size of your module
Remove code from the module. The most drastic variant is to strip anything 
and only leave an empty init function. If that still causes troubles, I'd 
suspect something in the environment or in the way you build the module.

3. Make sure the environment works
Try compiling and running the SWIG examples or any other SWIG code. Does it 
work? What are the differences to your code?

4. Post your code
If everything fails, you could try to reduce your module to the bare minimum 
and post that here. Make sure you really remove anything that's not 
necessary.


Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: Wait for a keypress before continuing?

2011-08-08 Thread Gelonida N
On 08/08/2011 04:44 AM, John Doe wrote:
> Steven D'Aprano  wrote: 
> 
>> Also, are you using an IDE? If so, it could very well be 
>> interfering with the keyboard buffer 
> 
> I really don't know how to answer your question. I am using 
> Windows XP SP3. Komodo Edit 6 for editing the *.py file. Dragon 
> Naturally Speaking, Natlink, and Dragonfly might all be part of 
> the process. 
> 
> Must be my system. I will post the solution if it comes up. 

Main question is whether your script is exectued in a console window
(like cmd.exe) or from within a graphical library without console.


you yould try to start cmd.exe and call your python script directly from
there.

if this doesn't work, then try just a simple test script containing
nothing else than the code to wait for a keypress.

Simple test script (working fine for me)
import msvcrt
print "before"
msvcrt.getch()
print "after"



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


Re: WxPython and TK

2011-08-08 Thread python
Azrael,

> Isn't it maybe time to throw out TK once and for all? Python is missing one 
> of the most important aspects of todays IT industry. GUI development native 
> library (I mean a serious one).

Check out enhancements to Tk like Ttk included in Python 2.7 and 3.1 and
above.
http://www.tkdocs.com/tutorial/styles.html

Tk/Ttk is a much lighter weight GUI than wxPython and allows for
commercial quality, cross-platform GUI development.

Malcolm



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


PyPDF Processing Errors (ValueError: invalid literal for int() with base 16: '\x00\x00')

2011-08-08 Thread blivori

I am trying to create a Python script using the PyPDF Module. What the
script does it take the 'Root' folder, merges all the PDFs in it and
outputs the merged PDF in an 'Output' folder and renames it to
'Root.pdf' (the folder which containes the split PDFs). What it does
then is do the same with the sub-directories, giving the final output
a name equal to the sub-directories.

I'm stuck when coming to process the sub-directories, giving me an
error code related to some hex values. (it seems that it is getting a
null value which is not in hex)

Please not that this happens only with certain PDF files. All of them
are non-corrupted PDFs and can be opened with any PDFViewer.

This is the error I get:

Traceback (most recent call last):
File "C:\Documents and Settings\student3\Desktop\Test\pdfMerger… line
76, in 
files_recursively(path)
File "C:\Documents and Settings\student3\Desktop\Test\pdfMerger… line
74, in files_recursively
os.path.walk(path, process_file, ())
File "C:\Python27\lib\ntpath.py", line 263, in walk
walk(name, func, arg)
File "C:\Python27\lib\ntpath.py", line 259, in walk
func(arg, top, names)
File "C:\Documents and Settings\student3\Desktop\Test\pdfMerger… line
38, in process_file
pdf = PdfFileReader(file( filename, "rb"))
File "C:\Python27\lib\site-packages\pyPdf\pdf… line 374, in __init__
self.read(stream)
File "C:\Python27\lib\site-packages\pyPdf\pdf… line 775, in read
newTrailer = readObject(stream, self)
File "C:\Python27\lib\site-packages\pyPdf\gen… line 67, in readObject
return DictionaryObject.readFromStream(stream, pdf)
File "C:\Python27\lib\site-packages\pyPdf\gen… line 531, in
readFromStream
value = readObject(stream, pdf)
File "C:\Python27\lib\site-packages\pyPdf\gen… line 58, in readObject
return ArrayObject.readFromStream(stream, pdf)
File "C:\Python27\lib\site-packages\pyPdf\gen… line 153, in
readFromStream
arr.append(readObject(stream, pdf))
File "C:\Python27\lib\site-packages\pyPdf\gen… line 69, in readObject
return readHexStringFromStream(stream)
File "C:\Python27\lib\site-packages\pyPdf\gen… line 276, in
readHexStringFromStream
txt += chr(int(x, base=16))
ValueError: invalid literal for int() with base 16: '\x00\x00'
-- 
http://mail.python.org/mailman/listinfo/python-list


Docstrings and class Attributes

2011-08-08 Thread Nick
Is it possible to put a doc string on a class attribute? Something
like this

class Test (object):
'''classx'''

fred = 10
'''attribute'''

print Test.__doc__
print Test.fred.__doc__

This code produces this output

classx
int(x[, base]) -> integer

Convert a string or number to an integer, if possible.  A floating
point
argument will be truncated towards zero (this does not include a
string
representation of a floating point number!)  When converting a string,
use
the optional base.  It is an error to supply a base when converting a
non-string.  If base is zero, the proper base is guessed based on the
string content.  If the argument is outside the integer range a
long object will be returned instead.

===

So the class doc string is return, but no doc string for the
attribute.


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


SQLObject 1.1.2

2011-08-08 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.1.2, a bugfix release of branch
1.1 of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://pypi.python.org/pypi/SQLObject/1.1.2

News and changes:
http://sqlobject.org/News.html


What's New
==

Features & Interface


* A bug was fixed in SelectResults slicing that prevented to slice a
  slice (my_results[:20][1:5]).

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Embedded python console and FILE* in python 3.2

2011-08-08 Thread Francis Labarre

Hello everyone,
I'm currently trying to port some embedded code from python 2.7 to python 3.2.
The current code replicate the basic behavior of the python interpreter in 
anMFC application. When a command is entered in our embedded interpreter, we 
write it to a FILE* then transform this FILE* into a Python file with the 
apifunction PyFile_FromFile and assign it to python's stdin. We also assign 
anotherFILE* as python's stdout and stderr. We then call PyRun_InteractiveOne 
to executethe statement as the python interpreter normally would. Finally, we 
can easily retrievethe result of the execution from the output FILE*.
This is currently the only approach we have found that allows us to retrieve 
the result of executing a statement exactly as the interpreter would.
The problem is that the implementation of files has changed in python 3 and the 
functionPyFile_FromFile has been removed.
Does anyone knows a way to achieve the same thing as this function either 
trough the io moduleor the python/C api? Or could there be a better approach to 
what we are trying to achieve?
Keep in mind that we need to obtain the result of any statement, i.e. :
If the command is "2+2" the result should be "4", if the command is "1/0" the 
result should be
Traceback (most recent call last):  File "", line 1, in 
ZeroDivisionError: division by zero

Thank you,
F.L.  -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
On 08/08/11 17:17, Francis Labarre wrote:
> Hello everyone,
> 
> I'm currently trying to port some embedded code from python 2.7 to
> python 3.2.
> 
> The current code replicate the basic behavior of the python interpreter
> in an
> MFC application. When a command is entered in our embedded interpreter, 
> we write it to a FILE* then transform this FILE* into a Python file with
> the api
> function PyFile_FromFile and assign it to python's stdin. We also assign
> another
> FILE* as python's stdout and stderr. We then call PyRun_InteractiveOne
> to execute
> the statement as the python interpreter normally would. Finally, we
> can easily retrieve
> the result of the execution from the output FILE*.
> 
> This is currently the only approach we have found that allows us to
> retrieve the 
> result of executing a statement exactly as the interpreter would.
> 
> The problem is that the implementation of files has changed in python 3
> and the function
> PyFile_FromFile has been removed.
> 
> Does anyone knows a way to achieve the same thing as this function
> either trough the io module
> or the python/C api? Or could there be a better approach to what we are
> trying to achieve?
> 
> Keep in mind that we need to obtain the result of any statement, i.e. :
> 
> If the command is "2+2" the result should be "4", if the command is
> "1/0" the result should be
> 
> Traceback (most recent call last):
> File "", line 1, in 
> ZeroDivisionError: division by zero
> 
> 
> Thank you,
> 
> F.L.
> 
> 


I assume you could simply use PyFile_FromFd?

The more elegant solution might be to create custom Python file-like
objects for std{in,out,err} that communicate directly with your application.

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


Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Katriel Cohn-Gordon
Is the `code` module (http://docs.python.org/library/code.html) an
insufficiently exact copy of an interpreter for you?

On Mon, Aug 8, 2011 at 4:17 PM, Francis Labarre
wrote:

>  Hello everyone,
>
> I'm currently trying to port some embedded code from python 2.7 to python
> 3.2.
>
> The current code replicate the basic behavior of the python interpreter in
> an
> MFC application. When a command is entered in our embedded interpreter,
> we write it to a FILE* then transform this FILE* into a Python file with
> the api
> function PyFile_FromFile and assign it to python's stdin. We also assign
> another
> FILE* as python's stdout and stderr. We then call PyRun_InteractiveOne to
> execute
> the statement as the python interpreter normally would. Finally, we
> can easily retrieve
> the result of the execution from the output FILE*.
>
> This is currently the only approach we have found that allows us to
> retrieve the
> result of executing a statement exactly as the interpreter would.
>
> The problem is that the implementation of files has changed in python 3 and
> the function
> PyFile_FromFile has been removed.
>
> Does anyone knows a way to achieve the same thing as this function either
> trough the io module
> or the python/C api? Or could there be a better approach to what we are
> trying to achieve?
>
> Keep in mind that we need to obtain the result of any statement, i.e. :
>
> If the command is "2+2" the result should be "4", if the command is "1/0"
> the result should be
>
> Traceback (most recent call last):
> File "", line 1, in 
> ZeroDivisionError: division by zero
>
>
> Thank you,
>
> F.L.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython and TK

2011-08-08 Thread Philip Semanchuk

On Aug 7, 2011, at 8:26 PM, azrael wrote:

> Today I found a quote from Guido.
> 
> wxPython is the best and most mature cross-platform GUI toolkit, given a 
> number of constraints. The only reason wxPython isn't the standard Python GUI 
> toolkit is that Tkinter was there first.
> -- Guido van Rossum
> 
> OK, now. Isn't it maybe time to throw out TK once and for all? Python is 
> missing one of the most important aspects of todays IT industry. GUI 
> development native library (I mean a serious one).

I don't see how removing TK from the standard library helps to fill the native 
GUI development library void that you see in 
Python. I guess you're promoting wxPython as the library to fill that void. 
Getting rid of TK is one argument, adding wxPython is different argument. Are 
you advocating one, the other, or both?



> If I would have gotten a dollar for every time I talked to someone in a 
> company about why they dont use python for their products and I was served 
> the answer "Well it kind of sucks in GUI development", I would be a 
> millionaire.

And if I had a dollar for every "Let's replace TK with XYZ" post, I'd also be a 
millionaire. 

I don't object to your argument; criticism of standard library is how it 
advances. But you're going to have to come up with a better argument than a 5+ 
year old quote from Guido and an exaggerated claim about why people don't use 
Python. The "best Python GUI library" conversation is repeated on this list at 
least once every few months. If the subject really interests you, I recommend 
that you read the archives and see some of the arguments for and against 
various GUI toolkits. 

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


smtp

2011-08-08 Thread Verde Denim
I'm working on learning various aspects of Py coding, and happened to review
the smtplib docs this morning.
I entered the sample code from
http://www.python.org/doc//current/library/smtplib.html

import smtplib
def prompt(prompt):
return raw_input(prompt).strip()
fromaddr = prompt("From: ")toaddrs  = prompt("To: ").split()print
"Enter message, end with ^D (Unix) or ^Z (Windows):"
# Add the From: and To: headers at the start!msg = ("From: %s\r\nTo: %s\r\n\r\n"
   % (fromaddr, ", ".join(toaddrs)))while 1:
try:
line = raw_input()
except EOFError:
break
if not line:
break
msg = msg + line
print "Message length is " + repr(len(msg))
server = 
smtplib.SMTP('localhost')server.set_debuglevel(1)server.sendmail(fromaddr,
toaddrs, msg)server.quit()

and it returns -
"TypeError" with no other information...
It appears to be generated from the line

msg = ("From: %s\r\nTo: %s\r\n\r\n"
   % (fromaddr, ", ".join(toaddrs)))

But I'm not sure why...

Any input is appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtp

2011-08-08 Thread Chris Angelico
On Mon, Aug 8, 2011 at 5:08 PM, Verde Denim  wrote:
> and it returns -
> "TypeError" with no other information...
> It appears to be generated from the line
>
> msg = ("From: %s\r\nTo: %s\r\n\r\n"
>% (fromaddr, ", ".join(toaddrs)))
>
> But I'm not sure why...
>

I transcribed pieces manually from your code into Python 2.4.5 and
didn't get an error. What did you enter at the From: and To: prompts?

As a side point: Does anyone else feel that it's potentially confusing
to have a function whose parameter has the same name as the function
itself? This is straight from the example.

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


Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 6:37 AM, Nick  wrote:
> Is it possible to put a doc string on a class attribute? Something
> like this

You can put a docstring on a property (which is a function):

class Test(object):
@property
def fred(self):
"attribute"
return 10

Python syntax supports implicitly building docstrings only for
modules, class definitions, and function definitions.

-eric

>
> class Test (object):
>    '''classx'''
>
>    fred = 10
>    '''attribute'''
>
> print Test.__doc__
> print Test.fred.__doc__
>
> This code produces this output
>
> classx
> int(x[, base]) -> integer
>
> Convert a string or number to an integer, if possible.  A floating
> point
> argument will be truncated towards zero (this does not include a
> string
> representation of a floating point number!)  When converting a string,
> use
> the optional base.  It is an error to supply a base when converting a
> non-string.  If base is zero, the proper base is guessed based on the
> string content.  If the argument is outside the integer range a
> long object will be returned instead.
>
> ===
>
> So the class doc string is return, but no doc string for the
> attribute.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtp

2011-08-08 Thread Verde Denim
On Mon, Aug 8, 2011 at 12:26 PM, Chris Angelico  wrote:

> On Mon, Aug 8, 2011 at 5:08 PM, Verde Denim  wrote:
> > and it returns -
> > "TypeError" with no other information...
> > It appears to be generated from the line
> >
> > msg = ("From: %s\r\nTo: %s\r\n\r\n"
> >% (fromaddr, ", ".join(toaddrs)))
> >
> > But I'm not sure why...
> >
>
> I transcribed pieces manually from your code into Python 2.4.5 and
> didn't get an error. What did you enter at the From: and To: prompts?
>
>
I'm running 2.6.5 on a debian base...
It didn't seem to matter what is input -
I tried using a single recipient as well as multiples (separated by comma).

Output appears as -
# python send_my_msg.py
From: m...@me.com
To: y...@you.com
Enter Message, end with ^D:
Traceback (most recent call last):
  File "send_my_msg.py", line 12, in 
 % (fromaddr, ", ".join(toaddr)))
TypeError


> As a side point: Does anyone else feel that it's potentially confusing
> to have a function whose parameter has the same name as the function
> itself? This is straight from the example.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtp

2011-08-08 Thread Chris Angelico
On Mon, Aug 8, 2011 at 5:45 PM, Verde Denim  wrote:
> I'm running 2.6.5 on a debian base...
> It didn't seem to matter what is input -
> I tried using a single recipient as well as multiples (separated by comma).

Since the recipient list is divided using split(), you should separate
multiple addresses with spaces. However, that won't cause your
problem.

I copied and pasted your exact code and tried it on three different
versions. Obviously Python 3 didn't like it (print statements). Python
2.4.5 failed on importing _socket, so I assume there's a minimum
version required. But 2.6.5 worked fine:


From: foo@bar
To: asdf@qwer
Enter message, end with ^D (Unix) or ^Z (Windows):
zxcvaasdf
ssdfzxcv
^Z
Message length is 49
Traceback (most recent call last):
  File "1test.py", line 24, in 
server = smtplib.SMTP('localhost')
  File "C:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
  File "C:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Python26\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
  File "C:\Python26\lib\socket.py", line 514, in create_connection
raise error, msg
socket.error: [Errno 10061] No connection could be made because the target machi
ne actively refused it

C:\>

I don't have an SMTP server running on localhost, but the script
worked fine. Can you quote a failing traceback please? It might be
instructive.

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


RE: Embedded python console and FILE* in python 3.2

2011-08-08 Thread F L

> Is the `code` module (http://docs.python.org/library/code.html) an 
> insufficiently exact copy of an interpreter for you?
The problem isn't really to emulate the behavior of the interpreter as to 
obtain the result of the execution as a string in c++. The code module doesn't 
seem to help with this matter.
> I assume you could simply use PyFile_FromFd?
According to the documentation using PyFile_FromFd seems unadvised, but I'll 
give it a try.
> The more elegant solution might be to create custom Python file-like> objects 
> for std{in,out,err} that communicate directly with your application.I thought 
> about this, but I need the console window to be non-modal and I'm afraid that 
> replacing stdin witha custom file-like object would cause a blocking call. 
> Executing python in a second thread would solve this problembut our 
> application isn't multi-threaded and executing python in another thread 
> causes errors.
Maybe I could use a file-like object to communicate the results to my c++ 
application and use the code module to execute code only when the c++ 
application needs it.
Thanks a lot for the tips, have a nice day.
F.L.  -- 
http://mail.python.org/mailman/listinfo/python-list


PyCon US 2012 Survey - We need your input!

2011-08-08 Thread Brian Curtin
Hi all,

As we ramp up our efforts on PyCon US 2012, we wanted to gather some
information from the community on what we can do best to serve you at the
March 2012 conference in Santa Clara, CA. We've put together a survey about
your experiences at past PyCons as well as what your interests are in the
upcoming conference. We're interested in what speakers and topics you'd like
to have at the tutorials, conference, and the poster sessions, as well as
any input you have on what we can improve in other aspects of the event.

If you have 5 minutes to spare, the survey is available at
https://www.surveymonkey.com/s/pycon2012_launch_survey and results will be
used to help us make PyCon 2012 the best conference yet.

Thanks,

The PyCon Organizers
http://us.pycon.org/2012/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
On 08/08/11 19:14, F L wrote:
>> Is the `code` module (http://docs.python.org/library/code.html) an
> insufficiently exact copy of an interpreter for you?
> 
> The problem isn't really to emulate the behavior of the interpreter as
> to obtain the result of the execution as a string in c++. 
> The code module doesn't seem to help with this matter.
> 
>> I assume you could simply use PyFile_FromFd?
> 
> According to the documentation using PyFile_FromFd seems unadvised, but
> I'll give it a try.
> 
>> The more elegant solution might be to create custom Python file-like
>> objects for std{in,out,err} that communicate directly with your application.
> 
> I thought about this, but I need the console window to be non-modal and
> I'm afraid that replacing stdin with
> a custom file-like object would cause a blocking call. Executing python
> in a second thread would solve this problem
> but our application isn't multi-threaded and executing python in another
> thread causes errors.

If you use the same workflow as you do currently, it won't:

1. Feed input to your custom stdin object, which will buffer the code.
2. Call PyRun_IteractiveOne - it will read from your object, which will
   return the buffer contents.
3. The result is somehow handled by custom stdout and stderr objects.

> 
> Maybe I could use a file-like object to communicate the results to my
> c++ application and use the code 
> module to execute code only when the c++ application needs it.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
On 08/08/11 19:44, Thomas Jollans wrote:
> If you use the same workflow as you do currently, it won't:
> 
> 1. Feed input to your custom stdin object, which will buffer the code.
> 2. Call PyRun_IteractiveOne - it will read from your object, which will
>return the buffer contents.
> 3. The result is somehow handled by custom stdout and stderr objects.
> 

Come to think of it, you might as well just use StringIO.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Embedded python console and FILE* in python 3.2

2011-08-08 Thread F L

> If you use the same workflow as you do currently, it won't
You're right it shouldn't cause a blocking call.
> Come to think of it, you might as well just use StringIO.
Yes I could probably replace std{in, out, err} with stringIO objects and 
retrieve their contents throughthe api.
I'll look into it, thank again.

F.L.

> Date: Mon, 8 Aug 2011 19:52:14 +0200
> From: t...@jollybox.de
> To: python-list@python.org
> Subject: Re: Embedded python console and FILE* in python 3.2
> 
> On 08/08/11 19:44, Thomas Jollans wrote:
> 
> > 
> > 1. Feed input to your custom stdin object, which will buffer the code.
> > 2. Call PyRun_IteractiveOne - it will read from your object, which will
> >return the buffer contents.
> > 3. The result is somehow handled by custom stdout and stderr objects.
> > 
> 
> Come to think of it, you might as well just use StringIO.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
  -- 
http://mail.python.org/mailman/listinfo/python-list


Re: smtp

2011-08-08 Thread Hegedüs , Ervin
hello,

> 
> import smtplib
> def prompt(prompt):
> return raw_input(prompt).strip()
> fromaddr = prompt("From: ")toaddrs  = prompt("To: ").split()print
> "Enter message, end with ^D (Unix) or ^Z (Windows):"
> # Add the From: and To: headers at the start!msg = ("From: %s\r\nTo: 
> %s\r\n\r\n"
>% (fromaddr, ", ".join(toaddrs)))while 1:
> try:
> line = raw_input()
> except EOFError:
> break
> if not line:
> break
> msg = msg + line
> print "Message length is " + repr(len(msg))
> server = 
> smtplib.SMTP('localhost')server.set_debuglevel(1)server.sendmail(fromaddr,
> toaddrs, msg)server.quit()
> 
> and it returns -
> "TypeError" with no other information...
> It appears to be generated from the line
> 
> msg = ("From: %s\r\nTo: %s\r\n\r\n"
>% (fromaddr, ", ".join(toaddrs)))
> 
> But I'm not sure why...

after I copied it to a script, I've got this result:


From: airw...@gmail.com
To: airw...@index.hu
Enter message, end with ^D (Unix) or ^Z (Windows):
Teszt
Message length is 55
send: 'ehlo slave.myhost.hu\r\n'
reply: '250-ns2.myhost.hu\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-SIZE 1024\r\n'
reply: '250-VRFY\r\n'
reply: '250-ETRN\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-AUTH PLAIN LOGIN\r\n'
reply: '250-AUTH=PLAIN LOGIN\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-8BITMIME\r\n'
reply: '250 DSN\r\n'
reply: retcode (250); Msg: ns2.myhost.hu
PIPELINING
SIZE 1024
VRFY
ETRN
STARTTLS
AUTH PLAIN LOGIN
AUTH=PLAIN LOGIN
ENHANCEDSTATUSCODES
8BITMIME
DSN
send: 'mail FROM: size=55\r\n'
reply: '250 2.1.0 Ok\r\n'
reply: retcode (250); Msg: 2.1.0 Ok
send: 'rcpt TO:\r\n'
reply: '250 2.1.5 Ok\r\n'
reply: retcode (250); Msg: 2.1.5 Ok
send: 'data\r\n'
reply: '354 End data with .\r\n'
reply: retcode (354); Msg: End data with .
data: (354, 'End data with .')
send: 'From: airw...@gmail.com\r\nTo: airw...@index.hu\r\n\r\nTeszt\r\n.\r\n'
reply: '250 2.0.0 Ok: queued as 643F144002\r\n'
reply: retcode (250); Msg: 2.0.0 Ok: queued as 643F144002
data: (250, '2.0.0 Ok: queued as 643F144002')
send: 'quit\r\n'
reply: '221 2.0.0 Bye\r\n'
reply: retcode (221); Msg: 2.0.0 Bye


And there is that mail in my inbox...


Debian Lenny, Python 2.5.2

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


Re: Docstrings and class Attributes

2011-08-08 Thread Terry Reedy

On 8/8/2011 8:37 AM, Nick wrote:

Is it possible to put a doc string on a class attribute?


Class and function docstrings are generated from string expression 
statements at the beginning of a suite.



class Test (object):
 '''classx'''

 fred = 10
 '''attribute'''


This is two statements that have no particular connection with each other.


print Test.__doc__
print Test.fred.__doc__

This code produces this output

classx
int(x[, base]) ->  integer

...
If an instance does not have a requested attribute, it is looked up on 
its class (and superclasses). Since all classes are subclasses of object 
and that has a docstring, I guess everything will.


--
Terry Jan Reedy

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


Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Eric Snow wrote:

> On Mon, Aug 8, 2011 at 6:37 AM, Nick  wrote:
>> Is it possible to put a doc string on a class attribute? Something
>> like this
> 
> You can put a docstring on a property (which is a function):
> 
> class Test(object):
> @property
> def fred(self):
> "attribute"
> return 10

Which, however, doesn't really help:

>>> t = Test()
>>> t.fred.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number to an integer ...'


The problem is that t.fred returns an integer, so t.fred.__doc__ returns the
docstring from the integer, not for the property.

>>> t.__class__.fred.__doc__
'attribute'



-- 
Steven

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


Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Nick wrote:

> Is it possible to put a doc string on a class attribute? Something
> like this
> 
> class Test (object):
> '''classx'''
> fred = 10
> '''attribute'''


The short answer is, no.

The longer answer is, maybe, if you can make Test.fred be some sort of
object with a docstring:

class MyInt(int):
'''attribute'''

class Test(object):
'''classx'''
fred = MyInt(10)


>>> Test.fred.__doc__
'attribute'


But the hard part is ensuring that Test.fred doesn't get replaced:

>>> Test.fred = 11
>>> Test.fred.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number ...'


Not impossible to solve, but an awful lot of trouble for very little
benefit. Just put your documentation in the class, where people expect to
find it:

class Test(object):
'''classx

Test.fred is an attribute.
'''
fred = 10



-- 
Steven

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


Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Terry Reedy

On 8/8/2011 11:17 AM, Francis Labarre wrote:

Hello everyone,

I'm currentlytrying to port some embedded code from python 2.7 to python
3.2.

The current code replicate the basic behavior of the python interpreter
in an
MFC application. When a command is entered in our embedded interpreter,
we write it to a FILE* then transform this FILE* into a Python file with
the api
function PyFile_FromFile and assign it to python's stdin. We also assign
another
FILE* as python's stdout and stderr. We then call PyRun_InteractiveOne
to execute
the statement as the python interpreter normally would. Finally, we can
easily retrieve
the result of the execution from the output FILE*.

This is currently the only approach we have found that allows us to
retrieve the
result of executing a statement exactly as the interpreter would.

The problem is that the implementation of files has changed in python 3
and the function
PyFile_FromFile has been removed.


The source for the function is still available in 2.7. You might be able 
to adapt it to work in 3.x.


IDLE imitates the interactive interpreter by running code in a separate 
non-console pythonw process. There have been issues with getting that to 
work right on Windows (see issue 12540), but it works well when it does. 
Depending on your use case, this might work for you too. Communication 
is through (wrapped) OS pipes, not normal Python file objects.


--
Terry Jan Reedy

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


Re: Docstrings and class Attributes

2011-08-08 Thread Ethan Furman

Steven D'Aprano wrote:

Eric Snow wrote:


On Mon, Aug 8, 2011 at 6:37 AM, Nick  wrote:

Is it possible to put a doc string on a class attribute? Something
like this

You can put a docstring on a property (which is a function):

class Test(object):
@property
def fred(self):
"attribute"
return 10


Which, however, doesn't really help:

--> t = Test()
--> t.fred.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number to an integer ...'


The problem is that t.fred returns an integer, so t.fred.__doc__ returns the
docstring from the integer, not for the property.

--> t.__class__.fred.__doc__
'attribute'


So if property docstrings are so hard to get to, what's the point in 
having them?


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


Re: Docstrings and class Attributes

2011-08-08 Thread Terry Reedy

On 8/8/2011 2:26 PM, Steven D'Aprano wrote:

Eric Snow wrote:


On Mon, Aug 8, 2011 at 6:37 AM, Nick  wrote:

Is it possible to put a doc string on a class attribute?


This really makes little sense. The purpose of docstrings is to give 
interactive help. The place to document data attributes of a class is in 
the class docstring. The value of an int is considered to be 
self-explanatory.



You can put a docstring on a property (which is a function):

class Test(object):
 @property
 def fred(self):
 "attribute"
 return 10


Which, however, doesn't really help:


t = Test()
t.fred.__doc__

'int(x[, base]) ->  integer\n\nConvert a string or number to an integer ...'


The problem is that t.fred returns an integer, so t.fred.__doc__ returns the
docstring from the integer, not for the property.


t.__class__.fred.__doc__

'attribute'


Which is to say, the descriptor protocol allows custom get, set, and 
delete methods, but not an attribute-specific getattribute method ;-).


--
Terry Jan Reedy

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


Re: smtp

2011-08-08 Thread Terry Reedy

On 8/8/2011 12:26 PM, Chris Angelico wrote:


As a side point: Does anyone else feel that it's potentially confusing
to have a function whose parameter has the same name as the function
itself? This is straight from the example.


Yes. I might change it someday when I can.

--
Terry Jan Reedy

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


Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Ethan Furman wrote:

> So if property docstrings are so hard to get to, what's the point in
> having them?

Hard to get, not impossible. But I have no idea really -- they don't seem
very useful to me.



-- 
Steven

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


Re: smtp

2011-08-08 Thread Terry Reedy

On 8/8/2011 12:08 PM, Verde Denim wrote:

I'm working on learning various aspects of Py coding, and happened to
review the smtplib docs this morning.
I entered the sample code from
http://www.python.org/doc//current/library/smtplib.html


When posting about error messages, please specify Python version used 
and copy *entire* traceback


--
Terry Jan Reedy

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


Re: smtp

2011-08-08 Thread Terry Reedy

On 8/8/2011 12:45 PM, Verde Denim wrote:


I'm running 2.6.5 on a debian base...
It didn't seem to matter what is input -
I tried using a single recipient as well as multiples (separated by comma).

Output appears as -
# python send_my_msg.py
From: m...@me.com 
To: y...@you.com 
Enter Message, end with ^D:
Traceback (most recent call last):
   File "send_my_msg.py", line 12, in 
  % (fromaddr, ", ".join(toaddr)))
TypeError


I am concerned about the lack of any message. It is close to being a 
bug. If this happens with current Python, 2.7.2 or 3.2.1, posting to the 
bug tracker a minimal example needed to get the above might result in a fix.


--
Terry Jan Reedy

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


Re: Docstrings and class Attributes

2011-08-08 Thread Chris Kaynor
They are actually quite easy to get to. help() on both the class or instance
produces the docstring, and __doc__ on the property as accessed from the
class produces the docstring.

>>> class Test(object):
... @property
... def fred(self):
... """*This is a docstring.*"""
... return 1
...
>>> help(Test)
Help on class Test in module __main__:

class Test(__builtin__.object)
 |  Data descriptors defined here:
 |
 |  __dict__
 |  dictionary for instance variables (if defined)
 |
 |  __weakref__
 |  list of weak references to the object (if defined)
 |
 |  fred
 |  *This is a docstring.*
>>> Test.fred.__doc__
'*This is a docstring*.'
>>> t = Test()
>>> t.fred.__doc__
'int(x[, base]) -> integer\n\n...'
>>> help(t)
Help on Test in module __main__ object:

class Test(__builtin__.object)
 |  Data descriptors defined here:
 |
 |  __dict__
 |  dictionary for instance variables (if defined)
 |
 |  __weakref__
 |  list of weak references to the object (if defined)
 |
 |  fred
 |  *This is a docstring.*





Chris


On Mon, Aug 8, 2011 at 12:05 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> Ethan Furman wrote:
>
> > So if property docstrings are so hard to get to, what's the point in
> > having them?
>
> Hard to get, not impossible. But I have no idea really -- they don't seem
> very useful to me.
>
>
>
> --
> Steven
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 1:05 PM, Steven D'Aprano
 wrote:
> Ethan Furman wrote:
>
>> So if property docstrings are so hard to get to, what's the point in
>> having them?
>
> Hard to get, not impossible. But I have no idea really -- they don't seem
> very useful to me.

They do show up in help(), but not as some sort of data-attribute docstring.

-eric

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


Object Diffs

2011-08-08 Thread Croepha
Hello Python list:

I am doing research into doing network based propagation of python
objects.  In order to maintain network efficiency. I wan't to just
send the differences of python objects, I was wondering if there
was/is any other research or development in this area? I was thinking
that I could look at how pickle works an implement a diff system
there, or I could actually create a pickle of the object and then use
difflib to compare the flattened text...

Ideas, or comments welcome

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


Re: Object Diffs

2011-08-08 Thread Chris Angelico
On Mon, Aug 8, 2011 at 8:50 PM, Croepha  wrote:
> I am doing research into doing network based propagation of python
> objects.  In order to maintain network efficiency. I wan't to just
> send the differences of python objects

You could send pickled versions of each of the object's attributes,
rather than the whole object. Then simply have a notation for "same as
before", and you are sending the delta of attributes. If your set of
important attributes is stable, this could be quite efficient. OTOH,
this won't help if your attributes are complex structures for which
you want to send detailed diffs, that won't work.

Another way would be to pickle the object, and then use any string
diff utility to find the significant portions. I don't know whether
pickle is guaranteed to be stable on dictionaries, though; you might
get a lot of "diff noise".

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


Re: Object Diffs

2011-08-08 Thread Dan Stromberg
You probably need a recursive algorithm to be fully general, and yes,
looking at pickle might be a good place to start.  Note that pickle can't
pickle everything, but it can handle most things.

Also check out NX - not the CPU feature, but the (re)transmission
compressing software (there are two different things with the name "NX").
NX is remarkably good at dealing with things like VNC sessions with virtual
desktops, as long as you don't throw a movie at it - and it's more general
than just doing VNC.

Note that sometimes computing a diff and sending the differences may end up
being slower than transmitting the whole object.

You might also check out pyro and similar tools.

On Mon, Aug 8, 2011 at 12:50 PM, Croepha  wrote:

> Hello Python list:
>
> I am doing research into doing network based propagation of python
> objects.  In order to maintain network efficiency. I wan't to just
> send the differences of python objects, I was wondering if there
> was/is any other research or development in this area? I was thinking
> that I could look at how pickle works an implement a diff system
> there, or I could actually create a pickle of the object and then use
> difflib to compare the flattened text...
>
> Ideas, or comments welcome
>
> Thanks,
> Dave Butler
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object Diffs

2011-08-08 Thread Terry Reedy

On 8/8/2011 3:50 PM, Croepha wrote:

Hello Python list:


Hi


I am doing research into doing network based propagation of python
objects.In order to maintain network efficiency. I want to just
send the differences of python objects, I was wondering if there
was/is any other research or development in this area? I was thinking
that I could look at how pickle works an implement a diff system
there, or I could actually create a pickle of the object and then use
difflib to compare the flattened text...


The problem cannot be tackled efficiently 'in general'. The important 
issue is to choose a representation that localizes differences in a 
particular application so that the diff is significantly smaller than 
just sending the changed version.


Source code systems regard files as sequences of lines. That is ok for 
formatted source code, not so good for prose in paragraphs where a small 
change in one line may cause re-wrapping that changes 20 lines. 
Compressed representations that spread the effect of localized changes 
are also bad for local diffs. A representation that arbitrarily orders 
items (and re-orders items at will), is also bad for local diffs.


I have no idea how stable and local pickles are, but I know they were 
not designed for diff-ing. Json or yaml representations might do better 
if applicable.


--
Terry Jan Reedy

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


Re: Object Diffs

2011-08-08 Thread python
Croepha,

You may find it simpler and sufficiently efficient to compress your
objects in whatever format they exist (pickle, json, xml, etc) and send
the compressed equivalents vs. trying to diff on side and reassemble on
the other side.

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


Re: Object Diffs

2011-08-08 Thread Chris Angelico
On Tue, Aug 9, 2011 at 1:23 AM, Terry Reedy  wrote:
> I have no idea how stable and local pickles are, but I know they were not
> designed for diff-ing. Json or yaml representations might do better if
> applicable.
>

In terms of stability, you'd probably have to have a rule that
dictionaries are sorted by their keys before being encoded. Currently
I can think of only one spec that requires that, and that's the
.torrent file definition (it's mandated so that the info hash is
stable). It may be necessary to build your own encoder routine to
enforce this; you could still use a standard format, which will mean
that a standard decoder will work fine.

Depending on what you're doing, though, it might well be easier to
abandon the entire notion of pickling an object and sending it, and
instead send higher-level conceptual data. I've always been a bit
leery of systems that let you "send an object" from one computer to
another, because they're so easily misused; instead of sending the
data that's needed at the other end, an entire complex object is sent,
and the far end extracts the data it wants. Not only does a ridiculous
amount of unnecessary data get encoded, transmitted, and decoded, but
sometimes it can have security implications (such as a certain
multiplayer game that reveals to any player the identities of all
other players, including their login email addresses and IP
addresses).

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


Re: Object Diffs

2011-08-08 Thread Steven D'Aprano
Croepha wrote:

> Hello Python list:
> 
> I am doing research into doing network based propagation of python
> objects.  In order to maintain network efficiency. I wan't to just
> send the differences of python objects,

Can you explain in more detail what you mean?

Are there constraints on what the objects can be? If you have two objects:

a = None
b = (1, 2, "hello world", [])

how would you describe the diff between a and b?

If a and b are both numbers, the diff between them is just a-b, but this
itself is a number and so transmitting it takes exactly as much memory as
just sending b.

Obviously if a and b are strings, the problem becomes trivial (just
transmitted the string diff, which is a solved problem).

> I was wondering if there 
> was/is any other research or development in this area? I was thinking
> that I could look at how pickle works an implement a diff system
> there, or I could actually create a pickle of the object and then use
> difflib to compare the flattened text...

The source code for pickle is available. See the pickle.py and
pickletools.py files in your Python installation.

Also, these resources may help:

http://wiki.python.org/moin/DistributedProgramming
http://wiki.python.org/moin/ParallelProcessing


-- 
Steven

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


Re: Docstrings and class Attributes

2011-08-08 Thread Ben Finney
Ethan Furman  writes:

> So if property docstrings are so hard to get to, what's the point in
> having them?

Why would you expect there be a special point to them?

Men, like all primates of any sex, have nipples.

Properties, like any function in Python, have docstrings.

They're an accident of the history that led to their implementation, and
of the pre-existing parts that they're built from. There doesn't need to
be a point to them (though they might be useful for reasons incidental
for the reasons they exist).

-- 
 \“I filled my humidifier with wax. Now my room is all shiny.” |
  `\—Steven Wright |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Ben Finney wrote:

> Ethan Furman  writes:
> 
>> So if property docstrings are so hard to get to, what's the point in
>> having them?
> 
> Why would you expect there be a special point to them?
> 
> Men, like all primates of any sex, have nipples.
> 
> Properties, like any function in Python, have docstrings.
> 
> They're an accident of the history that led to their implementation, and
> of the pre-existing parts that they're built from. There doesn't need to
> be a point to them (though they might be useful for reasons incidental
> for the reasons they exist).

But properties *aren't* functions, they are objects which obey the
descriptor protocol. Perhaps you are thinking of the individual getter,
setter and deleter parameters to property(). If so, then your comment is
relevant as far as it goes to the docstrings on the individual
getter/setter/deleter functions. But property() itself explicitly takes a
docstring parameter. It is that docstring that seems of limited value,
except that Eric Snow has pointed out that help(instance) will display
property help strings.


-- 
Steven

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


Re: Docstrings and class Attributes

2011-08-08 Thread Ben Finney
Steven D'Aprano  writes:

> Ben Finney wrote:
>
> > They're an accident of the history that led to their implementation,
> > and of the pre-existing parts that they're built from. There doesn't
> > need to be a point to them (though they might be useful for reasons
> > incidental for the reasons they exist).
>
> But property() itself explicitly takes a docstring parameter. It is
> that docstring that seems of limited value, except that Eric Snow has
> pointed out that help(instance) will display property help strings.

I had forgotten that there is explicit support for adding a docstring to
the property itself. That does raise the question of why :-/

Oh well, I like the analogy and will find a better place soon to
force-fit it to a technical discussion :-)

-- 
 \ Lucifer: “Just sign the Contract, sir, and the Piano is yours.” |
  `\ Ray: “Sheesh! This is long! Mind if I sign it now and read it |
_o__)later?” —http://www.achewood.com/ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Network shares in Windows

2011-08-08 Thread Nanda, Ameet
Hi All,

I was trying to access a network shared folder on a windows network. I couldn' 
t find of a good documentation online to do that. Are there any recommendations 
on how to do it in windows. So if my folder is shared as 
\\ameetn\Dropbox and when I am trying to open it up, 
it says I don't have privileges to open it every time I try doing that.

>>> open("ameetn\\Dropbox")
Traceback (most recent call last):
  File "", line 1, in 
IOError: [Errno 13] Permission denied: 'ameetn\\Dropbox'

Al though I try this from the administrator cmd, I still get the same error. 
Can anyone please recommend me a good way to do this.


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


Re: Network shares in Windows

2011-08-08 Thread MRAB

On 09/08/2011 02:46, Nanda, Ameet wrote:

Hi All,

I was trying to access a network shared folder on a windows network. I
couldn’ t find of a good documentation online to do that. Are there any
recommendations on how to do it in windows. So if my folder is shared as
\\ameetn\Dropbox  and when I am trying to open
it up, it says I don’t have privileges to open it every time I try doing
that.

 >>> open("ameetn\\Dropbox")

Traceback (most recent call last):

File "", line 1, in 

IOError: [Errno 13] Permission denied: 'ameetn\\Dropbox'

Al though I try this from the administrator cmd, I still get the same
error. Can anyone please recommend me a good way to do this.


\\ameetn\Dropbox is a folder. 'open' is for opening files.

If \\ameetn\Dropbox\foo is the path to a file, then:

f = open(r"\\ameetn\Dropbox\foo")

will open it.
--
http://mail.python.org/mailman/listinfo/python-list


Need help with Python to C code compiler

2011-08-08 Thread Vijay Anantha Murthy
Hi All,

Is there any compiler which will help me convert my python code to proper C
code?
In my python code I am using the XML.dom.minidom module to parse an xml and
process the results obtained by ElementsByTagName.
I don't know of any such compiler which will help me convert this kind of
python code to C code.

My intention is to convert python code to a readable C code which can later
be compile to an .exe file.
Cython will not be of much use to me as it is in the end writing c
extensions which will later be used in python.
However, I wish to use this as a proper readable C code which can later be
shared with users - the c source code as well as the exe along with its
corresponding
.py file.

My main impediment here is writing out the C code manually myself, my C
skills are quite poor and it would require a huge effort to sharpening my
C skills before writing the code myself, I can not afford that luxury of
time.

I was surfing and came across shedskin, but that might not just support the
xml minidom module for my purposes.

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


Re: Need help with Python to C code compiler

2011-08-08 Thread Dan Stromberg
Shedskin is one option - if it doesn't have the modules you need, you could
try finding pure python versions of them and translating them too, along
with your own code.

Cython is probably the one I hear the most about.

On Mon, Aug 8, 2011 at 10:37 PM, Vijay Anantha Murthy <
vijay.mur...@gmail.com> wrote:

> Hi All,
>
> Is there any compiler which will help me convert my python code to proper C
> code?
> In my python code I am using the XML.dom.minidom module to parse an xml and
> process the results obtained by ElementsByTagName.
> I don't know of any such compiler which will help me convert this kind of
> python code to C code.
>
> My intention is to convert python code to a readable C code which can later
> be compile to an .exe file.
> Cython will not be of much use to me as it is in the end writing c
> extensions which will later be used in python.
> However, I wish to use this as a proper readable C code which can later be
> shared with users - the c source code as well as the exe along with its
> corresponding
> .py file.
>
> My main impediment here is writing out the C code manually myself, my C
> skills are quite poor and it would require a huge effort to sharpening my
> C skills before writing the code myself, I can not afford that luxury of
> time.
>
> I was surfing and came across shedskin, but that might not just support the
> xml minidom module for my purposes.
>
> Thanks,
> Vijay
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list