Re: Find and Replace Simplification
On Friday, July 19, 2013 7:22:48 AM UTC-6, Devyn Collier Johnson wrote: > I have some code that I want to simplify. I know that a for-loop would > > work well, but can I make re.sub perform all of the below tasks at once, > or can I write this in a way that is more efficient than using a for-loop? > > DATA = re.sub(',', '', 'DATA') > DATA = re.sub('\'', '', 'DATA') > DATA = re.sub('(', '', 'DATA') > DATA = re.sub(')', '', 'DATA') Try DATA = re.sub(r'[(,\\)]', '', 'DATA') -- http://mail.python.org/mailman/listinfo/python-list
Re: Rant on web browsers
CoffeeScript maybe? http://jashkenas.github.com/coffee-script -- http://mail.python.org/mailman/listinfo/python-list
Re: Spurious issue in CPython 2.7.5
On Tuesday, May 24, 2016 at 5:47:55 AM UTC-6, thomas povtal.org wrote: ... >1: I get "RuntimeWarning: tp_compare didn't return -1 or -2 for >exception". It's a line like: > >"if Foo = False:" where Foo is a global variable (global Foo). ... Are you really using "if Foo = False:"? If so, it should be "if Foo == False:" "==" for equivalence rather than "=" for assignment. -- https://mail.python.org/mailman/listinfo/python-list
Re: Working with HTML5 documents
On Wednesday, November 19, 2014 2:08:27 PM UTC-7, Denis McMahon wrote: > So what I'm looking for is a method to create an html5 document using "dom > manipulation", ie: > > doc = new htmldocument(doctype="HTML") > html = new html5element("html") > doc.appendChild(html) > head = new html5element("body") > html.appendChild(head) > body = new html5element("body") > html.appendChild(body) > title = new html5element("title") > txt = new textnode("This Is The Title") > title.appendChild(txt) > head.appendChild(title) > para = new html5element("p") > txt = new textnode("This is some text.") > para.appendChild(txt) > body.appendChild(para) > > print(doc.serialise()) > > generates: > > This Is The Title head>This is some text. > > I'm finding various mechanisms to generate the structure from an existing > piece of html (eg html5lib, beautifulsoup etc) but I can't seem to find > any mechanism to generate, manipulate and produce html5 documents using > this dom manipulation approach. Where should I be looking? > > -- > Denis McMahon, Use a search engine (Google, DuckDuckGo etc) and search for 'python write html' -- https://mail.python.org/mailman/listinfo/python-list
Re: How can i use a dictionnary
On Tuesday, January 13, 2015 at 2:03:30 AM UTC-7, brice DORA wrote: > i consume a web service that return a element whose the type is "instance". > but this element seem be a dictionary but when i want to use it like a > dictionary, i got some errors. so this is the element and please someone can > tell me how can i use it. tkanks in advance. > > > (tCountryInfo){ >sISOCode = "CI" >sName = "Côte D'Ivoire (Ivory Coast)" >sCapitalCity = "Yamoussoukro" >sPhoneCode = "225" >sContinentCode = "AF" >sCurrencyISOCode = "XOF" >sCountryFlag = > "http://www.oorsprong.org/WebSamples.CountryInfo/Images/Côte D'Ivoire.jpg" >Languages = > (ArrayOftLanguage){ > tLanguage[] = > (tLanguage){ >sISOCode = "fr" >sName = "French" > }, > } > } This data is not a Python dictionary, nor is it a JSON object. You will probably need to code your own conversion function to make it a Python dictionary. -- https://mail.python.org/mailman/listinfo/python-list
Re: Martijn Faassen: The Call of Python 2.8
On Tuesday, April 15, 2014 12:32:14 PM UTC-6, Mark H. Harris wrote: > On 4/14/14 2:32 PM, Phil Dobbin wrote: > > On a related note, Guido announced today that there will be no 2.8 & > > that the eol for 2.7 will be 2020. > > > > Can you site the announcement? > > Thanks http://hg.python.org/peps/rev/76d43e52d978?utm_content=buffer55d59&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer -- https://mail.python.org/mailman/listinfo/python-list
Re: webware for python 3
On Monday, April 6, 2015 at 11:26:15 PM UTC-6, rah...@gmail.com wrote: > I have an old project which uses web ware, where i want to convert to latest > version 3.4 > > I am wondering whether any webware is available for python version 3.4. What > I am seeing is the webware version 1.1.1 which is old and seems like it is > not supporting the version 3.4 as I could see the print is written print abc > and no braces. > > So how should i approach converting this project which is based on python > 2.2.1 ? Some or all of what you need may already be done. See http://pythonpaste.org/wareweb/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Author of a Python Success Story Needs a Job!
Why is it so many, so called high tech companies, insist on the 19th century practice of demanding an employee's physical presence in a specific geographic location. This is the 21st century with climate change, carbon footprints, broadband internet, telecommuting, tele-presence, telephones, fax machines, mobile phones, electronic funds transfer, express shipping companies and a host of other gadgets and applications, that make geographic location almost irrelevant. I know whereof I speak, I have been fortunate enough to work remotely (across the country) for the last ten years, for two different employers. (possibly OT rant over) -- http://mail.python.org/mailman/listinfo/python-list
Re: Query about doing fortran-esque repeat formatting
How about: print ('%s ' + '%-5.4f ' * 7) % ('text',1,2,3,4,5,6,7) -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Way to extract Numbers from String
Regular expression are very powerful, and I use them a lot in my paying job (unfortunately not with Python). You are however, basically using a second programing language, which can be difficult to master. Does this give you the desired result? import re matches = re.findall('([\d\.,]+)\s*', code) for match in matches: print match resulting in this output: 43.150 43.200 43.130 43.290 43.100 7,450,447 -- http://mail.python.org/mailman/listinfo/python-list
Re: Use Regular Expressions to extract URL's
Or perhaps more generically: >>> import re >>> string = 'scatter "http://.yahoo.com quotes and text anywhere >>> www.google.com" "www.bing.com" or not' >>> print re.findall(r'(?:http://|www.)[^"\s]+',string) ['http://.yahoo.com', 'www.google.com', 'www.bing.com'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Need direction on mass find/replacement in HTML files
One single line regex solution would be: re.sub(r'http\://www.mysite.org/\?page=([^"]+)',r'pages/\1.htm',html) -- http://mail.python.org/mailman/listinfo/python-list
Re: rstrip()
On Jul 16, 10:58 am, Jason Friedman wrote: > $ python > Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55) > [GCC 4.4.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>> "x.vsd-dir".rstrip("-dir") > > 'x.vs' > > I expected 'x.vsd' as a return value. One way to achieve the desired result: 'x.vsd-dir'.split('-')[0] -- http://mail.python.org/mailman/listinfo/python-list