python.exe crash and ctypes use

2008-07-23 Thread waldek
Hi,

I have module A.py and B.dll which exports C functions by cdecl_

In A.py I pass callback (py callable) to dll. Next,  thread inside dll
simply calls my callback (in a loop). After few secs I got crash of
python.exe.

How to debug it?

I'm using winxp and py 2.5.2


===
def mycallback(data, size)
return 0

CBFUNC = CFUNCTYPE(c_int,POINTER(c_int), c_int)
dll  = cdll.mydll

if dll.RegisterCallback(CBFUNC(mycallback)) != 0:
print "Error."
===
--
http://mail.python.org/mailman/listinfo/python-list


Re: python.exe crash and ctypes use

2008-07-24 Thread waldek
On Jul 23, 4:39 pm, Thomas Heller <[EMAIL PROTECTED]> wrote:
> waldek schrieb:
>
>
>
> > Hi,
>
> > I have module A.py and B.dll which exports C functions by cdecl_
>
> > In A.py I pass callback (py callable) to dll. Next,  thread inside dll
> > simply calls my callback (in a loop). After few secs I got crash of
> > python.exe.
>
> > How to debug it?
>
> > I'm using winxp and py 2.5.2
>
> > ===
> > def mycallback(data, size)
> > return 0
>
> > CBFUNC = CFUNCTYPE(c_int,POINTER(c_int), c_int)
> > dll  = cdll.mydll
>
> > if dll.RegisterCallback(CBFUNC(mycallback)) != 0:
> > print "Error."
> > ===
>
> You need the callback function instance - what the CBFUNC(mycallback)
> call returns - alive as long as some C code is calling it.
> If you don't sooner or later the Python garbage collector will
> free it since it seems to be no longer used.  ctypes does NOT keep
> the callback function alive itself.
>
> Thomas

In fact ctypes does not keep references to callback passed directly to
dll. Now it works.
Thanks Thomas.

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


ctypes and reading value under pointer passed as param of a callback

2008-07-24 Thread waldek
Hi,

I'm using C dll with py module and wanna read value (buffer of bytes)
returned in py callback as parameter passed to dll function.

--
def  mycallback(data, size):
# how to read data buffer here ?
return 0

cbfunc = CFUNCTYPE(c_int, POINTER(c_uint8), c_int)

mydll = cdll.somedll
mdll.foo(cbfunct)
---

Question: How to get bytes from the buffer passed to mycallback ???
Let's assume that the buffer consist of 4 bytes 4 bytes 8 bytes.

I tried unpack("ii8s", data[0]) and nothing. I tried different ctypes
passed to callback and nothing.

Any sugestions ?

Thanks,
Waldek


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


Re: ctypes and reading value under pointer passed as param of a callback

2008-07-25 Thread waldek
On Jul 24, 5:01 pm, Thomas Heller <[EMAIL PROTECTED]> wrote:
> waldekschrieb:
>
> > Hi,
>
> > I'm using C dll with py module and wanna read value (buffer of bytes)
> > returned in py callback as parameter passed to dll function.
>
> The callback receives a pointer instance.  You can dereference the pointer
> to read individual bytes in this way:
>print data[0], data[5], data[42]
> or use slicing to read a bunch of bytes:
>print data[0:42]
>
> So, you probably want something like this:
>
> > --
> > def  mycallback(data, size):
> > # how to read data buffer here ?
>
>   print data[:size]
>
> > return 0
>
> > cbfunc = CFUNCTYPE(c_int, POINTER(c_uint8), c_int)
>
> > mydll = cdll.somedll
> > mdll.foo(cbfunct)
> > ---
>
> > Question: How to get bytes from the buffer passed to mycallback ???
> > Let's assume that the buffer consist of 4 bytes 4 bytes 8 bytes.
>
> > I tried unpack("ii8s", data[0]) and nothing. I tried different ctypes
> > passed to callback and nothing.
>
> Thomas

Cool, works fine now.

... and how to convert a list of bytes to py string or int ??

i.e
data[:4] -> py int
data[4:8] -> py int
data[8:] -> py strng

I tried unpack and unpack_from but the buff should be an string or
buffer not a list of bytes as data is.

any suggestions?
--
http://mail.python.org/mailman/listinfo/python-list


