Forced to Embed?

2005-10-31 Thread Lloyd
Hi

After researching on Extending and Embedding it appears Extending is 
favoured greatly over Embedding. I've tested Boost::Python successfully 
in a test project but have run into an issue.

I have about 10 shared libraries that up until now have only been 
statically linked into an application and used from C++. I'd like to 
expose a lot of this functionality as different Python modules ( core, 
network, input, etc ), however the interdependency between the libraries 
seem to prohibit this. The library dependencies are in a tree heirarchy 
with the basic core library at the bottom.

As far as I can tell I have to export these all in one massive module as 
there is no way for the different python modules to directly communicate 
with each other?

Because of this I have to assume any application specific code would 
have to be placed in this massive module aswell and thus the whole 
module setup is moot and I might aswell embed python in the application 
and import the different interfaces as modules into the python namespace 
while still having them communicate directly because they're in the same 
executable.

I'd prefer to extend while using the normal python interpreter but I see 
no way around this without a large restructure?

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


Python implementation of "include"

2007-12-13 Thread lloyd
Hello,

I've been using the
Python-based Karrigell web application framework. It has the very handy
word "include" that inserts a code file into into the stream of
execution. E.g. if myFile.py contains the code:

print "This is a message from myFile.py"

and my script is:

print "Something"
include "myFile.py"
print "Something more"

The output would be:

Something
This is a message from myFile.py
Something more

Since
I'm considering moving my application to a different web application
framework, I'd like to replace include with a pure python construct.
I've discovered several ways to do it, but they all seem kludgy in one
way or another. Is there a simple, elegant way to do this?

Many thanks,

Lloyd






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

Re: Python implementation of "include"

2007-12-13 Thread lloyd
Hi Tim,

Thanks for the response.

As I understand it, import myFile and include "myFile.py" are not quite the 
same.  

--
for import to work myFile.py must be in the same directory as the code
that calls it accessible through PYTHONPATH, whereas include
"../somedirectory/myFile.py" works in Karrigell, even though it is not
accessible through PYTHONPATH.

-- if imported, the print
statement myFile.py would only run the first time through unless
reload(myFile) is executed in the proper place.

Please correct me if I'm mistaken.

All the best,

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

file upload permissions

2007-12-19 Thread lloyd
Hello,

I have three web sites hosting the identical Python web application, each 
theoretically identical in content and configuration. One is used for 
development; the second is a back-up/mirror; and the third is the production 
site. The development site is running on my local network, the mirror and 
production sites are running on remote virtual private servers.

The administrative module of my application has a file up-load tool. The file 
upload tool worked just fine on all three servers up until several weeks ago. 
Now, it works fine for the mirror and production sites, but I get a permission 
error when I try to upload to the development site. 

All uploads are the identical file from the identical source directory. 
Permissions settings on the three target directories are the same.

I don't know what changed on my development server beyond routine maintenance.

I've been trying for the life of me to find out where and how permission is 
being denied on the development server. But it eludes me.

Would much appreciate guidance.

Best wishes,

Lloyd

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

RE: I want to set up a simple web server

2007-12-27 Thread lloyd
Hi,

Try Karrigell  (http://karrigell.sourceforge.net/)


> I want to setup simple python web server and I want it to just unzip

> and run, without any installation steps (have no right to do it).



> I've tried to write by myself, however, I find I am getting into more

> details like processing image file, different file type(like FLV) ..

> etc. Any recommendation or tools suggested for me?

All the best,

Lloyd


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

Python web aps - A matter of security

2008-01-05 Thread lloyd
Hello,

I'm developing a Python-based web ap, but don't understand how to best organize 
the modules and set permissions for maximum security.

Here's how the Python code for my ap is organized:

1) I have Python modules in a project directory. The path to that directory is 
in a  *.pth file  in the .*/pythonx-y/site-packages directory. 

Question: who should own these modules; what groups should have access, and how 
should permissions be set?

2) I have high-level modules that import the worker-bee modules in the web root 
directory tree that are called by the webserver.

Questions: who should own these modules, what groups should have access, and 
how should permissions be set?

3) Is there a better way to organize my Python modules? Are there other 
security issues I should heed?

Many thanks,

Lloyd



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

RE: Import and execfile()

2008-01-12 Thread lloyd
Hello,

> I maintain a few configuration files in Python syntax (mainly nested

> dicts of ints and strings) and use execfile() to read them back to

> Python. This has been working great; it combines the convenience of

> pickle with the readability of Python. So far each configuration is

> contained in a single standalone file; different configurations are

> completely separate files.


> Now I'd like to factor out the commonalities of the different

> configurations in a master config and specify only the necessary

> modifications and additions in each concrete config file. I tried the

> simplest thing that could possibly work:

I've been working with a similar problem; indeed, posted a question about it 
several weeks ago.

