weave and 64 bit issues

2013-05-14 Thread Jadhav, Alok
Hi everyone,

 

I am facing a strange problem using weave on 64 bit machine.
Specifically with weave's inline function. It has something to do with
weave's catalog. 

 

Similar issues I found in the past (very old)

 

http://mail.scipy.org/pipermail/scipy-dev/2006-June/005908.html

http://mail.scipy.org/pipermail/scipy-dev/2005-June/003042.html

 

 

I have a simple script to calculate moving average using weave's inline
function. 

 

 

 

File mvg.py

 

import numpy as np

import scipy.weave as weave

import distutils.sysconfig

import distutils.dir_util

import os

 

distutils.sysconfig._config_vars["LDSHARED"]="-LC:\strawberry64\c\x86_64
-w64-mingw32\lib"

 

 

def ExpMovAvg(data,time,lag):

if (data.size!=time.size):

print "error in EMA, data and time have different size"

return None

result=np.repeat(0.0,data.size)

code="""

#line 66 "basics.py"

result(0)=data(0);

for (int i=0;i1)

{

alpha=10;

}

result(i+1)=(1-alpha)*data(i)+alpha*result(i);

}

"""

 
weave.inline(code,["data","time","lag","result"],type_converters=weave.c
onverters.blitz,headers=[""],compiler="gcc",verbose=2)

return result

 

 

file test.py

 

import string

import numpy as np

import mvg

 

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

 

 

 

Output:

 

 

Working output:

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

[ 0.  0.  0.63212774  1.49679774  2.44701359  3.42869938
4.42196209  5.41948363  6.41857187  7.41823646]

 

Now if I keep running the script multiple times, sometimes I see correct
output... but suddenly sometimes I get below error.

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

repairing catalog by removing key



Looking for python27.dll

running build_ext

running build_src

build_src

building extension "sc_44f3fe3c65d5c3feecb45d9269ac207f5" sources

build_src: building npy-pkg config files

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

building 'sc_44f3fe3c65d5c3feecb45d9269ac207f5' extension

compiling C++ sources

C compiler: g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall

 

compile options: '-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz

-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c' 

 g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave

-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\pytho

n27\include -Ic:\python27\PC -c
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3f
e3c65d5c3feecb45d9269ac207f5.cpp -o c:\users\ajadhav2\ap

pdata\local\temp\ajadhav2\python27_intermediate\compiler_2d3e1e2e4de6a91
419d2376b162e5342\Release\users\ajadhav2\appdata\local\temp\ajadhav2\pyt
hon27_compiled\s

c_44f3fe3c65d5c3feecb45d9269ac207f5.o

Found executable C:\strawberry\c\bin\g++.exe

g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave-Ic:\python27\lib\site-packag
es\scipy\weave\scxx -Ic:\python27\lib\site-packages

\scipy\weave\blitz -Ic:\python27\lib\site-packages\numpy\core\include
-Ic:\python27\include -Ic:\python27\PC -c
c:\python27\lib\site-packages\scipy\weave\scxx\w

eave_imp.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\python27\lib\site-packages

\scipy\weave\scxx\weave_imp.o

g++ -g -shared
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\users\ajadhav2\appdata\loc
a

l\temp\ajadhav2\python27_compiled\sc_44f3fe3c65d5c3feecb45d9269ac207f5.o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4d

e6a91419d2376b162e5342\Release\python27\lib\site-packages\scipy\weave\sc
xx\weave_imp.o -Lc:\python27\libs -Lc:\python27\PCbuild\amd64 -lpython27
-lmsvcr90 -o c:

\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3fe3
c65d5c3feecb45d9269ac207f5.pyd

running scons

Traceback (most recent call last):

  File "s:\common\tools\python\python-2.7-64bit\test.py", line 5, in


print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

  File "s:\common\tools\python\python-2.7-64bit\mvg.py", line 30, in
ExpMovAvg

 
weave.inline(code,["data","time","lag","result"],type_converters=weave.c
onve

rters.blitz,headers=[""],compiler="gcc",verbose=2)

  File "c:\python27\lib\site-packages\scipy\weave\inline_tools.py", line
355, in

inline

**kw)

  File "c:\python27\lib\site-packages\scipy\weave\inline_tools.py",

Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:22 AM, Dave Angel  wrote:
> On 05/13/2013 06:53 PM, Mark Lawrence wrote:
>> I much prefer the alternative <> for != but some silly people insisted
>> that this be removed from Python3.  Just how stupid can you get?
>>
>
> So which special methods should the <> operator call?  By rights it ought to
> call both __gt__ and __lt__ and return True if either of them is True.

Why do you think that? After all, the != operator doesn't call
__factorial__ and __assignment__ and return True if either is True,
does it?

ChrisA

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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:40 AM, Fábio Santos  wrote:
> Well I am thus defying the law and order of this world by publishing
> it on the internets!
>
> ---
>
> And here it is:
> http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html

class Text(unicode, Enum):
one = u'one'
two = u'two'
three = u'three'

That looks like Python 2 code. Are you backporting Enum to Py2
manually? AIUI the Python core won't be adding features like that to
2.7, and there won't be a 2.8, so PEP 435 will be Py3.4+ only. Or have
I misunderstood it?

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


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
2013/5/14 Steven D'Aprano 