ctypes and how to copy data passed to callback

2008-07-28 Thread waldek
Hi,

I'm trying  to handle data passed to Py Callback which is called from
C dll. Callback passes data to another thread using Queue module and
there the data are printed out.

If data is printed out in a callback itself  it's ok. If I put on
queue and next get from queue in another thread script prints some
trash. Looks like the data is released when callback returned. I tired
to make d = copy.deepcopy(data), but it does not work - I got nothing.
Any idea why it's happening ?

- main thread  
def callback(data, size):
myqueue.put((data, size))

mydll = cdll.MyDLL
cbproto = CFUNCTYPE(c_int, POINTER(c_char), c_int)
mycallback = cbproto(callback)

mydll.RegisterCallback(mycallback)

-- thread listener
--

while True:
data, size = myqueue.get()
print "***", data[:size]

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


Re: ctypes and how to copy data passed to callback

2008-07-29 Thread waldek
On Jul 28, 4:03 pm, Thomas Heller <[EMAIL PROTECTED]> wrote:
> waldek schrieb:
>
>
>
> > Hi,
>
> > I'm trying  to handle data passed to Py Callback which is called from
> > C dll. Callback passes data to another thread using Queue module and
> > there the data are printed out.
>
> > If data is printed out in a callback itself  it's ok. If I put on
> > queue and next get from queue in another thread script prints some
> > trash. Looks like the data is released when callback returned. I tired
> > to make d = copy.deepcopy(data), but it does not work - I got nothing.
> > Any idea why it's happening ?
>
> > - main thread  
> > def callback(data, size):
> > myqueue.put((data, size))
>
> > mydll = cdll.MyDLL
> > cbproto = CFUNCTYPE(c_int, POINTER(c_char), c_int)
> > mycallback = cbproto(callback)
>
> > mydll.RegisterCallback(mycallback)
>
> > -- thread listener
> > --
>
> > while True:
> > data, size = myqueue.get()
> > print "***", data[:size]
>
> > --
>
> I guess your code would work if you change it in this way:
>
> > def callback(data, size):
> > myqueue.put(data[:size])
> > while True:
> > data = myqueue.get()
> > print "***", data
>
> Thomas

Both solutions work fine. The secon is nicer :)

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


Re: generate Windows exe on Linux

2012-02-22 Thread Waldek M.
On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote:
> I have a python script using only the standard libraries.
> Currently I use a Windows VM to generate exe's, which is cumbersome.

And what exactly *is* this exe about?

> Has anyone had success generating exe's from within Linux?

That doesn't seem to have anything to do with Python,
but you might want to google for cross-compiling.

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generate Windows exe on Linux

2012-02-23 Thread Waldek M.
On Wed, 22 Feb 2012 18:42:11 +0100, Jérôme wrote:
>>> Has anyone had success generating exe's from within Linux?
>> 
>> That doesn't seem to have anything to do with Python,
>> but you might want to google for cross-compiling.
> 
> I think his question is totally python related. 
> 
> As I understand it, Richard creates executables from python scripts using a
> tool, such as py2exe [1], that requires windows. He would like to have an
> equivalent tool that runs on linux, to avoid going through the trouble of
> having to run a windows installation.

Ah, that's the part I was missing :-)
Thanks.

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


Re: python 3 constant

2011-06-22 Thread Waldek M.
Dnia Wed, 22 Jun 2011 22:17:49 +0100, Noah Hall napisał(a):

> On Wed, Jun 22, 2011 at 7:54 PM, sidRo  wrote:
>> How to declare a constant in python 3?
> 
> There aren't true constants in Python, but instead we use a standard
> defined by PEP 8, which states constants are in all caps, for example,
> PI = 3.14, as opposed to pi = 3.14 which could change (according to
> PEP 8, that is)

That said, there are some workarounds for that:
http://code.activestate.com/recipes/65207-constants-in-python/?in=user-97991

Still, I'd reallly like to have constants as a built-in...

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3 constant

2011-06-23 Thread Waldek M.
Dnia Thu, 23 Jun 2011 17:22:37 +1000, Ben Finney napisał(a):
> If you mean creating a binding which can't be re-bound: −1.