I
can't speak to the issue of factoring out commonalities, but I've been
trying to find a really simple, elegant way to avoid the exec
functions. My approaches have been variations in __import__() and
loading as file, etc. Everything I've tried seems a bit kludgy. One
issue, as I recall, was that __import__() became rather unreliable when
you crossed directory boundaries.

Question: Why do so many sources discourage the use of exec(), execfile(), etc.?

Comment:
The Karrigell Python web framework
(http://karrigell.sourceforge.net/en/include.htm) has a truly elegant
function for loading stuff like some_config.py called Include(). I
haven't looked at the source, but it is very handy. I really wish it
was basic Python function.

All the best,

Lloyd



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

RE: where do my python files go in linux?

2008-01-12 Thread lloyd
Hello,

> Question 1. Where do I put the bulk of python scripts in a normal

> linux environment?

In my system I put them in
/usr/local/lib/python2.4/site-packages/my_scripts. And, I have *.pth
file in /usr/local/lib/python2.4/site-packages that points to
my_scripts. The *.pth file simply reads "my_scripts" -- without the
quotes, of course.

This one area where Python docs are pretty vague. It took me awhile to piece 
this together. But it works.

Best wishes,

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

Truncated postings

2008-02-13 Thread lloyd
Hello,

Over the past 24 hours or so, all of my Python-List e-mails have been truncated 
to subject list only. No posts. 

Are others experiencing this problem? Or is it just on my end?

Thanks,

Lloyd R. Prentice


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


Python evening class

2008-07-18 Thread lloyd


I am learning about python but I would like to attend and evening class at 
college as I find it hard to study at home.  Does anyone know of such a class 
in London UK?
 

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


Re: The Jihad Candidate

2008-08-21 Thread Lloyd
On Aug 19, 10:59 pm, [EMAIL PROTECTED] wrote:
> DUDE, have you gone mad ? The ZIONIST MEDIA never barked that it was a
> jew or a yank bastard when those fake anthrax letters were mailed. 911
> was an
> inside job. Thermate cutter charges were used by yank bastards
> themselves.
> The media never did their job for the people or truth. It did it for
> the corporations.
>
> Dont worry, McCain will win. Its the corporations who have supported
> your
> OBAMA. They have played a very CLEVER game this time. TO make McCain
> win, they made him look like a weakling in the initial stages and put
> all support
> behind OBAMA so he can DEFEAT HILLARY. She could have defeated McCain
> but this B-L-A-C-K who can be SLANDERED in a million ways:
>
> Moslem
> Black
> Nigger
>
> by yank bastards and jews like you is not going to win against McCain.
> McCain has
> said that we will start winning BEFORE the elections. This means there
> will be a
> BLITZKREIG of SLANDER and MALICE and ACCUSATIONS just BEFORE the
> ELECTIONS. Even if OBAMA wins, he is nigger. He did not make himself.
> He was
> made by CORPORATIONS. He is their stooge. Still he may be better than
> McCain
> by a hair.
>
> BTW, I use nigger word to emphasize how OTHERS think of him. I am not
> racist.
>
> On Aug 18, 10:30 am, "Running With Scissors" <[EMAIL PROTECTED]>
> wrote:
>
> > (X-posted)
>
> > Whether liberals are too arrogant or too subversive, they will read this (or
> > not) and buff up like cutworms and start throwing up strawman defenses in
> > order to conceal their own ignorance or perfidy.  I think both.
>
> >   The Jihad Candidate
> >   by Rich Carroll
>
> >  http://www.chronwatch-america. com/blogs/ 988/The-Jihad- Candidate. html
>
> >   Conspiracy theories make for interesting novels when the storyline is not
> > so absurd that it can grasp our attention.
> >   'The Manchurian Candidate' and 'Seven Days in May' are examples of
> > plausible chains of events that captures the reader's imagination at
> > best-seller level. 'What if' has always been the solid grist of fiction.
>
> >   Get yourself something cool to drink, find a relaxing position, but before
> > you continue, visualize the television photos of two jet airliners smashing
> > into the Twin Towers in lower Manhattan and remind yourself this cowardly
> > act of Muslim terror was planned for eight years.
>
> >   How long did it take Islam and their oil money to find a candidate for
> > President of the United States? As long as it took them to place a Senator
> > from Illinois and Minnesota? The same amount of time to create a large
> > Muslim enclave in Detroit? The time it took them to build over 2,000 mosques
> > in America? The same amount of time required to place radical wahabbist
> > clerics in our military and prisons as 'chaplains'?
>
> >   Find a candidate who can get away with lying about their father being a
> > 'freedom fighter' when he was actually part of the most corrupt and violent
> > government in Kenya's history. Find a candidate with close ties to The
> > Nation of Islam and the violent Muslim overthrow in Africa, a candidate who
> > is educated among white infidel Americans but hides his bitterness and anger
> > behind a superficial toothy smile. Find a candidate who changes his American
> > name of Barry to the Muslim name of Barack Hussein Obama, and dares anyone
> > to question his true ties under the banner of 'racism'. Nurture this
> > candidate in an atmosphere of anti-white American teaching and surround him
> > with Islamic teachers. Provide him with a bitter, racist, anti-white,
> > anti-American wife, and supply him with Muslim middle east connections and
> > Islamic monies. Allow him to be clever enough to get away with his
> > anti-white rhetoric and proclaim he will give $834 billion taxpayer dollars
> > to the Muslim controlled United Nations for use in Africa.
>
> >   Install your candidate in an atmosphere of deception, because questioning
> > him on any issue involving Africa or Islam would be seen as 'bigoted
> > racism'; two words too powerful to allow the citizenry to be informed of
> > facts.
> >   Allow your candidate to employ several black racist Nation of Islam Louis
> > Farrakhan followers as members of his Illinois Senatorial and campaign
> > staffs.
>
> >   Where is the bloodhound American 'free press' who doggedly overturned
> > every stone in the Watergate case?
> >   Where are our nation's reporters that have placed every Presidential
> > candidate under the microscope of detailed scrutiny; the same press who
> > pursue Bush's 'Skull and Bones' club or ran other candidates off with
> > persistent detective and research work? Why haven't 'newsmen' pursued the 65
> > blatant lies told by this candidate during the Presidential primaries? Where
> > are the stories about this candidate's cousin and the Muslim butchery in
> > Africa?
> >   Since when did our national press corps become weak, timid, and silent?
> > Why haven't they regale

Free Software University - Python Certificate - In reply to Noah Hall

2011-03-26 Thread Lloyd Hardy

Noah Hall enalicho at gmail.com
Tue Mar 22 17:38:48 CET 2011

>I've been following this project for a while, since it was annouced on 
the Ubuntu forums. I can't say that I've been at all impressed by 
anything they have to offer.


Hi Noah,

I'm interested in your post for a few reasons:

1. There is no Noah Hall registered in the FSU
2. Your email address is not registered in the FSU
3. The FSU is really about what _you_ have to offer
4. As has already been noted, we are currently making courses
5. The first course (Free Software Certificate) starts 2nd May 2011

..so, maybe you can help me to understand your post? It seems a strange 
post, based on these facts...


Maybe you'd like to come along and actually get involved? You would be 
most welcome.. our other 800 members will be happy to see you, I'm 
sure... come and contribute! :)