> On Tue, 14 May 2013 01:32:43 +0200, Citizen Kant wrote:
>
> >> An entity named Python must be somehow as a serpent. Don't forget that
> >> I'm with the freeing up of my memory, now I'm not trying to follow the
> >> path of what's told but acting like the monkey and pushing with my
> >> finger against the skin of the snake.
>
> >Python is not named after the snake, but after Monty Python the British
> >comedy troupe. And they picked their name because it sounded funny.
>
> > http://en.wikipedia.org/wiki/Monty_Python
>
>
>
>
> I'm sorry to hear that. Mostly because, as an answer, seems to example
> very well the "taken because I've been told how things are" kind of
> actions, which is exactly the opposite of the point I'm trying to state.
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
>>From: llanitedave 


>>On Monday, May 13, 2013 4:32:43 PM UTC-7, Citizen Kant wrote:

>>>An entity named Python must be
>>> somehow as a serpent.


llanitedave wrote:

 Moe like a dead parrot, actually.


That's a good one! Even If doesn't lead to the fact that Python (so to
speak) use to give an answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread Jean-Michel Pichavant
- Original Message -
> On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote:
> 
> > - Original Message -
> >> That's the title of this little beast
> >> http://www.acooke.org/cute/Pythonssad0.html if anybody's
> >> interested.
> >> 
> >> --
> >> If you're using GoogleCrap™ please read this
> >> http://wiki.python.org/moin/GoogleGroupsPython.
> >> 
> >> Mark Lawrence
> >> 
> >> --
> >> http://mail.python.org/mailman/listinfo/python-list
> >> 
> >> 
> > python 2.5
> > 
> > class Enum:
> >   class __metaclass__(type):
> > def __iter__(self):
> >   for attr in sorted(dir(self)):
> > if not attr.startswith("__"):
> >   yield getattr(self, attr)
> > 
> > class Colours(Enum):
> >   RED = "red"
> >   GREEN = "green"
> 
> py> class Experience(Enum):
> ... NOVICE = 'novice'
> ... GREEN = 'green'
> ... EXPERIENCED = 'experienced'
> ... MASTER = 'master'
> ...
> py>
> py> Colours.GREEN == Experience.GREEN
> True
> 
> 
> Oops.
> 
> 
> It's very easy to make something which does a few things that enums
> should do, and call it an Enum. It's much harder to do a lot of
> things
> that enums should do.
> 
> 
> 
> --
> Steven

I was just proposing a solution I've been using and found quite satisfactory. 
As for the perfect "enumness" of that solution, I don't know. To be honest, I'm 
not sure I know the exact definition of an enum, and whether or not the C enum 
fits 100% that definition. It does the job in python. Some people may find it 
useful, others may just ignore it.
Additionally, the "bug" you mentioned can be written in C as well, casts allow 
to compare apples and oranges:

(Colours::GREEN == (enum Coulours::Colour)Experiences::GREEN)


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread Fábio Santos
On 13 May 2013 12:05, "Jean-Michel Pichavant" 
wrote:
>
> class Enum:
>   class __metaclass__(type):

That's some cool metaclass fu! I didn't know that to be possible
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
Case study (kind of)