Perhaps. Or perhaps that could be done in some other fashion;
I admit that I usually stick to more strict languages
and while Python's flexibility is great... I'm really missing
constants.

> The ability to re-bind any attribute, even ones which the author thought
> should be constant, makes writing unit tests much easier. I don't see
> that putative benefits of constant bindings would be anywhere near as
> valuable.

Primo, isn't it usually the author that does the unit testing?
Anyway, correct me if I'm wrong but I always thought that unit tests
should prove the correctness and quality of the code under test,
and not the other way around, which would be sacrifising
code security to make testing easier.

Secundo, one can say that re-binding gives the freedom to change
what one likes; I'd say that I'd also like the freedom to decide what
is mutable and what is not.

Of course, it is just my personal opinion. It might be not pythonic,
I may be wrong, yet - concept of constants is not something new and
if other languages, like C/C++/Java/Perl/ (bash even) have them, 
I can't see the reason not to have them in Python.

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3 constant

2011-06-23 Thread Waldek M.
Dnia Fri, 24 Jun 2011 01:29:38 +1000, Chris Angelico napisał(a):
> You can have them in Python. Just run your code through cpp (the C
> preprocessor) first. Voila!
> 
> It's handy for other things too. Don't like Python's lack of "then"
> and "end if"?
[...]
Yup, got the sarcasm, that's for sure.
But your point was...?

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


Re: python 3 constant

2011-06-25 Thread Waldek M.
Dnia Thu, 23 Jun 2011 23:04:37 +1000, Ben Finney napisał(a):
>>> The ability to re-bind any attribute, even ones which the author
>>> thought should be constant, makes writing unit tests much easier. I
>>> don't see that putative benefits of constant bindings would be
>>> anywhere near as valuable.
>>
>> Primo, isn't it usually the author that does the unit testing?
> 
> I don't see how that's relevant. I'm referring to run-time re-binding of
> attributes, without the need for changing the code.

I meant simply that the author knows his/hers software and takes into
consideration while unit testing the fact that some things is constant.
I still can't see how checking if 2 == 2 (in the morning, in the afternoon
and in the night, and even tomorrow) helps making the software
significantly better.

>> Anyway, correct me if I'm wrong but I always thought that unit tests
>> should prove the correctness and quality of the code under test,
> 
> Right. Which often involves special set up of the environment in which
> that code runs, in order to conduct a proper test.
> 
> If the test I need to perform involves demonstrating what the code under
> test will do with different values for a name you consider constant,
> then I have Python's ability to re-bind that name at run-time.

In languages that allow constants, you can still make dirty hacks, like
casting to pointers, const_cast<>'ing and so on.
It is technically possible to override the constants one way or another;
yet I (and many people) find it useful that the language itself helps me
preventing myself from eg. distraction or being overwhelmed by the size of
a project.

Or, when a project is being developed by several people, helps
avoiding problems caused by 'hey, I thought binding 5 to this great 
name DOZEN was a realy great idea' attitude.

>> Secundo, one can say that re-binding gives the freedom to change what
>> one likes; I'd say that I'd also like the freedom to decide what is
>> mutable and what is not.
> 
> And I, as the user of your code, say that you don't get to dictate how I
> use it. I will take the authors's recommendations under advisement, but
> I reject any authority to restrict what I can do with it.
> 
> Unit tests are just an obvious example. The real lesson here is that the
> reciient of the code you write can, and probably will, use it in ways
> you never expected. It's not for you to decide which of those uses are
> permitted.

He can take my code and rework it if he/she likes. If that's what he wants,
that's fine with me. If he doesn't want to do that, I'm pretty sure he'll
find another ways to hack the logic I put into my code.
But he's one for a thousand; the rest would be rather grateful to me that
I let them know some things are constants. And currently, in Python,
I cannot do that.

>> Of course, it is just my personal opinion. It might be not pythonic,
> 
> Right. One useful phrase to remember from the founder of the Python
> language is that “We're all consenting adults here”.

I agree with that statement, sure. Only... I've never seen an adult who
doesn't make mistakes and who shouldn't be given any instructions.

> Indicate through the API and its documentation how you recommend I use
> your code; but treat me as an adult capable of making my own decisions
> about what risks I accept. Understand that I will be using the code you
> wrote in the way I see fit.