Lloyd
FSU Founder
--
http://mail.python.org/mailman/listinfo/python-list


Re: Free Software University - Python Certificate - In reply to Noah Hall

2011-03-28 Thread Lloyd Hardy



1) Perhaps Noah Hall is not my real name, nor the name I used to sign up. ;)
2) Perhaps I have multiple email addresses.
3) Regardless, it is still offers little, IMO ;)
4) As you have been for quite some time, yet little seems to change.
5) Most interesting.



Dear [Python List Member of Unknown Identity],

Please do not email me off-list. I do not know your identity and would 
not like to directly correspond with you in private. Your comments about 
my project were in public and I would prefer if your responses were also.


I _know_ that you are not registered under any name or email address 
from your response - as you would have known about 5) already... all 
registered users do! ;) So, you are making comments about something you 
have never been a part of, have no time to be involved in and have no 
intention of trying... not the most qualified review, if you don't mind 
me saying :)


Secondly, if you do use various names and email addresses and play 
'maybe this is my identity' games, we really don't want you in the FSU - 
as you are not an honest person - our work is based on the integrity of 
the faculty and students.


> (I mean, free education is always good),

While the courses will be gratis, it is not about gratis education, it's 
about _libre_ education - something you could learn in the FSC :)


> I don't have the time required to get involved.

Which is why it takes time to get such a project rolling... and 'little 
seems to change' - everyone is busy - jobs, family, etc.. but they have 
been giving some small time - 15 minutes or an hour a week, which is why 
the project is not dead. So, as you are in the same position, perhaps 
you can forgive them - as you understand their position so well? Many 
Free Software and Open Source projects have been successful, not because 
all contributors have endless amounts of time to devote, but because 
many contributors keep giving, continuously, steadily, with commitment.


They are not deterred by individuals who come along, with no knowledge 
of the subject (Free Software, as you have displayed with your comment 
about graitis education), no experience (you were not registered as you 
would have already known about the FSC starting date) and make negative, 
cynical comments.


I wish you well with any projects you start that are designed to give 
back to the Free Software community and hope that you are also not 
deterred by nay-sayers! :)


Lloyd
FSU Founder


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


Re: Free Software University - Python Certificate - In reply to Noah Hall

