[ANNOUNCE] Campaign to support the notmm project!

2012-08-13 Thread Etienne Robillard

Hi All,

I'm raising a campaign to support the notmm project, a freely accessible 
open source project i created
to develop an advanced web framework for Django. Furthermore the project 
is using ConfigObj internally for allowing

flexible configuration and Cython for extending Django apps in C.

If you would like thus supporting the time and work I invested into the 
project I would really appreciate
a small donation, as I'm now really poor and cannot even finance the 
server hosting. Your donation would therefore be used
to put back the website online and continue active development of an 
alternative web framework for Python which
doesn't necessarily force its users to log in Facebook or Twitter for 
commenting, or syndication purposes..


Lastly if you have any comments on this letter or would like further 
info before making a donation it will be my pleasure

to help..

Kind regards,
Etienne

http://pledgie.com/campaigns/16268

--
Etienne Robillard
Green Tea Hackers Club
Fine Software Carpentry For The Rest Of Us!
http://gthc.org/
e...@gthcfoundation.org

“It is easy to fly into a passion... anybody can do that, but to be angry with 
the right person to the right extent and at the right time and in the right way 
that is not easy.” -Aristotle

“You have to accept whatever comes and the only important thing is that you 
meet it with courage and with the best that you have to give.”
- Eleanor Roosevelt

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


Re: Idle no longer works

2012-08-13 Thread jussij
On Saturday, August 11, 2012 4:09:16 PM UTC-7, Opap-OJ wrote:

> I can no longer open the Idle IDE for Python on Windows 7.
> ..
> Any idea why?

It looks like your registry has changed.

To fix this just use the Windows Explorer, click on a Python file 
and use the 'Open with, Choose default program' menu and then 
select the Idle IDE as the default program.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: save dictionary to a file without brackets.

2012-08-13 Thread Steven D'Aprano
On Sun, 12 Aug 2012 17:15:12 -0700, alex23 wrote:

> On Aug 10, 7:37 pm, Mark Lawrence  wrote:
>> Well whatever you do *DON'T* mention Cython. I mentioned it just now
>> but I think I've got away with it.
> 
> While I'm not against threads straying off topic, you're beginning to
> come across as a bit of an asshole now.
> 
> Just let it go.

Chill out Alex, it's all good. Mark was channelling a famous scene from 
"Fawlty Towers", staring Monty Python's own John Cleese, hence it is on-
topic, for the sillier definitions of on-topic.

After making a German tourist cry with his repeated insensitive comments 
about World War Two, Basil Fawlty (Cleese) -- who is an obnoxious git at 
the best of times but is currently suffering from a concussion -- remarks 
to his staff, "Don't mention the war, I mentioned it once but I think I 
got away with it."

http://www.youtube.com/watch?v=7xnNhzgcWTk



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


Re: Threads and sockets

2012-08-13 Thread Ulrich Eckhardt

Am 10.08.2012 15:01, schrieb loial:

I am writing an application to send data to a printer port(9100) and
then recieve PJL responses back on that port. Because of the way PJL
works I have to do both in the same process(script).


If I understand that right, you are opening a TCP connection, so 
obviously this must be done in the same process, regardless of what PJL 
(whatever that exactly is) does.




At the moment I do not start to read responses until the data has
been sent to the printer. However it seems I am missing some
responses from the printer whilst sending the data, so I need to be
able to do the 2 things at the same time.


Using TCP, that shouldn't happen, so I really wonder what exactly you 
are doing here.




Can I open a port once and then use 2 different threads, one to write
to the post and one to read the responses)?


Yes, definitely, take a look at the select() function of the select 
module. This basically looks like this:


  (r, w, x) = select(...)
  if r:
  # read and handle incoming data
  ...
  if w:
  # write pending output data
  ...
  if x:
  # handle connection failure
  ...


If all this is not what you are doing and what you want (which I'm not 
100% sure of) then please elaborate a bit what you're doing and what 
kind of connection you are using.


Happy hacking!

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


Re: Official reason for omitting inspect.currentcallable() ?

2012-08-13 Thread Steven D'Aprano
On Sun, 12 Aug 2012 23:06:19 +, kj wrote:

> Is there an *explicitly stated* reason (e.g. in a PEP, or in some python
> dev list message) for why the inspect module (at least for Python 2.7)
> does not include anything like a "currentcallable()" function that would
> *stably*[1] return the currently executing callable object?

I doubt it. Should there be? "currentcallable" is not a standard function 
in any language I'm familiar with, although I may be missing something 
obvious.


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


testfixtures 2.3.5 Released!

2012-08-13 Thread Chris Withers

Hi All,

I'm pleased to announce the release of testfixtures 2.3.5. testfixtures 
is a collection of helpers for writing succinct unit tests including 
help for:


- Comparing objects and sequences

Better feedback when the results aren't as you expected along with 
support for comparison of objects that don't normally support comparison.


- Mocking out objects and methods

Easy to use ways of stubbing out objects, classes or individual methods 
for both doc tests and unit tests. Special helpers are provided for 
testing with dates and times.


- Testing logging

Helpers for capturing logging output in both doc tests and unit tests.

- Testing stream output

Helpers for capturing stream output, such as that from print statements, 
and making assertion about it.


- Testing with files and directories

Support for creating and checking files and directories in sandboxes for 
both doc tests and unit tests.


