Re: How to become more motivated to learn Python
On 5/3/2016 10:55 PM, Cai Gengyang wrote: Guess it would be really cool to work on AI and games. ( I have been addicted to computer games for a long time lol --- To be able to design a blockbuster like Starcraft 2, Diablo 3 or Final Fantasy 7 would be an incredible feat !) In case you like minecraft, I just discovered this today https://www.nostarch.com/programwithminecraft "Learn to Program with Minecraft" It uses a socket client written in 3.5 to interface to a minecraft 1.8 socket server written in java 7. One can at least do simple things like move the player, identify and place blocks, and put text in the chat box. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Trouble porting glob bash behavior with argparse to windows shell
Thank you Peter. I was starting to flail and thought my use of glob.glob was wrong. As an aside should I be using os.path to negate system inconsistency? Thanks Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Trouble porting glob bash behavior with argparse to windows shell
Oops sorry noticed you did in the glob. Sorry squinting at phone. Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
Jussi Piitulainen wrote: Ceterum censeo, the only suggested use for .swapcase I've ever heard of is encryption. Yep, all the smart terrorists these days are using a combination of swapcase and rot13. Totally bamboozles the FBI. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
After a year using Node.js, the prodigal son returns
A year ago, Gavin Vickery decided to move away from Python and give Javascript with Node.js a try. Twelve months later, he has written about his experiences: http://geekforbrains.com/post/after-a-year-of-nodejs-in-production -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Analytical Geometry in Python with GeoMath
On Wednesday 04 May 2016 09:48, Vinicius Mesel wrote: > I created a library called "GeoMath" that it's intent is to solve all > Analytical Geometry problems in a simple way using Python. > > If you want to check it out, here is the link: > https://github.com/vmesel/GeoMath > > And if you want to install it and start solving your problems with it, > just run: pip install geomath! Can you show us some examples? -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
On Wednesday 04 May 2016 18:34, Gregory Ewing wrote: > Jussi Piitulainen wrote: >> Ceterum censeo, the only suggested use for .swapcase I've ever heard of >> is encryption. > > Yep, all the smart terrorists these days are using a > combination of swapcase and rot13. Totally bamboozles > the FBI. > Heh, the Australian government is getting their panties in a twist over the whole encryption thing, because Apple versus FBI proves that encryption is evil or something. Which lead to this exchange in the IRC channel we use at work: (handles have been removed to anonymize the discussion) : newsflash, most criminals are too stupid to use encryption : https://en.wikipedia.org/wiki/Mujahedeen_Secrets : It's hilarious, they turn off all the "western" ciphers : the great thing about Mujahedeen Secrets (apart fromt he crypto apparently being poor) is the cyphertext is trivially detectable : like "-BEGIN PGP MESSAGE-" but it's "-DEATH TO INFIDELS-" or something : so XKeyscore can just go "this person is using Mujahedeen Secrets" in their regular traffic matching : Wait, Mujahedeen Secrets was released anonymously, it has easily broken encryption and is trivially detectable? Can you say "schmuck bait"? I think I know who the authors were... -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: How to become more motivated to learn Python
Terry Reedy : > In case you like minecraft, I just discovered this today > https://www.nostarch.com/programwithminecraft "Learn to Program with > Minecraft" > > It uses a socket client written in 3.5 to interface to a minecraft 1.8 > socket server written in java 7. One can at least do simple things > like move the player, identify and place blocks, and put text in the > chat box. Hm, I think it would be more exciting to construct a small Python engine using redstone. (I actually went pretty far trying to build a tiny, functional CPU using redstone. I can tell you it's tedious work. Makes you appreciate the advances in transistor density in the past half-century. Too bad redstone is glitchy -- by design, I suppose. After your contraption becomes large enough, it keeps glitching out and you spend all your time debugging and repairing it.) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to become more motivated to learn Python
I tend to not have the patience to go through programming tutorials, because I think they're boring. I sometimes use them as reference to see or recall how something is done, but I don't step through them in order to learn a language. Rather, I write programs to learn programming and languages. It's easier if you have some background in programming in some other language. I merely pick personal projects that interest me and then try to develop them to finish. I seek resources that help me do what I need to. I think it's easier to be motivated in actual projects that interest you, rather than programming assignments. -Matti Cai Gengyang kirjoitti 2016-05-03 14:20: So I have completed up to CodeAcademy's Python Unit 2 , now moving on to Unit3 : Conditionals and Control Flow. But I feel my motivation wavering , at times I get stuck and frustrated when trying to learn a new programming language ? This might not be a technical question per say, but it is a Python programming related one. How do you motivate a person (either yourself or your child) to become more interested in programming and stick with it ? Is determination in learning (especially in a tough field like software) partly genetic ? Related , This is a very well written essay on determination by Paul Graham http://www.paulgraham.com/determination.html Gengyang -- https://mail.python.org/mailman/listinfo/python-list
Mentor Request
Hi Wanting to ask if there was anyone on the list that would like to be a mentor? I have no expectation that you would do it for free, so would accept fair offers as well monetary or skill trade, or something regional from Australia that you would otherwise not have access to etc. I want to be clear on what I am wanting and why. Wanting to learn. * Troubleshooting, reading and locating what the errors mean. This is a key area for me, I struggle to understand what I am doing wrong. * What's idiomatic and good practise, I keep finding code examples I doubt the quality of. In practical terms the things I want to do effectively. * Move, clean and obtain data from various sources scraped, streaming json/xml, xml/csv files. * Data into and out of Excel and SQL stores, best storage and use with pandas and bokeh/matplotlib/plotly other? (D3). * Present the data as interactive format flask or django or pyramid etc. About me I have completed codeacademy Python, Pluralsight python (Austin Bingham), flask projects in Real Python course and bits from various books online courses, conference videos etc. It's really point one, errors and troubleshooting which causes me the frustration, I feel like I am shooting in the dark, well except for Flask debug=true which seems to give fairly clear errors. I have several other orielly books and what not, but the examples never seem to relate to what you actually do in the real world. About me. Live in New South Wales Australia somewhat regional, closest local python group is 2 and a half hours away in Sydney. I am a coach in a financial company, also I do trend analysis with excel and sharepoint and write coaching, training and facilitation documentation. Note: I am a coach so if you accept to help, I wont be second guessing what tools, approach or actions to do, I know the key to learning is to accept you are learning and go with it. Thanks Sayth NB: Unless referred directly by someone common and known to this list I will not accept your offer, only members I have seen and post honestly and with a level of group trust will I accept. -- https://mail.python.org/mailman/listinfo/python-list
Re: Mentor Request
On Wed, May 4, 2016 at 8:51 PM, Sayth Renshaw wrote: > Wanting to ask if there was anyone on the list that would like to be a mentor? > > I have no expectation that you would do it for free, so would accept fair > offers as well monetary or skill trade, or something regional from Australia > that you would otherwise not have access to etc. > > I want to be clear on what I am wanting and why. > > Wanting to learn. > > * Troubleshooting, reading and locating what the errors mean. This is a key > area for me, I struggle to understand what I am doing wrong. > > * What's idiomatic and good practise, I keep finding code examples I doubt > the quality of. > > In practical terms the things I want to do effectively. > > * Move, clean and obtain data from various sources scraped, streaming > json/xml, xml/csv files. > > * Data into and out of Excel and SQL stores, best storage and use with pandas > and bokeh/matplotlib/plotly other? (D3). > > * Present the data as interactive format flask or django or pyramid etc. > This fits in nicely with the kinds of things I do. The usual arrangement is a regular (eg weekly) meeting via videoconference, for which I'd give you an invoice; in between times, you'd be studying/practising on your own. Code review is one of the most efficient uses of our time, so if you spend a few days or a week working on a piece of code, we can discuss the results of that. Contact me off-list if you're interested in more information, including the sordid details. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to become more motivated to learn Python
Beyond motivation, it's not likely just reading a flat text will be retained meaningfully without creative problem solving. Personal projects are the best route in my opinion. I like reading technical books but I figure I retain a small percentage of the specifics. On May 4, 2016 6:32 AM, "mviljamaa" wrote: > I tend to not have the patience to go through programming tutorials, > because I think they're boring. I sometimes use them as reference to see or > recall how something is done, but I don't step through them in order to > learn a language. > > Rather, I write programs to learn programming and languages. It's easier > if you have some background in programming in some other language. > > I merely pick personal projects that interest me and then try to develop > them to finish. I seek resources that help me do what I need to. > > I think it's easier to be motivated in actual projects that interest you, > rather than programming assignments. > > -Matti > > Cai Gengyang kirjoitti 2016-05-03 14:20: > >> So I have completed up to CodeAcademy's Python Unit 2 , now moving on >> to Unit3 : Conditionals and Control Flow. >> >> But I feel my motivation wavering , at times I get stuck and >> frustrated when trying to learn a new programming language ? >> >> This might not be a technical question per say, but it is a Python >> programming related one. How do you motivate a person (either yourself >> or your child) to become more interested in programming and stick with >> it ? Is determination in learning (especially in a tough field like >> software) partly genetic ? >> >> Related , This is a very well written essay on determination by Paul >> Graham >> >> http://www.paulgraham.com/determination.html >> >> Gengyang >> > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: After a year using Node.js, the prodigal son returns
On 2016-05-04, Steven D'Aprano wrote: > A year ago, Gavin Vickery decided to move away from Python and give > Javascript with Node.js a try. Twelve months later, he has written about his > experiences: > > http://geekforbrains.com/post/after-a-year-of-nodejs-in-production [Regarding Python] Its stood the test of time, has some great standards, libraries, its easy to debug and performs very well. Sure it has its worts. It even makes Beer! Talk about "batteries included"... -- Grant Edwards grant.b.edwardsYow! We are now enjoying at total mutual interaction in gmail.coman imaginary hot tub ... -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
On 5/3/2016 11:28 PM, Steven D'Aprano wrote: On Wed, 4 May 2016 12:49 am, Jussi Piitulainen wrote: DFS writes: On 5/3/2016 9:13 AM, Chris Angelico wrote: It doesn't invert, the way numeric negation does. What do you mean by 'case inverted'? It looks like it swaps the case correctly between upper and lower. There's letters that do not come in exact pairs of upper and lower case, Languages with two distinct lettercases, like English, are called bicameral. The two cases are technically called majuscule and minuscule, but colloquially known as uppercase and lowercase since movable type printers traditionally used to keep the majuscule letters in a drawer above the minuscule letters. Many alphabets are unicameral, that is, they only have a single lettercase. Examples include Hebrew, Arabic, Hangul, and many others. Georgian is an interesting example, as it is the only known written alphabet that started as a bicameral script and then became unicameral. Consequently, many letters are neither upper nor lower case, and have Unicode category "Letter other": py> c = u'\N{ARABIC LETTER FEH}' py> unicodedata.category(c) 'Lo' py> c.isalpha() True py> c.isupper() False py> c.islower() False Even among bicameral alphabets, there are a few anomalies. The three most obvious ones are Greek sigma, German Eszett (or "sharp S") and Turkish I. (1) The Greek sigma is usually written as Σ or σ in uppercase and lowercase respectively, but at the end of a word, lowercase sigma is written as ς. (This final sigma is sometimes called "stigma", but should not be confused with the archaic Greek letter stigma, which has two cases Ϛ ϛ, at least when it is not being written as digamma Ϝϝ -- and if you're confused, so are the Greeks :-) Python 3.3 correctly handles the sigma/final sigma when upper- and lowercasing: py> 'ΘΠΣΤΣ'.lower() 'θπστς' py> 'ΘΠΣΤΣ'.lower().upper() 'ΘΠΣΤΣ' (2) The German Eszett ß traditionally existed in only lowercase forms, but despite the existence of an uppercase form since at least the 19th century, when the Germans moved away from blackletter to Roman-style letters, the uppercase form was left out. In recent years, printers in Germany have started to reintroduce an uppercase version, and the German government have standardized on its use for placenames, but not other words. (Aside: in Germany, ß is not considered a distinct letter of the alphabet, but a ligature of ss; historically it derived from a ligature of ſs, ſz or ſʒ. The funny characters you may or may not be able to see are the long-S and round-Z.) Python follows common, but not universal, German practice for eszett: py> 'ẞ'.lower() 'ß' py> 'ß'.upper() 'SS' Note that this is lossy: given a name like "STRASSER", it is impossible to tell whether it should be title-cased to "Strasser" or "Straßer". It also means that uppercasing a string can make it longer. For more on the uppercase eszett, see: https://typography.guru/journal/germanys-new-character/ https://typography.guru/journal/how-to-draw-a-capital-sharp-s-r18/ (3) In most Latin alphabets, the lowercase i and j have a "tittle" diacritic on them, but not the uppercase forms I and J. Turkish and a few other languages have both I-with-tittle and I-without-tittle. (As far as I know, there is no language with a dotless J.) So in Turkish, the correct uppercase to lowercase and back again should go: Dotless I: I -> ı -> I Dotted I: İ -> i -> İ Python does not quite manage to handle this correctly for Turkish applications, since it loses the dotted/dotless distinction: py> 'ı'.upper() 'I' py> 'İ'.lower() 'i' and further case conversions follow the non-Turkish rules. Note that sometimes getting this wrong can have serious consequences: http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail Linguist much? -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
On Thu, May 5, 2016 at 12:09 AM, DFS wrote: > On 5/3/2016 11:28 PM, Steven D'Aprano wrote: >> [ lengthy piece about text, Unicode, and letter case ] > > Linguist much? As an English-only speaker who writes code that needs to be used around the world, you end up accruing tidbits of language and text trivia in the form of edge cases that you need to remember to test. Among them: * Turkish dotless and dotted i * Greek medial and final sigma * German eszett * Hebrew and Arabic right-to-left text * Chinese non-BMP characters * Combining characters (eg diacriticals starting U+0300) * Non-characters eg U+FFFE And then a post like Steven's basically comes from pulling up all those from your memory, and maybe doing a spot of quick testing and/or research to get some explanatory details. You don't have to be a linguist, necessarily - just a competent debugger. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Conditionals And Control Flows
I am trying to understand the boolean operator "and" in Python. It is supposed to return "True" when the expression on both sides of "and" are true For instance, 1 < 3 and 10 < 20 is True --- (because both statements are true) 1 < 5 and 5 > 12 is False --- (because both statements are false) bool_one = False and False --- This should give False because none of the statements are False bool_two = True and False --- This should give False because only 1 statement is True bool_three = False and True --- This should give False because only 1 statement is True bool_five = True and True --- This should give True because only 1 statement is True Am I correct ? -- https://mail.python.org/mailman/listinfo/python-list
Re: After a year using Node.js, the prodigal son returns
Grant Edwards writes: > On 2016-05-04, Steven D'Aprano wrote: >> A year ago, Gavin Vickery decided to move away from Python and give >> Javascript with Node.js a try. Twelve months later, he has written about his >> experiences: >> >> http://geekforbrains.com/post/after-a-year-of-nodejs-in-production > > [Regarding Python] > >Its stood the test of time, has some great standards, libraries, >its easy to debug and performs very well. Sure it has its worts. > > It even makes Beer! > > Talk about "batteries included"... Since _I_ didn't know this wort, let the joke not go missing: https://en.wikipedia.org/wiki/Wort Google asked if I meant "worst" :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
On Wed, May 4, 2016 at 10:46 AM Cai Gengyang wrote: > I am trying to understand the boolean operator "and" in Python. It is > supposed to return "True" when the expression on both sides of "and" are > true > Not exactly, because they will short-circuit. Take a look at the docs. ( https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not ) -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
On May 4, 2016 10:45 AM, "Cai Gengyang" wrote: > > I am trying to understand the boolean operator "and" in Python. It is supposed to return "True" when the expression on both sides of "and" are true > > For instance, > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > bool_one = False and False --- This should give False because none of the statements are False > bool_two = True and False --- This should give False because only 1 statement is True > bool_three = False and True --- This should give False because only 1 statement is True > bool_five = True and True --- This should give True because only 1 statement is True > > Am I correct ? Yes. Caveat : python Boolean operators return the value of the last argument necessary to determine the outcome. Example : 2 or 3 results in 2 2 and 3 results in 3. 0 and 3 results in 0. HTH. -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
On Thu, May 5, 2016 at 12:41 AM, Cai Gengyang wrote: > I am trying to understand the boolean operator "and" in Python. It is > supposed to return "True" when the expression on both sides of "and" are true > > For instance, > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > bool_one = False and False --- This should give False because none of the > statements are False > bool_two = True and False --- This should give False because only 1 statement > is True > bool_three = False and True --- This should give False because only 1 > statement is True > bool_five = True and True --- This should give True because only 1 statement > is True > > Am I correct ? Not entirely so, but very close. So long as you stick to the exact values True and False (or simple conditional expressions, like your examples), yes, that's what you'd get. The best way to try these out is the interactive interpreter. On Windows, look in your Start menu for "IDLE"; on other platforms, open up a terminal and type "python3". Then just start messing around: >>> 1 < 3 and 10 < 20 True >>> 1 < 5 and 5 > 12 False This is far and away the easiest way to learn how Python works. You can even play with some other things, and learn how Python's 'and' operator handles other types of data: >>> 1 and 4 4 >>> 0 and 3 0 Confused? Keep messing around. Build up a theory as to what's going on, test your theory, then go check your theory against the documentation. (Or come and ask here, if you can't find it in the docs.) Python doesn't mind how much you poke around with it, and you will learn ever so much more than we can explain! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
Cai Gengyang writes: > I am trying to understand the boolean operator "and" in Python. It is > supposed to return "True" when the expression on both sides of "and" > are true > > For instance, > > 1 < 3 and 10 < 20 is True --- (because both statements are true) Yes. > 1 < 5 and 5 > 12 is False --- (because both statements are false) No :) > bool_one = False and False --- This should give False because none of the > statements are False > bool_two = True and False --- This should give False because only 1 statement > is True > bool_three = False and True --- This should give False because only 1 > statement is True Yes. > bool_five = True and True --- This should give True because only 1 statement > is True No :) > Am I correct ? Somewhat. In a technical programming-language sense, these are "expressions", not "statements". Technically, if the first expression evaluates to a value that counts as true in Python, the compound expression "E and F" evaluates to the value of the second expression. Apart from False, "empty" values like 0, "", [] count as false in Python, and all the others count as true. But it's true that "E and F" only evaluates to a true value when both E and F evaluate to a true value. Your subject line is good: Python's "and" is indeed a conditional, control-flow operator. -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
Jussi Piitulainen writes: > Cai Gengyang writes: > >> I am trying to understand the boolean operator "and" in Python. It is >> supposed to return "True" when the expression on both sides of "and" >> are true >> >> For instance, >> >> 1 < 3 and 10 < 20 is True --- (because both statements are true) > > Yes. > >> 1 < 5 and 5 > 12 is False --- (because both statements are false) > > No :) > >> bool_one = False and False --- This should give False because none >> of the statements are False >> bool_two = True and False --- This should give False because only 1 >> statement is True >> bool_three = False and True --- This should give False because only >> 1 statement is True > > Yes. > >> bool_five = True and True --- This should give True because only 1 >> statement is True > > No :) > >> Am I correct ? > > Somewhat. Just an observation on the language... Change "only 1 statement" to "only statement 1" and you get much closer to a correct explanation. -- Ben. -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
Sorry I mistyped , this should be correct : bool_one = False and False --- This should give False because none of the statements are True bool_two = True and False --- This should give False because only 1 statement is True bool_three = False and True --- This should give False because only 1 statement is True bool_five = True and True --- This should give True because both statements are True On Wednesday, May 4, 2016 at 11:10:28 PM UTC+8, Jussi Piitulainen wrote: > Cai Gengyang writes: > > > I am trying to understand the boolean operator "and" in Python. It is > > supposed to return "True" when the expression on both sides of "and" > > are true > > > > For instance, > > > > 1 < 3 and 10 < 20 is True --- (because both statements are true) > > Yes. > > > 1 < 5 and 5 > 12 is False --- (because both statements are false) > > No :) > > > bool_one = False and False --- This should give False because none of the > > statements are False > > bool_two = True and False --- This should give False because only 1 > > statement is True > > bool_three = False and True --- This should give False because only 1 > > statement is True > > Yes. > > > bool_five = True and True --- This should give True because only 1 > > statement is True > > No :) > > > Am I correct ? > > Somewhat. > > In a technical programming-language sense, these are "expressions", not > "statements". Technically, if the first expression evaluates to a value > that counts as true in Python, the compound expression "E and F" > evaluates to the value of the second expression. > > Apart from False, "empty" values like 0, "", [] count as false in > Python, and all the others count as true. > > But it's true that "E and F" only evaluates to a true value when both E > and F evaluate to a true value. > > Your subject line is good: Python's "and" is indeed a conditional, > control-flow operator. -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
On Thu, 5 May 2016 12:09 am, DFS wrote: > On 5/3/2016 11:28 PM, Steven D'Aprano wrote: >> Languages with two distinct lettercases, like English, are called >> bicameral. [...] > Linguist much? Possibly even a cunning one. Somebody-had-to-say-it-ly y'rs, -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Mentor Request
Sayth Renshaw writes: > Live in New South Wales Australia somewhat regional, closest local > python group is 2 and a half hours away in Sydney. Try here: https://wiki.hackerspaces.org/RoboDojo -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
Cai Gengyang writes: > Sorry I mistyped , this should be correct : > > bool_one = False and False --- This should give False because none of the > statements are True > bool_two = True and False --- This should give False because only 1 statement > is True > bool_three = False and True --- This should give False because only 1 > statement is True > bool_five = True and True --- This should give True because both statements > are True Yes. (That is, afterwards bool_one, bool_two, ... evaluate to the stated truth values, for the stated reasons.) -- https://mail.python.org/mailman/listinfo/python-list
Re: Analytical Geometry in Python with GeoMath
Yes sure, To add a point, you do: From geomath import point A = point.Point(x,y) A.distance(PointB) A.mispoint(PointB) A.quadrant() To make usage of the Figure class From geomath import figure Square = figure.Figure() Square.addpoints(pointA, PointB, PointC, PointD) To make use of the line class From geomath import line Line = line.Line(PointA, PointB ) Line.equation() These are some basic functions, the others we are still implementing. Tnx, Vinicius Mesel > Em 4 de mai de 2016, às 6:08 AM, Steven D'Aprano > escreveu: > >> On Wednesday 04 May 2016 09:48, Vinicius Mesel wrote: >> >> I created a library called "GeoMath" that it's intent is to solve all >> Analytical Geometry problems in a simple way using Python. >> >> If you want to check it out, here is the link: >> https://github.com/vmesel/GeoMath >> >> And if you want to install it and start solving your problems with it, >> just run: pip install geomath! > > > Can you show us some examples? > > > > -- > Steve > > -- https://mail.python.org/mailman/listinfo/python-list
Re: After a year using Node.js, the prodigal son returns
On Wednesday, May 4, 2016 at 1:59:15 AM UTC-7, Steven D'Aprano wrote: > A year ago, Gavin Vickery decided to move away from Python and give > Javascript with Node.js a try. Twelve months later, he has written about his > experiences: > > > http://geekforbrains.com/post/after-a-year-of-nodejs-in-production > > > > -- > Steve "Packages that consist of trivial code no more than 10 lines of code are downloaded in the thousands every day from NPM." *cough* left-pad *cough* -- https://mail.python.org/mailman/listinfo/python-list
Interacting with Subprocesses
I am attempting to write a Python program that will interact with a (non-Python) process. The programs will run under MinGW. The process can use stdin/stdout commands and responses and can work with pipes. The problem I'm having is that I can't find any way in Python to have a continuing dialog with the process. I have tried Popen communicate, but that protocol seems to be limited to a single message/response pair, and the response is not returned to the message originator until the process terminates. Unfortunately I don't have access to the process' source code so I can't change the communication medium. Is there some feature that will allow me to initiate the process and execute multiple message/response pairs between the Python program and the process during a single execution of the process? Thanks! Dick -- https://mail.python.org/mailman/listinfo/python-list
Re: Conditionals And Control Flows
On Wed, May 4, 2016, at 07:41 AM, Cai Gengyang wrote: > I am trying to understand the boolean operator "and" in Python. It is > supposed to return "True" when the expression on both sides of "and" are > true The thing is, its kinda dubious to think of 'and' as a 'boolean operator', because once you go down that road, some people start wanting it to be a *pure* boolean operator. Something that always returns True or False. Instead, 'and' and 'or' return something that is true, or something that is false. Notice the lower case. (I know the docs call them Boolean Operations, but I still think saying 'boolean' is unhelpful) Python defines false things as False, None, 0 (of any numeric type), an empty container (lists, tuples, mappings, something else that defines __len__ and it returns 0), and instances of classes that define __nonzero__ that return 0 or False. Everything else is a true thing. If you see "x and y", the rule is: if x is a false thing, it'll return something false. As it happens, it has x handy, and since its decided x is false, it'll return that. Therefore, "x and y" is false. If x is true, though, it'll return y. In this case, "x and y" will be a true thing if y is a true thing, and a false thing if y is a false thing. As you can see, all of this logic happens without ever using True or False. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list
Re: Analytical Geometry in Python with GeoMath
On 05/04/2016 01:48 AM, Vinicius Mesel wrote: f you want to check it out, here is the link:https://github.com/vmesel/GeoMath Thanks! What differences will your package have with shapely? https://github.com/Toblerity/Shapely Cheers Fabien -- https://mail.python.org/mailman/listinfo/python-list
windows 7 install trouble
hello, could someone please help. I had installed python 3.? on my computer. it had issues. so i tried to uninstall and it wouldn't. so i deleted all the files and used microsoft fixit to uninstall. that worked. but i now can't re-install it. on the off chance it was firewall related, tried all combinations of firewall. here are the links to the error logs. any help would be appreciated. -eric https://docs.google.com/document/d/1V_1BrmKdCMOwXH9Lt4Zl2xlXp8wkM-sjcrteSRzkucM/pub Python 3.5.1 (32-bit)_20160503210453_000_core_JustForMe.log | | -- https://mail.python.org/mailman/listinfo/python-list
Re: Interacting with Subprocesses
Dick Holmes writes: > I am attempting to write a Python program that will interact with > a (non-Python) process. The programs will run under MinGW. The > process can use stdin/stdout commands and responses and can work > with pipes. The problem I'm having is that I can't find any > way in Python to have a continuing dialog with the process. I > have tried Popen communicate, but that protocol seems to be > limited to a single message/response pair, and the response > is not returned to the message originator until the process > terminates. Unfortunately I don't have access to the process' > source code so I can't change the communication medium. > > Is there some feature that will allow me to initiate the process > and execute multiple message/response pairs between the Python > program and the process during a single execution of the process? > Pass stdin=PIPE, stdout=PIPE and use p.stdin, p.stdout file objects to write input, read output from the child process. Beware, there could be buffering issues or the child process may change its behavior some other way when the standard input/output streams are redirected. See http://pexpect.readthedocs.io/en/stable/FAQ.html#whynotpipe btw, If pexpect module works in MingGW environment (if pty is available); you could try it to communicate with the process interactively. You might also find the list of Stackoverflow question related to the subprocess module useful http://stackoverflow.com/tags/subprocess/info Akira -- https://mail.python.org/mailman/listinfo/python-list
Re: Not x.islower() has different output than x.isupper() in list output...
On 5/4/2016 11:37 AM, Steven D'Aprano wrote: On Thu, 5 May 2016 12:09 am, DFS wrote: On 5/3/2016 11:28 PM, Steven D'Aprano wrote: Languages with two distinct lettercases, like English, are called bicameral. [...] Linguist much? Possibly even a cunning one. I see you as more of a Colonel Angus. -- https://mail.python.org/mailman/listinfo/python-list
No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access
Both of the following python commands successfully create a SQLite3 datafile which crashes Access 2003 immediately upon trying to open it (via an ODBC linked table). import sqlite3 conn = sqlite3.connect("dfile.db") import pyodbc conn = pyodbc.connect('Driver={SQLite3 ODBC Driver};Database=dfile.db') The file is created, a table is added, I add rows to the table in code, etc., and it can be read by 'DB Browser for SQLite' so it's a valid SQLite3 database, but Access won't read it. I can create and store a link to the table - using that ODBC driver - but as soon as I try to open it: "Microsoft Access has stopped working" On the other hand, a SQLite3 file created in VBScript, using the same ODBC driver, /is/ readable with Access 2003: Set conn = CreateObject("ADODB.Connection") conn.Open "Driver={SQLite3 ODBC Driver};Database=dfile.db;" python 2.7.11, pyodbc 3.0.6, ODBC driver, and Access 2003: all 32-bit OS is Win8.1Pro 64-bit. I can't find anything on the web. Any ideas? Thanks -- https://mail.python.org/mailman/listinfo/python-list
[ANN] Aenum 1.4.1
aenum 1.4.1 Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants aenum includes a Python stdlib Enum-compatible data type, as well as a metaclass-based NamedTuple implementation and a NamedConstant class. An Enum is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over. If using Python 3 there is built-in support for unique values, multiple values, auto-numbering, and suspension of aliasing (members with the same value are not identical), plus the ability to have values automatically bound to attributes. A NamedTuple is a class-based, fixed-length tuple with a name for each possible position accessible using attribute-access notation as well as the standard index notation. A NamedConstant is a class whose members cannot be rebound; it lacks all other Enum capabilities, however; consequently, it can have duplicate values. Utility functions include: - skip: class that prevents attributes from being converted to a constant or enum member - module: inserts NamedConstant and Enum classes into sys.modules where it will appear to be a module whose top-level names cannot be rebound - extend_enum: add new members to enumerations after creation - enum: helper class for creating members with keywords - constant: helper class for creating constant members https://pypi.python.org/pypi/aenum https://bitbucket.org/stoneleaf/aenum -- https://mail.python.org/mailman/listinfo/python-list
Re: Interacting with Subprocesses
On 5/4/2016 2:41 PM, Dick Holmes wrote: I am attempting to write a Python program that will interact with a (non-Python) process. The programs will run under MinGW. The process can use stdin/stdout commands and responses and can work with pipes. The problem I'm having is that I can't find any way in Python to have a continuing dialog with the process. I have tried Popen communicate, but that protocol seems to be limited to a single message/response pair, and the response is not returned to the message originator until the process terminates. Unfortunately I don't have access to the process' source code so I can't change the communication medium. Is there some feature that will allow me to initiate the process and execute multiple message/response pairs between the Python program and the process during a single execution of the process? I have been told that multiprocessing works better for this. Not sure is true. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Interacting with Subprocesses
Terry Reedy writes: > On 5/4/2016 2:41 PM, Dick Holmes wrote: >> I am attempting to write a Python program that will interact with >> a (non-Python) process. The programs will run under MinGW. The >> process can use stdin/stdout commands and responses and can work >> with pipes. The problem I'm having is that I can't find any >> way in Python to have a continuing dialog with the process. I >> have tried Popen communicate, but that protocol seems to be >> limited to a single message/response pair, and the response >> is not returned to the message originator until the process >> terminates. Unfortunately I don't have access to the process' >> source code so I can't change the communication medium. >> >> Is there some feature that will allow me to initiate the process >> and execute multiple message/response pairs between the Python >> program and the process during a single execution of the process? > > I have been told that multiprocessing works better for this. Not sure > is true. OP wants to interact with a *non-Python* process—*multiprocessing* module won't help here. -- https://mail.python.org/mailman/listinfo/python-list
Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access
On Wed, May 4, 2016, at 03:46 PM, DFS wrote: > I can't find anything on the web. Have you tried: http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users If you really must access it over a newsgroup, you can use the Gmane mirror: http://gmane.org/info.php?group=gmane.comp.db.sqlite.general > Any ideas? Sorry, I don't use Access. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list
Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access
On Wed, May 4, 2016, 6:51 PM DFS wrote: > Both of the following python commands successfully create a SQLite3 > datafile which crashes Access 2003 immediately upon trying to open it > (via an ODBC linked table). > Have you tried using Access 2013? On the other hand, a SQLite3 file created in VBScript, using the same > ODBC driver, /is/ readable with Access 2003 Microsoft is pretty intense about backwards compatibility, sometimes even staying compatibile with old bugs. Not saying that's the case here, but it wouldn't surprise me. > -- https://mail.python.org/mailman/listinfo/python-list
Whittle it on down
Want to whittle a list like this: [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'www.custombuiltpt.com/', 'RACQUETBALL COURTS PRIVATE', 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS', '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact Us', 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] down to ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] Want to keep all elements containing only upper case letters or upper case letters and ampersand (where ampersand is surrounded by spaces) Is it easier to extract elements meeting those conditions, or remove elements meeting the following conditions: * elements with a lower-case letter in them * elements with a number in them * elements with a period in them ? So far all I figured out is remove items with a period: newlist = [ x for x in oldlist if "." not in x ] Thanks for help, python gurus. -- https://mail.python.org/mailman/listinfo/python-list
Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access
On 5/4/2016 10:02 PM, Stephen Hansen wrote: On Wed, May 4, 2016, at 03:46 PM, DFS wrote: I can't find anything on the web. Have you tried: http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users If you really must access it over a newsgroup, you can use the Gmane mirror: http://gmane.org/info.php?group=gmane.comp.db.sqlite.general Thanks Any ideas? Sorry, I don't use Access. -- https://mail.python.org/mailman/listinfo/python-list
Re: Whittle it on down
On Wed, May 4, 2016, at 09:58 PM, DFS wrote: > Want to whittle a list like this: > > [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & > Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', > 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', > 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', > 'www.custombuiltpt.com/', 'RACQUETBALL COURTS PRIVATE', > 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', > 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', 'www.lafitness.com', > 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & > PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & > GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS', > '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact Us', > 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', > 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] > > down to > > ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', > 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', > 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS > TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS > PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS > & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] Sometimes regular expressions are the tool to do the job: Given: >>> input = [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & >>> Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', >>> 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH >>> CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'www.custombuiltpt.com/', >>> 'RACQUETBALL COURTS PRIVATE', 'www.lafitness.com', 'GYMNASIUMS', 'HEALTH & >>> FITNESS CLUBS', 'www.lafitness.com', 'HEALTH & FITNESS CLUBS', >>> 'www.lafitness.com', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & >>> GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', >>> 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS >>> TRAINERS', '5', '4', '3', '2', '1', 'Yellow Pages', 'About Us', 'Contact >>> Us', 'Support', 'Terms of Use', 'Privacy Policy', 'Advertise With Us', >>> 'Add/Update Listing', 'Business Profile Login', 'F.A.Q.'] Then: >>> pattern = re.compile(r"^[A-Z\s&]+$") >>> output = [x for x in list if pattern.match(x)] >>> output ['PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'RACQUETBALL COURTS PRIVATE', 'GYMNASIUMS', 'HEALTH & FITNESS CLUBS', 'HEALTH & FITNESS CLUBS', 'PERSONAL FITNESS TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'EXERCISE & PHYSICAL FITNESS PROGRAMS', 'FITNESS CENTERS', 'HEALTH CLUBS & GYMNASIUMS', 'HEALTH CLUBS & GYMNASIUMS', 'PERSONAL FITNESS TRAINERS'] -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list
Re: Whittle it on down
DFS writes: . . > Want to keep all elements containing only upper case letters or upper > case letters and ampersand (where ampersand is surrounded by spaces) > > Is it easier to extract elements meeting those conditions, or remove > elements meeting the following conditions: > > * elements with a lower-case letter in them > * elements with a number in them > * elements with a period in them > > ? > > > So far all I figured out is remove items with a period: > newlist = [ x for x in oldlist if "." not in x ] > Either way is easy to approximate with a regex: import re upper = re.compile(r'[A-Z &]+') lower = re.compile(r'[^A-Z &]') print([datum for datum in data if upper.fullmatch(datum)]) print([datum for datum in data if not lower.search(datum)]) I've skipped testing that the ampersand is between spaces, and I've skipped the period. Adjust. This considers only ASCII upper case letters. You can add individual letters that matter to you, or you can reach for the documentation to find if there is some generic notation for all upper case letters. The newer regex package on PyPI supports POSIX character classes like [:upper:], I think, and there may or may not be notation for Unicode character categories in re or regex - LU would be Letter, Uppercase. -- https://mail.python.org/mailman/listinfo/python-list
Re: Whittle it on down
On Thursday 05 May 2016 14:58, DFS wrote: > Want to whittle a list like this: [...] > Want to keep all elements containing only upper case letters or upper > case letters and ampersand (where ampersand is surrounded by spaces) Start by writing a function or a regex that will distinguish strings that match your conditions from those that don't. A regex might be faster, but here's a function version. def isupperalpha(string): return string.isalpha() and string.isupper() def check(string): if isupperalpha(string): return True parts = string.split("&") if len(parts) < 2: return False # Don't strip leading spaces from the start of the string. parts[0] = parts[0].rstrip(" ") # Or trailing spaces from the end of the string. parts[-1] = parts[-1].lstrip(" ") # But strip leading and trailing spaces from the middle parts # (if any). for i in range(1, len(parts)-1): parts[i] = parts[i].strip(" ") return all(isupperalpha(part) for part in parts) Now you have two ways of filtering this. The obvious way is to extract elements which meet the condition. Here are two ways: # List comprehension. newlist = [item for item in oldlist if check(item)] # Filter, Python 2 version newlist = filter(check, oldlist) # Filter, Python 3 version newlist = list(filter(check, oldlist)) In practice, this is the best (fastest, simplest) way. But if you fear that you will run out of memory dealing with absolutely humongous lists with hundreds of millions or billions of strings, you can remove items in place: def remove(func, alist): for i in range(len(alist)-1, -1, -1): if not func(alist[i]): del alist[i] Note the magic incantation to iterate from the end of the list towards the front. If you do it the other way, Bad Things happen. Note that this will use less memory than extracting the items, but it will be much slower. You can combine the best of both words. Here is a version that uses a temporary list to modify the original in place: # works in both Python 2 and 3 def remove(func, alist): # Modify list in place, the fast way. alist[:] = filter(check, alist) -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Whittle it on down
On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: > Start by writing a function or a regex that will distinguish strings that > match your conditions from those that don't. A regex might be faster, but > here's a function version. > ... snip ... Yikes. I'm all for the idea that one shouldn't go to regex when Python's powerful string type can answer the problem more clearly, but this seems to go out of its way to do otherwise. I don't even care about faster: Its overly complicated. Sometimes a regular expression really is the clearest way to solve a problem. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.python.org/mailman/listinfo/python-list