2011-03-29 Thread Lloyd Hardy

Hi 'News123',

The message which you seem to think was a reply to you, wasn't. It was 
sent 2 days ago in reply to another message, not yours.


_03/27/2011_ 01:15 PM


Well, that is - as far as I know - I'm not sure if you're 'Noah Hall' or not.. 
maybe you are? That's the problem with having an alias I guess, lol.. maybe all 
three of us are the same person and this is a big conspiracy by a proprietary 
software company to make free software proponents look stupid? Lol... :D



(I mean, free education is always good),


> Not if you even don't know if this education really exists before
registering.


I didn't write that, lol...

..but I do think it's unusual that you're concerned about email 
harvesting.. yet post your email address on a mailing list.. That 
doesn't make any sense at all? I think each project owner decides the 
terms of their project. I feel academic pursuits require integrity - as 
all learning institutions do.. and accountability. Certificates cannot 
be awarded to aliases and teacher credentials cannot be verified. So, 
there will be no aliases in the FSU. I'm sorry if you do not agree with 
this, but it will not change - identity is important in any examination 
/ certification.


Please feel free to register for the FSU under your real name, not an alias. 
Please feel free to post reviews of the FSU after you have taken a course :)

It's very kind of you to make suggestions, thank you - although there has so 
far been no problem with attracting people - you appear to be misinformed :) 
I'm sure the community themselves will select a design / change of design of 
the FSU resources. If you'd like to join the FSU community then your views 
would certainly be considered :)

Thanks again!


Lloyd



On 29/03/11 22:01, News123 wrote:

Hi Loyd,


It wasn't me sending you the private email.

I'm just a little surprised about this: "if you don't post under your
real name you must be a bad person" - attitude.

On 03/27/2011 01:15 PM, Lloyd Hardy wrote:

Secondly, if you do use various names and email addresses and play
'maybe this is my identity' games, we really don't want you in the FSU -
as you are not an honest person - our work is based on the integrity of
the faculty and students.

Some people are just scared of data mining.

Having internet aliases has absolutely nothing with honesty, but just
about not wanting to be easily profiled by persons whom you don't even know.


To be a good member of whatever an identity is not important.
What counts are the contributions and the quality of the feed back




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


Re: [OT] Re: SysLogHandler is drivin me nuts PEBCAC

2004-11-29 Thread Lloyd Zusman
Jan Dries <[EMAIL PROTECTED]> writes:

> Slightly OT, but regarding the title, shouldn't it be PEBKAC, since it's
> keyboard and not ceyboard?

Your computer didn't come with a ceyboard?  :)

-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: [Tutor] Re: Reading text lines from a socket

2005-03-25 Thread Lloyd Kvam
Well, I've never used it, but sockets do have the makefile method.  That
would seem to fit what you're trying to do.

Sandip Bhattacharya wrote:

> [Reposting to the general list too]
>
> Lloyd Kvam wrote:
>
>> Sockets deal with packetized data.  The network protocols do not
>> guarantee
>> keeping the data in line oriented chunks - even if the data starts out
>> that way.
>>
>> You need to deal with extracting lines from chunks.  So long as the
>> connection is
>> working properly, this is easy.  The challenge occurs when the
>> remainder of a line
>> never gets delivered.  The best strategy depends upon the details of
>> what you are
>> doing.
>
>
> I understand that. In Python using sockets is like using sockets in C.
>
> However, I was looking for a python equivalent of the perl idiom of
> opening a socket and getting a file handle ... and then reading this
> file handle as any other line oriented file using $socket->readline
>
> I am trying to write a simple Netcraft style script which tries the HEAD
> method on a webserver and reads the Server: header from the response. I
> would not like to use urllib, because even a call to something like
> urllib.info() reads in the complete webpage on an open().
>
> Even if this particular problem could be done elegantly, I would be
> interested to know the answer to my original question because the
> feature of reading a line at a time from a socket will help me in a lot
> of other places in the future.
>
> - Sandip
>

--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:  603-653-8139
fax:801-459-9582


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

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


__pycache__

2015-02-03 Thread Luke Lloyd
I am in school and there is a problem with my code:



When I try to run my code in the python code in the python shell it waits
about 10 seconds then shows an error that says “IDLE’s subprocess didn’t
make connection. Either IDLE can’t start a subprocess or personal firewall
software is blocking the connection.” Then when I press OK it just closes.



P.S: My code is encrypting and decrypting using an offset factor.
-- 
https://mail.python.org/mailman/listinfo/python-list


Recommended way to force a thread context switch?

2007-01-06 Thread Lloyd Zusman
I have a python (2.5) program with number of worker threads, and I want
to make sure that each of these does a context switch at appropriate
times, to avoid starvation.  I know that I can do a time.sleep(0.001) to
force such a switch, but I'm wondering if this is the recommended
method.