Imagine that I use to explore with my mind a particular topic and I want to
map and model the mechanics of that exploration. That's mostly
metaphysical. I have a partner called Python with whom I must communicate
in Python. Which would be the basics that I must "know" in order to pass my
ideas to him properly. With this I mean using the units of my natural
language skills that match with his language, and using them in Python's
language context, in order to "program" at the highest level possible. It's
true that my program won't run yet but for me this is not an obstacle at
all, as when one writes a book one can start writing an index. For some
people, this index or highest level programming could look mostly like a
void thing coz lacks of the proper meat that a Python use to eat, and in a
sense they are right. But that's not the point. The point is that as soon
as I can I would start to dig deeper in that structure and build the proper
meat that my highest level labels are just naming. What if using my ability
to name what I actually think and recognize the path of whichever method I
call from my object of thinking, I'd like to start setting a context for
further immersion (inmersion with advanced mathematical notation an that?
Somebody commented about a couple of basic elements which I'm familiarized
with, like +, -, /, =, 1,2,3,4,5,6,7,8,9,0, (), etc. I know that Python has
a set of keywords, there's also a proper way in which one must express
wholes in Python, proper way which I'm not familiarized with but I'm able
to learn. Does this help?

For me, starting with Python is an affair of connecting with it. It's not
about including it in me or including me in it, but a kind of symbiotic
relationship. Unless for me, using my natural language as far as I can, but
constrained (formalized) by Python syntax in order to model using objects
and methods and classes that are still unable to run in Python (yet) seems
to be a good starting point for a symbiotic relationship. Understanding
might depend in our ability to set ourselves in the shoes of another.

Any clues? Since this is a real goal that I'm looking to accomplish, any
question that would clarify a bit more my states will be highly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


ssl proxy server

2013-05-14 Thread 23alagmy
ssl proxy server

http://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python for philosophers

2013-05-14 Thread Terry Jan Reedy



2013/5/14 Steven D'Aprano mailto:steve+comp.lang.pyt...@pearwood.info>>



 >Python is not named after the snake, but after Monty Python the
British
 >comedy troupe. And they picked their name because it sounded funny.


That does not mean they were unaware that Pythons are snakes.
"requiring a "slippery-sounding" surname, they settled on "Python""


 > http://en.wikipedia.org/wiki/Monty_Python





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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Terry Jan Reedy

On 5/14/2013 3:52 AM, Chris Angelico wrote:

On Tue, May 14, 2013 at 9:40 AM, Fábio Santos  wrote:



http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html


 class Text(unicode, Enum):
 one = u'one'
 two = u'two'
 three = u'three'


Is this supposed to be a quote? or your rewrite? or did Santos rewrite 
after you posted? The blog currently has a 3.x version of that.



That looks like Python 2 code. Are you backporting Enum to Py2
manually? AIUI the Python core won't be adding features like that to
2.7, and there won't be a 2.8, so PEP 435 will be Py3.4+ only. Or have
I misunderstood it?


As far as official CPython goes, Enum is 3.4+ only. I believe the module 
will continue to work on earlier 3.x and will remain externally 
available as a 3rd party module. Ethan said he plans to backport to 2.7 
so 2 & 3 code can use enums.



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


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-14 Thread Mr. Joe
Sorry for digging this old topic back. I see that my "'property' does not
play well with polymorphic code" comment generated some controversy. So
here's something in my defense:

Here's the link to stackoveflow topic I am talking about:

http://stackoverflow.com/questions/237432/python-properties-and-inheritance

The solution that fits my taste:
http://stackoverflow.com/a/14349742

A related blogpost:

http://requires-thinking.blogspot.com/2006/03/note-to-self-python-properties-are-non.html

Yes, I like decorators and descriptors. I also like the ability to create a
"virtual property" in a python class by binding a bunch of methods as
setter/getter. But I find the implementation of this "virtual property
feature" a bit awkward sometimes - every time I need to override a
getter/setter in a child class, I need to decorate them again. Some of you
may like this "explicitness", but I don't.

To Steven D'Aprano: Seriously, what's all the bashing in your last reply
about? You dissected my "thank-you reply" more strictly than the python
interpreter checking for syntax errors. Not in a mood for fight, but I find
your opinions about "bug finding time", "hacks" and "stackoverflow" quite
silly.
-- 
http://mail.python.org/mailman/listinfo/python-list


PDF generator decision

2013-05-14 Thread Christian Jurk
Hi folks,

This questions may be asked several times already, but the development of 
relevant software continues day-for-day. For some time now I've been using 
xhtml2pdf [1] to generate PDF documents from HTML templates (which are rendered 
through my Django-based web application. This have been working for some time 
now but I'm constantly adding new templates and they are not looking like I 
want it (sometimes bold text is bold, sometimes not, layout issues, etc). I'd 
like to use something else than xhtml2pdf.

So far I'd like to ask which is the (probably) best way to create PDFs in 
Python (3)? It is important for me that I am able to specify not only 
background graphics, paragaphs, tables and so on but also to specify page 
headers/footers. The reason is that I have a bunch of documents to be generated 
(including Invoice templates, Quotes - stuff like that).

Any advice is welcome. Thanks.

[1] https://github.com/chrisglass/xhtml2pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PDF generator decision

2013-05-14 Thread Frank Miles
On Tue, 14 May 2013 08:05:53 -0700, Christian Jurk wrote:

> Hi folks,
> 
> This questions may be asked several times already, but the development
> of relevant software continues day-for-day. For some time now I've been
> using xhtml2pdf [1] to generate PDF documents from HTML templates (which
> are rendered through my Django-based web application. This have been
> working for some time now but I'm constantly adding new templates and
> they are not looking like I want it (sometimes bold text is bold,
> sometimes not, layout issues, etc). I'd like to use something else than
> xhtml2pdf.
> 
> So far I'd like to ask which is the (probably) best way to create PDFs
> in Python (3)? It is important for me that I am able to specify not only
> background graphics, paragaphs, tables and so on but also to specify
> page headers/footers. The reason is that I have a bunch of documents to
> be generated (including Invoice templates, Quotes - stuff like that).
> 
> Any advice is welcome. Thanks.
> 
> [1] https://github.com/chrisglass/xhtml2pdf

Reportlab works well in Python 2.x.  Their _next_ version is supposed to 
work with Python3... {yes, not much help there}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy  wrote:
> On 5/14/2013 3:52 AM, Chris Angelico wrote:
>>
>> On Tue, May 14, 2013 at 9:40 AM, Fábio Santos 
>> wrote:
>
>>> http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html
>>
>>
>>  class Text(unicode, Enum):
>>  one = u'one'
>>  two = u'two'
>>  three = u'three'
>
>
> Is this supposed to be a quote? or your rewrite? or did Santos rewrite after
> you posted? The blog currently has a 3.x version of that.

It was a quote from the blog post as it had been when I posted it.
Presumably he edited the post subsequently, as I'm now seeing the same
thing you are, a 3.x-compat version. (The u'xx' prefixes wouldn't be a
problem, incidentally, so this could be dual-versionned just by going
"unicode = str".)

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


First post

2013-05-14 Thread Carlos Nepomuceno
Hi guys! This is my first post on this list.

I'd like have your opinion on how to safely implement WSGI on a production 
server.

My benchmarks show no performance differences between our PHP and Python 
environments. I'm using mod_wsgi v3.4 with Apache 2.4.

Is that ok or can it get faster?

Thanks in advance.

Regards,

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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Fábio Santos
I corrected it indeed.

On Tue, May 14, 2013 at 4:36 PM, Chris Angelico  wrote:
> On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy  wrote:
>> On 5/14/2013 3:52 AM, Chris Angelico wrote:
>>>
>>> On Tue, May 14, 2013 at 9:40 AM, Fábio Santos 
>>> wrote:
>>
 http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html
>>>
>>>
>>>  class Text(unicode, Enum):
>>>  one = u'one'
>>>  two = u'two'
>>>  three = u'three'
>>
>>
>> Is this supposed to be a quote? or your rewrite? or did Santos rewrite after
>> you posted? The blog currently has a 3.x version of that.
>
> It was a quote from the blog post as it had been when I posted it.
> Presumably he edited the post subsequently, as I'm now seeing the same
> thing you are, a 3.x-compat version. (The u'xx' prefixes wouldn't be a
> problem, incidentally, so this could be dual-versionned just by going
> "unicode = str".)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list



-- 
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PDF generator decision

2013-05-14 Thread jmfauth
On 14 mai, 17:05, Christian Jurk  wrote:
> Hi folks,
>
> This questions may be asked several times already, but the development of 
> relevant software continues day-for-day. For some time now I've been using 
> xhtml2pdf [1] to generate PDF documents from HTML templates (which are 
> rendered through my Django-based web application. This have been working for 
> some time now but I'm constantly adding new templates and they are not 
> looking like I want it (sometimes bold text is bold, sometimes not, layout 
> issues, etc). I'd like to use something else than xhtml2pdf.
>
> So far I'd like to ask which is the (probably) best way to create PDFs in 
> Python (3)? It is important for me that I am able to specify not only 
> background graphics, paragaphs, tables and so on but also to specify page 
> headers/footers. The reason is that I have a bunch of documents to be 
> generated (including Invoice templates, Quotes - stuff like that).
>
> Any advice is welcome. Thanks.
>
> [1]https://github.com/chrisglass/xhtml2pdf

-

1) Use Python to collect your data (db, pictures, texts, ...)
and/or to create the material (text, graphics, ...) that will
be the contents (source) of your your pdf's.
2) Put this source in .tex file (a plain text file).
3) Let it compile with a TeX engine.

- I can not figure out something more versatile and basically
simple (writing a text file).
- Do not forget you are the only one who knows the content
and the layout of your document(s).

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


Re: ssl proxy server

2013-05-14 Thread Chris “Kwpolska” Warrick
On Tue, May 14, 2013 at 2:34 PM, 23alagmy  wrote:
> ssl proxy server
>
> hxxp://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
> --
> http://mail.python.org/mailman/listinfo/python-list

I have been seeing those mails for a long time.  Why didn’t anybody
ban that guy?  If it comes from Usenet (and headers say it does), and
you can’t destroy stuff easily there, maybe just put a ban on the
Mailman side of things, making the world much better for at least some
people?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-14 Thread Mark Janssen
On Sat, May 11, 2013 at 1:03 PM, Citizen Kant  wrote:
>I'm making my way to Python (and
> OOP in general) from a philosophical perspective or point of view and try to
> set the more global definition of Python's core as an "entity". In order to
> do that, and following Wittgenstein's indication about that the true meaning
> of words doesn't reside on dictionaries but in the use that we make of them,
> the starting question I make to myself about Python is: which is the single
> and most basic use of Python as the entity it is?

It is a way to form order from ideas, an *experimental* philosophy.
One can apply and implement a philosophy, taking it out of the realm
of ideas and simulate them in the machine.

> I mean, beside
> programming, what's the single and most basic result one can expect from
> "interacting" with it directly (interactive mode)?

A game of interactions.

> I roughly came to the
> idea that Python could be considered as an economic mirror for data, one
> that mainly mirrors the data the programmer types on its black surface,

That is called the "editor window" in our world that is displayed on
an electronic device called a computer display, but in Samael's world
it is a mirror into our world.  He misused it to rape the crown of the
Hebrew story (found in the Bible).

> So, would it be legal (true) to define Python's core as an entity that
> mirrors whatever data one presents to it (or feed it with) showing back the
> most shortened expression of that data?

No, that is me, Marcos.
-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Illegal seek error with seek() and os.lseek()

2013-05-14 Thread krishna2prasad
I am trying to use os.open() and os.lseek() methods to operate on a device file 
in Linux. My code goes something like this -

 # first, open the file as a plain binary
 try:
 self.file = open(/dev/relpcfpga, "r+b", buffering=0)
 
 except IOError:
 raise IOError ('Failed to open.')

 # Figure out file size
  self.file.seek(0, 2)
  self.file_size = self.file.tell()
 

The method seek() complains "OSError: [Errno 29] Illegal seek"
The device relpcfpga is a char device.

The same code works with a normal text file.
I have tried to use os.open() and os.lseek() methods, but see the same error.
Is there a different method to operate on device files?


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


Re: Message passing syntax for objects | OOPv2

2013-05-14 Thread Mark Janssen
> Sounds a lot like reddit threads.

It's similar, but it goes a lot further.  Where every other site
without centralized editors, the thread mess on a simple flat page
doesn't scale after about a 100 interactions.  To sort out the mess,
it takes another dimension.  The project I'm working on uses a 3
dimensional visualization model that can scale and order millions of
nodes.

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ssl proxy server

