Re: Help with suds: HTTP Error 401

2014-07-29 Thread dieter
> ...
HTTP Error 401 means "Unauthorized": the service you tried to use
requires authentication and either it has not found authentication
information or it was wrong.

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


Re: rpath alike feature for python scripts

2014-07-29 Thread dieter
Olaf Hering  writes:

> On Mon, Jul 28, Albert-Jan Roskam wrote:
>> does this help: https://nixos.org/patchelf.html. It is not specific to 
>> Python, though.
>
> No, this does not help because its not about patching the result.
> The questions is how to obtain the value with should be patched into the
> result.

You wanted to know how to emulate the "rpath" feature with
Python scripts. The use case for the "rpath" feature looks like:
 
   A binary depends on some shared objects stored at a non-standard
   place. The person linking the binary knows those places
   where the shared objects can likely be found. He uses
   the "rpath" linker option to provide this information.
   It is stored with the created binary and instructs the
   dynamic linker in what additional places it should look
   for shared objects.


Python correspondences:

   binary ~ script
   dynamic linker ~ Python's import mechanism

Python lacks the (static) linking phase. You must invent something:
you may see it as part of script development or as part of the installation
or design it as creating some wrapper which extends the standard
configuration for Python's import mechanism and then call the script
itself.


The primary ways to interact with Python's import mechanism
are "sys.path" and the envvar "PYTHONPATH" (which corresponds
to the envvar "LD_LIBRARY_PATH").


> Looks like I have to dissect setup.py and mimic its behaviour in the
> Makefile.

"setup.py" does nothing with Python's "sys.path".

It looks at "sys.prefix" and "sys.execprefix" to learn where
to install modules/packages and binary scripts.

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


Re: Load a CSV with different row lengths

2014-07-29 Thread Miki Tebeka
Greetings,