Thanks in advance.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: Recommended way to force a thread context switch?

2007-01-06 Thread Lloyd Zusman
Duncan Booth <[EMAIL PROTECTED]> writes:

> Lloyd Zusman <[EMAIL PROTECTED]> wrote:
>
>> I have a python (2.5) program with number of worker threads, and I want
>> to make sure that each of these does a context switch at appropriate
>> times, to avoid starvation.  I know that I can do a time.sleep(0.001) to
>> force such a switch, but I'm wondering if this is the recommended
>> method.
>
> The recommended method is to start a new thread rather than following up on 
> an existing thread with an unrelated question.

I accidentally hit "a" in my mailer instead of "w" ("reply" instead of
"compose").  Geez.  It was an accident.  I'm sorry.


> Why do you think that just letting the threads run won't have the effect 
> you desire? Leave it to the system to schedule the threads.

I can already see that they don't have the effect I desire.  They are
long numerical calculations in tight loops.  I have to periodically put
explicit time.sleep(0.001) calls in place to force the context
switching, and I was wondering if that's the recommended method.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: Recommended way to force a thread context switch?

2007-01-06 Thread Lloyd Zusman
Duncan Booth <[EMAIL PROTECTED]> writes:

> [ ... ]
>
> If the context isn't switching enough for you then try calling 
> sys.setcheckinterval(n) with varying values of n until you find one which 
> is suitable. Calling it with a lower value of n will increase the frequency 
> that you switch thread contexts, although of course it will also increase 
> the overall runtime for your program.

Thank you very much.  The sys.setcheckinterval function is what I need.
It seems that the original writer of the app had set this interval to a
high value in a part of the code that I overlooked until you mentioned
this right now.


> [ ... ]
>
> Why does it matter whether individual threads are being 'starved'? Surely 
> you want them all to complete in any case, so does it matter if they run 
> sequentially or in parallel?

Because some of the threads perform monitoring and notification that
need to occur in a timely fashion.  Since these threads are doing IO,
they switch context appropriately, but once one of the big
number-crunching threads gets control, it starves out the monitoring
threads, which is not a good thing for my app ... or at least it did
so with the original large checkinterval.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Announce: Python for .NET 1.0 RC1 released

2005-05-10 Thread Brian Lloyd
Hi all -

I'm happy to announce the release of Python for .NET 1.0 RC1.
You can download it from:

  http://www.zope.org/Members/Brian/PythonNet

Highlights of this release:

- Implemented a workaround for the fact that exceptions cannot be
  new-style classes in the CPython interpreter. Managed exceptions
  can now be raised and caught naturally from Python

- Implemented support for invoking methods with out and ref parameters.
  Because there is no real equivalent to these in Python, methods that
  have out or ref parameters will return a tuple. The tuple will contain
  the result of the method as its first item, followed by out parameter
  values in the order of their declaration in the method signature.

- Fixed a refcount problem that caused a crash when CLR was imported in
  an existing installed Python interpreter.

- Added an automatic conversion from Python strings to byte[]. This
makes
  it easier to pass byte[] data to managed methods (or set properties,
  etc.) as a Python string without having to write explicit conversion
  code. Also works for sbyte arrays. Note that byte and sbyte arrays
  returned from managed methods or obtained from properties or fields
  do *not* get converted to Python strings - they remain instances of
  Byte[] or SByte[].

- Added conversion of generic Python sequences to object arrays when
  appropriate (thanks to Mackenzie Straight for the patch).

- Added a bit of cautionary documentation for embedders, focused on
  correct handling of the Python global interpreter lock from managed
  code for code that calls into Python.

- PyObject.FromManagedObject now correctly returns the Python None
  object if the input is a null reference. Also added a new
AsManagedObject
  method to PyObject, making it easier to convert a Python-wrapped
  managed object to the real managed object.

- Created a simple installer for windows platforms.


All known bugs have also been fixed - thanks to all who have sent in issue
reports and patches for past releases.

At this point, the only thing I plan to do before a 1.0 final is fix any
new issues and add to the documentation (probably including a few specific
examples of embedding Python for .NET in a .NET application).

Enjoy! ;)


Brian Lloyd[EMAIL PROTECTED]
V.P. Engineering   540.361.1716
Zope Corporation   http://www.zope.com

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


Announce: Python for .NET 1.0 RC2 released

2005-06-05 Thread Brian Lloyd
Hi all -

I'm happy to announce the release of Python for .NET 1.0 RC2.
You can download it from:

  http://www.zope.org/Members/Brian/PythonNet

Highlights of this release:

- Changed some uses of Finalize as a static method name that confused
the
  Mono compiler and people reading the code. Note that this may be a
  breaking change if anyone was calling PythonEngine.Finalize(). If so,
  you should now use PythonEngine.Shutdown().