Yup. That's what I'd like to do: be able to indicate in the API that some
things should be *better* left unchanged. That A_DOZEN_IN_INTEGER IMO
should really stay 12, not 1 or -23.34. 

Documentation is a great thing, but tends to go out of date pretty soon..
much sooner than the code itself. Not mentioning those who just don't read
them carefully enough (I guess you'd call them non-adults, right? ;-) ).

So let me warn with language syntax that it's probably not a good idea
to change 'this' and 'that'. Do they still want to change it? It's their
responsibility, I'd let them hack themselves silly...

To summarize: I do miss constants in Python and I think Python could really
benefit from them. I haven't seen so far any convincing argument to not
have them. That said, I'm not that kind of person who says "hey, you Python
people, give me my constants or I won't use it". No, I like the language, 
I will still learn it and use it...  and I'll still miss the constants ;-)

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3 constant

2011-06-25 Thread Waldek M.
Dnia Thu, 23 Jun 2011 20:04:43 -0700 (PDT), alex23 napisał(a):
>> But your point was...?
> 
> That it's easier for you to find ways to achieve what you want than it
> is require Python to change to accommodate your need.

And when exactly did I write that I require anyone to change anything?
I'd like that, sure. IMHO it'd be useful. But I don't *require*.

Can you see the slight difference? :-)

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3 constant

2011-06-25 Thread Waldek M.
Dnia Fri, 24 Jun 2011 08:00:06 +1000, Chris Angelico napisał(a):
>> Yup, got the sarcasm, that's for sure.
>> But your point was...?
> 
> That if you want something, there's usually a way to get it.
> Sometimes, giving someone what they want - or showing them how to get
> it - makes it obvious to them whether or not they really want it.
> 
> Chris Angelico

Usually, it does. But presenting me with a fake and
obviously-not-logical-and-useful version of constants didn't really
say anything about why is having constants such a bad idea :-)
Just like presenting me with a rotten apple doesn't prove
anything general about that fruit.

I'm not into endless/pointless advocacy; I'm really curious.

And - as I've answered to someone else - I dont't *require* anyone
to change anything in the language. I just miss the feature and can't
really think of a sensible reason why it so wrong.

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python 3 constant

2011-06-25 Thread Waldek M.
Dnia Sat, 25 Jun 2011 20:59:17 +1000, Chris Angelico napisał(a):
> In all seriousness, sometimes adding features to one language is best
> done by dropping to another. This is probably not as useful in
> interpreted languages like Python, but I have on multiple occasions
> run code through the C preprocessor as part of my compilation process,
> as per my example.

A little off-topic but I see your point :-) Tried it once or twice - when
generating some C++ and .sip files code from a template, then generating
SIP wrappers, then generating .pyd libraries, then using in Python...  

Yeah, might be useful, even if sometimes complexity of the process
is a bit overwhelming to me :-)

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


Re: ANN: pyparsing 1.5.6 released!

2011-07-01 Thread Waldek M.
Dnia Thu, 30 Jun 2011 23:09:18 -0700 (PDT), Paul McGuire napisał(a):
> After about 10 months, there is a new release of pyparsing, version
> 1.5.6.  This release contains some small enhancements, some bugfixes,
> and some new examples.

Thanks! That is great news.

I'm not using pyparsing right now, but I used to and surely
will. I just wish it was included in the standard Python distribution
some day...

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-05 Thread Waldek M.
Dnia Tue, 5 Jul 2011 14:11:56 + (UTC), Grant Edwards napisał(a):
> Because those specially-formatted comments are wrong.

... because?
Not in sarcasm mode; just curious why you don't like them.

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


Re: Testing if a global is defined in a module

2011-07-05 Thread Waldek M.
Dnia Wed, 06 Jul 2011 03:36:24 +1000, Steven D'Aprano napisał(a):
> Because unless you are extremely disciplined, code and the comments
> describing them get out of sync. [...]
True, but that gets far worse with external docs.
Do you have in mind any better replacement?

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


Re: Implicit initialization is EVIL!