2013-05-14 Thread Skip Montanaro
I haven't touched the SpamBayes setup for the usenet-to-mail gateway
in a long while.  For whatever reason, this message was either held
and then approved by the current list moderator(s), or (more likely)
slipped through unscathed.  No filter is perfect.

Skip

On Tue, May 14, 2013 at 1:40 PM, Chris “Kwpolska” Warrick
 wrote:
> On Tue, May 14, 2013 at 2:34 PM, 23alagmy  wrote:
>> ssl proxy server
>>
>> hxxp://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
> I have been seeing those mails for a long time.  Why didn’t anybody
> ban that guy?  If it comes from Usenet (and headers say it does), and
> you can’t destroy stuff easily there, maybe just put a ban on the
> Mailman side of things, making the world much better for at least some
> people?
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread mar...@python.net
On Tue, May 14, 2013, at 03:00 PM, krishna2pra...@gmail.com wrote:
> I am trying to use os.open() and os.lseek() methods to operate on a
> device file in Linux. My code goes something like this -
> 
>  # first, open the file as a plain binary
>  try:
>  self.file = open(/dev/relpcfpga, "r+b", buffering=0)
>  
>  except IOError:
>  raise IOError ('Failed to open.')
> 
>  # Figure out file size
>   self.file.seek(0, 2)
>   self.file_size = self.file.tell()
>  
> 
> The method seek() complains "OSError: [Errno 29] Illegal seek"
> The device relpcfpga is a char device.
> 
> The same code works with a normal text file.
> I have tried to use os.open() and os.lseek() methods, but see the same
> error.
> Is there a different method to operate on device files?

Some file streams are not seekable.  Specifically, some (all?) char
devices aren't seekable (because e.g. they can't be rewound or they have
no end).  You'd get the same error in C (well it would return -1).

See also: http://www.linuxintro.org/wiki/Device
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Roy Smith
In article <50bf9366-46e0-4a7f-865b-3f7c7b0f6...@googlegroups.com>,
 krishna2pra...@gmail.com wrote:

> I am trying to use os.open() and os.lseek() methods to operate on a device 
> file in Linux. My code goes something like this -
> 
>  # first, open the file as a plain binary
>  try:
>  self.file = open(/dev/relpcfpga, "r+b", buffering=0)
>  
>  except IOError:
>  raise IOError ('Failed to open.')
> 
>  # Figure out file size
>   self.file.seek(0, 2)
>   self.file_size = self.file.tell()
>  
> 
> The method seek() complains "OSError: [Errno 29] Illegal seek"
> The device relpcfpga is a char device.
> 
> The same code works with a normal text file.
> I have tried to use os.open() and os.lseek() methods, but see the same error.
> Is there a different method to operate on device files?

In general, seek() works on special files, when it makes sense.  But, 
the "in general" part is critical.  Not all devices support the seek 
operation.  I have no idea what /dev/relpcfpga is (a google search for 
relpcfpga came up with exactly one hit -- your post!) so I can't tell 
you if it supports seek() or not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-14 Thread Fábio Santos
Impressive, I'd say.

On Tue, May 14, 2013 at 8:11 PM, Mark Janssen  wrote:
>> Sounds a lot like reddit threads.
>
> It's similar, but it goes a lot further.  Where every other site
> without centralized editors, the thread mess on a simple flat page
> doesn't scale after about a 100 interactions.  To sort out the mess,
> it takes another dimension.  The project I'm working on uses a 3
> dimensional visualization model that can scale and order millions of
> nodes.
>
> --
> MarkJ
> Tacoma, Washington


--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Andreas Perstinger

On 14.05.2013 21:00, krishna2pra...@gmail.com wrote:

  # first, open the file as a plain binary
  try:
  self.file = open(/dev/relpcfpga, "r+b", buffering=0)


Aren't you missing the quotes for "/dev/relpcfpga"?


The method seek() complains "OSError: [Errno 29] Illegal seek"
The device relpcfpga is a char device.


Are you sure that your device is seekable?
Try

f = open("/dev/relpcfpga", "r+b", buffering=0)
print(f.seekable())

Bye, Andreas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python for philosophers

2013-05-14 Thread DJC

On 14/05/13 09:34, Citizen Kant wrote:

2013/5/14 Steven D'Aprano 


On Tue, 14 May 2013 01:32:43 +0200, Citizen Kant wrote:


An entity named Python must be somehow as a serpent. Don't forget that
I'm with the freeing up of my memory, now I'm not trying to follow the
path of what's told but acting like the monkey and pushing with my
finger against the skin of the snake.



Python is not named after the snake, but after Monty Python the British
comedy troupe. And they picked their name because it sounded funny.



http://en.wikipedia.org/wiki/Monty_Python





I'm sorry to hear that. Mostly because, as an answer, seems to example
very well the "taken because I've been told how things are" kind of
actions, which is exactly the opposite of the point I'm trying to state.




Emanual Kant was a real piss ant
Who was very rarely stable
--
http://mail.python.org/mailman/listinfo/python-list


Re: Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-14 Thread Steven D'Aprano
On Tue, 14 May 2013 19:01:38 -0400, Dennis Lee Bieber wrote:

> On 14 May 2013 05:09:48 GMT, Steven D'Aprano
>  declaimed the following in
> gmane.comp.python.general:

>> The <> operator comes from Pascal, where it was used as "not equal"
>> since
> 
>   I thought it came from BASIC...
> http://en.wikipedia.org/wiki/Dartmouth_BASIC