- Tweaked assembly lookup to ensure that assemblies can be found in the
  current working directory, even after changing directories using
things
  like os.chdir() from Python.

- Fixed some incorrect finalizers (thanks to Greg Chapman for the
report)
  that may have caused some threading oddities.

- Tweaked support for out and ref parameters. If a method has a return
  type of void and a single ref or out parameter, that parameter will be
  returned as the result of the method. This matches the current
behavior
  of IronPython and makes it more likely that code can be moved between
  Python for .NET and IP in the future.

- Refactored part of the assembly manager to remove a potential case of
  thread-deadlock in multi-threaded applications.

- Added a __str__ method to managed exceptions that returns the Message
  attribute of the exception and the StackTrace (if available).


Thanks to all who have sent in issue reports, patches and suggestions
for this and past releases.

Enjoy! ;)


Brian Lloyd[EMAIL PROTECTED]
V.P. Engineering   540.361.1716
Zope Corporation   http://www.zope.com

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


Re: subexpressions (OT: math)

2007-06-03 Thread Lloyd Zusman
"Steven D'Aprano" <[EMAIL PROTECTED]> writes:

> On Sun, 03 Jun 2007 11:26:40 -0700, [EMAIL PROTECTED] wrote:
>
>> if you are discordant read more :P :
>> sine is a dimensionless value.
>> if we expand sine in taylor series sin(x) = x - (x^3)/6 + (x^5)/120
>> etc.
>> you can see that sin can be dimensionless only if x is dimensionless
>> too.
>> 
>> I am a professional physicist and a know about what I talk
>
> I am confused why you get different results for the square root of an
> angle depending on whether you use degrees or radians:
>
> sqrt(25°) = 5° = 0.087266462599716474 radians
> sqrt(25*pi/180) = 0.66055454960100179 radians
>
> If angles are dimensionless numbers, then:
>
> degrees_to_radians(sqrt(25°)) 
>
> should equal 
>
> sqrt(degrees_to_radians(25°))
>
> but they don't.

That's because for arbitrary functions f and g, 

  f(g(x)) is not equivalent to g(f(x))

This has nothing to do with whether or not x is a dimensionless number.

(replace "f" with "degrees_to_radians" and "g" with "sqrt")


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: Working with fixed format text db's

2007-06-09 Thread Lloyd Zusman
Frank Millman <[EMAIL PROTECTED]> writes:

> On Jun 8, 5:50 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> Many of the file formats I have to work with are so-called
>> fixed-format records, where every line in the file is a record,
>> and every field in a record takes up a specific amount of space.
>>
>> [ ... ]
>
> We already have '%-12s' to space fill for a length of 12, but it is
> not truly fixed-length, as if the value has a length greater than 12
> you need it to be truncated, and this construction will not do that.

In this case, we can use '%-12.12s'.

-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: print a ... z, A ... Z, "\n"' in Python

2007-03-03 Thread Lloyd Zusman
"js " <[EMAIL PROTECTED]> writes:

>> But note that you return the last item of the range too, and that
>> goes against the semantic of the usual Python range/xrange, so you
>> may want to call this function with another name.
>
> That makes sense. 100% agree with you.
>
>> Maybe there are better ways to solve this problem. Maybe a way to
>> generate (closed?) char ranges can be added to the Python standard
>> lib.
>
> Maybe we don't want char range If string constants would be rich
> enough.

But as soon as we want a string that doesn't correspond to any
pre-defined constants, we're hosed.  For example, there isn't
a constant that would correspond to this Perl-ism:

  print l ... w, e ... j, L ... W, E ... J, "\n";


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Joining threads but allowing signals to main thread?

2007-01-10 Thread Lloyd Zusman
I have a python-2.5 program running under linux in which I spawn a
number of threads.  The main thread does nothing while these subsidiary
threads are running, and after they all complete, the main thread will
then exit.

I know that I can manage this through the use of Thread.join(), but
when I do it as follows, the main thread doesn't respond to signals:

  import sys, time, signal, threading

  signaled = False

  class Signaled(Exception):
  pass

  def sighandler(signum, frame):
  global signaled
  print 'aborted!'
  signaled = True

  def sigtest():
  global signaled
  if signaled:
  raise Signaled

  def myfunc(arg):
  while True:
  try:
  sigtest()
  # do something
  except Signaled:
  return

  threads = []
  for a in sys.argv[1:]:
  t = threading.Thread(myfunc, args=(a,))
  threads.append(t)

  # do some initialization

  for s in (signal.SIGHUP,  \
signal.SIGINT,  \
signal.SIGQUIT, \
signal.SIGTERM):
  signal.signal(s, sighandler)

  for t in threads:
  t.start()

  for t in threads:
  t.join()

  sys.exit(0)