2011-07-06 Thread Waldek M.
Dnia Wed, 6 Jul 2011 08:10:27 -0700 (PDT), rantingrick napisał(a):
>> In the Unix/Linux world, there is a graphical application called xkill which
>> has no menus and no windows, all it has is a mouse cursor! No, it does not
>> run in the background: it is a foreground app.
> 
> Wow nice corner case. Can you come up with at least five of them
> though? You and I both know that the vast majority of GUI's require
> visible windows.

- 90% of MS DOS games; should I list them here? ;-)
- M$ Windows taskbar-only applications
- Linux apps using framebuffer but not X

One could argue that the second and the third case are - in one
way or another - using windows. But not the first case, and I don't think
you'd call them GUI-less.

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


Re: How to get or set the text of a textfield?

2011-07-10 Thread Waldek M.
Dnia Sun, 10 Jul 2011 21:14:10 -0500, Anthony Papillion napisał(a):
> 
> So I've built a UI with Glade and have loaded it using the standard
> Python code. In my UI, I have a textfield called txtUsername. How do I
> get and set the text in this field from my Python code?

http://developer.gnome.org/pygtk/stable/
http://www.learningpython.com/2006/05/07/creating-a-gui-using-pygtk-and-glade/

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


Re: Python ++ Operator?

2011-07-16 Thread Waldek M.
Dnia Fri, 15 Jul 2011 23:09:02 +0200, Stefan Behnel napisał(a):
[...]
>> array[count++]=value;
>>
>> or the more direct pointer management:
>> *ptr++=value;
> 
> More direct, sure. But readable? Well, only when you know what this 
> specific pattern does. If you have to think about it, it may end up hurting 
> your eyes before you figure it out.

Oh, come on. I don't say the post- and pre-incrementing is 
good or bad, but please don't exagerate. 

Almost any other construction is unreadable to people, who
don't know this construction, eg. a==1, a+=1
may be completely senseless to mathematicians.

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python threading/multiprocessing issue.

2011-07-16 Thread Waldek M.
Dnia Fri, 15 Jul 2011 22:15:15 -0700, Dennis Lee Bieber napisał(a):
>   And (so far as I understand it) each process can claim its own CPU
> core, whereas threads share the active core.

I do not think so. AFAIK, threads may be distributed over differrent
CPUs (just like in any other programming language), only because of GIL, 
you might not notice any performance improvement with that.

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Waldek M.
>> I'm still looking for the perfect programming font. Suggestions
>> welcomed.
> 
> When you find it Dotan, let me know, I've been looking since the later 
> '70's.

For me, it's Terminus* (from sourceforge).

Br.
Waldek
[*] As long as you don't need anything but iso8859-1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: AUTO: Craig Churchill is out of the office (returning 27/07/2011)

2011-07-18 Thread Waldek M.
> I am out of the office until 27/07/2011.
> 
> I will respond to your message when I return.
> If you require assitance in relation to the SPEAR Integration project
> please contact Terry Mandalios.

Why, thank you Craig. I will definitely contact Terry ;-)

Br.
Waldek
PS. Sorry, couldn't stop myself.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: os.path needs immediate attention!

2011-07-29 Thread Waldek M.
Dnia Fri, 29 Jul 2011 14:41:22 -0500, harrismh777 napisał(a):
> The backslash sep is an asinine CPM/80 | DOS disk based carry-over which 
> does not fit well with the modern forward direction. The disk based file 
> system carry-over is bad enough; but, propagating multiple ways of doing 
> simple things like specifying file-system paths is not helpful in any 
> context.

Please, do tell it to Microsoft. And once you've convinced them,
and they've implemented it, do report :-)

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


Re: Help parsing a text file

2011-08-30 Thread Waldek M.
On Mon, 29 Aug 2011 23:05:23 +0200, Thomas Jollans wrote:
> A name that is often thrown around on this list for this kind of
> question is pyparsing. Now, I don't know anything about it myself, but
> it may be worth looking into.

Definitely. I did use it and even though it's not perfect - it's very
useful indeed. Due to it's nature it is not a demon of speed when parsing
complex and big structures, so you might want to keep it in mind.
But I whole-heartedly recommend it.

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


Re: what's the command for (cd ..) in python

2011-09-10 Thread Waldek M.
On Fri, 09 Sep 2011 23:03:10 +1000, Steven D'Aprano wrote:
> But think carefully before doing this. Some functions may be confused if you
> change directories while they are running. You may be better off staying in
> the same directory, and adjusting the path names to the files as you work
> with them.

