Re: reportlab and python 3
Le lundi 17 septembre 2012 10:48:30 UTC+2, Laszlo Nagy a écrit : > Reportlab is on the wall of shame. http://python3wos.appspot.com/ > > > > Is there other ways to create PDF files from python 3? There is pyPdf. I > > haven't tried it yet, but it seem that it is a low level library. It > > does not handle "flowables" that are automatically split across pages. > > It does not handle "table headers" that are repeated automatically on > > the top of every page (when the table does not fit on a page). I need a > > higher level API, with features compareable to reportlab. Is there such > > thing? > > > > Thanks, > > > > Laszlo A big yes and it is very easy. I assume you know how to write a plain text file with Python :-). Use your Python to generate a .tex file and let it compile with one of the pdf TeX engines. Potential problems: - It requires a TeX installation (a no problem). - Of course I requires some TeX knowledge. Learning it is not so complicate. Learn how to use TeX with a text editor and you will quickly understand what you have to program in Python. Bonus: you learn at the same time a good text editing engine. I can not figure out something more simple, versatile and powerful. jmf -- http://mail.python.org/mailman/listinfo/python-list
How to use __getattr__ to the current module, for automatically add attributes of the real-time
Want to work so:
import sys
class Foo(object):
def __getattr__(self, t):
print 'use __getattr__ - ', t
return type(t, (object,), {})
def funct1(self): pass
def funct2(self): pass
sys.modules[__name__] = Foo()
ttt('yy')
name 'ttt' is not defined.
__getattr__ not work (((.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Hiring Python Developer @ CA, USA
[email protected] writes: > ...Must be an export in this language... Are you hiring proof readers as well? :) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to queue functions
On Tue, Sep 18, 2012 at 10:26 AM, Dhananjay wrote:
> Dear all,
>
> I am trying to use multiprocessing module.
> I have 5 functions and 2000 input files.
>
> First, I want to make sure that these 5 functions execute one after the
> other.
> Is there any way that I could queue these 5 functions within the same script
> ?
>
>
> Next, as there are 2000 input files.
> I could queue them by queue.put() and get back to run one by one using
> queue.get() as follows:
>
> for file in files:
> if '.dat.gz' in file:
> q.put(file)
>
> while True:
> item = q.get()
> x1 = f1(item)
> x2 = f2(x1)
> x3 = f3(x2)
> x4 = f4(x3)
> final_output = f5(x4)
>
>
> However, how can I input them on my 8 core machine, so that at a time 8
> files will be processed (to the set of 5 functions; each function one after
> the other) ?
>
The multiprocessing.Pool class seems to be what you need.
Documentation at
http://docs.python.org/py3k/library/multiprocessing.html#using-a-pool-of-workers
Example:
#!/usr/bin/env python3
import multiprocessing
def file_handler(filename):
# do processing on filename, return the final_output
print('working on {}'.format(filename))
return 'processed-{}'.format(filename)
def main():
p = multiprocessing.Pool(8)
files = [ 'a', 'b', 'c' ]
result = p.map(file_handler, files)
print(result)
if __name__ == '__main__':
main()
If you want, you can also implement everything using
multiprocessing.Process and multiprocessing.Queue, but using pools
should be simpler.
--
regards,
kushal
--
http://mail.python.org/mailman/listinfo/python-list
ANN: eGenix mxODBC Zope/Plone Database Adapter 2.1.0
ANNOUNCEMENT mxODBC Zope/Plone Database Adapter Version 2.1.0 for Zope and the Plone CMS Available for Plone 4.0, 4.1 and 4.2, Zope 2.12 and 2.13, on Windows, Linux, Mac OS X, FreeBSD and other platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.0-GA.html INTRODUCTION The eGenix mxODBC Zope DA allows you to easily connect your Zope or Plone CMS installation to just about any database backend on the market today, giving you the reliability of the commercially supported eGenix product mxODBC and the flexibility of the ODBC standard as middle-tier architecture. The mxODBC Zope Database Adapter is highly portable, just like Zope itself and provides a high performance interface to all your ODBC data sources, using a single well-supported interface on Windows, Linux, Mac OS X, FreeBSD and other platforms. This makes it ideal for deployment in ZEO Clusters and Zope hosting environments where stability and high performance are a top priority, establishing an excellent basis and scalable solution for your Plone CMS. Product page: http://www.egenix.com/products/zope/mxODBCZopeDA/ NEWS We are pleased to announce a new version 2.1.0 of our mxODBC Zope/Plone Database Adapter product. Updated Plone Support - In this new release, we have focused on a simplified zc.buildout deployment as used in Plone 4.x and the latest Zope 2.13 releases. The mxODBC Zope DA is now again compatible with all recent Plone versions. Please see the mxODBC Zope DA documentation for details on how to install the product for use in Plone. For the full list of features, please see the mxODBC Zope DA feature list: http://www.egenix.com/products/zope/mxODBCZopeDA/#Features Enhanced ODBC Driver Support We have also updated the integrated mxODBC Python Extension to the latest 3.2 release, which includes a number of important new features and ODBC driver compatibility enhancements: * Added support for the DataDirect ODBC manager on Linux which is used by several data warehouse database backends * Added MS SQL Server ODBC Driver 1.0 for Linux support * Added Teradata support * Added Netezza support * Switched to unixODBC 2.3.1+ API for better 64-bit support on Linux * Enhanced Oracle Instance Client support * Enhanced IBM DB2 driver support * Enhanced Sybase ASE driver support * Enhanced FreeTDS ODBC driver support * Enhanced PostgreSQL driver support * Enhanced generic support for many other ODBC compatible databases Please see the mxODBC 3.2 release announcement for a complete set of changes available in the underlying mxODBC 3.2 package used in mxODBC Zope/Plone DA 2.1: http://www.egenix.com/company/news/eGenix-mxODBC-3.2.0-GA.html Lowered Overall Licensing Costs --- Starting with version 2.1, we have also simplified our license terms to clarify the situation on multi-core and virtual machines. In most cases, you no longer need to purchase more than one license per Zope/Plone instance, if you are running on a multi-core processor or virtual machine, scaling down the overall license costs significantly compared to earlier mxODBC Zope DA releases. Minor other changes --- * Error screens have been changed to plain text after the recent hot fix which disabled showing HTML in error messages * The "Security" tab now also works in Zope 2.13 UPGRADING Users are encouraged to upgrade to this latest mxODBC Zope/Plone DA release to benefit from the new features and updated ODBC driver support. We have taken special care not to introduce backwards incompatible changes, making the upgrade experience as smooth as possible. For upgrade purchases, we will give out 20% discount coupons going from mxODBC Zope DA 1.x to 2.1 and 50% coupons for upgrades from mxODBC 2.x to 2.1. After upgrade, use of the original license from which you upgraded is no longer permitted. Please contact the eGenix.com Sales Team with your existing license serials for details for an upgrade discount coupon. If you want to try the new release before purchace, you can request 30-day evaluation licenses by visiting our web-site or writing to [email protected], stating your name (or the name of the company) and the number of eval licenses that you need. MORE INFORMATION For more information on the mxODBC Zope Database Adapter, licensing and download instructions, plea
Re: reportlab and python 3
A big yes and it is very easy. I assume you know how to write a plain text file with Python :-). Use your Python to generate a .tex file and let it compile with one of the pdf TeX engines. Potential problems: - It requires a TeX installation (a no problem). - Of course I requires some TeX knowledge. Learning it is not so complicate. Learn how to use TeX with a text editor and you will quickly understand what you have to program in Python. Bonus: you learn at the same time a good text editing engine. I can not figure out something more simple, versatile and powerful. jmf This is a good idea. Thank you. I wanted to learn TeX anyway. The TeX installation is problematic. I also want to use this under MS Windows. Yes, I know here is MikTeX for Windows. But there is significant difference. ReportLab can be embedded into a small program created with py2exe. LaTeX on the other side is a 150MB separate installation package that must be installed separately by hand. But in my particular case, it is still a good solution. Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: How to use __getattr__ to the current module, for automatically add attributes of the real-time
- Original Message -
> Want to work so:
>
> import sys
> class Foo(object):
> def __getattr__(self, t):
>print 'use __getattr__ - ', t
>return type(t, (object,), {})
> def funct1(self): pass
> def funct2(self): pass
>
> sys.modules[__name__] = Foo()
> ttt('yy')
>
> name 'ttt' is not defined.
> __getattr__ not work (((.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
I think __getattr__ would be triggered by using Foo().ttt or getattr(Foo(),
'ttt').
I think this hack is meant to work on modules object only, not in the global
namespace where locals() and globals() are used instead (global namespace may
not be the proper word, I don't know if there is a technical term for that).
Here's how to make it work:
foo.py
import sys
class Foo(object):
def __getattr__(self, t):
print 'use __getattr__ - ', t
return type(t, (object,), {})
def funct1(self): pass
def funct2(self): pass
sys.modules[__name__] = Foo()
Now in a python shell, or in another file:
import foo
foo.ttt
use __getattr__ - ttt
use __getattr__ - ttt
<
JM
PS : Looks like a hell of a hack
--
http://mail.python.org/mailman/listinfo/python-list
Re: Docstring parsing and formatting
On Tue, Sep 18, 2012 at 1:03 AM, Terry Reedy wrote: > On 9/17/2012 10:03 PM, Ben Finney wrote: >> >> Howdy all, >> >> Where can I find a standard implementation of the docstring parsing and >> splitting algorithm from PEP 257? Do you know about pydoc? I haven't looked at its source, but since it does a great job of printing documentation from docstrings it might contain what you need -- Joel Goldstick -- http://mail.python.org/mailman/listinfo/python-list
Re: Hiring Python Developer @ CA, USA
Incidentally and I know this is region specific, but what's the average salary approximately in the US/UK for a Senior Python programmer? ITJobsWatch in the UK says - http://www.itjobswatch.co.uk/jobs/uk/python.do Is that about right? Jon. On 18 September 2012 08:40, Paul Rudin wrote: > [email protected] writes: > > > ...Must be an export in this language... > > Are you hiring proof readers as well? :) > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: reportlab and python 3
Le mardi 18 septembre 2012 11:04:19 UTC+2, Laszlo Nagy a écrit : > > A big yes and it is very easy. I assume you know how > > > to write a plain text file with Python :-). > > > > > > Use your Python to generate a .tex file and let it compile > > > with one of the pdf TeX engines. > > > > > > Potential problems: > > > - It requires a TeX installation (a no problem). > > > - Of course I requires some TeX knowledge. Learning it > > > is not so complicate. Learn how to use TeX with a text > > > editor and you will quickly understand what you have to > > > program in Python. Bonus: you learn at the same time > > > a good text editing engine. > > > > > > I can not figure out something more simple, versatile and > > > powerful. > > > > > > jmf > > > > > This is a good idea. Thank you. I wanted to learn TeX anyway. The TeX > > installation is problematic. I also want to use this under MS Windows. > > Yes, I know here is MikTeX for Windows. But there is significant > > difference. ReportLab can be embedded into a small program created with > > py2exe. LaTeX on the other side is a 150MB separate installation package > > that must be installed separately by hand. > > > > But in my particular case, it is still a good solution. > > > > Thanks, > > > > Laszlo I understood, you have Python on a platform and starting from this you wish to create pdf files. Obviously, embedding "TeX" is practically a no solution, although distibuting a portable standalone TeX distribution is a perfectly viable solution, especially on Windows! To "I wanted to learn TeX anyway.": I can only warmly recommend to start with one of the two unicode compliant engines, LuaTeX or XeTeX. jmf -- http://mail.python.org/mailman/listinfo/python-list
a few questions about scrapy
I've installed scrapy and gotten a basic set-up working, and I have a few odd questions that I haven't been able to find in the documentation. I plan to run it occasionally from the command line or as a cron job, to scrape new content from a few sites. To avoid duplication, I have in memory two sets of long with the md5 hashes of the URLs and files crawled, and the spider ignores any that it has seen before. I need to load them from two disk files when the scrapy job starts, and save them to disk when it ends. Are there hooks or something similar for start-up and shut-down tasks? How can I put a random waiting interval between HTTP GET calls? Is there any way to set the proxy configuration in my Python code, or do I have so set the environment variables http_proxy and https_proxy before running scrapy? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
Am 15.09.2012 16:18 schrieb 8 Dihedral: The concept of decorators is just a mapping from a function ... or class ... > to another function ... or any other object ... > with the same name in python. Thomas -- http://mail.python.org/mailman/listinfo/python-list
SOLVED: Docstring parsing and formatting
Joel Goldstick writes: > On Tue, Sep 18, 2012 at 1:03 AM, Terry Reedy wrote: > > On 9/17/2012 10:03 PM, Ben Finney wrote: > >> Where can I find a standard implementation of the docstring parsing > >> and splitting algorithm from PEP 257? > > Do you know about pydoc? I haven't looked at its source, but since it > does a great job of printing documentation from docstrings it might > contain what you need Yes, I have now learned about the ‘pydoc’ module following the lead from investigating the interactive interpreter's ‘help’ function http://docs.python.org/library/pydoc.html>. The ‘pydoc.splitdoc’ function, though not documented in the library documentation, does what I need. It takes a docstring as input, and returns a tuple of (synopsis, description). Thanks to everyone who helped. -- \ “Value your freedom or you will lose it, teaches history. | `\ “Don't bother us with politics,” respond those who don't want | _o__) to learn.” —Richard Stallman, 2002 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Batching HTTP requests with httplib (Python 2.7)
On 2012-09-14, Xavier Combelle wrote:
> Le 14/09/2012 12:56, Dwight Hutto a ?crit :
>> service_num_list = [num for num in range(0,5)]
>> for service_num in service_num_list:
>> eval("web_service_call%i(%i)" % (service_num,service_num))
>>
>>
> service_num_list = [num for num in range(0,5)]
service_num_list = list(range(5))
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
Re: 'indent'ing Python in windows bat
Thank you all. Roy Smith gets the most thanks, though he didn't answer my general question -- he showed me how to look at that specific structure differently. Terry Reedy might get thanks for her idea if I can ever figure the correct escape sequences that will make both windows and the Python interpreter happy. Bat makes bash/sed combos look like a breeze... I thought you guys wouldn't want a treatise about WHY I was doing it this way and left it at one sentence. For whatever record, this is the sentence most missed. I'm converting windows bat files little by little to Python 3 as I find time and learn Python. I COULD stop doing all my other work to learn Python and convert all the batch files in one fell swoop. Efficiency? Fast way to get fired. Better to fit this in during the many small breaks I have. That's how the bat files were built over time in the first place. Or this email. I COULD break down each batch file and write dozens of mini python scripts to be called. I already have a few, too. Efficiency? Speed is bad, but these are bat files, after all. The cost of trying to work with a multitude of small files is high, though, and I realized I had better go to a mix. Some sections can be broken down to one liners. Efficiency? Speed is terrible, but it's far faster than typing commands. OTOH, I have the organization I need on the original bat file, which is slowly being rem'ed out. As I learn and have the time, the one-liners will melt together into a py file to be called from the bat file. Eventually, the bat will disappear back into the broken Window from whence it came. Ugly, eh? I have under my belt scads of different languages from Fortran (using JCL!), Pascal, C++ to bash, sed, awk to Forth, assembly and a large cast of others. No big deal. My brain and Python, however, do NOT mix. I have been trying to learn the thing for over a decade and figure this will either force my brain into seeing the heart of the beast, or be swallowed in the attempt. Bat files are ugly cripples, but even on Windows a two-legged quick and dirty dog is better than mistake-prone typing and button clicking. After conversion, I'm aiming to make these erstwhile ugly cripples fly when I find the time and as I stuff more Python down my gullet. I agree. For those who have the unbroken time and understanding of Python, this is idiotic. back to work, -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
On 2012-09-14, Chris Angelico wrote: > But then again, who actually ever needs fibonacci numbers? If it should happen that your question is not facetious: http://en.wikipedia.org/wiki/Fibonacci_number#Applications -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
On Tue, Sep 18, 2012 at 11:19 PM, Neil Cerutti wrote: > On 2012-09-14, Chris Angelico wrote: >> But then again, who actually ever needs fibonacci numbers? > > If it should happen that your question is not facetious: > > http://en.wikipedia.org/wiki/Fibonacci_number#Applications It wasn't entirely facetious. I know there are a few cases where they're needed, but I think they're calculated far more often to demonstrate algorithms than because you actually have use of them. :) Though it's as well to mention these sorts of things now and then. I remember one time writing up something or other, and my dad was looking over my shoulder and asked me why I'd written a little Pascal's Triangle generator. He didn't know that it had direct application to whatever-it-was. And unfortunately I don't remember what I was even writing at the time :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: reportlab and python 3
I understood, you have Python on a platform and starting from this you wish to create pdf files. Obviously, embedding "TeX" is practically a no solution, although distibuting a portable standalone TeX distribution is a perfectly viable solution, especially on Windows! To "I wanted to learn TeX anyway.": I can only warmly recommend to start with one of the two unicode compliant engines, LuaTeX or XeTeX. All right. Which one is the better? :-) I'm totally a beginner. I would also like to use mathematical expressions but I guess they are both capable of that. Another requirement would be: easy installation under unix and windows, good multilingual support. -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
I have a similar problem, something which I've never quite understood about subprocess... Suppose I do this: proc = subprocess.Popen(['ls', '-lR'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) now I created a process, which has a PID, but it's not running apparently... It only seems to run when I actually do the wait. I don't want to make it waiting, so an easy solution is just to use a thread, but is there a way with subprocess? -- http://mail.python.org/mailman/listinfo/python-list
Re: splitting numpy array unevenly
On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote: > On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer wrote: > > > I need to divide a 512x512 image array with the first horizontal and > > vertical division 49 pixels in. Then every 59 pixels in after that. hsplit > > and vsplit want to start at the edges and create a bunch of same size > > arrays. Is there a command to chop off different sized arrays? > > > > > > > > > > > > Thanks > > > > I don't know that I follow completely, but can't you just slice what you are > after? > > > > x = np.random.rand(512*512).reshape(512,512) > > xx = x[0,:49] > > And put the rest of the slices in a loop...? I was trying to avoid the loop. I figured it out. hsplit and vsplit will work. I just need to give it a list of break points. I still need a loop though. breakPoints = range(49,512,59) rowArrays = hsplit(InputArray, breakPoints) OutArrays = [] for r in rowArrays: OutArrays.append(vsplit(r, breakPoints)) -- http://mail.python.org/mailman/listinfo/python-list
[Ann] pyBug - Python Belgian User Group
Hello everyone and, especially all python user from Belgium. I'm proud to announce the creation of a User Group around Python for the Belgium community. It has been baptized pyBug which stands for Python Belgian User Group. We're just starting out and will need all the help we can get , even if it's just becoming a member. Our main focus is enjoying ourself by organizing events where we can talk, collaborate around everything that is related to Python. If you care to join or just listen what's going on, we've registered a mailing list at google groups. It's located at: https://groups.google.com/forum/?fromgroups#!forum/python-belgian-user-group You can also subscribe by sending an email to [email protected] Hope to see you there. Yours sincerely, Jonas Geiregat.-- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
Chris Angelico於 2012年9月18日星期二UTC+8下午9時25分04秒寫道: > On Tue, Sep 18, 2012 at 11:19 PM, Neil Cerutti wrote: > > > On 2012-09-14, Chris Angelico wrote: > > >> But then again, who actually ever needs fibonacci numbers? > > > > > > If it should happen that your question is not facetious: > > > > > > http://en.wikipedia.org/wiki/Fibonacci_number#Applications > > > > It wasn't entirely facetious. I know there are a few cases where > > they're needed, but I think they're calculated far more often to > > demonstrate algorithms than because you actually have use of them. :) > > > > Though it's as well to mention these sorts of things now and then. I > > remember one time writing up something or other, and my dad was > > looking over my shoulder and asked me why I'd written a little > > Pascal's Triangle generator. He didn't know that it had direct > > application to whatever-it-was. And unfortunately I don't remember > > what I was even writing at the time :) > > > > ChrisA I would suggest one should solve the Fibnaci(5) first and fast in Python. Then one can think about computing c(n,k) in Python for large n. Then -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
Neil Hodgson wrote: Ethan Furman: *plonk* I can't work out who you are plonking. While more than one of the posters on this thread seem worthy of a good plonk, by not including sufficient context, you've left me feeling puzzled. Is there a guideline for this in basic netiquette? You're right, my apologies. Dwight Hutto is the one I plonked. His signal to noise ratio seems incredibly low. alex23 can definitely be abrasive, but his ratio is high. (Now I'm wondering what that says about me as far as who I agree with and why... I'll have to think about that.) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Tue, Sep 18, 2012 at 11:12 AM, Ethan Furman wrote: > Neil Hodgson wrote: >> >> Ethan Furman: >>> >>> *plonk* >> >> >>I can't work out who you are plonking. While more than one of the >> posters on this thread seem worthy of a good plonk, by not including >> sufficient context, you've left me feeling puzzled. Is there a guideline for >> this in basic netiquette? > > > You're right, my apologies. Dwight Hutto is the one I plonked. His signal > to noise ratio seems incredibly low. Is this just because of the lack of context, or because of the content of my response to the OP following the question? And with all the netiquette talk being passed around, why isn't this a new thread instead of hijacking the OP's original question, and engaging in bickering about netiquette that goes on all the time? And it seems redundant to argue this topic other than to comment, and let it pass, unless there's seems to be a legitimate reason why someone 'disobeyed' posting policy. > > alex23 can definitely be abrasive, but his ratio is high. > > (Now I'm wondering what that says about me as far as who I agree with and > why... I'll have to think about that.) > > ~Ethan~ > -- > http://mail.python.org/mailman/listinfo/python-list -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
>>> sufficient context, you've left me feeling puzzled. Is there a guideline for >>> this in basic netiquette? >> www.woodgate.org/FAQs/netiquette.html -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
> > You're right, my apologies. Dwight Hutto is the one I plonked. You can call me David. I go by my middle name. And it seem to me I made some valid points about a few simple trimming of postings, that didn't seem necessary in the context of a small quick conversation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Wed, Sep 19, 2012 at 2:17 AM, Dwight Hutto wrote: >> >> You're right, my apologies. Dwight Hutto is the one I plonked. > You can call me David. I go by my middle name. You're most often going to be addressed by the name that's given in your post headers. In this case "David" has been reduced to an initial, and is visible only in your email address, whereas "Dwight" is right there in your real-name. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: reportlab and python 3
Le mardi 18 septembre 2012 15:31:52 UTC+2, Laszlo Nagy a écrit : > > I understood, you have Python on a platform and starting > > > from this you wish to create pdf files. > > > Obviously, embedding "TeX" is practically a no solution, > > > although distibuting a portable standalone TeX distribution > > > is a perfectly viable solution, especially on Windows! > > > > > > To "I wanted to learn TeX anyway.": > > > I can only warmly recommend to start with one of the two > > > unicode compliant engines, LuaTeX or XeTeX. > > All right. Which one is the better? :-) I'm totally a beginner. I would > > also like to use mathematical expressions but I guess they are both > > capable of that. Another requirement would be: easy installation under > > unix and windows, good multilingual support. I basically recommend nothing. I pointed the LuaTeX or Xe(La)TeX engines because there are the unicode compliant engines. Today, most of the work target these engines. By Unicode compliance, you should not understand only the coding of characters, but everything which is related to the unicode technology (characters, unicode features, typography, font technology). "...good multilingual support. ..." Don't worry. It's much better than the future of Python ;-) FYI I'm not a expert. I have only accumulated experience, I wrote my first TeX document 20(?) years ago. Now, I use XeLaTeX from MiKTeX on Win7. Why? Answer: why not? jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
Jean-Michel Pichavant writes: > - Original Message - >> Jean-Michel Pichavant wrote: > [snip] >> One minor note, the style of decorator you are using loses the >> docstring >> (at least) of the original function. I would add the >> @functools.wraps(func) >> decorator inside your decorator. > > Is there a way to not loose the function signature as well ? Look at the "decorator" module. -- http://mail.python.org/mailman/listinfo/python-list
Re: reportlab and python 3
On 9/18/2012 9:31 AM, Laszlo Nagy wrote: capable of that. Another requirement would be: easy installation under unix and windows, good multilingual support. By using 3.3, your Python string manipulations will act the same on all platforms, even when using extended plane (non-BMP) characters. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: HMM based Chunker NLTK
On 18/09/2012 19:35, [email protected] wrote: Dear Group, If anyone of the learned members can kindly help with a HMM/CRF based chunker on NLTK. Regards, Subhabrata. Certainly but how do you intend paying us? :) An alternative approach is to provide us with an idea of what you've researched, what code you've written and what problems you've got with it. If you get a code exception please provide the complete traceback and a mimimal code snippet that reproduces the issue. This way you're much more likely to get help. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: HMM based Chunker NLTK
On Wednesday, September 19, 2012 12:40:00 AM UTC+5:30, Mark Lawrence wrote: > On 18/09/2012 19:35, [email protected] wrote: > > > Dear Group, > > > If anyone of the learned members can kindly help with a HMM/CRF based > > chunker on NLTK. > > > > > > Regards, > > > Subhabrata. > > > > > > > Certainly but how do you intend paying us? :) > > > > An alternative approach is to provide us with an idea of what you've > > researched, what code you've written and what problems you've got with > > it. If you get a code exception please provide the complete traceback > > and a mimimal code snippet that reproduces the issue. This way you're > > much more likely to get help. > > > > -- > > Cheers. > > > > Mark Lawrence. Two possibilities Mark, either nltk.chunk.(something) or nltk.tag.hmm etc. I am thinking to experiment Regular Expressions, Unigram/Bigram based chunkers are running good even with Indian languages. HMM tag is also going great. I am thinking on the issue. Regards, Subhabrata. -- http://mail.python.org/mailman/listinfo/python-list
User defined lexical scoping... can I do this?
I want to define a 'with' command that makes entries in dictionary available within the local scope, and stores new local variables into that dictionary. The original scope should be restored on exit, and called functions should not see anything special. Can I do this? my_dict = dict(a=1, b=2) with MyScope(my_dict): print "A", a, "B", b x = 3 print my_dict["x"] print x # FAIL, unbound -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
> You're most often going to be addressed by the name that's given in > your post headers. In this case "David" has been reduced to an > initial, and is visible only in your email address, whereas "Dwight" My sig says David, but it was just to let him know he can call me by my used name. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On 09/18/2012 10:10 PM, porkfried wrote: > I want to define a 'with' command that makes entries > in dictionary available within the local scope, and > stores new local variables into that dictionary. The > original scope should be restored on exit, and called > functions should not see anything special. Can I do this? No.* It is not possible to set locals by ways other than an assignment**, and it is certainly not possible to set locals in a scope other than the one you're in**. You should simply type out the dict's name. This is a lot clearer. If you want to minimize typing, you can give the variable a one-character name. Also, Python scope simply doesn't work like that. There is no block scope, only local (=function) scope, and global scope, with a dash of non-locals to spice things up a bit. > > my_dict = dict(a=1, b=2) > with MyScope(my_dict): > print "A", a, "B", b > x = 3 > print my_dict["x"] > print x # FAIL, unbound > *You could set global variables, and remove them on exit, but this is ugly for a number of reasons: this could overwrite existing globals if you're not very careful, called functions would see these globals, and they would also be exposed to other threads. **I believe there is actually a way to edit a caller's locals, but this is not documented, not portable across Python implementations and versions, and you couldn't create new locals like this, so it'd be fairly pointless here -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On Tuesday, September 18, 2012 4:10:32 PM UTC-4, porkfried wrote: > I want to define a 'with' command that makes entries > > in dictionary available within the local scope, and > > stores new local variables into that dictionary. The > > original scope should be restored on exit, and called > > functions should not see anything special. Can I do this? > > > > my_dict = dict(a=1, b=2) > > with MyScope(my_dict): > > print "A", a, "B", b > > x = 3 > > print my_dict["x"] > > print x # FAIL, unbound Well there's wired stuff like this: In [1]: locals()["x"] = 5 In [2]: print x 5 In [3]: but it didn't help me do what I wanted. -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On 09/18/2012 10:50 PM, [email protected] wrote: > Well there's wired stuff like this: > > In [1]: locals()["x"] = 5 > > In [2]: print x > 5 > No, there isn't. Modifying the dictionary returned by locals() has no effect. >>> def f (): ... locals()["x"] = 1 ... return x ... >>> f () Traceback (most recent call last): File "", line 1, in File "", line 3, in f NameError: global name 'x' is not defined >>> >>> locals()["x"] = 1 >>> x 1 >>> #this works because ... locals() is globals() True >>> The exception is the case when local scope is identical to global scope. In this case, locals() has globals() semantics. -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On 18/09/2012 21:10, porkfried wrote: I want to define a 'with' command that makes entries in dictionary available within the local scope, and stores new local variables into that dictionary. The original scope should be restored on exit, and called functions should not see anything special. Can I do this? my_dict = dict(a=1, b=2) with MyScope(my_dict): print "A", a, "B", b x = 3 print my_dict["x"] print x # FAIL, unbound If you could state what you're trying to achieve rather than how you're trying to achieve it then perhaps people could give you a solution to your problem. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
Terry Reedy於 2012年9月15日星期六UTC+8上午4時40分32秒寫道: > 2nd try, hit send button by mistake before > > > > On 9/14/2012 5:28 AM, Jean-Michel Pichavant wrote: > > > > > Decorators are very popular so I kinda already know that the fault is > > > mine. Now to the reason why I have troubles writing them, I don't > > > know. Every time I did use decorators, I spent way too much time > > > writing it (and debugging it). > > > > You are writing parameterized decorators, which require inverted > > currying of the wrapper maker. Perhaps that is why you have trouble. As > > I showed in response to Cameron, it may be easier to avoid that by using > > a traditional post-def wrapping call instead of decorator syntax. > > > > -- > > Terry Jan Reedy I'll give another example to show the decorators in python in versions above 2.4 . # a general function with the variable input : def fname( *argc, **argn) # a deco is a mapping from an input funtion to another function def deco( fn, *list_in, **dict_in): # use list_in and dict_in to modify fn """ deco wrapper """ # deco.__doc__ #print list_in, dict_in, " in the deco" def wrapper( fn, *argc, **argan): # to be returned as a function # do things one wants before calling fn result=fn(*argc, **argn) # call the original, save the result # do things after calling fn return result # enhance the wrapper and get info of fn wrapper.__doc__=fn.__doc__ # enhance wrapper with result, fn, list_in, dict_in # return wrapper def f1(): """ doc of f1""" print "inside f1" f2=deco(f1, 2,3,4,5,6, MSG="deco f1 to f2") f2() # invoke the decorated function from f1 # For a deco maps a deco to another deco can be done similarly -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 18/09/2012 21:40, Dwight Hutto wrote: You're most often going to be addressed by the name that's given in your post headers. In this case "David" has been reduced to an initial, and is visible only in your email address, whereas "Dwight" My sig says David, but it was just to let him know he can call me by my used name. Any particular him? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Fwd: Programming Issues
-- Forwarded message -- From: Nathan Spicer Date: Tue, Sep 18, 2012 at 8:32 PM Subject: Programming Issues To: [email protected] Hello, My name is Nathan Spicer. I'm taking a computer programming class using python. I have a project that's due in a week and I'm not certain how to d this. I'm totally new to this form of programming. I've stated the scope of the project below. Any form of help would be great. Ask the user for the amount of change expressed in cents. Your program must compute and display the number of half-dollars, quarters, dimes, nickels, and pennies to be returned. Return as many half-dollars as possible, then quarters, dimes, nickels, and pennies, in that order. Your program must allow the user to continue entering different amounts of change until they enter 0 to indicate they are finished. If the user enters a negative number, inform them of their mistake and ask them to enter a correct value. -Code that is formatted to be easy to read Thank you for your time, Nathan Spicer -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Tue, 18 Sep 2012 12:17:40 -0400, Dwight Hutto wrote: > You can call me David. I go by my middle name. If you want to be known as David, why do you give your name as Dwight? In your email client or newsreader, set your name as David and attributions will be to David, and people will know to call you David. Otherwise, people will continue to call you Dwight. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Programming Issues
On 09/18/2012 08:47 PM, Nathan Spicer wrote: > -- Forwarded message -- > From: Nathan Spicer > Date: Tue, Sep 18, 2012 at 8:32 PM > Subject: Programming Issues > To: [email protected] > > > Hello, > > My name is Nathan Spicer. I'm taking a computer programming class using > python. I have a project that's due in a week and I'm not certain how to d > this. I'm totally new to this form of programming. I've stated the scope of > the project below. Any form of help would be great. > > > Ask the user for the amount of change expressed in cents. Your program must > compute and display the number of half-dollars, quarters, dimes, nickels, > and pennies to be returned. > Return as many half-dollars as possible, then quarters, dimes, nickels, and > pennies, in that order. > Your program must allow the user to continue entering different amounts of > change until they enter 0 to indicate they are finished. If the user enters > a negative number, inform them of their mistake and ask them to enter a > correct value. > > -Code that is formatted to be easy to read > > Thank you for your time, > Nathan Spicer > > > What version of Python are you learning? And you're stuck where? There are lots of ways to ask a user a question, ranging from raw_input() to presenting a wxPython dialog box. The choice depends on what version you're using, and what GUI library if any you have available. Then you have to validate the string you get, and then do some computations, displaying the result. The whole thing needs to be inside a loop. Show us the code you've got so far, and indicate where the exception is happening, with full traceback. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On 9/18/2012 5:51 PM, Thomas Jollans wrote: On 09/18/2012 10:50 PM, [email protected] wrote: Well there's wired stuff like this: In [1]: locals()["x"] = 5 In [2]: print x 5 No, there isn't. Modifying the dictionary returned by locals() has no effect. Last time I tried it, it does within a class -- in cpython at least. That locals dict usually becomes the __dict__ of the class. But not to be depended on indefinitely and across implmentations. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On Thu, Sep 13, 2012 at 09:00:19AM -0700, andrea crotti wrote: > I have to give a couple of Python presentations in the next weeks, and > I'm still thinking what is the best approach. > > In one presentation for example I will present decorators and context > managers, and my biggest doubt is how much I should show and explain in > slides and how much in an interactive way (with ipython for example). FWIW, I gave a presentation on decorators to the New York Python User Group back in 2008. Relevant blog post: http://blogs.onresolve.com/?p=48 There's a link to the PowerPoint presentation I used in the first paragraph. It's in .pptx format; let me know if you'd like it in some other form. Regards, Trent. -- http://mail.python.org/mailman/listinfo/python-list
Re: User defined lexical scoping... can I do this?
On Tue, 18 Sep 2012 21:38:19 -0400, Terry Reedy wrote: > On 9/18/2012 5:51 PM, Thomas Jollans wrote: >> On 09/18/2012 10:50 PM, [email protected] wrote: >>> Well there's wired stuff like this: >>> >>> In [1]: locals()["x"] = 5 >>> >>> In [2]: print x >>> 5 >>> >>> >> No, there isn't. Modifying the dictionary returned by locals() has no >> effect. > > Last time I tried it, it does within a class -- in cpython at least. > That locals dict usually becomes the __dict__ of the class. But not to > be depended on indefinitely and across implmentations. Exactly. The behaviour of modifying the dict returned by locals() is not defined. For example, this is what happens under Python 2.6, Jython 2.5, and IronPython 2.6: steve@runes:~$ cat test.py a = b = 'global' def test(): a = None locals()['a'] = 'local' locals()['b'] = 'local' print a, b test() steve@runes:~$ python test.py None global steve@runes:~$ jython test.py None global steve@runes:~$ ipy test.py local global Other Python implementations may do differently. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: 'indent'ing Python in windows bat
> I'm converting windows bat files little by little to Python 3 as I find time > and learn Python. > The most efficient method for some lines is to call Python like: > python -c "import sys; sys.exit(3)" > > How do I "indent" if I have something like: > if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else > sys.exit(3) Some months ago I posted what I think is a similar question in the Unix world: I wanted to call a small portion of Python from within a Bash script. Someone on this list answered (for Bash): #!/bin/bash command1 command2 python -c "if True: import module if condition: do_this else: do_that " command4 # end code Perhaps something similar would work for a .bat file. -- http://mail.python.org/mailman/listinfo/python-list
python immersion
It's been several years since I announced this page the first time, so I feel like it's okay to announce it again, possibly introducing a few new people to Python's elegance and simplicity. This is my attempt to teach Python to programmers who have experience in other languages, using gentle immersion: http://wiki.python.org/moin/SimplePrograms -- http://mail.python.org/mailman/listinfo/python-list
iPhone App To Help You Learn Chinese (Mandarin) Faster By Using Flashcards With Pictures
http://goo.gl/lCAUy - "Chinese Flashcards with Pictures" is an iPhone app that will help you learn Chinese (Mandarin) faster by using flashcards with pictures (learn over 300 most commonly used words in the English / Chinese language from A to Z), thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: splitting numpy array unevenly
On 18/09/12 16:02:02, Wanderer wrote: > On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote: >> On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer wrote: >>> I need to divide a 512x512 image array with the first horizontal >>> and vertical division 49 pixels in. Then every 59 pixels in after >>> that. hsplit and vsplit want to start at the edges and create a >>> bunch of same size arrays. Is there a command to chop off >>> different sized arrays? >> I don't know that I follow completely, but can't you just slice >> what you are after? >> x = np.random.rand(512*512).reshape(512,512) >> xx = x[0,:49] >> And put the rest of the slices in a loop...? > I was trying to avoid the loop. I figured it out. hsplit and vsplit > will work. I just need to give it a list of break points. I still > need a loop though. > breakPoints = range(49,512,59) > rowArrays = hsplit(InputArray, breakPoints) > OutArrays = [] > for r in rowArrays: > OutArrays.append(vsplit(r, breakPoints)) How about a list display: breakPoints = range(49,512,59) rowArrays = hsplit(InputArray, breakPoints) OutArrays = [vsplit(r, breakPoints) for r in rowArrays] In some sense, it's still a loop, but at least it doesn't look like one. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