However, if I get rid of the t.join() loop and replace the last three
executable lines of the program with these, the main thread responds to
signals just fine:

  ...

  while threading.activeCount() > 1:
  time.sleep(0.001)

  sys.exit(0)

Is there any way to allow my program to respond to signals without
having to busy-wait in the main thread?

Thanks in advance.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: Joining threads but allowing signals to main thread?

2007-01-11 Thread Lloyd Zusman
Gabriel Genellina <[EMAIL PROTECTED]> writes:

> At Thursday 11/1/2007 03:43, Lloyd Zusman wrote:
>
>>   while threading.activeCount() > 1:
>>   time.sleep(0.001)
>>
>>   sys.exit(0)
>>
>>Is there any way to allow my program to respond to signals without
>>having to busy-wait in the main thread?
>
> Don't worry too much, this is *not* a busy wait, because you use
> sleep. You can use a longer sleep, it will be terminated by any
> signal. But not too long, or the check for activeCount() will be delayed
> in excess. (I use sleep(1) usually but your needs may be different)

Well, if this is the best that we can currently do in python, then so be
it.

My sincere thanks.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


Re: How to covert ASCII to integer in Python?

2007-02-22 Thread Lloyd Zusman
"John" <[EMAIL PROTECTED]> writes:

> I just found ord(c), which convert ascii to integer.
>
> Anybody know what the reverse is?

The inverse of "ord" is "chr":

  % python
  Python 2.5 (r25:51908, Jan  5 2007, 00:12:45) 
  [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> ord('i')
  105
  >>> chr(105)
  'i'
  >>>

IIRC, the first use of the names "ord" and "chr" for these functions
appeared in the Basic language in the 1960's ... in case anyone is
interested in this bit of historical trivia.


-- 
 Lloyd Zusman
 [EMAIL PROTECTED]
 God bless you.

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


WeakrefValueDictionary of Callables?

2006-05-20 Thread Lloyd Weehuizen
Hey

I'm trying to set up a WeakrefValueDictionary of callables however as 
soon as my method that adds the callable to the dictionary exits the 
value is removed? Is there any way around this?

Example:
import weakref
TEST_EVENT = 1

class TestBinder:
def __init__( self ):
self.entries = weakref.WeakValueDictionary()

def BindFunction( self, event_id, function ):
self.entries[event_id] = function

def CallFunction( self, event_id, *args ):
self.entries[event_id]( *args )


class TestCase:
def __init__( self, binder ):
binder.BindFunction( TEST_EVENT, self.TestFunction )

def TestFunction():
print "TestFunction OK"

test_binder = TestBinder()
test_case = TestCase( test_binder )

test_binder.CallFunction( TEST_EVENT )

This generates a KeyError: 1, if I don't use weakrefs, then the TestCase 
object is never cleaned up until TestBinder is destroyed.

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


Re: WeakrefValueDictionary of Callables?

2006-05-21 Thread Lloyd Weehuizen

Thanks for that, I had a feeling that was the problem. Is there anyway 
around this? I'd prefer not to have to assume the method name on the object.

This could be solved by passing the object and method name in as two 
separate parameters to the Bind function. But ideally I'd like to 
extract this information somehow from the bound method and give the 
external API a more natural feel. Is that possible?

Steve Holden wrote:
 > Lloyd Weehuizen wrote:
 >> Hey
 >>
 >> I'm trying to set up a WeakrefValueDictionary of callables however as
 >> soon as my method that adds the callable to the dictionary exits the
 >> value is removed? Is there any way around this?
 >
 >
 > I believe your problem is that the bound method references aren't
 > being retained (i.e. referenced) anywhere else. A bound method is an
 > object its own right, and can cease to exist at any time -
 > particularly in your
 > case when the weak reference is the only reference to it!
 >
 > Consider that the following code actually appears to work:
 >
 >import weakref
 >TEST_EVENT = 1
 >
 >class TestBinder:
 > def __init__(self):
 > self.entries = weakref.WeakValueDictionary()
 >
 > def BindFunction(self, event_id, obj):
 > self.entries[event_id] = obj
 >
 > def CallFunction(self, event_id, *args):
 > self.entries[event_id].TestFunction(*args)


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


MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Christopher Lloyd
Hello all,

I'm new to Python and new to this list, although I've done some digging in the 
archives and already read up on the problem I'm about to describe.

I'm a relatively inexperienced programmer, and have been learning some basic 
C++ and working through the demos in Ron Penton's "MUD Game Programming" book. 
In it, Python modules are run from inside a C++ program.

The problem that I'm having is making the Python part work. Take the following 
code:

// This program shows you how to integrate Python in a very basic manner

#include 
#include 
#include "Python.h"

int main()
{
std::cout << "Starting Python Demo Test" << std::endl;

Py_Initialize();// initialize python

std::string str;
std::getline( std::cin, str );
while( str != "end" )
{
PyRun_SimpleString( const_cast( str.c_str() ) );
std::getline( std::cin, str );
}

Py_Finalize();  // shut down python

std::cout << "Demo Complete!" << std::endl;

return 0;
}

If I try to compile this in MS Visual C++ 2008 (debug mode), I get the 
following error:

LINK : fatal error LNK1104: cannot open file 'python26_d.lib'

>From my reading, it looks like there's a problem with compiling in release 
>mode or debug mode either in C++ or in Python. At the moment, I'm using the 
>Python Windows .exe download. I'm not using version 2.6 for any particular 
>reason - I'm also trying 2.2 and 2.3.

So I don't have the Python source code downloaded (and I'm not entirely sure 
what to do with it if I do download it, since the instructions for the .tar 
file are for Linux, not windows). The Windows executables for 2.2 and 2.3 came 
on a CD with the book, so it seems clear that the author thought that the 
source code wasn't required anyway.