Ah, well apparently BASIC used it earlier, but I don't know whether it 
was an influence on Pascal (except as "what not to do").


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


weave in 64 bit strange behavior

2013-05-14 Thread Jadhav, Alok
Hi everyone,

 

I realize my previous post was quite unreadable, thanks to my email
client. I am going to report my question here, with slight enhancements.
Apologies for inconvenience caused and spamming your mailboxes.

 

I am facing a strange problem using weave on 64 bit machine.
Specifically with weave's inline function. It has something to do with
weave's catalog. 

 

Similar issues I found in the past (very old)

 

http://mail.scipy.org/pipermail/scipy-dev/2006-June/005908.html 

http://mail.scipy.org/pipermail/scipy-dev/2005-June/003042.html

 

Common things I have in my observation are:

 

-  Already working setup in 32 bit doesn't work in same manner
in 64 bit env

-  Weave recompiles inline code which does not require any
recompilation. This is random behavior.  Whenever weave recompiles I see
a notification "repairing catalog by removing key" in the output which
ends up in the error message "ImportError: DLL load failed: Invalid
access to memory location"

-  Sometimes gcc gets into an infinite loop printing error
message "Looking for python27.dll". Even though the dll is on the path.
This process doesn't end. Had to kill it forcefully. G++ process became
ghost even after killing python process. 

 

Could someone advise what am I missing here. Is there any specific setup
that I need to do? Is there an issue with python 27 64 bit weave
implementation? 

 

Regards,

Alok

 



 

I have a simple script to calculate moving average using weave's inline
function. 

 

source mvg.py

 

import numpy as np

import scipy.weave as weave

import distutils.sysconfig

import distutils.dir_util

import os

 

distutils.sysconfig._config_vars["LDSHARED"]="-LC:\strawberry\c\x86_64-w
64-mingw32\lib"

 

def ExpMovAvg(data,time,lag):

if (data.size!=time.size):

print "error in EMA, data and time have different size"

return None

 

result=np.repeat(0.0,data.size)

code="""

#line 66 "basics.py"

result(0)=data(0);

for (int i=0;i1)

{

alpha=10;

}

result(i+1)=(1-alpha)*data(i)+alpha*result(i);

}

"""

 
weave.inline(code,["data","time","lag","result"],type_converters=weave.c
onverters.blitz,headers=[""],compiler="gcc",verbose=2)

return result

 

source test.py

 

import string

import numpy as np

import mvg

 

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

 

 

Output:

 

Working output:

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe

s:\common\tools\python\python-2.7-64bit\test.py

 

[ 0.  0.  0.63212774  1.49679774  2.44701359  3.42869938

4.42196209  5.41948363  6.41857187  7.41823646]

 

Now if I keep running the script multiple times, sometimes I see correct

output... but suddenly sometimes I get below error.

 

Y:\STMM\alpha\klse\PROD>c:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

 

repairing catalog by removing key



Looking for python27.dll

running build_ext

running build_src

build_src

building extension "sc_44f3fe3c65d5c3feecb45d9269ac207f5" sources

build_src: building npy-pkg config files

Looking for python27.dll

 

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

building 'sc_44f3fe3c65d5c3feecb45d9269ac207f5' extension

compiling C++ sources

C compiler: g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall

 

compile options: '-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c' 

g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3f
e3c65d5c3feecb45d9269ac207f5.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\users\ajadhav2\appdata\loc
al\temp\ajadhav2\python27_compiled\sc_44f3fe3c65d5c3feecb45d9269ac207f5.
o

 

Found executable C:\strawberry\c\bin\g++.exe

g++ -g -DDEBUG -DMS_WIN64 -O0
-Wall-Ic:\python27\lib\site-packages\scipy\weave-Ic:\python27\lib\site-p
ackages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include-Ic:\python27\include
-Ic:\python27\PC -c
c:\python27\lib\site-packages\scipy\weave\scxx\weave_imp.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\python27\lib\site-packages
\scipy\weave\scxx\weave_imp.o

g++ -g -shared
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler

Re: Python's sad, unimaginative Enum

2013-05-14 Thread 88888 Dihedral
Chris Angelico於 2013年5月14日星期二UTC+8上午1時36分34秒寫道:
> On Mon, May 13, 2013 at 8:17 PM, Steven D'Aprano
> 
>  wrote:
> 
> > Let's look at his major criticisms:
> 
> >
> 
> > 1) values aren't automatically generated.
> 
> >
> 
> > True. So what? That is the *least* important part of enums.
> 
> 
> 
> I stopped following the -ideas threads about enums, but IIRC
> 
> autogeneration of values was in quite a few of the specs early on. So
> 
> you can probably find the arguments against it in the list archives.
> 
> 
> 
> FWIW, though, I do like C's autogeneration of enum values - but use it
> 
> in only a small proportion of my enums. It's not a terrible loss, but
> 
> it is a loss.
> 
> 
> 
> ChrisA

Because a hash table can replace the enums in other languages,
it is more pythonic to use a dictionary built first
to replace the enums.

