delete from pattern to pattern if it contains match
HI All, can you help me out in doing below. file: guava fruit mango fruit orange fruit need to delete from start to end if it contains mango in a file... output should be: guava fruit orange fruit Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: What iterable method should I use for Lists of Lists
> > You're getting very chatty with yourself, which is fine... but do you > need to quote your entire previous message every time? We really don't > need another copy of your XML file in every post. > > Thanks! > > ChrisA Oops sorry, everytime I posted I then thought of another resource and kept reading. I have a working messy solution hopefully I can resolve it to something nicer. Sayth -- https://mail.python.org/mailman/listinfo/python-list
buy ambien online overnight shipping cheapest ambien with quick delivery
Click here to buy ambien ! 100 % Highest Quality! Save Your Time and Money! http://ow.ly/101LRw Looking for ambien ? No problem! Click here to buy ambien online order ambien without prescription | overnight ambien without a prescription | buy cheap ambien no Prescription BIEN online purchase | cheap ambien no prescription next day delivery | cod delivery ambien ambien without perscription |buy ambien without prescription pay cod | ambien shipped with no prescription how to get ambien prescription | pharmacy ambien no prescrption | buy ambien without perscription no prescription ambien fedex delivery | buy cheapGET OVERNIGHT ambien | ambien OVERNIGHT | ambien CHEAP FEDEX DELIVERY |BUY ambien cheap cod | ambien without presciption | doctor shopping for ambien script __ Click here to buy ambien ! 100 % Highest Quality! Save Your Time and Money! http://ow.ly/101LRw ambien overnight fedex ambien overnight shipping order ambien overnight ambien fast shipping-usa ambien for sale how to get ambien online buy zolpidem online buy ambien online next day delivery buy ambien online overnight shipping cheapest ambien with quick delivery ambien overnight fedex __ -- https://mail.python.org/mailman/listinfo/python-list
Re: QWERTY was not designed to intentionally slow typists down (was: Unicode normalisation [was Re: [beginner] What's wrong?])
On Monday 18 April 2016 12:01, Random832 wrote: > On Sun, Apr 17, 2016, at 21:39, Steven D'Aprano wrote: >> Oh no, it's the thread that wouldn't die! *wink* >> >> Actually, yes it is. At least, according to this website: >> >> http://www.mit.edu/~jcb/Dvorak/history.html > > I'd really rather see an instance of the claim not associated with > Dvorak marketing. So would I, but this is hardly a Dvorak *marketing*. The author even points out that the famous case-study done by the US Navy was "biased, and at worst, fabricated". http://www.mit.edu/~jcb/Dvorak/ And he too repeats the canard that "Contrary to popular opinion" QWERTY wasn't designed to slow typists down. (Even though he later goes on to support the popular opinion.) You can also read the article in Reason magazine: http://reason.com/archives/1996/06/01/typing-errors You can skip the entire first page -- it is almost entirely a screed against government regulation and a defence of the all-mighty free-market. But the article goes through some fairly compelling evidence that Dvorak keyboards are barely more efficient that QWERTY, and that there was plenty of competition in type-writers in the late 1800s. I don't agree with the Reason article that they have disproven the conventional wisdom that QWERTY won the typewriter wars due to luck and path-dependence. The authors are (in my opinion) overly keen to dismiss path-dependence, for instance taking it as self-evidently true that the use of QWERTY in the US would have no influence over other countries' choice in key layout. But it does support the contention that, at the time, QWERTY was faster than the alternatives. Unfortunately, what it doesn't talk about is whether or not the alternate layouts had fewer jams. Wikipedia's article on QWERTY shows the various designs used by Sholes and Remington, leading to the modern layout https://en.wikipedia.org/wiki/QWERTY One serious problem for discussion is that the QWERTY keyboard we use now is *not* the same as that designed by Sholes. For instance, one anomaly is that two very common digraphs, ER and RE, are right next to each other. But that's not how Sholes laid out the keys. On his keyboard, the top row was initially AEI.?Y then changed to QWE.TY. Failure to recognise this leads to errors like this blogger's claim that it is "wrong" that QWERTY was designed to break apart common digraphs: http://yasuoka.blogspot.com.au/2006/08/sholes-discovered-that-many- english.html Even on a modern keyboard, out of the ten most common digraphs: th he in er an re nd at on nt only er/re use consecutive keys, and five out of the ten use alternate hands. Move the R back to its original position, and there are none with consecutive keys and seven with alternate hands. > It only holds up as an obvious inference from the > nature of how typing works if we assume *one*-finger hunt-and-peck > rather than two-finger. I don't agree, but neither can I prove it conclusively. > Your website describes two-finger as the method > that was being replaced by the 1878 introduction of ten-finger typing. > >> The QWERTY layout was first sold in 1873 while the first known use of >> ten-fingered typing was in 1878, and touch-typing wasn't invented for >> another decade, in 1888. > > Two-finger hunt-and-peck is sufficient for placing keys on opposite > hands to speed typing up rather than slow it down. Correct, once you take into account jamming. That's the whole point of separating the keys. But consider common letter combinations that can be typed by the one hand: QWERTY has a significant number of quite long words that can be typed with one hand, the *left* hand. That's actually quite harmful for both typing speed and accuracy. Anyway, you seem to have ignored (or perhaps you just have nothing to say) my comments about the home keys. It seems clear to me that even with two- finger typing, a layout that puts ETAOIN on the home keys, such as the Blickensderfer typewriter, would minimize the distance travelled by the fingers and improve typing speed -- but only so long as the problem of jamming was solved. Interestingly, Wikipedia makes it clear that in the 19th century, the problem of jamming arms was already solved by doing away with the arms and using a wheel or a ball. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy install error,need help its important
Τη Δευτέρα, 18 Απριλίου 2016 - 6:53:30 π.μ. UTC+3, ο χρήστης Xristos Xristoou
έγραψε:
> guys i have big proplem i want to install scipy
> but all time show me error
> i have python 2.7 and windows 10
> i try to use pip install scipy and i take that error
>
> raise NotFoundError('no lapack/blas resources found')
> numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
>
>
> Command "C:\Python27\python.exe -u -c "import setuptools,
> tokenize;__file__='c:\\users\\name\\appdata\\local\\temp\\pip-build-a3fjaf\\scipy\\setup.py';exec(compile(getattr(tokenize,
> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
> install --record
> c:\users\name\appdata\local\temp\pip-pgtkuz-record\install-record.txt
> --single-version-externally-managed --compile" failed with error code 1 in
> c:\users\name\appdata\local\temp\pip-build-a3fjaf\scipy\
yes i have idle python 2.7 before,must delete first before install anaconda
?how can anaconda packages to run with old idle ?because i have to many
packages in old python.
--
https://mail.python.org/mailman/listinfo/python-list
RE: delete from pattern to pattern if it contains match
Hi, Try to use the xml module. import xml.etree.ElementTree as ET That might help. BR Joaquin -Original Message- From: Python-list [mailto:[email protected]] On Behalf Of [email protected] Sent: 18 April 2016 08:08 To: [email protected] Subject: delete from pattern to pattern if it contains match HI All, can you help me out in doing below. file: guava fruit mango fruit orange fruit need to delete from start to end if it contains mango in a file... output should be: guava fruit orange fruit Thank you -- https://mail.python.org/mailman/listinfo/python-list This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python2.7 win64 --- cannot install the package of scipy
On 2016-04-16, [email protected] wrote: > I failed to install the package of scipy on Python2.7(win64). Have you tried anaconda python -- https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-4.0.0-Windows-x86_64.exe -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Steven D'Aprano : > One technique which is common in Pascal, but less so in Python, is to get > the best of both worlds by using nested functions. In Python syntax: > > def Do_The_Thing(): > def internal_subpart_start(): ... > def internal_subpart_middle(): ... > def internal_subpart_end(): ... > ... That really should be done more. C weaned us from the routine Pascal mechanism, but there's no reason not to exploit it again in Python. It also solves the problem of lugging the local context between internal functions, especially now that Python possesses the "nonlocal" keyword. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] Java generics
On 17 April 2016 at 23:38, Ian Kelly wrote: The diamond operator in JDK 7 makes this a lot more tolerable, IMO: The diamond notation helps slightly, but not very much. What would help a lot more would be something like C's typedef for giving aliases to type expressions. It's understandable that Java didn't originally have a typedef, because all types had short enough names anyway. But generics changed that in a big way, and it baffles me that some form of typedef wasn't added soon afterwards. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Marko Rauhamaa wrote: Steven D'Aprano : def Do_The_Thing(): def internal_subpart_start(): ... def internal_subpart_middle(): ... def internal_subpart_end(): ... ... That really should be done more. C weaned us from the routine Pascal mechanism, but there's no reason not to exploit it again in Python. Two things Python has that Pascal didn't are modules and classes. They take care of a lot of the grouping that you had to rely on nested functions for in Pascal. I do find myself nesting functions like that in Python, but only very occasionally. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: delete from pattern to pattern if it contains match
On Monday, April 18, 2016 at 1:19:43 PM UTC+5:30, Joaquin Alzola wrote: > Hi, > > Try to use the xml module. > > import xml.etree.ElementTree as ET > > That might help. > > BR > > Joaquin > > -Original Message- > > > HI All, > > can you help me out in doing below. > > file: > > guava > fruit > > > mango > fruit > > > orange > fruit > > > need to delete from start to end if it contains mango in a file... > > output should be: > > > guava > fruit > > > orange > fruit > > > Thank you > -- > https://mail.python.org/mailman/listinfo/python-list > This email is confidential and may be subject to privilege. If you are not > the intended recipient, please do not copy or disclose its content but > contact the sender immediately upon receipt. Hi Alzola, Still any easier way ?? -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Rustom Mody wrote: Come to think of it take an SQL DBMS browser. Should we say: Horizontal scrolls are BAD; just reformat the table after reaching 80 columns? I would say, yes, horizontal scrolling *is* bad in a table -- probably even worse than it is for text or code. The reason is that tables are usually laid out so that data items in a row are related to each other. You can't make sense of a piece of data in the table without seeing the other items in the same row. That's hard to do if you can't see the whole row at once. In fact much of the point of http://blog.languager.org/2012/10/layout-imperative-in-functional.html is just this: that as code becomes more and more data-ish, a more-lines-less-columns regime becomes correspondingly irksome. I draw the opposite conclusion. The more your code is laid out like a table, the more important it is to be able to see the whole width of it at once. Your Haskell lexer example looks all very nice in a good wide browser window. But reduce it so you can only see half of it at a time and then tell me how readable it is. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] Java generics
Gregory Ewing : > It's understandable that Java didn't originally have a typedef, > because all types had short enough names anyway. But generics changed > that in a big way, and it baffles me that some form of typedef wasn't > added soon afterwards. Java's opposition to typedef seems to be something fundamental and philosophical, although I don't exactly understand what. What people do then is they define classes and interfaces as typedefs, which is even worse. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Gregory Ewing : > Marko Rauhamaa wrote: >> Steven D'Aprano : >> >>>def Do_The_Thing(): >>>def internal_subpart_start(): ... >>>def internal_subpart_middle(): ... >>>def internal_subpart_end(): ... >>>... >> >> That really should be done more. C weaned us from the routine Pascal >> mechanism, but there's no reason not to exploit it again in Python. > > Two things Python has that Pascal didn't are modules and classes. They > take care of a lot of the grouping that you had to rely on nested > functions for in Pascal. I don't think Pascal did it for grouping or readability but for conceptual correctness. When I moved from Pascal to C, I felt the absence of local functions; it was a slight unease about abstraction leakage. > I do find myself nesting functions like that in Python, but only very > occasionally. Same for me. Essentially, I use local functions to register callbacks. Decades of C has done that to us. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: scipy install error,need help its important
On 18 April 2016 at 08:38, Xristos Xristoou wrote:
> Τη Δευτέρα, 18 Απριλίου 2016 - 6:53:30 π.μ. UTC+3, ο χρήστης Xristos Xristoou
> έγραψε:
>> guys i have big proplem i want to install scipy
>> but all time show me error
>> i have python 2.7 and windows 10
>> i try to use pip install scipy and i take that error
>>
>> raise NotFoundError('no lapack/blas resources found')
>> numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
>>
>
> yes i have idle python 2.7 before,must delete first before install anaconda
> ?how can anaconda packages to run with old idle ?because i have to many
> packages in old python.
Just install numpy and scipy from here (as already mentioned earlier
in the thread):
http://www.lfd.uci.edu/~gohlke/pythonlibs/
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
Re: QWERTY was not designed to intentionally slow typists down
Steven D'Aprano wrote: Even on a modern keyboard, out of the ten most common digraphs: th he in er an re nd at on nt only er/re use consecutive keys, Also keep in mind that E and R being adjacent on the keyboard does *not* mean they're adjacent in the type basket -- they're actually separated by two other characters (D and C). That's only one less than I and N (separated by U, J nd M). -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Python2.7 win64 --- cannot install the package of scipy
On 16 April 2016 at 22:53, wrote: > I failed to install the package of scipy on Python2.7(win64). > > 1. I tried the direct way that use cmd--pip install scripy. The result shows > that it failed with error code 1 in > c:\tyk\appdata\local\temp\pip-build-an9fye\scipy\. > > 2. I tried to install in another way. I download the > scipy-0.17.0-cp27-none-win_amd64.whl from Unofficial Windows Binaries for > Python Extension Packages. And use cmd to install that in the Scripts > direction, but still failed.(I have installed the package wheel already). The > result shows that scipy-0.17.0-cp27-none-win_amd64.whl is not a supported > wheel on this platform. That should be the right wheel if you have 64-bit Python 2.7 on Windows. Note that it's possible you have 32 bit Python even if the computer and Windows is 64-bit. It's also possible that you need to update pip. -- Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: What iterable method should I use for Lists of Lists
Sayth Renshaw wrote:
> Think I have a solution of sorts, although my numpy array failed, zip
> worked.
>
> from pyquery import PyQuery as pq
> import numpy as np
>
> d = pq(filename='20160319RHIL0_edit.xml')
> res = d('nomination')
> # myAt = pq.each(res.attr('bbid'))
> # print(repr(res))
> # myAt = [res.eq(i).attr('horse') for i in range(len(res))]
> # print(myAt)
>
> nomID = [res.eq(i).attr('id') for i in range(len(res))]
> horseName = [res.eq(i).attr('horse') for i in range(len(res))]
> zipped = zip(nomID, horseName)
>
> # yes = np.array(zipped)
> for items in zipped:
> print(items)
>
> In [8]: ('171115', 'Vergara')
> ('187674', 'Heavens Above')
> ('184732', 'Sweet Fire')
> ('181928', 'Alegria')
> ('158914', 'Piamimi')
> ('171408', 'Blendwell')
> ('166836', 'Adorabeel (NZ)')
> ('172933', 'Mary Lou')
> ('182533', 'Skyline Blush')
> ('171801', 'All Cerise')
> ('181079', 'Gust of Wind (NZ)')
>
> Still interested if there is a better to do this.
I don't know pyquery, so there may still be better ways. This is how far I
got with dir() and the common Python wisdom "Never use range(len(...))":
>>> import pyquery
>>> d = pyquery.PyQuery(filename="horse.xml")
>>> pairs = [(n.attrib["horse"], n.attrib["id"]) for n in d("nomination")]
>>> import pprint
>>> pprint.pprint(pairs)
[('Vergara', '171115'),
('Heavens Above', '187674'),
('Sweet Fire', '184732'),
('Alegria', '181928'),
('Piamimi', '158914'),
('Blendwell', '171408'),
('Adorabeel (NZ)', '166836'),
('Mary Lou', '172933'),
('Skyline Blush', '182533'),
('All Cerise', '171801'),
('Gust of Wind (NZ)', '181079')]
pprint is not really necessary, it just gives more readable output than
>>> pairs
[('Vergara', '171115'), ('Heavens Above', '187674'), ('Sweet Fire',
'184732'), ('Alegria', '181928'), ('Piamimi', '158914'), ('Blendwell',
'171408'), ('Adorabeel (NZ)', '166836'), ('Mary Lou', '172933'), ('Skyline
Blush', '182533'), ('All Cerise', '171801'), ('Gust of Wind (NZ)',
'181079')]
To extract more than one attribute operator.itemgetter comes in handy:
>>> from operator import itemgetter
>>> get = itemgetter("horse", "id", "saddlecloth")
>>> pprint.pprint([get(n.attrib) for n in d("nomination")])
[('Vergara', '171115', '4'),
('Heavens Above', '187674', '2'),
('Sweet Fire', '184732', '6'),
('Alegria', '181928', '7'),
('Piamimi', '158914', '11'),
('Blendwell', '171408', '10'),
('Adorabeel (NZ)', '166836', '3'),
('Mary Lou', '172933', '8'),
('Skyline Blush', '182533', '9'),
('All Cerise', '171801', '5'),
('Gust of Wind (NZ)', '181079', '1')]
If you need to do some post-processing use a helper function:
>>> def extract(n):
... attrib = n.attrib
... id = int(attrib["id"])
... name = attrib["horse"].upper()
... return id, name
...
>>> pprint.pprint([extract(n) for n in d("nomination")])
[(171115, 'VERGARA'),
(187674, 'HEAVENS ABOVE'),
(184732, 'SWEET FIRE'),
(181928, 'ALEGRIA'),
(158914, 'PIAMIMI'),
(171408, 'BLENDWELL'),
(166836, 'ADORABEEL (NZ)'),
(172933, 'MARY LOU'),
(182533, 'SKYLINE BLUSH'),
(171801, 'ALL CERISE'),
(181079, 'GUST OF WIND (NZ)')]
--
https://mail.python.org/mailman/listinfo/python-list
How to track files processed
Hi If you are parsing files in a directory what is the best way to record which files were actioned? So that if i re-parse the directory i only parse the new files in the directory? Thanks Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Monday, April 18, 2016 at 2:34:10 PM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > Come to think of it take an SQL DBMS browser. > > Should we say: Horizontal scrolls are BAD; just reformat the table after > > reaching 80 columns? > > I would say, yes, horizontal scrolling *is* bad in a table -- > probably even worse than it is for text or code. > > The reason is that tables are usually laid out so that > data items in a row are related to each other. You can't > make sense of a piece of data in the table without seeing > the other items in the same row. That's hard to do if > you can't see the whole row at once. "horizontal scrolling: BAD" + "Need to see whole row at once" How to reconcile these two? (Think of a 50 column table/spreadsheet) The only answer I know in DBMS lingo is "normalize" (refactor in programming lingo) which one way or other amounts to "Store some of those columns in your head" Obviously I am not against normalization when it actually cleans up I am against normalization just to reduce no of columns > > > In fact much of the point of > > http://blog.languager.org/2012/10/layout-imperative-in-functional.html > > is just this: that as code becomes more and more data-ish, > > a more-lines-less-columns regime becomes correspondingly irksome. > > I draw the opposite conclusion. The more your code is > laid out like a table, the more important it is to be > able to see the whole width of it at once. > > Your Haskell lexer example looks all very nice in a > good wide browser window. But reduce it so you can only > see half of it at a time and then tell me how readable > it is. Horrible. So what are we (if at all) disagreeing on? -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] Java generics (was: Guido sees the light: PEP 8 updated)
On 18 April 2016 at 09:30, Chris Angelico wrote: > On Mon, Apr 18, 2016 at 8:02 AM, Tim Delaney > wrote: > > I also wouldn't describe Java as a > > "perfectly good language" - it is at best a compromise language that just > > happened to be heavily promoted and accepted at the right time. > > > > Python is *much* closer to my idea of a perfectly good language. > > "Java" was originally four related, but separate, concepts: a source > language, a bytecode, a sandboxing system, and one other that I can't > now remember. I was very specifically referring to Java the language. The JVM is fairly nice, especially with the recent changes specifically aimed at more easily supporting dynamic languages. Speaking of JVM changes - I had to take over support of a chat applet developed by a contractor built on Java 1.0. We just could not get it to work reliably (this was for the original Foxtel web site - I remember trying to keep it up and running while Richard Fidler was doing a promoted chat session ...). Then Java 1.1 was released and what a huge improvement that was. Tim Delaney -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
2016-04-18 5:19 GMT+02:00 Steven D'Aprano :
> On Mon, 18 Apr 2016 11:39 am, Rustom Mody wrote:
>
>> yes we can agree on this -- arbitrary line lengths are almost certainly
>> unreadable.
>> The problem then becomes so what is optimal?
>
> I really don't think it is a problem. We have about 400 years
> of experience with printed text, and that experience tells us
> that the optimal width for reading prose in Western languages
> is about 60 characters, give or take. This width is optimal
> for eye movement, and minimizes the number of errors and
> reduces eye-strain.
>
> There's only so far that our eyes can follow a line to the
> right without increasing stress or reading errors, and
> likewise when returning back to the left margin. The longer
> the line, the higher the chance of losing track, and the
> physical effort it takes to read. (You have to move the eyes
> further, and for extremely long lines, you may have to move
> your entire head.)
>
> Long lines are simply harder to read because you have to
> move your eyes more, and the longer the lines, the greater
> the tendency to wander across the lines. Especially if the
> lines are close together and the height of the lines is
> small. (It boggles my mind how many programmers I've met who
> routinely view their code in tiny physical heights, even
> when reading it in fine detail.)
>
> The optimal width for eye-tracking (that is, the maximum
> width for which the rate of such errors can be disregarded)
> is somewhere about sixty characters per line.
>
> The same eye-tracking considerations apply to code, but:
>
> when it comes to code, we don't always have to track all the
> way back to the left-hand margin. If we start (say) up to
> twenty columns in, then we can afford to write up to twenty
> columns further to the right too.
>
>
> (Also, code tends to have VERY ragged right-hand margins.
> Not all lines end up even close to sixty characters wide.)
>
> There are other considerations though. Unlike prose, with
> code, shorter lines *may* sometimes force an increase in
> complexity. For instance, temporary variables need to be
> created, or new functions created, just to avoid otherwise
> excessively long lines. So one might be willing to accept a
> little more eye-movement for a little less code complexity.
>
> So allowing a total width of 80 (give or take) is already a
> compromise from the optimal sixty characters. This compromise
> allows for indented code, and allows up to 20 characters
> extra to avoid creating more complexity elsewhere.
>
>
> But there's another factor: long lines of code are themselves
> a code-smell. Perhaps:
>
> - you have indented too deeply, suggesting that your function
> is doing too much or has too much internal complexity:
>
> def func():
> if a:
> for b in seq:
> while c:
> with d:
> try:
> try:
> for e in it:
> block # only 48 columns available here
>
> (But note also that even with this extreme example, eight
> indentation levels deep, you can still fit almost
> characters per line without breaking the 80-char limit.
> You can do a lot in 50 characters.)
>
>
> - you have too many expressions on one line, suggesting that
> the over-all complexity of the line is excessive;
>
> - your variable or function names are needlessly verbose or
> are doing too much or are too specific
> ("calculate_number_of_pages_and_number_of_semicolons_in_chapter_one");
>
> - or you are violating the rule of Demeter:
> get(customer.trousers.pocket.wallet).open().money.pay(1)
>
>
> In other words, long lines of code are themselves an
> indication of poorly-designed code. Even though there are
> exceptions, we should resist strongly the urge to extend
> beyond the 60-80 (or perhaps 90 in extreme cases) limit.
> Whenever I hear people saying that they regularly need to
> use 100 or even 120 columns for their code, what I hear is
> "my code is badly written".
>
>
>
> --
> Steven
>
> --
> https://mail.python.org/mailman/listinfo/python-list
Excellent! Thank you for this contribution.
--
https://mail.python.org/mailman/listinfo/python-list
Re: How to track files processed
Sayth Renshaw wrote: > If you are parsing files in a directory what is the best way to record > which files were actioned? What do you do with the result of the parsing process? If you write it to another file you can just look if that file already exists. If you write it to a database there may be a specific record to look for. > So that if i re-parse the directory i only parse the new files in the > directory? Can you give some context? What are you trying to do? Is your application running all the time or would you like to invoke it, process new files and then terminate? -- https://mail.python.org/mailman/listinfo/python-list
ANN: Wing IDE 5.1.11 released
Hi, Wingware has released version 5.1.11 of Wing IDE, our cross-platform integrated development environment for the Python programming language. Wing IDE features a professional code editor with vi, emacs, visual studio, and other key bindings, auto-completion, call tips, context-sensitive auto-editing, goto-definition, find uses, refactoring, a powerful debugger, version control, unit testing, search, project management, and many other features. This release includes the following minor improvements: Fix Django template debugging for Django version 1.9 (requires 1.9.3+) Fix Debian package dependency for newer Linux distributions Fix git status when --use-porcelain is disabled with recent git versions Correctly find points of use of class attributes Added block commenting option for PEP8 style column 0 comment Fix analysis of extension modules when using Python 3.5 on Windows Sort alphabetically within type in Source Browser when using Sort by Type Fix problems with extra argument passing to unit test runners Several auto-editing fixes About 20 other bug fixes For details see http://wingware.com/news/2016-04-15 and http://wingware.com/pub/wingide/5.1.11/CHANGELOG.txt What's New in Wing 5.1: Wing IDE 5.1 adds multi-process and child process debugging, syntax highlighting in the shells, support for pytest, Find Symbol in Project, persistent time-stamped unit test results, auto-conversion of indents on paste, an XCode keyboard personality, support for Flask, Django 1.7, 1.8, and 1.9, Python 3.5 and recent Google App Engine versions, improved auto-completion for PyQt, recursive snippet invocation, and many other minor features and improvements. Free trial: http://wingware.com/wingide/trial Downloads: http://wingware.com/downloads Feature list: http://wingware.com/wingide/features Sales: http://wingware.com/store/purchase Upgrades: https://wingware.com/store/upgrade Questions? Don't hesitate to email us at [email protected]. Thanks, -- Stephan Deibel Wingware | Python IDE The Intelligent Development Environment for Python Programmers wingware.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Sat, Apr 16, 2016 at 8:25 PM, Terry Reedy wrote: > On 4/16/2016 12:58 PM, Larry Martell wrote: > >> On Sat, Apr 16, 2016 at 12:51 PM, Marko Rauhamaa >> wrote: >> >>> Larry Martell : >>> >>> I have worked for many companies where you are required to get a clean run of pep8 on your code before your pull request will even be considered for approval. I don't agree with this at all, as I think it makes the code very ugly, especially enforcing the max line length. >>> >>> Agh, I was with you until your last remark. >>> >>> A max line length of 79 characters is among the *only* rigorous >>> principles I judge coding style on. >>> >>> It comes with the maxim that one function must be visible at once on the >>> screen. >>> >> >> if we still had 1970's 80 character TTYs that would matter but on my >> 29" 1920x1080 screen it doesn't. >> > > It depends on whether one prefers to use the extra width to have long > lines or side-by-side windows. I prefer the latter. That's my use case as well, and why I admire the forethought in the width length. Side by side windows rock when doing TTD. -Sivan -- https://mail.python.org/mailman/listinfo/python-list
Re: Moderation and slight change of (de facto) policy
On Apr 17, 2016, at 06:08 PM, Matt Ruffalo wrote: >That seems like a reasonable approach, though I think there *really* >needs to be an option along the lines of "subscribed to the list for the >purposes of moderation, but not receiving list messages via email". We can do this effectively in Mailman 2.1 by adding the non-member to accept_these_nonmembers, and that's fairly easy to do from the admin page. Mailman 3 will make this more explicit by actually assigning a role of "nonmember" to the person, so as to be able to more granularly control their posting privileges. While we're starting to roll out some Mailman 3 lists, it will probably be a while before python-list is converted. Alternatively, individuals can subscribe to a mailing list and then disable delivery to their address. This essentially accomplishes the same thing, although for some lists, posts start out moderated until the person builds some positive reputation. Then the admin can turn off their moderation bit and their posts will go straight through. Cheers, -Barry -- https://mail.python.org/mailman/listinfo/python-list
Re: Moderation and slight change of (de facto) policy
On 2016-04-18, Barry Warsaw wrote: > On Apr 17, 2016, at 06:08 PM, Matt Ruffalo wrote: > >>That seems like a reasonable approach, though I think there *really* >>needs to be an option along the lines of "subscribed to the list for the >>purposes of moderation, but not receiving list messages via email". > Alternatively, individuals can subscribe to a mailing list and then disable > delivery to their address. AFAIR, all the mailing lists I've ever joined offer this setting, and I generally use it (I read all my mailing lists by pointing a NNTP client at news.gmane.org). If a mailing list doesn't allow to to disable delivery, then it's usually pretty trivial to set up a filter to toss all messages received from that list into /dev/null. -- Grant Edwards grant.b.edwardsYow! ... I want to perform at cranial activities with gmail.comTuesday Weld!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a hot vector (numpy)
Às 05:05 de 18-04-2016, Reto Brunner escreveu: > Hi, > It is called broadcasting an array, have a look here: > http://docs.scipy.org/doc/numpy-1.10.1/user/basics.broadcasting.html > So, there are two broadcasts here. OK. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to track files processed
Greetings,
>If you are parsing files in a directory what is the best way to
>record which files were actioned?
>
>So that if i re-parse the directory i only parse the new files in
>the directory?
How will you know that the files are new?
If a file has exactly the same content as another file, but a
different name, is it new?
Often this depends on the characteristics of the system in which
your (planned) software is operating.
Peter Otten has also asked for some more context, which would help
us give you some tips that are more targetted to the problem you are
trying to solve.
But, I'll just forge ahead and make some assumptions:
* You are watching a directory for new/changed files.
* New files are appearing regularly.
* Contents of old files get updated and you want to know.
Have you ever seen an MD5SUMS file? Do you know what a content hash
is? You could find a place to store the content hash (a.k.a.
digest) of each file that you process.
Below is a program that should work in Python2 and Python3. You
could use this sort of approach as part of your solution. In order
to make sure you have handled a file before, you should store and
compare two things.
1. The filename.
2. The content hash.
Note: If you are sure the content is not going to change, then just
use the filename to track whether you have handled something or not.
How would you use this tracking info ?
* Create a dictionary (or a set), e.g.:
handled = dict()
handled[('410c35da37b9a25d9b5d701753b011e5','setup.py')] = time.time()
Lasts only as long as the program runs. But, you will know
that you have handled any file by the tuple of its content hash
and filename.
* Store the filename (and/or digest) in a database. So many
options: sqlite, pickle, anydbm, text file of your own
crafting, SQLAlchemy ...
* Create a file, hardlink or symlink in the filesystem (in the
same directory or another directory), e.g.:
trackingfile = os.path.join('another-directory', 'setup.py')
with open(trackingfile, 'w') as f:
f.write('410c35da37b9a25d9b5d701753b011e5')
OR
os.symlink('setup.py', '410c35da37b9a25d9b5d701753b011e5-setup.py')
Now, you can also examine your little cache of handled files to
compare for when the content hash changes. If the system is an
automated system, then this can be perfectly fine. If humans
create the files, I would suggest not doing this. Humans tend
to be easily confused by such things (and then want to delete
the files or just be intimidated by them; scary hashes!).
There are lots of options, but without some more context, we can
only make generic suggestions. So, I'll stop with my generic
suggestions now.
Have fun and good luck!
-Martin
#! /usr/bin/python
from __future__ import print_function
import os
import sys
import logging
import hashlib
logformat = '%(levelname)-9s %(name)s %(filename)s#%(lineno)s ' \
+ '%(funcName)s %(message)s'
logging.basicConfig(stream=sys.stderr, format=logformat, level=logging.ERROR)
logger = logging.getLogger(__name__)
def hashthatfile(fname):
contenthash = hashlib.md5()
try:
with open(fname, 'rb') as f:
contenthash.update(f.read())
return contenthash.hexdigest()
except IOError as e:
logger.warning("See exception below; skipping file %s", fname)
logger.exception(e)
return None
def main(dirname):
for fname in os.listdir(dirname):
if not os.path.isfile(fname):
logger.debug("Skipping non-file %s", fname)
continue
logger.info("Found file %s", fname)
digest = hashthatfile(fname)
logger.info("Computed MD5 hash digest %s", digest)
print('%s %s' % (digest, fname,))
return os.EX_OK
if __name__ == '__main__':
if len(sys.argv) == 1:
sys.exit(main(os.getcwd()))
else:
sys.exit(main(sys.argv[1]))
# -- end of file
--
Martin A. Brown
http://linux-ip.net/
--
https://mail.python.org/mailman/listinfo/python-list
Re: Convert input to upper case on screen as it is typed
Ben Finney writes: > Ben Finney writes: > > > Okay, ‘termios.tcgetattr’ will let me preserve the attributes, and > > with Dan Sommers's suggestion of which attribute to use, I may have > > a shot at setting the terminal attributes. > > This works! Except, it doesn't. As designed and documented in the Single Unix Specification http://pubs.opengroup.org/onlinepubs/7908799/>, the behaviour of the OLCUC feature is: OLCUC Map lower case to upper on output. (LEGACY) http://pubs.opengroup.org/onlinepubs/7908799/xbd/termios.html> That ominous “LEGACY” annotation is applied, notably, to all the case-conversion features of ‘termios’. The mapping is ignorant of Unicode, ignorant of ANSI escape sequences; it blindly converts bytes via a mapping that assumes all bytes are ASCII text, regardless of whether those bytes actually represent text. It breaks the “visual bell” feature, among others. I end up with garbage on the screen, that would otherwise have been Unicode text or useful control sequences. > I had been hoping that I could simply wrap some stream in a simple > “convert what they actually type so it's upper case” text codec, > without fiddling at such a low operating-system specific level. This > is rather more esoteric than I had hoped. And, it turns out, doesn't address the requirements without causing more problems. I am still looking for a solution (a Python-specific one would be fine). -- \ “Anything that we scientists can do to weaken the hold of | `\religion should be done and may in the end be our greatest | _o__) contribution to civilization.” —Steven Weinberg | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Changing the meaning of bool.__invert__
On Sun, Apr 17, 2016 at 12:24 PM, Pavol Lisy wrote: > 2016-04-09 17:43 GMT+02:00, Steven D'Aprano : >> flag ^ flag is useful since we don't have a boolean-xor operator and >> bitwise-xor does the right thing for bools. And I suppose some people >> might prefer & and | over boolean-and and boolean-or because they're >> shorter and require less typing. I don't think that's a particularly >> good reason for using them, and as you say, you do have to guard >> against non-bools slipping, but Consenting Adults applies. > > They are also useful if you need to avoid short-circuit evaluation. One can easily write functions to do that. def long_or(a, b): """Equivalent to a or b but always evaluates both expressions.""" return a or b long_or(a, b) may not be as pretty as a | b, but I'll argue that it's more readable since it's up-front about its intent, whereas a | b looks like it could just be a mistake. -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Why is it that Python continues to use a fixed width font and therefore specifies the maximum line width as a character count? An essential part of the language is indentation which ought to continue to mandate that lines start with a multiple of 4 em worth of space (or some other size or encode with hard tabs, that is not germane to my question). The content of the line need not be bound by the rules needed to position its start. -- Pete Forman -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Mon, Apr 18, 2016 at 3:14 PM, Pete Forman wrote: > Why is it that Python continues to use a fixed width font and therefore > specifies the maximum line width as a character count? > > An essential part of the language is indentation which ought to continue > to mandate that lines start with a multiple of 4 em worth of space (or > some other size or encode with hard tabs, that is not germane to my > question). The content of the line need not be bound by the rules needed > to position its start. How many spaces is "4 em worth"? How would you incorporate that into the Python compiler or a linter without needing to know what particular font the programmer is using? What happens when another programmer reviews the code using a different font and finds that there is only 3.5em worth of space? Do we descend into Calibri / Verdana line-length edit wars? -- https://mail.python.org/mailman/listinfo/python-list
Re: I have been dealing with Python for a few weeks...
On 04/14/2016 10:12 PM, justin walters wrote: On Thu, Apr 14, 2016 at 1:50 PM, Fillmore wrote: ...and I'm loving it. Sooo much more elegant than Perl...and so much less going back to the manual to lookup the syntax of simple data structures and operations... REPL is so useful and you guys rock too cheers -- https://mail.python.org/mailman/listinfo/python-list Good to hear you're enjoying it. Out of curiosity, what were you using Perl for? I am a programmer by education but have not programmed in years. Sometimes I need to get my point across to people in my team that something can be done. The fact that I could prototype in Perl (now Python) certainly makes it harder for others to argue that this or that cannot be done in (java/PHP) or that it would take a disproportionate amount of time to carry out... Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: How to track files processed
Thank you Martin and Peter To clarify Peter at the moment only writing to csv but am wanting to set up an item pipeline to SQL db next. I will have a go at your examples Martin and see how i go. Thank you both for taking time to help. Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Ian Kelly writes: > On Mon, Apr 18, 2016 at 3:14 PM, Pete Forman wrote: >> Why is it that Python continues to use a fixed width font and >> therefore specifies the maximum line width as a character count? >> >> An essential part of the language is indentation which ought to >> continue to mandate that lines start with a multiple of 4 em worth of >> space (or some other size or encode with hard tabs, that is not >> germane to my question). The content of the line need not be bound by >> the rules needed to position its start. > > How many spaces is "4 em worth"? How would you incorporate that into > the Python compiler or a linter without needing to know what > particular font the programmer is using? What happens when another > programmer reviews the code using a different font and finds that > there is only 3.5em worth of space? Do we descend into Calibri / > Verdana line-length edit wars? 4 em is what PEP 8 implies, with the implicit use of a monospaced font. I was trying to convey that the mechanics of indentation was not relevant to my question about why Python and indeed other programming languages are rarely edited or viewed with proportional fonts. The programmer, other humans reading the source and the interpreter need to be able to discern structure by the indentation. It is what follows the indentation that interests me. The current Python interpreter will happily digest a combination of spaces and hard tabs as long as consistency rules are obeyed. My question was intended to concentrate on the presentation after the leading whitespace. -- Pete Forman -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Pete Forman writes: > Why is it that Python continues to use a fixed width font I think you know this isn't true. > and therefore specifies the maximum line width as a character count? and that this “therefore” is not justified by that. You've seen elsewhere the justification for *having* a maximum line width (primarily because of limits on human cognition of lines of text). As for what the limit *is*, it's much better to have an easy-to-apply and easy-to-measure rule, because consistent application is important for such a guide. Counting characters is objectively easy and easily comparable. -- \ “I think Western civilization is more enlightened precisely | `\ because we have learned how to ignore our religious leaders.” | _o__)—Bill Maher, 2003 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Why are my files in in my list - os module used with sys argv
Hi
Why would it be that my files are not being found in this script?
from pyquery import PyQuery as pq
import pandas as pd
import os
import sys
if len(sys.argv) == 2:
print("no params")
sys.exit(1)
dir = sys.argv[1]
mask = sys.argv[2]
files = os.listdir(dir)
fileResult = filter(lambda x: x.endswith(mask), files)
# d = pq(filename='20160319RHIL0_edit.xml')
data = []
for file in fileResult:
print(file)
for items in fileResult:
d = pq(filename=items)
res = d('nomination')
attrs = ('id', 'horse')
data = [[res.eq(i).attr(x) for x in attrs] for i in range(len(res))]
# from nominations
# res = d('nomination')
# nomID = [res.eq(i).attr('id') for i in range(len(res))]
# horseName = [res.eq(i).attr('horse') for i in range(len(res))]
# attrs = ('id', 'horse')
frames = pd.DataFrame(data)
print(frames)
I am running this from the bash prompt as
(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ python jqxml.py samples *.xml
my directory structure
(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ ls -a
. .. environment.yml .git .gitignore #jqxml.py# jqxml.py samples
and samples contains
(pyquery)sayth@sayth-E6410:~/Projects/pyquery/samples$ ls -a
. 20160319RHIL0_edit.xml 20160409RAND0.xml
.. 20160402RAND0.xml 20160416RAND0.xml
yet I get no files out of the print statement.
Ideas?
Sayth
--
https://mail.python.org/mailman/listinfo/python-list
Re: Why are my files in in my list - os module used with sys argv
On Tue, 19 Apr 2016 09:44 am, Sayth Renshaw wrote: > Hi > > Why would it be that my files are not being found in this script? You are calling the script with: python jqxml.py samples *.xml This does not do what you think it does: under Linux shells, the glob *.xml will be expanded by the shell. Fortunately, in your case, you have no files in the current directory matching the glob *.xml, so it is not expanded and the arguments your script receives are: "python jqxml.py" # not used "samples" # dir "*.xml" # mask You then call: fileResult = filter(lambda x: x.endswith(mask), files) which looks for file names which end with a literal string (asterisk, dot, x, m, l) in that order. You have no files that match that string. At the shell prompt, enter this: touch samples/junk\*.xml and run the script again, and you should see that it now matches one file. Instead, what you should do is: (1) Use the glob module: https://docs.python.org/2/library/glob.html https://docs.python.org/3/library/glob.html https://pymotw.com/2/glob/ https://pymotw.com/3/glob/ (2) When calling the script, avoid the shell expanding wildcards by escaping them or quoting them: python jqxml.py samples "*.xml" -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Why are my files in in my list - os module used with sys argv
On 2016-04-19 00:44, Sayth Renshaw wrote:
Hi
Why would it be that my files are not being found in this script?
from pyquery import PyQuery as pq
import pandas as pd
import os
import sys
if len(sys.argv) == 2:
print("no params")
sys.exit(1)
dir = sys.argv[1]
mask = sys.argv[2]
files = os.listdir(dir)
fileResult = filter(lambda x: x.endswith(mask), files)
# d = pq(filename='20160319RHIL0_edit.xml')
data = []
for file in fileResult:
print(file)
for items in fileResult:
d = pq(filename=items)
res = d('nomination')
attrs = ('id', 'horse')
data = [[res.eq(i).attr(x) for x in attrs] for i in range(len(res))]
# from nominations
# res = d('nomination')
# nomID = [res.eq(i).attr('id') for i in range(len(res))]
# horseName = [res.eq(i).attr('horse') for i in range(len(res))]
# attrs = ('id', 'horse')
frames = pd.DataFrame(data)
print(frames)
I am running this from the bash prompt as
(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ python jqxml.py samples *.xml
my directory structure
(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ ls -a
. .. environment.yml .git .gitignore #jqxml.py# jqxml.py samples
and samples contains
(pyquery)sayth@sayth-E6410:~/Projects/pyquery/samples$ ls -a
. 20160319RHIL0_edit.xml 20160409RAND0.xml
.. 20160402RAND0.xml 20160416RAND0.xml
yet I get no files out of the print statement.
Ideas?
I don't use Linux, but I think it might be a problem with what you have
on the command line. I believe that Linux expands wildcarded names, so
what you might be getting is "samples" followed by all the names in the
current directory that match "*.xml".
Even if that isn't the case, and mask is "*.xml", the filtering that
you're doing is asking for those names that end with "*.xml"; you might
find a name that ends with ".xml", but I doubt you'll ever find one that
ends with "*.xml"!
--
https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Monday, April 18, 2016 at 2:14:17 PM UTC-7, Pete Forman wrote: > Why is it that Python continues to use a fixed width font and therefore > specifies the maximum line width as a character count? > > An essential part of the language is indentation which ought to continue > to mandate that lines start with a multiple of 4 em worth of space (or > some other size or encode with hard tabs, that is not germane to my > question). The content of the line need not be bound by the rules needed > to position its start. > > -- > Pete Forman "Why is it that Python continues to use a fixed width font " This guy is trolling, right? -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Tuesday, April 19, 2016 at 6:49:34 AM UTC+5:30, sohcatoa wrote: > On Monday, April 18, 2016 at 2:14:17 PM UTC-7, Pete Forman wrote: > > Why is it that Python continues to use a fixed width font and therefore > > specifies the maximum line width as a character count? > > > > An essential part of the language is indentation which ought to continue > > to mandate that lines start with a multiple of 4 em worth of space (or > > some other size or encode with hard tabs, that is not germane to my > > question). The content of the line need not be bound by the rules needed > > to position its start. > > > > -- > > Pete Forman > > "Why is it that Python continues to use a fixed width font " > > This guy is trolling, right? See elastic tabstops: http://nickgravgaard.com/elastic-tabstops/ And more generally that programmers sticking to text when rest of world has moved on is rather backward: http://blog.languager.org/2012/10/html-is-why-mess-in-programming-syntax.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Mon, Apr 18, 2016, at 23:04, Rustom Mody wrote: > See elastic tabstops: http://nickgravgaard.com/elastic-tabstops/ >From there: >A column block is a run of uninterrupted vertically adjacent cells. How's that going to handle this case: if foo: # comment that is aligned do some stuff # across multiple indent levels As far as I can tell, the model being proposed would align the indented code either with the first line's comment, or somewhere after the colon. I think it's excessively "clever" to think you can or should use the same model to solve indentation as other forms of alignment. -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Tuesday, April 19, 2016 at 9:00:12 AM UTC+5:30, Random832 wrote: > On Mon, Apr 18, 2016, at 23:04, Rustom Mody wrote: > > See elastic tabstops: http://nickgravgaard.com/elastic-tabstops/ > > >From there: > >A column block is a run of uninterrupted vertically adjacent cells. > > How's that going to handle this case: > > if foo: # comment that is aligned > do some stuff # across multiple indent levels Just tried it with the jar file¹ he supplies and it seems to work Start no tabs: if foo# comment that is aligned do some stuff# across multiple indent levels Add tabs as leading indents with second line indented 1 tab more (showing tabs as |) |if foo# comment that is aligned ||do some stuff# across multiple indent levels Indent the first comment with 2 tabs At this point the first comment is/shows lefter than the second Indent the second with 1 tab -- the two #es now line up The invariant of course is clear -- if the total no of tabs in the line prior to the char are equal then all such lines line up ¹ yeah thats not very secure! And does not work with open java, works with Sun/Oracle java -- https://mail.python.org/mailman/listinfo/python-list
Re: delete from pattern to pattern if it contains match
On Monday, April 18, 2016 at 1:19:43 PM UTC+5:30, Joaquin Alzola wrote: > Hi, > > Try to use the xml module. > > import xml.etree.ElementTree as ET > > That might help. > > BR > > Joaquin > > -Original Message- > From: Python-list > [mailto:[email protected]] On Behalf > Of [email protected] > Sent: 18 April 2016 08:08 > To: [email protected] > Subject: delete from pattern to pattern if it contains match > > > HI All, > > can you help me out in doing below. > > file: > > guava > fruit > > > mango > fruit > > > orange > fruit > > > need to delete from start to end if it contains mango in a file... > > output should be: > > > guava > fruit > > > orange > fruit > > > Thank you > -- > https://mail.python.org/mailman/listinfo/python-list > This email is confidential and may be subject to privilege. If you are not > the intended recipient, please do not copy or disclose its content but > contact the sender immediately upon receipt. hi Alzola, xml parsing solution works fine only in the below case if input file is in below format. guava fruit mango fruit orange fruit its not working if the input file as below, just a change in the starting header... http://xmlns.jcp.org/xml/ns/javaee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"; version="3.1"> guava fruit mango fruit orange fruit inthis case its not working pls suggest what i have to do to make it work.. -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
On Mon, Apr 18, 2016, at 23:54, Rustom Mody wrote:
> Start no tabs:
> if foo# comment that is aligned
> do some stuff# across multiple indent levels
>
> Add tabs as leading indents with second line indented 1 tab more
> (showing tabs as |)
> |if foo# comment that is aligned
> ||do some stuff# across multiple indent levels
>
> Indent the first comment with 2 tabs
> At this point the first comment is/shows lefter than the second
>
> Indent the second with 1 tab -- the two #es now line up
Yeah but now the second line of code is to the right of the whole first
line of code. "if foo" must have been too short to illustrate it (it's
long enough if a tab is four spaces, but I guess it's longer in the
sample), but I assumed you would get the concept of what I was saying
and try putting something longer there or try extending the comments in
the C code the sample preloads.
Like, it ends up looking like this:
if foo("what if it's a much longer condition"):# comment
do something #
comment2
There's no way to get this:
if foo("what if it's a much longer condition"): # comment
do something # comment2
--
https://mail.python.org/mailman/listinfo/python-list
Re: error with tkinter, help
On Sunday, April 17, 2016 at 10:24:32 AM UTC-7, BlueRidiculous wrote: > On Sunday, April 17, 2016 at 10:18:09 AM UTC-7, BlueRidiculous wrote: > > On Saturday, April 16, 2016 at 9:30:39 PM UTC-7, Terry Reedy wrote: > > > On 4/16/2016 9:31 PM, [email protected] wrote: > > > > So I was reading https://wiki.python.org/moin/TkInter for help. > > > > I got to step 3 under "Checking your Tkinter support." > > > > Nothing happens when I do steps 1 or 2, and when I do step 3, > > > > I get this error: > > > > > > > > Traceback (most recent call last): > > > > File "", line 301, in runcode > > > > File "", line 1, in > > > > File "C:\Python34\lib\tkinter\__init__.py", line 3882, in _test > > > > root = Tk() > > > > File "C:\Python34\lib\tkinter\__init__.py", line 1856, in __init__ > > > > self.tk = _tkinter.create(screenName, baseName, className, > > > > interactive, wantobjects, useTk, sync, use) > > > > _tkinter.TclError: Can't find a usable init.tcl in the following > > > > directories: > > > > C:/Python34/lib/tcl8.6 C:/lib/tcl8.6 C:/lib/tcl8.6 C:/library > > > > C:/library C:/tcl8.6.1/library C:/tcl8.6.1/library > > > > > > > > This probably means that Tcl wasn't installed properly. > > > > " > > > > > > The directory list is obsolete. You should have C:/Python34/tcl > > > How did you install Python? The Windows PSF installer from python.org > > > will create this directory unless you uncheck the box to include tcl/tk. > > > > > > -- > > > Terry Jan Reedy > > > > What is a PSF installer? Anyway, I installed the "Windows x86 MSI > > installer" from https://www.python.org/downloads/release/python-344/ Is > > that correct? > > Actually nevermind, I uninstalled and reinstalled Python and it works now. I > remember I uninstalled and reinstalled before, and it worked, then stopped > working, so I'm not sure how permanent this fix will be. Stay tuned for > updates. Thanks again. So no need to "stay tuned for updates" anymore, it has been working for a day and I think that it is good now. If ever it breaks again, I'll just start a new thread. You guys can ignore this now. Thanks again to you guys for the help. -- https://mail.python.org/mailman/listinfo/python-list
Re: Guido sees the light: PEP 8 updated
Ian Kelly wrote: What happens when another programmer reviews the code using a different font and finds that there is only 3.5em worth of space? Do we descend into Calibri / Verdana line-length edit wars? That's easy, we just decree that all Python source code is to be displayed in this font: http://fontstruct.com/fontstructions/show/89341/flying_circus -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Convert input to upper case on screen as it is typed
Ben Finney wrote: I am still looking for a solution (a Python-specific one would be fine). The only other way I can think of is to put the tty into raw mode and do your own line editing and echoing. You could wrap it all up in a file-like object for the rest of the code to use. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Python packages for hydrology and DEM
I want to ask for hydrology python packages with complete function to calculate hydrology tasks like fill,flow direction,flow accumulator and more?or how can i find genetic algorithms for to do this tasks to finaly create a complete hydro model with python. can someone tell me some documentation to do that with python ? i want to find like this TopoToolbox from matlab in python using also i want to ask and for python psckage for digital elevation models calcultor like idw krigging spline and more...or some documentation for this or some genetic algorithm for this ty. -- https://mail.python.org/mailman/listinfo/python-list