So, what happens if I try compiling the above C++ in release mode? Actually, 
nothing - It compiles just fine. However, upon running the resulting program, 
my command line box displays the following:

>   Starting Python Demo Test

That's all. The program has hung halfway through and the test isn't completed.

It's been suggested that I replace the first part of my C++ code with the 
following, and then try to compile in release mode:

#ifdef _DEBUG
#undef _DEBUG
#include 
#define _DEBUG
#else
#include 
#endif

I've tried this, and it compiles successfully but when run, the program is the 
same - It doesn't work.

I've correctly set up all my library files and link (at least, lets assume its 
not that, since I've already spent several hours checking and re-checking that).

I'd be very grateful for any help or asvice people might have on this.

Thanks,

Chris Lloyd

-- 


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


Python version of perl's "if (-T ..)" and "if (-B ...)"?

2010-02-12 Thread Lloyd Zusman
Perl has the following constructs to check whether a file is considered
to contain "text" or "binary" data:

if (-T $filename) { print "file contains 'text' characters\n"; }
if (-B $filename) { print "file contains 'binary' characters\n"; }

Is there already a Python analog to these? I'm happy to write them on
my own if no such constructs currently exist, but before I start, I'd
like to make sure that I'm not "re-inventing the wheel".

By the way, here's what the perl docs say about these constructs. I'm
looking for something similar in Python:

... The -T  and -B  switches work as follows. The first block or so
... of the file is examined for odd characters such as strange control
... codes or characters with the high bit set. If too many strange
... characters (>30%) are found, it's a -B file; otherwise it's a -T
... file. Also, any file containing null in the first block is
... considered a binary file. [ ... ]

Thanks in advance for any suggestions.

-- 
 Lloyd Zusman
 l...@asfast.com
 God bless you.


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


Re: A possible change to decimal.Decimal?

2012-03-04 Thread A. Lloyd Flanagan
On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote:
> Jeff Beardsley wrote:
> > HISTORY:  
...
> 
> What you should be doing is:
> 
>import decimal
>from decimal import Decimal
> 
>reload(decimal)
>Decimal = decimal.Decimal   # (rebind 'Decimal' to the reloaded code)
> 
> ~Ethan~

Agree that's how the import should be done. On the other hand, removing 
gratuitous use of isinstance() is generally a Good Thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why would anyone use python when java is there?

2006-11-30 Thread A. Lloyd Flanagan
On Nov 30, 3:19 am, "gavino" <[EMAIL PROTECTED]> wrote:
> I want to learn to program and I can't seem to pick a direction.  A
> java guy I know makes a lot of $, but a lot of reading I have done
> shows lisp smalltalk and haskell to be really nice, as well as of
> course python.  It seems python is 4/5 way to lisp yet has a lot of

This may be a troll, but it's a chance for me to make a good point.  I
love making a point...

If you're serious about learning to program, you're thinking of it the
wrong way.  You need to learn HOW to program, which is independent of
knowing a particular language or environment.  In that sense it doesn't
matter what language you start with.  That said, Python is an excellent
teaching language due to its combination of simplicity and power.

If you're going to be a professional programmer, you should learn as
many different languages as you can.  Each brings its own "mindset" to
programming, and by learning the language you gain skills and concepts
that are applicable even when you're using a different language.

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


Re: When will 2.5.1 be released?

2007-03-06 Thread A. Lloyd Flanagan
On Mar 4, 2:49 pm, "Nile" <[EMAIL PROTECTED]> wrote:
> This is not a big deal but I would like to use Tix with 2.5.  My
> understanding is this bug will be fixed in the 2.5.1 release. Does

And while we're waiting for 2.5.1, can somebody post a clear (as
opposed to the one that comes with Tix ;)) explanation of how to
manually install Tix into python 2.5?  It should be possible...

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