- Testing exceptions

Easy to use ways of checking that a certain exception is raised, even 
down the to the parameters the exception is raised with.


This release fixes a small bug that meant failures in dictionary 
comparison didn't always produce the same output. (It was correct, just 
partly unsorted)


The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


http://www.simplistix.co.uk/software/python/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Official reason for omitting inspect.currentcallable() ?

2012-08-13 Thread Chris Angelico
On Mon, Aug 13, 2012 at 6:24 PM, Steven D'Aprano
 wrote:
> On Sun, 12 Aug 2012 23:06:19 +, kj wrote:
>
>> Is there an *explicitly stated* reason (e.g. in a PEP, or in some python
>> dev list message) for why the inspect module (at least for Python 2.7)
>> does not include anything like a "currentcallable()" function that would
>> *stably*[1] return the currently executing callable object?
>
> I doubt it. Should there be? "currentcallable" is not a standard function
> in any language I'm familiar with, although I may be missing something
> obvious.

I'm not familiar with it by that name, but Pike's this_function is
what the OP's describing.

(Yes, I'm citing Pike again. Sorry.)

It's a useful construct in theory when you want to write in recursion,
which was part of the rationale behind PEP 3130 (btw, Terry, it would
have been nice if you'd mentioned the number instead of sending me to
the index to try to figure out which one you were referring to, but
anyway). But how often is it actually useful in practice? I've never
actually used this_function other than in writing a crazy recursive
lambda (was testing different languages' handling of infinite
recursion - high level languages shouldn't segfault, one much-maligned
language DOES).

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


How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Xantipius
subj
-- 
http://mail.python.org/mailman/listinfo/python-list


Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Blind Anagram
I thought I would try out Python 3.3 beta 2.  


This works well so far but I keep getting the message:

Exception KeyError: KeyError(6308,) infrom 'c:\\Program Files\\Python33\\lib\\threading.py'> ignored


after some of my python code completes.  


Is this an issue worth reporting?

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Steven D'Aprano
On Mon, 13 Aug 2012 03:18:49 -0700, Xantipius wrote:

> subj

The same way as you compressed it, only in reverse.

When you ask a sensible question, I'm sure that somebody will give you a 
sensible answer.


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


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Chris Angelico
On Mon, Aug 13, 2012 at 8:36 PM, Blind Anagram  wrote:
> I thought I would try out Python 3.3 beta 2.
> This works well so far but I keep getting the message:
>
> Exception KeyError: KeyError(6308,) in  'c:\\Program Files\\Python33\\lib\\threading.py'> ignored
>
> after some of my python code completes.
> Is this an issue worth reporting?

It might be, but it depends on what your code is and is doing. Can you
put together a minimal test case?

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


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Blind Anagram
"Chris Angelico"  wrote in message 
news:mailman.3222.1344856408.4697.python-l...@python.org...


On Mon, Aug 13, 2012 at 8:36 PM, Blind Anagram  wrote:

I thought I would try out Python 3.3 beta 2.
This works well so far but I keep getting the message:

Exception KeyError: KeyError(6308,) in  ignored

after some of my python code completes.
Is this an issue worth reporting?


It might be, but it depends on what your code is and is doing. Can you
put together a minimal test case?

===
Thank you for your response.

Here is a fairly short bit of code which produces the exception:

for pre in ('12', '13', '14', '15', '21' ):
 n = int(pre + '543')
 s = str(n * n)
 if len(set(s)) == 9:
   print(n, s)

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


Re: Running Python web apps on shared ASO servers?

2012-08-13 Thread Gilles
On Sun, 12 Aug 2012 22:26:19 +0100, Tim Golden 
wrote:
>Just to make a point: one person's "isn't a good solution" is another 
>person's "works perfectly well for me". Modern servers are really quite 
>quick: the cost of starting up a Python process and generating an HTML 
>page can be really quite low. I've certainly had low-traffic production 
>websites running for years on CGI without anyone complaining.

Thanks Tim for the input. I'll try the different solutions available
and see if CGI is good enough for my needs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Chris Angelico
On Mon, Aug 13, 2012 at 9:24 PM, Blind Anagram  wrote:
>
> Here is a fairly short bit of code which produces the exception:
>
> for pre in ('12', '13', '14', '15', '21' ):
>  n = int(pre + '543')
>  s = str(n * n)
>  if len(set(s)) == 9:
>print(n, s)

Interesting. I just downloaded a clean 3.3 onto this Windows box,
saved your script to a file ("booom.py" hehe), and ran it - no
exception. Same thing pasting that code into the interactive
interpreter or idle. Did you import anything before running that code?
If not, it may be a site.py problem or something.

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


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Steven D'Aprano
On Mon, 13 Aug 2012 12:24:55 +0100, Blind Anagram wrote:

> Here is a fairly short bit of code which produces the exception:
> 
> for pre in ('12', '13', '14', '15', '21' ):
>   n = int(pre + '543')
>   s = str(n * n)
>   if len(set(s)) == 9:
> print(n, s)


Um, I don't think so. 


>>> for pre in ('12', '13', '14', '15', '21' ):
...   n = int(pre + '543')
...   s = str(n * n)
...   if len(set(s)) == 9:
... print(n, s)
...
12543 157326849



Since your code doesn't even import threading, let alone use it, I can't 
imagine how you get an error in threading.


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


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Chris Angelico
On Mon, Aug 13, 2012 at 9:38 PM, Steven D'Aprano
 wrote:
> Since your code doesn't even import threading, let alone use it, I can't
> imagine how you get an error in threading.

Hey, I try not to get scornful until at least the sixth post :)

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Ben Finney
Xantipius  writes:

> subj

resp

-- 
 \ “What is needed is not the will to believe but the will to find |
  `\   out, which is the exact opposite.” —Bertrand Russell, _Free |
_o__)   Thought and Official Propaganda_, 1928 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Blind Anagram
"Chris Angelico"  wrote in message 
news:mailman.3223.1344857956.4697.python-l...@python.org...


On Mon, Aug 13, 2012 at 9:24 PM, Blind Anagram  wrote:


Here is a fairly short bit of code which produces the exception:

for pre in ('12', '13', '14', '15', '21' ):
 n = int(pre + '543')
 s = str(n * n)
 if len(set(s)) == 9:
   print(n, s)


Interesting. I just downloaded a clean 3.3 onto this Windows box,
saved your script to a file ("booom.py" hehe), and ran it - no
exception. Same thing pasting that code into the interactive
interpreter or idle. Did you import anything before running that code?
If not, it may be a site.py problem or something.

===
Thanks to you both for your responses.

Its an IDE issue of some kind (I am using WING).

When I run under a command prompt (or IDLE) all is well.

Sorry to have bothered you.

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


Re: Threading KeyError in Python 3.3 beta 2?

2012-08-13 Thread Chris Angelico
On Mon, Aug 13, 2012 at 9:51 PM, Blind Anagram  wrote:
> Thanks to you both for your responses.
>
> Its an IDE issue of some kind (I am using WING).
>
> When I run under a command prompt (or IDLE) all is well.

Next time, do mention that sort of environmental consideration in the
original post :)

As a general rule, be careful of threading and windowing toolkits;
quite a few of them have restrictions on what you can and can't do, or
even completely do not support threads.

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


Re: decoding a byte array that is unicode escaped?

2012-08-13 Thread strong . drug
пятница, 6 ноября 2009 г., 12:48:47 UTC+4 пользователь sam написал:

> I am simply trying to display this copyright symbol on a webpage, so
> how do I encode the byte array to utf-8 given that it is 'escape
> encoded' in the above way?  I tried:
> 
> responseByteArray.decode('utf-8')
> and responseByteArray.decode('unicode_escape')
> and str(responseByteArray).
> 
> I am using Python 3.1.
I had some problem with reading zip archive in raw (binary) mode.
I solve it this way

open (filename, 'rb').read ().encode('string_escape')
# now we had strings with strange symbols are escaped
# than we can handle it without decoding excepions for example:
body = '\r\n'.join (lines) 

# if we have unescaped strings we can get an exception there
# after opertions, we needed we must unescape all content
# and drop it out to network (in my case)
body = body.decode('string-escape')

# then we can send so to the server
connection.request('POST', upload_url,  body, headers)

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


Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence

On 13/08/2012 01:15, alex23 wrote:

On Aug 10, 7:37 pm, Mark Lawrence  wrote:

Well whatever you do *DON'T* mention Cython. I mentioned it just now but
I think I've got away with it.


While I'm not against threads straying off topic, you're beginning to
come across as a bit of an asshole now.

Just let it go.



Why on your say so?

--
Cheers.

Mark Lawrence.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Mark Lawrence

On 13/08/2012 11:18, Xantipius wrote:

subj



Either

a) write some code and when and if it fails give us a small code snippet 
that demonstates the problem with the complete traceback.


or

b) state how much you are willing to pay for someone here to come up 
with a solution for you.


--
Cheers.

Mark Lawrence.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread PythonAB

On 13 aug 2012, at 14:40, Mark Lawrence wrote:

> On 13/08/2012 11:18, Xantipius wrote:
>> subj
>> 
> 
> Either
> 
> a) write some code and when and if it fails give us a small code snippet that 
> demonstates the problem with the complete traceback.
> 
> or
> 
> b) state how much you are willing to pay for someone here to come up with a 
> solution for you.
> 
> -- 
> Cheers.
> 
> Mark Lawrence.
> 

or... go out and buy the DVD it's ripped from... ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Miki Tebeka
Have a look at PyMedia.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: psutil 0.6.0 released

2012-08-13 Thread Giampaolo Rodolà
Hi folks,
I'm pleased to announce the 0.6.0 release of psutil:
http://code.google.com/p/psutil/

This is one of the best releases so far as it addresses two important
issues: system memory functions management and permission errors
occurring on Windows and OSX.


=== Memory functions ===

psutil.phymem_usage() and psutil.virtmem_usage() are deprecated.
Instead we now have psutil.virtual_memory() and psutil.swap_memory(),
which should provide all the necessary pieces to monitor the actual
system memory usage, both physical and swap/disk related.

The refactoring was modeled after Zabbix, see:
http://code.google.com/p/psutil/issues/detail?id=311
http://blog.zabbix.com/when-alexei-isnt-looking/#vm.memory.size
http://www.zabbix.com/documentation/2.0/manual/appendix/items/vm.memory.size_params

If you don't want to read how and why I did that, the bottom line is:
if you want to monitor actual system memory usage in a cross platform
fashion use:

>>> psutil.virtual_memory().available


=== No more AccessDenied exceptions when querying processes ===

On Windows and OSX the Process methods below were always raising AccessDenied
for any process owned by another user:

OSX
- name
- get_memory_info()
- get_memory_percent()
- get_cpu_times()
- get_cpu_percent()
- get_num_threads()

WINDOWS
- create_time
- get_children()
- get_cpu_times()
- get_cpu_percent()
- get_memory_info()
- get_memory_percent()
- get_num_handles()
- get_io_counters()

Especially on OSX this made psutil basically unusable as a limited
user, even for determining basic process information such as CPU
percent or memory usage.
Now this is no longer the case.
For further details see:
http://code.google.com/p/psutil/issues/detail?id=297
http://code.google.com/p/psutil/issues/detail?id=303


=== Other major enhancements ===

- per-process extended memory stats.
- per-process number of voluntary and involuntary context switches.
- per-process connections: added UNIX sockets support.
- (BSD) Process.get_connections() rewritten in C and no longer requiring lsof.
- (OSX) added support for process cwd
- psutil.network_io_counters() now provides the number of in/out
packets dropped and with errors.
- new example scripts:
example/meminfo.py
example/free.py
example/netstat.py
example/pmap.py


=== New features by example ===

>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>>
>>> p.get_num_ctx_switches()
amount(voluntary=78, involuntary=19)
>>>
>>> p.get_ext_memory_info()
meminfo(rss=9662464, vms=49192960, shared=3612672, text=2564096,
lib=0, data=5754880, dirty=0)
>>>
>>> p.get_connections(kind='unix')
[connection(fd=8, family=1, type=1,
local_address='/tmp/unix_socket.sock', remote_address=None,
status='')]
>>>
>>>
>>> psutil.virtual_memory()
vmem(total=8374149120L, available=2081050624L, percent=75.1,
used=8074080256L, free=300068864L, active=3294920704,
inactive=1361616896, buffers=529895424L, cached=1251086336)
>>>
>>> psutil.swap_memory()
swap(total=2097147904L, used=296128512L, free=1801019392L,
percent=14.1, sin=304193536, sout=677842944)
>>>

=== Compatitility notes ===

0.6.0 version does not introduce any backward incompatibility.
Nevertheless it introduces some deprecations warnings:

- psutil.phymem_usage() is deprecated in favor of psutil.virtual_memory()
- psutil.virmem_usage() is deprecated in favor of psutil.swap_memory()
- psutil.cached_phymem() is deprecated in favor of
psutil.virtual_memory().cached
- psutil.phymem_buffers() is deprecated in favor of
psutil.virtual_memory().buffers

The deprecated functions will be removed in next 1.0.0 version.


=== Links ===

* Home page: http://code.google.com/p/psutil
* Source tarball: http://psutil.googlecode.com/files/psutil-0.6.0.tar.gz
* Api Reference: http://code.google.com/p/psutil/wiki/Documentation


Please try out this new release and let me know if you experience any
problem by filing issues on the bug tracker.
Thanks in advance.


--- Giampaolo Rodola'

http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/
http://code.google.com/p/pysendfile/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Official reason for omitting inspect.currentcallable() ?

2012-08-13 Thread kj
In  Chris Angelico 
 writes:

>I'm not familiar with it by that name, but Pike's this_function is
>what the OP's describing.

You got it.

>It's a useful construct in theory when you want to write in recursion,
>which was part of the rationale behind PEP 3130 

Thank you!

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


print(....,file=sys.stderr) buffered?

2012-08-13 Thread Helmut Jarausch
Hi,

for tracing purposes I have added some print outs like

print('+++ before calling foo',file=sys.stderr)
x=foo(..)
print('--- after  calling foo',

and within 'foo'
print('>>> entering foo ...',file=sys.stderr)

Now, when executing this, I always get

+++ before calling foo
--- after  calling foo
>>> entering foo ...

When outputting to stderr from C/C++ it's guaranteed that the different 
outputs appear in the same order as they have been generated.

Is this guarantee no more valid in Python 3.2 ?

Many thanks for a comment,
Helmut.

(That's a single-threaded application)

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


Re: print(....,file=sys.stderr) buffered?

2012-08-13 Thread Ramchandra Apte
As far as I know,
stdout is usually buffered (not necessary) in both C++ and Python
stderr is non-buffered in both C++ and Python (I can't imagine the point of
stderr if it were buffered)
Even with this, stdout usually come immediately - the situation you have
shouldn't happen.
Are you using an IDE? If so, which one?

On 13 August 2012 20:46, Helmut Jarausch  wrote:

> Hi,
>
> for tracing purposes I have added some print outs like
>
> print('+++ before calling foo',file=sys.stderr)
> x=foo(..)
> print('--- after  calling foo',
>
> and within 'foo'
> print('>>> entering foo ...',file=sys.stderr)
>
> Now, when executing this, I always get
>
> +++ before calling foo
> --- after  calling foo
> >>> entering foo ...
>
> When outputting to stderr from C/C++ it's guaranteed that the different
> outputs appear in the same order as they have been generated.
>
> Is this guarantee no more valid in Python 3.2 ?
>
> Many thanks for a comment,
> Helmut.
>
> (That's a single-threaded application)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone have an activate script for portable python?

2012-08-13 Thread Ramchandra Apte
PS:virtualenv is added to the stdlib in Python 3.3

On 13 August 2012 05:42, alex23  wrote:

> On Aug 12, 9:09 am, Gelonida N  wrote:
> > In Pythons installed with virtualenv there is on windows an activate.bat
> > script, that can be used to setup the cmd-shell such, that the search
> > path for python and pythor elated tools (pip / easy_install) is setup
> > properly.
> > Do such a scripts also exist for Portable python?
>
>
> Portable Python is just Python with some helper scripts for not
> requiring a system installation.
>
> So "command-line-command-to-run-portable-python virtualenv  name>" should be all you need.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print(....,file=sys.stderr) buffered?

2012-08-13 Thread Grant Edwards
On 2012-08-13, Helmut Jarausch  wrote:
> Hi,
>
> for tracing purposes I have added some print outs like
>
> print('+++ before calling foo',file=sys.stderr)
> x=foo(..)
> print('--- after  calling foo',
>
> and within 'foo'
> print('>>> entering foo ...',file=sys.stderr)
>
> Now, when executing this, I always get
>
> +++ before calling foo
> --- after  calling foo
 entering foo ...
>
> When outputting to stderr from C/C++ it's guaranteed that the different 
> outputs appear in the same order as they have been generated.

You're not printing to stderr in the second print() call -- you're
printing to stdout.  The two file objects have separate buffers and
may even be using two different buffering modes (e.g. line vs. block).
You can't interleave writes to stderr and stdout and assume order is
preserved unless you take specific steps (such as forcing them both to
be unbuffered or flushing them at certain points).

> Is this guarantee no more valid in Python 3.2 ?

If you write to stderr all three times, it should work the way you
want it to.

-- 
Grant Edwards   grant.b.edwardsYow! ... I'm IMAGINING a
  at   sensuous GIRAFFE, CAVORTING
  gmail.comin the BACK ROOM of a
   KOSHER DELI --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 13, 10:37 pm, Mark Lawrence  wrote:
> Why on your say so?

My mistake, I didn't realise you wanted to sound so tedious. Knock
yourself out.


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


Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 13, 6:05 pm, Steven D'Aprano  wrote:
> Chill out Alex, it's all good. Mark was channelling a famous scene from
> "Fawlty Towers", staring Monty Python's own John Cleese, hence it is on-
> topic, for the sillier definitions of on-topic.

Thank you, yes, I get that. However, Mark has repeatedly been
directing this dickishness at Stefan Behnel ever since he was asked to
not stray off topic. While Mark doesn't have to listen to anyone else
about his behaviour, he can't expect not to be called a dick when
acting like one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print(....,file=sys.stderr) buffered?

2012-08-13 Thread Helmut Jarausch
On Mon, 13 Aug 2012 15:43:31 +, Grant Edwards wrote:

> On 2012-08-13, Helmut Jarausch  wrote:
>> Hi,
>>
>> for tracing purposes I have added some print outs like
>>
>> print('+++ before calling foo',file=sys.stderr)
>> x=foo(..)
>> print('--- after  calling foo',

Sorry, this is a cut'n paste error. I did use
print('--- after  calling foo',file=sys.stderr)

>>
>> and within 'foo'
>> print('>>> entering foo ...',file=sys.stderr)
>>
>> Now, when executing this, I always get
>>
>> +++ before calling foo --- after  calling foo
> entering foo ...
>>
>> When outputting to stderr from C/C++ it's guaranteed that the different
>> outputs appear in the same order as they have been generated.
> 
> You're not printing to stderr in the second print() call -- you're
> printing to stdout.  The two file objects have separate buffers and may
> even be using two different buffering modes (e.g. line vs. block).
> You can't interleave writes to stderr and stdout and assume order is
> preserved unless you take specific steps (such as forcing them both to
> be unbuffered or flushing them at certain points).
> 
>> Is this guarantee no more valid in Python 3.2 ?
> 
> If you write to stderr all three times, it should work the way you want
> it to.

It seems it doesn't do so in my case.

Thanks,
Helmut.


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


Re: save dictionary to a file without brackets.

2012-08-13 Thread rusi
On Aug 13, 1:05 pm, Steven D'Aprano  wrote:
>
> Chill out Alex, it's all good. Mark was channelling a famous scene from
> "Fawlty Towers", staring Monty Python's own John Cleese, hence it is on-
> topic, for the sillier definitions of on-topic.

Ha! Thanks for that connection.
Watched and enjoyed Fawlty towers as a kid but have never seen a Monty
Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print(....,file=sys.stderr) buffered?

2012-08-13 Thread Jerry Hill
On Mon, Aug 13, 2012 at 11:16 AM, Helmut Jarausch  wrote:
> Now, when executing this, I always get
>
> +++ before calling foo
> --- after  calling foo
 entering foo ...

Can you give us a piece of code we can run that produces this output
for you?  You gave us an outline in your original post, but it would
be useful to have a self contained example that you can say reliably
produces the unexpected output for you.

Also, what environment, OS, and exact python version is this?  Is the
code being run in an IDE of some sort?  Does the behavior change if
you call your code directly from the command line?

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


Sharing code between different projects?

2012-08-13 Thread andrea crotti
I am in the situation where I am working on different projects that
might potentially share a lot of code.

I started to work on project A, then switched completely to project B
and in the transiction I copied over a lot of code with the
corresponding tests, and I started to modify it.

Now it's time to work again on project A, but I don't want to copy
things over again.

I would like to design a simple and nice way to share between projects,
where the things I want to share are simple but useful things as for
example:

class TempDirectory:
"""Create a temporary directory and cd to it on enter, cd back to
the original position and remove it on exit
"""
def __init__(self):
self.oldcwd = getcwd()
self.temp_dir = mkdtemp()

def __enter__(self):
logger.debug("create and move to temp directory %s" % self.temp_dir)
return self.temp_dir

def __exit__(self, type, value, traceback):
# I first have to move out
chdir(self.oldcwd)
logger.debug("removing the temporary directory and go back to
the original position %s" % self.temp_dir)
rmtree(self.temp_dir)


The problem is that there are functions/classes from many domains, so it
would not make much sense to create a real project, and the only name I
could give might be "utils or utilities"..

In plus the moment the code is shared I must take care of versioning and
how to link different pieces together (we use perforce by the way).

If then someone else except me will want to use these functions then of
course I'll have to be extra careful, designing really good API's and so
on, so I'm wondering where I should set the trade-off between ability to
share and burden to maintain..

Anyone has suggestions/real world experiences about this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence

On 13/08/2012 17:14, alex23 wrote:

On Aug 13, 10:37 pm, Mark Lawrence  wrote:

Why on your say so?


My mistake, I didn't realise you wanted to sound so tedious. Knock
yourself out.




Yes m'lud.  Do I lick your boots or polish them?

--
Cheers.

Mark Lawrence.

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


Re: save dictionary to a file without brackets.

2012-08-13 Thread Mark Lawrence

On 13/08/2012 01:15, alex23 wrote:

On Aug 10, 7:37 pm, Mark Lawrence  wrote:

Well whatever you do *DON'T* mention Cython. I mentioned it just now but
I think I've got away with it.


While I'm not against threads straying off topic, you're beginning to
come across as a bit of an asshole now.

Just let it go.



http://mail.python.org/pipermail/pypy-dev/2012-February/009277.html

--
Cheers.

Mark Lawrence.

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


Re: Idle no longer works

2012-08-13 Thread Terry Reedy

On 8/13/2012 1:43 PM, Dennis Lee Bieber wrote:

On Mon, 13 Aug 2012 00:11:06 -0700 (PDT), jus...@zeusedit.com declaimed
the following in gmane.comp.python.general:


On Saturday, August 11, 2012 4:09:16 PM UTC-7, Opap-OJ wrote:


I can no longer open the Idle IDE for Python on Windows 7.
..
Any idea why?


It looks like your registry has changed.


Most likely, or the Python installation has be damaged.


To fix this just use the Windows Explorer, click on a Python file
and use the 'Open with, Choose default program' menu and then
select the Idle IDE as the default program.


That is probably the worst choice to make -- since what you've
defined means double clicking on ANY .py file will NOT RUN IT -- but
rather attempt to open it with the editor (IDLE)... But since IDLE
itself is a .py file, it may fail to start at all.

If double-clicking an IDLE.py file does not start it, then the
registry has lost the association of .py to python.exe, not to IDLE. OR
-- .py IS associated to python.exe but the association (the "run
command" is not passing the .py file name to the python executable).

On WinXP (with ActiveState 2.5.x version) my associations are as:

E:\UserData\Wulfraed\My Documents>assoc .py
.py=py_auto_file

E:\UserData\Wulfraed\My Documents>ftype py_auto_file
py_auto_file="E:\Python25\python.exe" "%1" %*

E:\UserData\Wulfraed\My Documents>

(with similar entries for .pyw to hook into pythonw.exe)
{Just booted the Win7 laptop with Python 2.7.x: The only real difference
is that it uses Python.File where the above has py_auto_file}


Re-installing, as I suggested in the first response, is much easier, 
especially for someone not familiar with the above.


--
Terry Jan Reedy

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


Re: Does anyone have an activate script for portable python?

2012-08-13 Thread Gelonida N

On 08/13/2012 02:12 AM, alex23 wrote:

On Aug 12, 9:09 am, Gelonida N  wrote:

In Pythons installed with virtualenv there is on windows an activate.bat
script, that can be used to setup the cmd-shell such, that the search
path for python and pythor elated tools (pip / easy_install) is setup
properly.
Do such a scripts also exist for Portable python?



Portable Python is just Python with some helper scripts for not
requiring a system installation.

So "command-line-command-to-run-portable-python virtualenv " should be all you need.


Hmm I guess I didn't express myself very well.

The idea is to easily create a cmd window, that the path is setup in 
order to point to portably python by default.


At a first glance at Portable Python it seemed to me, that this doesn't 
exist.


Having a small icon to click at, that opens a cmd window with the right 
setup or just a .bat file, that could be called to adapt the setup of an 
existing cmd window.



It's not too difficult to write such scipts, but I though it would be 
interesting to see whether I'm the only one missing such feature in 
portable Python.

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


Re: Sharing code between different projects?

2012-08-13 Thread Rob Day
I'd just create a module - called shared_utils.py or similar - and import
that in both projects. It might be a bit messy if there's no 'unifying
theme' to the module - but surely it'd be a lot less messy than your
TempDirectory class, and anyone else who knows Python will understand
'import shared_utils' much more easily.

I realise you might not want to say, but if you could give some idea what
sort of projects these are, and what sorts of code you're trying to share,
it might make things a bit clearer.

I'm not really sure what your concerns about 'versioning and how to link
different pieces together' are - what d you think could go wrong here?

On 13 August 2012 17:53, andrea crotti  wrote:

> I am in the situation where I am working on different projects that
> might potentially share a lot of code.
>
> I started to work on project A, then switched completely to project B
> and in the transiction I copied over a lot of code with the
> corresponding tests, and I started to modify it.
>
> Now it's time to work again on project A, but I don't want to copy
> things over again.
>
> I would like to design a simple and nice way to share between projects,
> where the things I want to share are simple but useful things as for
> example:
>
> class TempDirectory:
> """Create a temporary directory and cd to it on enter, cd back to
> the original position and remove it on exit
> """
> def __init__(self):
> self.oldcwd = getcwd()
> self.temp_dir = mkdtemp()
>
> def __enter__(self):
> logger.debug("create and move to temp directory %s" %
> self.temp_dir)
> return self.temp_dir
>
> def __exit__(self, type, value, traceback):
> # I first have to move out
> chdir(self.oldcwd)
> logger.debug("removing the temporary directory and go back to
> the original position %s" % self.temp_dir)
> rmtree(self.temp_dir)
>
>
> The problem is that there are functions/classes from many domains, so it
> would not make much sense to create a real project, and the only name I
> could give might be "utils or utilities"..
>
> In plus the moment the code is shared I must take care of versioning and
> how to link different pieces together (we use perforce by the way).
>
> If then someone else except me will want to use these functions then of
> course I'll have to be extra careful, designing really good API's and so
> on, so I'm wondering where I should set the trade-off between ability to
> share and burden to maintain..
>
> Anyone has suggestions/real world experiences about this?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Robert K. Day
robert@merton.oxon.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sharing code between different projects?

2012-08-13 Thread Chris Angelico
On Tue, Aug 14, 2012 at 2:53 AM, andrea crotti
 wrote:
> The problem is that there are functions/classes from many domains, so it
> would not make much sense to create a real project, and the only name I
> could give might be "utils or utilities"..

There's actually much merit in a generic utilities module. Keep things
nicely segregated (ideally such that you know what things depend on
what other, but at very least keep track of where one ends and another
begins - that's trivial if everything's "one function" or "one class",
but less so when you have a family of related functions), and then you
can consider promoting one block of code to stand-alone module. But in
the meantime, you have a single module used in two places, even if it
doesn't have a very clear definition as yet.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Xantipius
On Aug 13, 3:40 pm, Mark Lawrence  wrote:
> On 13/08/2012 11:18, Xantipius wrote:
>
> > subj
>
> Either
>
> a) write some code and when and if it fails give us a small code snippet
> that demonstates the problem with the complete traceback.
>
> or
>
> b) state how much you are willing to pay for someone here to come up
> with a solution for you.
>
> --
> Cheers.
>
> Mark Lawrence.

Mark, in regard your last remark:
it's just a recreation for me. Nothing more in it.
I like to put some weird and useless problems before myself.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Chris Angelico
On Tue, Aug 14, 2012 at 9:00 AM, Xantipius  wrote:
> Mark, in regard your last remark:
> it's just a recreation for me. Nothing more in it.
> I like to put some weird and useless problems before myself.

In that case, I strongly recommend that you write some code instead of
throwing zero-effort questions onto a mailing list.

Though this sort of request does tend to have amusement value. Thanks Ben!

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Mark Lawrence

On 14/08/2012 00:00, Xantipius wrote:

On Aug 13, 3:40 pm, Mark Lawrence  wrote:

On 13/08/2012 11:18, Xantipius wrote:


subj


Either

a) write some code and when and if it fails give us a small code snippet
that demonstates the problem with the complete traceback.

or

b) state how much you are willing to pay for someone here to come up
with a solution for you.

--
Cheers.

Mark Lawrence.


Mark, in regard your last remark:
it's just a recreation for me. Nothing more in it.
I like to put some weird and useless problems before myself.

Cheers.



Is it your normal practice to communicate with yourself via a public 
mailing list/news group?  When did you seek my permission to call me by 
my forename?


--
Cheers.

Mark Lawrence.

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


Re: save dictionary to a file without brackets.

2012-08-13 Thread alex23
On Aug 14, 3:43 am, Mark Lawrence  wrote:
> On 13/08/2012 01:15, alex23 wrote:
>
> > On Aug 10, 7:37 pm, Mark Lawrence  wrote:
> >> Well whatever you do *DON'T* mention Cython. I mentioned it just now but
> >> I think I've got away with it.
>
> > While I'm not against threads straying off topic, you're beginning to
> > come across as a bit of an asshole now.
>
> > Just let it go.
>
> http://mail.python.org/pipermail/pypy-dev/2012-February/009277.html
>
> --
> Cheers.
>
> Mark Lawrence.

Yeah, you're really coming across as holding the moral high ground
here.

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


Re: save dictionary to a file without brackets.

2012-08-13 Thread Steven D'Aprano
On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote:

> On 13/08/2012 17:14, alex23 wrote:
>> On Aug 13, 10:37 pm, Mark Lawrence  wrote:
>>> Why on your say so?
>>
>> My mistake, I didn't realise you wanted to sound so tedious. Knock
>> yourself out.
>>
>>
>>
> Yes m'lud.  Do I lick your boots or polish them?


Children children, if you won't play nice don't play at all. You're 
scaring away the people who are here to learn about Python.




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


Re: How to uncompress a VOB file? (Win XP)

2012-08-13 Thread Steven D'Aprano
On Tue, 14 Aug 2012 01:34:46 +0100, Mark Lawrence wrote:

> When did you seek my permission to call me by my forename?

Sheesh. It's 2012, not 1812. If you sign your posts with your full name, 
you have to expect that people will call you "Mark" rather than "Mr 
Lawrence" or "Lord High Mucky-Muck Grand Poohbar Lawrence" -- even if 
they haven't been formally introduced.

Mark, we're all human and the occasional snark is only to be expected, 
but demanding that people ask permission to call you by your first name 
in an informal forum like this crosses the line to total dickishness. 
Chill out before you get yourself kill-filed into irrelevance.



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


how to call perl script from html using python

2012-08-13 Thread mullapervez
Hi,

I wanna call perl script in HTML form n store that data in DB using Python.

How can i do this...??

Please help me

Thank you
Pervez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Simon Cropper

On 14/08/12 15:12, mullaper...@gmail.com wrote:

Hi,

I wanna call perl script in HTML form n store that data in DB using Python.

How can i do this...??

Please help me

Thank you
Pervez



Google you question.

Many solutions already exist on the Internet.

--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread mullapervez
On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, mulla...@gmail.com wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez

Hey Simon,

Thank You for your mail and time,

Yest I spent entire day for this , But I didn't get any solution for this 
problem .I google it but am not able to get any solution for this 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Simon Cropper

On 14/08/12 15:31, mullaper...@gmail.com wrote:

On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, mulla...@gmail.com wrote:

Hi,



I wanna call perl script in HTML form n store that data in DB using Python.



How can i do this...??



Please help me



Thank you

Pervez


Hey Simon,

Thank You for your mail and time,

Yest I spent entire day for this , But I didn't get any solution for this 
problem .I google it but am not able to get any solution for this



Then you should outline what you have tried and what the problems you 
encountered that way people can help.


--
Cheers Simon

   Simon Cropper - Open Content Creator

   Free and Open Source Software Workflow Guides
   
   Introduction   http://www.fossworkflowguides.com
   GIS Packages   http://www.fossworkflowguides.com/gis
   bash / Pythonhttp://www.fossworkflowguides.com/scripting
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Steven D'Aprano
On Mon, 13 Aug 2012 22:12:48 -0700, mullapervez wrote:

> Hi,
> 
> I wanna call perl script in HTML form n store that data in DB using
> Python.
> 
> How can i do this...??
> 
> Please help me

Okay, let me give you some general advice first, then some programming 
advice

If your question looks like you have put no thought into the question, 
you will get answers that also have no thought put into them.

Try to write proper English sentences. We will make allowances for non-
native English speakers, and simple typos, but if u cnt b bothrd 2 rite 
gd we cnt b bothrd 2 answr gd ethr.


To solve your programming problem, break it up into smaller pieces:

1) write some code to get a perl script from some HTML;

2) write some more code to take a perl script and run it, collecting the 
results;

3) write some more code to take those results and put them into a 
database;

4) finally write some code to put the first three pieces together.


Do you need help on any of these? If so, please tell us:

- What is your experience with Python? Complete newbie, beginner, 
intermediate, advanced, expert, guru. Do you know any other programming 
languages?

- What you have already tried? Show us your code.

- Show us some *simple* sample data.


The more you help us, the more we can help you.



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


Re: how to call perl script from html using python

2012-08-13 Thread Pervez Mulla
On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez

Thank you for your advice steven,

I am beginner to this language, I have exp in JAVA and C

I wanna call perl objects using Python . I checked in internet ,I can make use 
of inline function for this, But in HTML..??

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


pylagiarism -- Need help now! Please provide code...

2012-08-13 Thread Simon Cropper

Hi Everyone,

I just had a great idea for a new python module. I haven't bothered 
googling it or doing any research.


I need help putting together some code; today preferably, my boss is on 
my back. Can someone please contribute a functioning module showing me 
how to do it?


Once I have all your submissions, I will compile a functioning  package, 
which I hope to sell. Don't worry, no one will be at risk of being sued, 
I don't intend to credit you with the code and you will not know 
anything about what I have done because I don't intend to post and 
feedback to the list. Licenses are not a problem either, I don't believe 
in them and even if you find out I have plagiarized your stuff you have 
bub-kiss chance of suing me as I am in another jurisdiction.


So, now you know where I am coming from, I would like to thank you for 
all your help. Remember though, I need help now, so please stop what you 
are doing and submit something quickly. I'm waiting...


Still waiting...

Hey, stop reading and get on with writing some code, I don't have all day!

--
Simon

Disclaimer  :) Please don't flame me, I have written this with my tongue 
in my cheek and a light hearted take on some people request for 
assistance on a range of mail lists. It was not meant to target anyone 
in particular only to exaggerate how some people's requests appear to 
lurkers and contributors on many fora I frequent.

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