I think it is the same style of programming  in perl and ruby.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread rusi
On May 14, 2:24 pm, Jean-Michel Pichavant 
wrote:
> - Original Message -
> > On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote:
>
> > > - Original Message -
> > >> That's the title of this little beast
> > >>http://www.acooke.org/cute/Pythonssad0.htmlif anybody's
> > >> interested.
>
> > >> --
> > >> If you're using GoogleCrap™ please read this
> > >>http://wiki.python.org/moin/GoogleGroupsPython.
>
> > >> Mark Lawrence
>
> > >> --
> > >>http://mail.python.org/mailman/listinfo/python-list
>
> > > python 2.5
>
> > > class Enum:
> > >   class __metaclass__(type):
> > >     def __iter__(self):
> > >       for attr in sorted(dir(self)):
> > >         if not attr.startswith("__"):
> > >           yield getattr(self, attr)
>
> > > class Colours(Enum):
> > >   RED = "red"
> > >   GREEN = "green"
>
> > py> class Experience(Enum):
> > ...     NOVICE = 'novice'
> > ...     GREEN = 'green'
> > ...     EXPERIENCED = 'experienced'
> > ...     MASTER = 'master'
> > ...
> > py>
> > py> Colours.GREEN == Experience.GREEN
> > True
>
> > Oops.
>
> > It's very easy to make something which does a few things that enums
> > should do, and call it an Enum. It's much harder to do a lot of
> > things
> > that enums should do.
>
> > --
> > Steven
>
> I was just proposing a solution I've been using and found quite satisfactory. 
> As for the perfect "enumness" of that solution, I don't know. To be honest, 
> I'm not sure I know the exact definition of an enum, and whether or not the C 
> enum fits 100% that definition. It does the job in python. Some people may 
> find it useful, others may just ignore it.
> Additionally, the "bug" you mentioned can be written in C as well, casts 
> allow to compare apples and oranges:
>
> (Colours::GREEN == (enum Coulours::Colour)Experiences::GREEN)


Enums are like names.
And like names are impossible to do right:
http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-14 Thread Ramchandra Apte
On Sunday, 12 May 2013 01:33:15 UTC+5:30, Citizen Kant  wrote:
> Hi,
> this could be seen as an extravagant subject but that is not my original 
> purpose. I still don't know if I want to become a programmer or not. At this 
> moment I'm just inspecting the environment. I'm making my way to Python (and 
> OOP in general) from a philosophical perspective or point of view and try to 
> set the more global definition of Python's core as an "entity". In order to 
> do that, and following Wittgenstein's indication about that the true meaning 
> of words doesn't reside on dictionaries but in the use that we make of them, 
> the starting question I make to myself about Python is: which is the single 
> and most basic use of Python as the entity it is? I mean, beside programming, 
> what's the single and most basic result one can expect from "interacting" 
> with it directly (interactive mode)? I roughly came to the idea that Python 
> could be considered as an economic mirror for data, one that mainly mirrors 
> the data the programmer types on its black surface, not exactly as the 
> programmer 
 originally typed it, but expressed in the most economic way possible. That's 
to say, for example, if one types >>>1+1 Python reflects >>>2. When data 
appears between apostrophes, then the mirror reflects, again, the same but 
expressed in the most economic way possible (that's to say without the 
apostrophes).
> So, would it be legal (true) to define Python's core as an entity that 
> mirrors whatever data one presents to it (or feed it with) showing back the 
> most shortened expression of that data?
> Don't get me wrong. I can see the big picture and the amazing things that 
> programmers write on Python, it's just that my question points to the lowest 
> level of it's existence.
> Thanks a lot for your time.
I expected some spam but this actually makes some sense.

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


IndexError: pop index out of range

2013-05-14 Thread Andrew Z
hello,
 going fru some basic examples and can't figureout why the following errors
out. Help is very much appreciated:

def front_x(words):
  # +++your code here+++
print "words passed : ", words
list_xx = []
list_temp = words[:]
print "list_temp -", list_temp
print "words -", words
for idx, val in enumerate(words):
print val, idx
# str_idx = val.find('x',0,2)
if val[0] == 'x':
vl = list_temp.pop(idx)
list_xx.append(vl)

print "appending list_xx", list_xx

list_xx.sort
list_temp.sort
print "words sorted : " + str(words)
print "list_temp sorted : ", list_temp
list_xx.append(words)
print "list_xx" + str(list_xx)
return True

front_x
words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
bbb 0
ccc 1
axx 2
xzz 3
appending list_xx ['xzz']
xaa 4
Traceback (most recent call last):
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 119, in 
main()
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 100, in main
test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']),
  File
"/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",
line 55, in front_x
vl = list_temp.pop(idx)
IndexError: pop index out of range


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


RE: IndexError: pop index out of range

2013-05-14 Thread Carlos Nepomuceno
Your "for idx, val in enumerate(words):" is running on words not list_temp.
As you remove from list_temp and keeps parsing words you get the IndexError.