Curious.
Do you mean multi-threaded environment or even in single thread?
If the latter is the case, I'd say those functions make 
very nasty assumptions. Who are they, anyways? ;)

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


Re: what's the command for (cd ..) in python

2011-09-10 Thread Waldek M.
On Sat, 10 Sep 2011 21:11:32 +1000, Steven D'Aprano wrote:
> The main one that comes to mind is os.walk, which has this to say:
> 
> Caution:  if you pass a relative pathname for top, don't change the
> current working directory between resumptions of walk.  walk never
> changes the current directory, and assumes that the client doesn't
> either.
> 
> Seems like a reasonable assumption to me.

Oh, that kind of functions.
Yes, that *is* surely reasonable, just as mixing chdir/mkdir/remove
and whatever else that affects the directory structure is not a good idea,
or at least something to be done carefully.
I just wouldn't think to give it some special credit.

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


Re: Request for research feedback

2011-09-15 Thread Waldek M.
On Thu, 15 Sep 2011 16:55:13 +0100, Fulvio Valente wrote:

> Hi, I am a research intern at the University of Strathclyde
> who has been doing a summer research internship.

I don't want to be rude, but please: could you rather first research
how to use a newsreader before you use it?
These long lines (a few times the limit of 78 characters per line)
make your post unreadable.

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


Re: Request for research feedback

2011-09-15 Thread Waldek M.
On Thu, 15 Sep 2011 16:11:13 -0400, Prasad, Ramit wrote:
> I don't want to be rude but...
> Not rude:
> Rude:

You're right. I must have gotten a few bad habits I didn't
even realize. Thanks.

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


Re: Freelance Django developer needed

2011-10-11 Thread Waldek M.
> (First to everyone not into Django: sorry for the shameless job 
> advertisement!)
> 
> We are searching for a Freelance Django developer to help us out!

Well, if you're sorry then why do you go on?

There's a much better place to post the job offer:
http://www.python.org/community/jobs/

There, you'd probably even earn credit for your posting :-)

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Job Offer: 3 Python Backend Developer and other Positions in Berlin

2011-10-23 Thread Waldek M.
On Sun, 23 Oct 2011 17:50:54 +0200, webcrowd.net wrote:
> hope it is okay to post job offers here. If not sorry for the spam and 
> please let me know!

Not really. It's a newsgroup on Python *language*, not
on Python-everything.

You might want to post here instead, though:
http://www.python.org/community/jobs/

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic variable creation from string

2011-12-07 Thread Waldek M.
On Wed, 7 Dec 2011 09:09:16 -0800 (PST), Massi wrote:
> def Sum(D) :
> return D['a']+D['b']+D['c']
> 
> Is there a way to create three variables dynamically inside Sum in
> order to re write the function like this?
> 
> def Sum(D) :
> # Here some magic to create a,b,c from D
> return a+b+c

Hello,

> It is really important that the scope of a,b,c is limited to the Sum
> function, they must not exisit outside it or inside any other nested
> functions.
> Thanks in advance for your help!

Can you clarify a bit? I'm not sure why do you need to define any
additional variables at all. You do not return variables
from a function - you can return *a value* which may be
a simple type or complex type.

Or maybe you mean something like creating a global name
from inside of a function? Well, that doesn't sound like a good idea,
though...

>>> def foo():
global a
a = 5
    
>>> foo()
>>> print("The variable is: ", a)
The variable is:  5
>>> 



Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: InvalidResponseError: headers must be str

2012-01-02 Thread Waldek M.
On Sat, 31 Dec 2011 17:40:15 -0800 (PST), Niklas Rosencrantz wrote:
> Thanks for the replies here. I will have patience but this bug
> is blocking my integration efforts. I tried logging the TCP
> packets with tcpdump and nothing special appeared.

Well, it's free software, isn't it?
You may either wait a little, fix it yourself or pay someone 
to fix it for you, if you're in a hurry. Or stay with 2.5 / try upgrading
to 3.x.

The Python community is usually very helpful and friendly, but
by *demanding& a fix ASAP you may accidentily step on people's toes :-)

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list