> I should've mentioned that I want to import my csv as a data frame or numpy 
> array or as a table.
If you know the max length of a row, then you can do something like:
def gen_rows(stream, max_length):
for row in csv.reader(stream):
yield row + ([None] * (max_length - len(line))

max_length = 10
with open('data.csv') as fo:
df = pd.DataFrame.from_records(gen_rows(fo, max_length))


HTH,
Miki
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help with suds: HTTP Error 401

2014-07-29 Thread manelclos
Use a SUDS fork that works, I tried https://github.com/unomena/suds

See here:
http://stackoverflow.com/questions/18455945/python-suds-runtimeerror-maximum-recursion-depth-exceeded-while-calling-a-pyth/24908676#24908676



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


Re: Windows Studio 2008 Download

2014-07-29 Thread TP
On Tue, Jul 29, 2014 at 5:54 AM, Colin J. Williams 
wrote:

> ii. The Service Pack 1 has the original studio as a prerequisite.  That is
> no longer available from Microsoft.


I haven't tried it but the Visual Studio 2008 Professional 90 Day Trial iso
*is* available from Microsoft at [1]. This doesn't show up by searching
download.microsoft.com. You have to stumble upon the link elsewhere. I
guess Microsoft *really* doesn't want people to use VS2008 anymore :)

[1]
http://download.microsoft.com/download/8/1/d/81d3f35e-fa03-485b-953b-ff952e402520/VS2008ProEdition90dayTrialENUX1435622.iso
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exploring Python for next desktop GUI Project

2014-07-29 Thread pecore
Roy Smith  writes:

> In article <87mwbtjg9r@pascolo.net>, pec...@pascolo.net wrote:
>
>> >> 2. Python 2 or 3? Which will serve me better in the future?
>> >
>> > Long term (7 years), [Python] 3.
>> 
>> I have STRONG suicidal intent and no access to treatment,
>> should I better learn Python 2?
>
> In that case, go with PHP.

ah, well said! but I went with PHP already and look at me now!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lxml and namespaces

2014-07-29 Thread Irmen de Jong
On 29-7-2014 20:35, Marc Aymerich wrote:


> Got it!
> xml = lxml.builder.ElementMaker(
>  nsmap = {
>  None: "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
>  'xsi': "http://www.w3.org/2001/XMLSchema-instance";,
>  }
> )
> doc = xml.Document()


Thanks for taking the time to actually post the solution you came up with 
yourself!

Irmen


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


Re: lxml and namespaces

2014-07-29 Thread Marc Aymerich
On Tue, Jul 29, 2014 at 8:19 PM, Marc Aymerich  wrote:

> Hi, I'm desperately trying to construct an XML with the following document
> declaration:
>
>  xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
>
> I'm using LXML, and what I'm doing is this
>
> >>> from lxml import etree
> >>> from lxml.builder import E
> >>> doc = E.Document(
> ... {
> ... 'xmlns': "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
> ... '{xmlns}xsi': "http://www.w3.org/2001/XMLSchema-instance";,
> ... }
> ... )
> >>> print etree.tostring(doc)
> http://www.w3.org/2001/XMLSchema-instance";
> xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"/>
>
>
> I've tried everything I can imagine and this is the best I can do :(
>
> Any idea on how to get the xmlns and xmlns:xsi attributes correctly?
>


Got it!
xml = lxml.builder.ElementMaker(
 nsmap = {
 None: "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
 'xsi': "http://www.w3.org/2001/XMLSchema-instance";,
 }
)
doc = xml.Document()


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


lxml and namespaces

2014-07-29 Thread Marc Aymerich
Hi, I'm desperately trying to construct an XML with the following document
declaration:

http://www.w3.org/2001/XMLSchema-instance”>

I'm using LXML, and what I'm doing is this

>>> from lxml import etree
>>> from lxml.builder import E
>>> doc = E.Document(
... {
... 'xmlns': "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
... '{xmlns}xsi': "http://www.w3.org/2001/XMLSchema-instance";,
... }
... )
>>> print etree.tostring(doc)
http://www.w3.org/2001/XMLSchema-instance";
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"/>


I've tried everything I can imagine and this is the best I can do :(

Any idea on how to get the xmlns and xmlns:xsi attributes correctly?

Thanks!!

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


Re: Windows Studio 2008 Download

2014-07-29 Thread Chris Angelico
On Tue, Jul 29, 2014 at 10:54 PM, Colin J. Williams
 wrote:
> i.  I've seen notes, in various places to say that the Express version is
> not acceptable for compiling Python packages.  Is it, in fact usable for
> this purpose?

I'm not 100% sure on the details, but I do believe the intention was
always for the Express version to be suitable.

> ii. The Service Pack 1 has the original studio as a prerequisite.  That is
> no longer available from Microsoft.

There are probably unofficial third-party sites where you can get it,
but if you're going to go down that route, you'd do better to just
grab a third-party Numpy binary and save yourself the trouble.

It's also possible to get a different compiler and build your own
Python and extensions. But that's going to be a lot of work, too.

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


Re: Windows Studio 2008 Download

2014-07-29 Thread Mark Lawrence

On 29/07/2014 13:54, Colin J. Williams wrote:

i.  I've seen notes, in various places to say that the Express version
is not acceptable for compiling Python packages.  Is it, in fact usable
for this purpose?


All wrong, I've been using the express editions for years with no 
problems.  See here for more 
https://docs.python.org/devguide/setup.html#windows




ii. The Service Pack 1 has the original studio as a prerequisite.  That
is no longer available from Microsoft.

Any advice would be welcomed.

Colin W.



And please don't top post, thanks.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Load a CSV with different row lengths

2014-07-29 Thread Ryan de Vera
Hey skip,

I should've mentioned that I want to import my csv as a data frame or numpy
array or as a table.

Best regards,

Ryan


On Tue, Jul 29, 2014 at 6:29 AM, Skip Montanaro  wrote:

> > How can I load this into python? I tried using both NumPy and Pandas.
>
> To add to Peter's response, I would be very surprised if numpy or
> Pandas couldn't be coaxed into loading your CSV file, but you didn't
> provide any details about what you expected and what you got. I've
> used Pandas to read CSV files a lot recently, and run into any
> trouble. (I suspect all but a few have equal length rows, but in cases
> where data are missing, I've found it generally inserts NaNs.)
>
> In general, you'll get more useful feedback with more complete
> questions. I'm not saying you need to necessarily provide code, but a
> traceback or unexpected output would be helpful.
>
> Skip
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Studio 2008 Download

2014-07-29 Thread Colin J. Williams
i.  I've seen notes, in various places to say that the Express version is
not acceptable for compiling Python packages.  Is it, in fact usable for
this purpose?

ii. The Service Pack 1 has the original studio as a prerequisite.  That is
no longer available from Microsoft.

Any advice would be welcomed.

Colin W.


On 28 July 2014 16:04, TP  wrote:

> Hmmm. Now that I think about it the full Microsoft Visual Studio 2008
> Service Pack 1 download I mentioned in my last email probably needs to have
> Visual Studio 2008 already installed (it's been a number of years since I
> had to install VS2008)? You could try it and see if it works.
>
> If not download the free Express version I mentioned instead. Trying to
> find the download link for the free VS2008 Express version is much harder
> so I guess that's why people keep asking for it :)
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Load a CSV with different row lengths

2014-07-29 Thread Skip Montanaro
> How can I load this into python? I tried using both NumPy and Pandas.

To add to Peter's response, I would be very surprised if numpy or
Pandas couldn't be coaxed into loading your CSV file, but you didn't
provide any details about what you expected and what you got. I've
used Pandas to read CSV files a lot recently, and run into any
trouble. (I suspect all but a few have equal length rows, but in cases
where data are missing, I've found it generally inserts NaNs.)

In general, you'll get more useful feedback with more complete
questions. I'm not saying you need to necessarily provide code, but a
traceback or unexpected output would be helpful.

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


Re: What happens when you 'break' a generator?

2014-07-29 Thread Frank Millman

"Peter Otten" <__pete...@web.de> wrote in message 
news:lr7ilg$de4$1...@ger.gmane.org...
> Frank Millman wrote:
>
>> Hi all
>>
>> Python 3.4.1
>>
>> Here is a simple generator -
>>
>> def test():
>> print('start')
>> for i in range(5):
>> yield i
>> print('done')
>>
>> x = test()
>> for j in x:
>> print(j)
>>
>> As expected, the output is -
>>
>> start
>> 0
>> 1
>> 2
>> 3
>> 4
>> done
>>
>> Here I break the loop -
>>
>> x = test()
>> for j in x:
>> print(j)
>> if j == 2:
>> break
>>
>> Now the output is -
>>
>> start
>> 0
>> 1
>> 2
>>
>> 'done' does not appear, so the generator does not actually terminate. 
>> What
>> happens to it?
>>
>> My guess is that normal scoping rules apply. Using my example, the
>> generator is referenced by 'x', so when 'x' goes out of scope, the
>> generator is garbage collected, even though it never completed.
>>
>> Is this correct?
>
> Yes. In newer Pythons try...finally works, so you can see for yourself:
>
 def f():
> ... try:
> ... for c in "abc": yield c
> ... finally:
> ... print("done")
> ...
 g = f()
 for c in g:
> ... print(c)
> ... if c == "b": break
> ...
> a
> b
 del g
> done
>
> Also:
>
 g = f()
 next(g)
> 'a'
 g.throw(GeneratorExit)
> done
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "", line 3, in f
> GeneratorExit
>
>

Thanks for the clarification, Peter.

The subconscious does funny things. When I scanned your reply quickly, I 
could have sworn it said something about 'forcing a break'. When I read it 
more slowly, I could not find that. Then I realised it actually says 'for c 
in g' ...

Frank



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


Re: What happens when you 'break' a generator?

2014-07-29 Thread Terry Reedy

On 7/29/2014 3:18 AM, Frank Millman wrote:

Hi all

Python 3.4.1

Here is a simple generator -

def test():
 print('start')
 for i in range(5):
 yield i
 print('done')

x = test()
for j in x:
 print(j)

As expected, the output is -

start
0
1
2
3
4
done

Here I break the loop -

x = test()
for j in x:
 print(j)
 if j == 2:
 break

Now the output is -

start
0
1
2

'done' does not appear, so the generator does not actually terminate. What
happens to it?


It sits there waiting for you to ask for the next value. Add
for j in x: print(j)
to exhaust it.  Even then, it sits there until garbage collected.



--
Terry Jan Reedy

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


Re: What happens when you 'break' a generator?

2014-07-29 Thread Johannes Schneider

On 29.07.2014 09:18, Frank Millman wrote:

there's not print 'done' statement at the and.



Here I break the loop -

x = test()
for j in x:
 print(j)
 if j == 2:
 break

Now the output is -

start
0
1
2

'done' does not appear, so the generator does not actually terminate. What
happens to it?

My guess is that normal scoping rules apply. Using my example, the generator
is referenced by 'x', so when 'x' goes out of scope, the generator is
garbage collected, even though it never completed.

Is this correct?

Frank Millman






--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Load a CSV with different row lengths

2014-07-29 Thread Peter Otten
Ryan de Vera wrote:

> I am trying to load a csv with different row lengths. For example,
> 
> I have the csv
> 
> a,b
> a,b,c,d
> a,b,c
> 
> How can I load this into python? I tried using both NumPy and Pandas.

The csv module in the standard library can deal with varying row lengths 
just fine:

>>> import csv
>>> with open("data.csv") as f:
... data = list(csv.reader(f))
... 
>>> data
[['a', 'b'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c']]

Depending on your use case you may need to do some post-processing in your 
code (e. g. converting strings to numbers).

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


Re: rpath alike feature for python scripts

2014-07-29 Thread Olaf Hering
On Mon, Jul 28, Albert-Jan Roskam wrote:

> does this help: https://nixos.org/patchelf.html. It is not specific to 
> Python, though.

No, this does not help because its not about patching the result.
The questions is how to obtain the value with should be patched into the
result.

Looks like I have to dissect setup.py and mimic its behaviour in the
Makefile.

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


Re: What happens when you 'break' a generator?

2014-07-29 Thread Peter Otten
Frank Millman wrote:

> Hi all
> 
> Python 3.4.1
> 
> Here is a simple generator -
> 
> def test():
> print('start')
> for i in range(5):
> yield i
> print('done')
> 
> x = test()
> for j in x:
> print(j)
> 
> As expected, the output is -
> 
> start
> 0
> 1
> 2
> 3
> 4
> done
> 
> Here I break the loop -
> 
> x = test()
> for j in x:
> print(j)
> if j == 2:
> break
> 
> Now the output is -
> 
> start
> 0
> 1
> 2
> 
> 'done' does not appear, so the generator does not actually terminate. What
> happens to it?
> 
> My guess is that normal scoping rules apply. Using my example, the
> generator is referenced by 'x', so when 'x' goes out of scope, the
> generator is garbage collected, even though it never completed.
> 
> Is this correct?

Yes. In newer Pythons try...finally works, so you can see for yourself:

>>> def f():
... try:
... for c in "abc": yield c
... finally:
... print("done")
... 
>>> g = f()
>>> for c in g:
... print(c)
... if c == "b": break
... 
a
b
>>> del g
done

Also:

>>> g = f()
>>> next(g)
'a'
>>> g.throw(GeneratorExit)
done
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in f
GeneratorExit


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


Load a CSV with different row lengths

2014-07-29 Thread Ryan de Vera
I am trying to load a csv with different row lengths. For example,

I have the csv

a,b
a,b,c,d
a,b,c

How can I load this into python? I tried using both NumPy and Pandas.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TypeError: 'NoneType' object is not callable

2014-07-29 Thread Peter Otten
Satish ML wrote:

> Hi,
> 
> TypeError: 'NoneType' object is not callable? Why this error and what is
> the solution? Code:
> class SuperMeta:
> def __call__(self, classname, supers, classdict):
> print('In SuperMeta.call: ', classname, supers, classdict,
> sep='\n...') Class = self.__New__(classname, supers, classdict)
> self.__Init__(Class, classname, supers, classdict)
> class SubMeta(SuperMeta):
> def __New__(self, classname, supers, classdict):
> print('In SubMeta.new: ', classname, supers, classdict,
> sep='\n...') return type(classname, supers, classdict)
> def __Init__(self, Class, classname, supers, classdict):
> print('In SubMeta init:', classname, supers, classdict,
> sep='\n...') print('...init class object:',
> list(Class.__dict__.keys()))
> class Eggs:
> pass
> print('making class')
> class Spam(Eggs, metaclass=SubMeta()):
> data = 1
> def meth(self, arg):
> pass
> print('making instance')
> X = Spam()
> 
> print('data:', X.data)
> Output:
> making class
> In SuperMeta.call:
> ...Spam
> ...(,)
> ...{'meth': , '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} In SubMeta.new:
> ...Spam
> ...(,)
> ...{'meth': , '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} In SubMeta init:
> ...Spam
> ...(,)
> ...{'meth': , '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} ...init class object:
> ['meth', '__module__', 'data', '__doc__'] making instance
> Traceback (most recent call last):
>   File "C:/Users/Satish/Desktop/Python/Metaclasses7.py", line 21, in
>   
> X = Spam()
> TypeError: 'NoneType' object is not callable

As I have no idea what you are up to I can only list some adjustments you 
probably need to make:

- __init__() and __new__() are spelt in lowercase.
- do not instantiate the metaclass:
  class Spam(Eggs, metaclass=SubMeta): 
  ...
- The metaclasses of Spam and Eggs must share a common base. 
  This can be achieved with
  class SuperMeta(type): 
  ...


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


What happens when you 'break' a generator?

2014-07-29 Thread Frank Millman
Hi all

Python 3.4.1

Here is a simple generator -

def test():
print('start')
for i in range(5):
yield i
print('done')

x = test()
for j in x:
print(j)

As expected, the output is -

start
0
1
2
3
4
done

Here I break the loop -

x = test()
for j in x:
print(j)
if j == 2:
break

Now the output is -

start
0
1
2

'done' does not appear, so the generator does not actually terminate. What 
happens to it?

My guess is that normal scoping rules apply. Using my example, the generator 
is referenced by 'x', so when 'x' goes out of scope, the generator is 
garbage collected, even though it never completed.

Is this correct?

Frank Millman



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