> From: form...@gmail.com 
> Date: Wed, 15 May 2013 00:22:05 -0400 
> Subject: IndexError: pop index out of range 
> To: python-list@python.org 
>  
> hello, 
>   going fru some basic examples and can't figureout why the following  
> errors out. Help is very much appreciated: 
>  
> def front_x(words): 
># +++your code here+++ 
>  print "words passed : ", words 
>  list_xx = [] 
>  list_temp = words[:] 
>  print "list_temp -", list_temp 
>  print "words -", words 
>  for idx, val in enumerate(words): 
>  print val, idx 
>  # str_idx = val.find('x',0,2) 
>  if val[0] == 'x': 
>  vl = list_temp.pop(idx) 
>  list_xx.append(vl) 
>  
>  print "appending list_xx", list_xx 
>  
>  list_xx.sort 
>  list_temp.sort 
>  print "words sorted : " + str(words) 
>  print "list_temp sorted : ", list_temp 
>  list_xx.append(words) 
>  print "list_xx" + str(list_xx) 
>  return True 
>  
> front_x 
> words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
> list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
> words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
> bbb 0 
> ccc 1 
> axx 2 
> xzz 3 
> appending list_xx ['xzz'] 
> xaa 4 
> Traceback (most recent call last): 
>File  
> "/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",  
> line 119, in  
>  main() 
>File  
> "/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",  
> line 100, in main 
>  test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']), 
>File  
> "/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py",  
> line 55, in front_x 
>  vl = list_temp.pop(idx) 
> IndexError: pop index out of range 
>  
>  
>  
> -- http://mail.python.org/mailman/listinfo/python-list
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-14 Thread dieter
"Mr. Joe"  writes:
> ...
> Sorry for digging this old topic back. I see that my "'property' does not
> play well with polymorphic code" comment generated some controversy. So
> here's something in my defense:

I did not intend to "attack" you.

> ...
> Yes, I like decorators and descriptors. I also like the ability to create a
> "virtual property" in a python class by binding a bunch of methods as
> setter/getter. But I find the implementation of this "virtual property
> feature" a bit awkward sometimes - every time I need to override a
> getter/setter in a child class, I need to decorate them again. Some of you
> may like this "explicitness", but I don't.

True, I have been hit by this, too - not with "property" but with
other decorators (those for caching).
But, after reflection, I came to the conclusion that I should be
happy with this feature:

  If Python would automatically redecorate overridden methods in a derived
  class, I would have no control over the process. What if I need
  the undecorated method or a differently decorated method (an
  uncached or differently cached method, in my case)?

Your getter/setter use case can quite easily be solved
with a class "DelayedMethodAccessor":

  class DelayedMethodAccess(object):
"""
def __init__(self, name): self.__name = name
def __call__(self, inst, *args, **kw): 
  return getattr(inst, self.__name)(*args, **kw)

You can then use:

   prop = property(DelayedMethodAccess(""), ...)

Or define a new decorator "property_by_name" and then
use

   prop = property_by_name("", ...)

Of course, this requires that the property name and the getter/setter names
differ, but this should be naturally enough.


Python's current behavior is very natural once you know that
decorators are just syntactic sugar and

   @
   def ...

simply means:

   def ...
   f = (f)

True, this is no perfect fit for all use cases - but
such a fit (if it existed at all) would have to be so complex
that only experts could understand it.

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


Re: PDF generator decision

2013-05-14 Thread dieter
Christian Jurk  writes:

> ...
> So far I'd like to ask which is the (probably) best way to create PDFs in 
> Python (3)? It is important for me that I am able to specify not only 
> background graphics, paragaphs, tables and so on but also to specify page 
> headers/footers. The reason is that I have a bunch of documents to be 
> generated (including Invoice templates, Quotes - stuff like that).

High quality layouts, especially those containing (potentially complex
tables), are very difficult to generate automatically.

I do not suppose that you will find a generic solution - one applicable
to a wide range of document classes and garanteeing high quality
layout for almost all of its document instances.

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


Determine actually given command line arguments

2013-05-14 Thread Henry Leyh

Hello,
I am writing a program that gets its parameters from a combination of 
config file (using configparser) and command line arguments (using 
argparse).  Now I would also like the program to be able to _write_ a 
configparser config file that contains only the parameters actually 
given on the commandline.  Is there a simple way to determine which 
command line arguments were actually given on the commandline, i.e. does 
argparse.ArgumentParser() know which of its namespace members were 
actually hit during parse_args().


I have tried giving the arguments default values and then looking for 
those having a non-default value but this is really awkward, especially 
if it comes to non-string arguments.  Also, parsing sys.argv looks 
clumsy because you have to keep track of short and long options with and 
without argument etc. i.e. all things that I got argparse for in the 
first place.


Thanks && Greetings,
Henry
--
http://mail.python.org/mailman/listinfo/python-list


RE: PDF generator decision

2013-05-14 Thread Carlos Nepomuceno
Christian, have you tried pod[1]? You can use create templates in OpenDocument 
format and then create the PDFs just passing the arguments, like:

args = {'name':'John', 'email':'j...@example.com'}
renderer = Renderer('template.odt', args, 'result.odt')renderer.run()



[1] http://appyframework.org/pod.html


> To: python-list@python.org
> From: die...@handshake.de
> Subject: Re: PDF generator decision
> Date: Wed, 15 May 2013 08:22:25 +0200
>
> Christian Jurk  writes:
>
>> ...
>> So far I'd like to ask which is the (probably) best way to create PDFs in 
>> Python (3)? It is important for me that I am able to specify not only 
>> background graphics, paragaphs, tables and so on but also to specify page 
>> headers/footers. The reason is that I have a bunch of documents to be 
>> generated (including Invoice templates, Quotes - stuff like that).
>
> High quality layouts, especially those containing (potentially complex
> tables), are very difficult to generate automatically.
>
> I do not suppose that you will find a generic solution - one applicable
> to a wide range of document classes and garanteeing high quality
> layout for almost all of its document instances.
>
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list