Sorry. I was wrong about "global" statement.
Then examples seems to be even more intricate:
def Synhronised(loc k,func):
lock.acquire()
try:
func()
finally:
lock.release()
.....
lock=Lock()
def Here_I_work(*a) : return 1 # Stub
def asd(a): return a # Stub
def Some():
local_var1=1
local_var2=2
local_var3=[None]
def Work():
local_var3[0]=Here_I_work(lo cal_var1,local_ var2,local_var3 )
Synhronised(loc k,Work)
return asd(local_var3[0])
FileOpenClose Example:
def FileOpenClose(n ame,mode,func):
f=file(name,mod e)
try:
func(f)
finally:
f.close()
.....
def Another(name):
local_var3=[None]
def Work(f):
local_var3[0]=[[x,y(i)] for i in f]
FileOpenClose(n ame,'r',Work)
return local_var3[0]
Here we must to declare local_var3 as array, though we using it as scalar.
Following is from previous letter (with correction). Please do not be severe, I'm not great programmer
and my English isn't A and even B graduated.
I think it is possible to introduce(inter nally) block-object in analogy to lambda-object
(and function-object).
It's difference from function:
it has no true self local variables, all global(free) and local variables it steels from outter
scope. And all local vars, introduced in block are really introduced in outter scope
(i think, during parse state). So its global dicts and local dicts are realy corresponding dicts
of outter scope (so, may be block call would be faster than function call. I don't know)
Syntax can be following:
lock=Lock()
def Some():
local_var1=1
local_var2=2
local_var3=3
Synhronised(loc k,block):
local_var3=Here _I_work(local_v ar1,local_var2, local_var3)
return asd(local_var3)
def Another(name):
FileOpenClose(n ame,'r',block{f }):
local_var3=[[x,y(i)] for i in f]
return local_var3
And here is sample of returning value:
def Foo(context,pro c):
context.enter()
try:
res=proc(contex t.x,context.y)* 2
except Exception,Err:
context.throw(E rr)
finally:
context.exit()
return res
....
context=MyConte xt()
....
def Bar():
result=Foo(cont ext,block{x,y}) :
continue x+y
return result
The idea was stolen from Ruby. My be it is not Pythonic. 0 1482 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christoph Becker-Freyseng |
last post by:
Hello,
recently there was a lot discussion about a new Path-class. So Gerrit
Holl started to write a pre-PEP
http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
We tried to summarize the good ideas and suggestions. Some are still
missing and concepts of already existing modules have to be
added/thought over. Furthermore it turns out that not a new class is
needed but a module. The pre-PEP is already quite big --- Gerrit Holl
|
by: Edward K. Ream |
last post by:
Hello all,
First of all, my present state of mind re pep 318 is one of sheepish
confusion. I suspect pep 318 will not affect Leo significantly, but I am
most surprised that an apparently controversial feature is being added
without a notice, say, in comp.lang.python.announce. I say sheepish,
because everyone knows that one should make sure new proposals don't bite
you. Still, I would have thought that there were other ways of keeping...
|
by: John Roth |
last post by:
PEP 263 is marked finished in the PEP index, however
I haven't seen the specified Phase 2 in the list of changes
for 2.4 which is when I expected it.
Did phase 2 get cancelled, or is it just not in the
changes document?
John Roth
|
by: Nick Coghlan |
last post by:
Anyone playing with the CPython interpreter's new command line switch might have
noticed that it only works with top-level modules (i.e. scripts that are
directly on sys.path). If the script is inside a package, the invocation will
fail with a "Module not found" error.
This PEP is aimed at fixing that :)
Cheers,
Nick.
|
by: Nick Coghlan |
last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path.
Trying to use it with modules inside packages will fail with a "Module not
found" error. This PEP aims to fix that for Python 2.5.
Previously, posting of a draft version of the PEP to python-dev and python-list
didn't actually generate any responses. I'm not sure if that's an indication
that people don't see the restriction to top-level modules as a problem...
| |
by: Steven Bethard |
last post by:
In the "empty classes as c structs?" thread, we've been talking in some
detail about my proposed "generic objects" PEP. Based on a number of
suggestions, I'm thinking more and more that instead of a single
collections type, I should be proposing a new "namespaces" module
instead. Some of my reasons:
(1) Namespace is feeling less and less like a collection to me. Even
though it's still intended as a data-only structure, the use cases...
|
by: Micah Elliott |
last post by:
I also have this living as a wiki <http://tracos.org/codetag/wiki/Pep>
if people would like to add comments there. I might try to capture there
feedback from this group anyway. First try at a PEP -- thanks for any
feedback!
Please add **NOTE:** comments to the bottom of this wiki document
using `WikiRestructuredText`:trac:.
=======================================
|
by: Bryan Olson |
last post by:
Though I tried to submit a (pre-) PEP in the proper form through the proper
channels, it has disappeared into the ether.
In building a class that supports Python's slicing interface,
http://groups.google.com/group/comp.lang.python/msg/8f35464483aa7d7b
I encountered a Python bug, which, upon further discussion, seemed to be
a combination of a wart and a documentation error.
|
by: Ben Finney |
last post by:
Howdy all,
PEP 354: Enumerations in Python has been accepted as a draft PEP. The
current version can be viewed online:
<URL:http://www.python.org/peps/pep-0354.html>
Here is the reStructuredText source as it is today. Please discuss it
here so I can see what issues people may have.
|
by: dustin |
last post by:
I've been hacking away on this PEP for a while, and there has been some
related discussion on python-dev that went into the PEP:
http://mail.python.org/pipermail/python-dev/2007-February/070921.html
http://mail.python.org/pipermail/python-dev/2007-February/071155.html
http://mail.python.org/pipermail/python-dev/2007-February/071181.html
I'd love to have feedback on this PEP:
- from a user's perspective (would you want to write...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |