Re: Why 'files.py' does not print the filenames into a table format?
On 15/6/2013 11:37 μμ, Joshua Landau wrote: On 15 June 2013 20:51, Nick the Gr33k supp...@superhost.gr wrote: On 15/6/2013 10:46 μμ, Jarrod Henry wrote: Nick, at this point, you need to hire someone to do your work for you. The code is completely ready. Some detail is missing and its not printing the files as expected. Look, Nick, A lot of people are frustrated by you. You should understand that. If you cannot, you need to step back and consider, or you really are a troll. Now, obviously it's not going to get you any help to have half of the forum angry at you. People have stopped helping, at least in large. This is fine; people here are volunteers. But you want help. So, Nick, listen. You need to learn how to ask *smart* questions. If you do, I *guarantee* that people will respect you a lot more. I'll be willing to give a bit of time to explain what I mean. 1) What is your problem. Not I want to know why it doesn't print anything. Here's an example, for some random idea: I've written some code to find the first file in a directory which is not UTF-8. Lines 40-42 are meant to print out the file found to a log (/home/joshua/.logs/log). Unfortunately, although there is no error, no file is printed to the log. 2) What have you tried? What debugging have you done? For someone of your skill level, it's also important to tell us what you think your code is doing. Example: I've tried checking for a failure - when there is no non-UTF-8 file in the directory the appropriate error is raised. I think this should mean that the else after the for loop would be run, and this should run the lines 40-42 above when there *is* a non-UTF-8 file. 3) If possible, give us an example we can run. To make helping easier, I've removed the code that searches the directory as I know that works, and instead there's a list of BytesIO and StringIO objects that pretend to be them. The bug is still there. Do you see the difference? Irrelevant to my question i just noticed weird behavior about my pelatologio.py script which can be seen here: http://superhost.gr/?show=stats The first 3 files are of my doing. All the rest are of someone else's that managed to append entries into my counters database utilizing this code: try: #find the needed counter for the page URL cur.execute('''SELECT ID FROM counters WHERE url = %s''', page ) data = cur.fetchone()#URL is unique, so should only be one if not data: #first time for page; primary key is automatic, hit is defaulted cur.execute('''INSERT INTO counters (url) VALUES (%s)''', page ) cID = cur.lastrowid#get the primary key value of the new record == Does someone want to state something? Sure. Here I go: What's the question? I DID, I FINALLY DID IT JUST NOW!! HERE ARE THE MODIFICATIONS THAT MADE IT HAPPEN! == # Convert wrongly encoded filenames to utf-8 == path = b'/home/nikos/public_html/data/apps/' filenames = os.listdir( path ) utf8_filenames = [] for filename in filenames: # Compute 'path/to/filename' filename_bytes = path + filename encoding = guess_encoding( filename_bytes ) if encoding == 'utf-8': # File name is valid UTF-8, so we can skip to the next file. utf8_filenames.append( filename_bytes ) continue elif encoding is None: # No idea what the encoding is. Hit it with a hammer until it stops moving. filename = filename_bytes.decode( 'utf-8', 'xmlcharrefreplace' ) else: filename = filename_bytes.decode( encoding ) # Rename the file to something which ought to be UTF-8 clean. newname_bytes = filename.encode('utf-8') os.rename( filename_bytes, newname_bytes ) utf8_filenames.append( newname_bytes ) # Once we get here, the file ought to be UTF-8 clean and the Unicode name ought to exist: assert os.path.exists( newname_bytes.decode('utf-8') ) i SMASHED MY HEAD INTO THE WALL, BUT I MADE IT FINALLY AFTER 15 DAYS!! FEEL FREE TO CONGRATULATE ME! -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 17/6/2013 8:58 πμ, Νίκος wrote: On 15/6/2013 11:37 μμ, Joshua Landau wrote: On 15 June 2013 20:51, Nick the Gr33k supp...@superhost.gr wrote: On 15/6/2013 10:46 μμ, Jarrod Henry wrote: Nick, at this point, you need to hire someone to do your work for you. The code is completely ready. Some detail is missing and its not printing the files as expected. Look, Nick, A lot of people are frustrated by you. You should understand that. If you cannot, you need to step back and consider, or you really are a troll. Now, obviously it's not going to get you any help to have half of the forum angry at you. People have stopped helping, at least in large. This is fine; people here are volunteers. But you want help. So, Nick, listen. You need to learn how to ask *smart* questions. If you do, I *guarantee* that people will respect you a lot more. I'll be willing to give a bit of time to explain what I mean. 1) What is your problem. Not I want to know why it doesn't print anything. Here's an example, for some random idea: I've written some code to find the first file in a directory which is not UTF-8. Lines 40-42 are meant to print out the file found to a log (/home/joshua/.logs/log). Unfortunately, although there is no error, no file is printed to the log. 2) What have you tried? What debugging have you done? For someone of your skill level, it's also important to tell us what you think your code is doing. Example: I've tried checking for a failure - when there is no non-UTF-8 file in the directory the appropriate error is raised. I think this should mean that the else after the for loop would be run, and this should run the lines 40-42 above when there *is* a non-UTF-8 file. 3) If possible, give us an example we can run. To make helping easier, I've removed the code that searches the directory as I know that works, and instead there's a list of BytesIO and StringIO objects that pretend to be them. The bug is still there. Do you see the difference? Irrelevant to my question i just noticed weird behavior about my pelatologio.py script which can be seen here: http://superhost.gr/?show=stats The first 3 files are of my doing. All the rest are of someone else's that managed to append entries into my counters database utilizing this code: try: #find the needed counter for the page URL cur.execute('''SELECT ID FROM counters WHERE url = %s''', page ) data = cur.fetchone()#URL is unique, so should only be one if not data: #first time for page; primary key is automatic, hit is defaulted cur.execute('''INSERT INTO counters (url) VALUES (%s)''', page ) cID = cur.lastrowid#get the primary key value of the new record == Does someone want to state something? Sure. Here I go: What's the question? I DID, I FINALLY DID IT JUST NOW!! HERE ARE THE MODIFICATIONS THAT MADE IT HAPPEN! == # Convert wrongly encoded filenames to utf-8 == path = b'/home/nikos/public_html/data/apps/' filenames = os.listdir( path ) utf8_filenames = [] for filename in filenames: # Compute 'path/to/filename' filename_bytes = path + filename encoding = guess_encoding( filename_bytes ) if encoding == 'utf-8': # File name is valid UTF-8, so we can skip to the next file. utf8_filenames.append( filename_bytes ) continue elif encoding is None: # No idea what the encoding is. Hit it with a hammer until it stops moving. filename = filename_bytes.decode( 'utf-8', 'xmlcharrefreplace' ) else: filename = filename_bytes.decode( encoding ) # Rename the file to something which ought to be UTF-8 clean. newname_bytes = filename.encode('utf-8') os.rename( filename_bytes, newname_bytes ) utf8_filenames.append( newname_bytes ) # Once we get here, the file ought to be UTF-8 clean and the Unicode name ought to exist: assert os.path.exists( newname_bytes.decode('utf-8') ) i SMASHED MY HEAD INTO THE WALL, BUT I MADE IT FINALLY AFTER 15 DAYS!! FEEL FREE TO CONGRATULATE ME! oups! everything work as expected but not the part when the counter of a filename gets increased when the file have been requested. I don't see how since: if filename: #update file counter cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Python API
Hi What are all the python api, u used in your python programming, we used more api but may we forgot those, so i just want to list down the api we familiar aboutplease add your replies... -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
Op 15-06-13 02:28, Cameron Simpson schreef: On 14Jun2013 15:59, Nikos as SuperHost Support supp...@superhost.gr wrote: | So, a numeral = a string representation of a number. Is this correct? No, a numeral is an individual digit from the string representation of a number. So: 65 requires two numerals: '6' and '5'. Wrong context. A numeral as an individual digit is when you are talking about individual characters in a font. In such a context the set of glyphs that represent a digit are the numerals. However in a context of programming, numerals in general refer to the set of strings that represent a number. -- Antoon. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python API
On Jun 17, 11:38 am, Ganesh Pandi guruganes...@gmail.com wrote: Hi What are all the python api, u used in your python programming, we used more api but may we forgot those, so i just want to list down the api we familiar aboutplease add your replies... Maybe you are referring to this?? http://docs.python.org/2/extending/ If not, please explain more clearly what you mean by API -- http://mail.python.org/mailman/listinfo/python-list
Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Mon, 17 Jun 2013 08:17:48 +0300, Νίκος wrote: [...] The latter is false because the binding of b to the int 6 was broken in order to bind b to the int 5. Very surprising. a and b was *references* to the same memory address, it was like a memory address having 2 names to be addresses as. b = a name we use to address some memory location, do we agree on that? So, b = 6, must have changed the stored value of its mapped memory location, but given you example it seems its changing the mapping of b to some other memory address. I don't follow its act of course. Let me explain how variables work in some other languages, and how they work in Python. (And Ruby, and Java, and many others.) In a language like Pascal, or C, the compiler keeps a table mapping variable names to fixed memory addresses, like this: Variable Address === x 10234 y 10238 z 10242 Code like: x := 42; y := x + 1; will get compiled into something that looks like this: # Pseudo-code STORE 42 AT ADDRESS 10234; READ ADDRESS 10234; STORE (LAST RESULT + 1) AT ADDRESS 10238; The important thing is that memory addresses are known at compile time, and at least in general, variables cannot move around in memory. Another important thing is that assignment is copying: x := y; becomes: READ ADDRESS 10234; STORE (LAST RESULT) AT ADDRESS 10238; which is equivalent to: COPY ADDRESS 10234 TO ADDRESS 10238; If, instead of an integer, x was an array of 1000 integers, all 1000 integers would need to be copied. Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world In Python, namespaces are *dicts*, just like those you create with {}. Code like: x = 42 y = x + 1 is treated as: # Pseudocode create the object 42 bind it to the name 'x' look up the name 'x' add 1 to it bind it to the name 'y' where bind means to change the association in the namespace: global namespace: x -- 42 y -- 43 One important thing is that binding does *not* make a copy of the object. Assignment is equally fast whether you have one int or a list or a million ints. So code like this: x = y results in both names 'x' and 'y' being associated to the same object. With ints, that's pretty boring, but for mutable objects like lists, it means that you get two names for the same list: py x = [] py y = x py y.append(Surprise!) py x ['Surprise!'] This sort of behaviour is trivial in languages with name-binding semantics, like Python, but quite tricky in languages like Pascal. You have to explicitly work with pointers or other indirect memory access, leading to extra effort and the possibility of serious bugs. Note also that because you aren't dealing with fixed memory addresses, objects are free to be moved in memory for better memory usage and less fragmentation. CPython doesn't do this, but PyPy does, and I expect that both Jython and IronPython probably do too. So long as the runtime environment can (somehow) track when objects are moved, it all works out fine. Another difference is that in C-like languages, variables always have a value, even if it's not a useful value. As soon as the compiler decides that variable 'z' will be at address 10242, then 'z' has an implied value made up of whatever junk happens to be at that address. Some compilers will warn you if you try to use a variable without assigning to it first, since using junk you happen to find lying around in memory is usually a bad thing, but not all compilers. In contrast, Python doesn't have this issue. If you haven't assigned to 'z', then there is no such thing as 'z' in your namespace, and trying to use it will automatically give you an error: py x = z - 1 Traceback (most recent call last): File stdin, line 1, in module NameError: name 'z' is not defined There are other differences in regards to passing arguments to functions. I've written about that before: http://mail.python.org/pipermail/tutor/2010-December/080505.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On Mon, 17 Jun 2013 09:11:05 +0300, Νίκος wrote: everything work as expected but not the part when the counter of a filename gets increased when the file have been requested. I don't see how since: if filename: #update file counter cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) Have you read these links yet? http://sscce.org/ http://www.catb.org/esr/faqs/smart-questions.html They will teach you how to successfully ask for help. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
On 17Jun2013 08:49, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: | Op 15-06-13 02:28, Cameron Simpson schreef: | On 14Jun2013 15:59, Nikos as SuperHost Support supp...@superhost.gr wrote: | | So, a numeral = a string representation of a number. Is this correct? | | No, a numeral is an individual digit from the string representation of a number. | So: 65 requires two numerals: '6' and '5'. | | Wrong context. A numeral as an individual digit is when you are talking about | individual characters in a font. In such a context the set of glyphs that | represent a digit are the numerals. | | However in a context of programming, numerals in general refer to the set of | strings that represent a number. No, those are just numbers or numeric strings (if you're being overt about them being strings at all). They're numeric strings because they're composed of numerals. If you think otherwise your vocabulary needs adjusting. A numeral is a single digit. -- Cameron Simpson c...@zip.com.au English is a living language, but simple illiteracy is no basis for linguistic evolution. - Dwight MacDonald -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. If the help files are too technical for you, you will need to improve your technical ability. (Though the PEPs shouldn't need to concern you, generally.) Live help is a VERY expensive service to offer, because it involves an expert's time dedicated to one single person. Collective help is far more efficient - that's why documentation exists, because it gets read by far more people than wrote it (at least, that's the theory). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
Op 16-06-13 22:04, Steven D'Aprano schreef: On Sun, 16 Jun 2013 20:16:34 +0200, Antoon Pardon wrote: You are trying to get it both ways. On the one hand you try to argue that there are no boundaries I have never, ever argued that there are no boundaries. I have repeatedly made it clear to Nikos when I thought he was behaving improperly. And I've done the same to others when they've acted improperly. That doesn't mean much. People can and do contradict themselves. So the fact that you made it clear to Nikos that he behaved improperly doesn't contradict you arguing somewhere else in a way that strongly suggest there are no boudaries. But I'll take note that you assert there are boundaries. So I'll take it that there is nothing wrong with playing Internet Police and taking people to task who transgress this boundaries? One thing I would like to make clear, is that I find you making it clear he behaviour is improper, to be inadequate for the reason that it ignores the possibility that you are playing a troll game. To make an analogy. Suppose someone want to play a game of troll-chess with you. The rules of troll-chess are the following. You are allowed any kind of piece movement or you can utter the statement: TIC (That is cheating). So in troll-chess you are allowed to move your bisshops like a queen. The only thing is, that if you do a move that is illegal in ordinary chess and your opponent answers with TIC, you must take back that move and make a move that is legal ordinary chess. So you make think you are making it clear to your troll-chess opponent that he is cheating for your troll-chess opponet you are just participating in his game. Now it is possible that your opponent is not in fact playing troll chess but just doesn't know enough of the game to know what is a legal move and what is not. In my opinion that doesn't matter. If your opponent doesn't want to invest the time needed to at least have a reasonable idea of what moves are legal and so in practice is hardly distinguishable from those who's intent it is to play troll chess, the end result is the same. to what is acceptable by calling people who do try to enforce such boundaries the Internet Police. On the other hand you do suggest that playing Internet Police is out of bound behaviour. Yes. Trying to start flame wars with Nikos is unacceptable behaviour. It is unproductive, it makes this a hostile, unpleasant place to be, it ruins the environment for the rest of the community, it's off topic, and it simply doesn't work to discourage trolls. I'm sorry but again I find that you are trying to have it both ways. IMO, and I suspect I'm not alone in that judgement, the threads that Nikos starts are in general, boring, repetitive, unproductive and draining. Not only that they are having an effect on the mailing list as a whole making it an unpleasant place. To the people who come with that complain, your respons, seems to be that if those people would just ignore the nikos-threads. They don't have to experience this unpleasantnes. But now that you start to experience unpleasantness, this unproductiveness and unpleasantness is cause for you to label behaviour unacceptable. But the same remedy is available here. Just ignore threads with behaviour that you find unacceptable and you (and others) don't have to experience this hostility and unpleasantness. Those you accuse of ruining the environment, find this environment already partly ruined by nikos and those that enable him. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
Op 17-06-13 05:46, ru...@yahoo.com schreef: On 06/16/2013 02:04 PM, Steven D'Aprano wrote: Yes. Trying to start flame wars with Nikos is unacceptable behaviour. It is unproductive, it makes this a hostile, unpleasant place to be, it ruins the environment for the rest of the community, it's off topic, and it simply doesn't work to discourage trolls. The difficulty with trying to suppress such responses is that the flamers get just as much pleasure from having a target to unrestrainedly spew their pent up anger and vile at, as the troll gets from simulating that reaction. The result is a positive feedback loop. Well if asocial behaviour of one provokes asocial behaviour in others, you can't claim the problem is not the social behaviour of the first. I could be wrong but I don't think Nikos is a pure troll -- someone motivated purely by provoking reaction and discord. He has a real website and his problems with Python seem like genuine problems many beginners have. He seems to have little knowledge, not much concern for anyone else but a lot of determination to get things working. I have certainly known people like that in the real world. Does that matter? I don't care what Nikos's motivation is. I care about the result or effect of his behaviour and that seems to differ very little from a troll. Intent is not magic. Bad behaviour with the best of intentions still results in annoyance. The only way it which intent makes a difference is when the person with good intentions, upon learning his behaviour is bothersome, tries to adapt his behaviour. I speculate that half of his bad behavior is simple I want now and don't care about your conventions. The rest is a reaction to we're the alphas, your a beta attitude expressed by many here and later, overt hostility directed at him. He has changed some things -- his posting method, he's made an effort to understand his encoding issues, etc. I don't see that much change in his style. He just admitted not reading help files (because they are too technical for him). So essentialy he is asking we give him a beginners tutorial in everything he doesn't understand without much effort of him trying to understand things on his own and without much appreciation for the time of others. So I think Steven's approach of responding to his questions, at least those that are coherent and don't require reading a dozen posts over several threads to piece together, with an actual attempt to help (not a bunch of obscure hints, links to wikipedia, and you're an idiot replies) is right. A respons that is in effect reinforcing bad bahaviour. If Nikos fails to respond with better questions, then those that do answer will get tired of trying to help and stop answering. In the meantime everyone else can just killfile or otherwise ignore him rather than egging him on by intentionally provoking him (unless of course you enjoy the results.) In the mean time you and steve can just killfile those you think are just egging him on. So positive reinforcement for less bad behavior, negative reinforcement (which for trolling is NO response, not negative responses) for more bad. Standard behavioral conditioning. It means you are still reinforcing bad behaviour. Less bad is still bad. And if it doesn't work it will still be a much nicer and quieter here with only Nikos' trolling than with 10x as much garbage from the local vigilantes who are more obnoxious than he. But not quiet enough for some people. They hope that somehow punishing Nikos for his behaviour, although it may make the environment even less nice in the short term, may help to make the environment as nice again as it was before Nikos started his quest for spoon feeders. While reinforcing bad bahaviour provides no hope at all for that. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
Op 17-06-13 07:04, Ferrous Cranus schreef: On 17/6/2013 6:46 πμ, ru...@yahoo.com wrote: I could be wrong but I don't think Nikos is a pure troll -- someone motivated purely by provoking reaction and discord. He has a real website and his problems with Python seem like genuine problems many beginners have. He seems to have little knowledge, not much concern for anyone else but a lot of determination to get things working. I have certainly known people like that in the real world. This is the best definition of me. It is very nice to see that someone has understood my character and intentions. It still describes you as a jerk. Someone who acts without much concerns for others, is a jerk even if he has no malice in mind. The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. An yes, i'm not trolling this fine newsgroup. If it wasn't for the help of some of the nicest fellows here my site would be up and working neither with Python 3.3.2 nor with 2.6. Yes you are trolling this newsgroup. Intent is not magic. You just admitted to have little concerns for others. So if your behaviour happens to be rude and provoke people in behaving badly, you just don't care and continue to act essentially in the same way. That is trolling even if it is not your intention. Many difficulties that occurred to me when trying to write some code were addresses here making my website actually happen. I could have made it to Joomla(that's web design) instead of Python(web development_ but i really like Python and the reason i ask in detail is because i don't want only provided code that will help address an issue i have, but i want to know how things work. Sure, but you don't want to make any effort yourself in getting to know how things work. You expect others to spoon feed you. -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
Op 17-06-13 09:08, Cameron Simpson schreef: On 17Jun2013 08:49, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: | Op 15-06-13 02:28, Cameron Simpson schreef: | On 14Jun2013 15:59, Nikos as SuperHost Support supp...@superhost.gr wrote: | | So, a numeral = a string representation of a number. Is this correct? | | No, a numeral is an individual digit from the string representation of a number. | So: 65 requires two numerals: '6' and '5'. | | Wrong context. A numeral as an individual digit is when you are talking about | individual characters in a font. In such a context the set of glyphs that | represent a digit are the numerals. | | However in a context of programming, numerals in general refer to the set of | strings that represent a number. No, those are just numbers or numeric strings (if you're being overt about them being strings at all). They're numeric strings because they're composed of numerals. If you think otherwise your vocabulary needs adjusting. A numeral is a single digit. -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
Op 17-06-13 09:08, Cameron Simpson schreef: On 17Jun2013 08:49, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: | Op 15-06-13 02:28, Cameron Simpson schreef: | On 14Jun2013 15:59, Nikos as SuperHost Support supp...@superhost.gr wrote: | | So, a numeral = a string representation of a number. Is this correct? | | No, a numeral is an individual digit from the string representation of a number. | So: 65 requires two numerals: '6' and '5'. | | Wrong context. A numeral as an individual digit is when you are talking about | individual characters in a font. In such a context the set of glyphs that | represent a digit are the numerals. | | However in a context of programming, numerals in general refer to the set of | strings that represent a number. No, those are just numbers or numeric strings (if you're being overt about them being strings at all). They're numeric strings because they're composed of numerals. If you think otherwise your vocabulary needs adjusting. A numeral is a single digit. Just because you are unfamiliar with a context in which numeral means a representation of a number, doesn't imply my vocabularly needs adjusting. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Jun 17, 2013, at 6:17, Νίκος supp...@superhost.gr wrote: On 16/6/2013 9:53 μμ, R. Michael Weylandt wrote: On Sun, Jun 16, 2013 at 2:47 PM, Ferrous Cranus supp...@superhost.gr wrote: On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: If, instead of the above, you have a = 6 b = a b = 5 you will find that b == 5 and a == 6. So b is not the same as a. Else one would have changed when the other changed. I would say that a and b are different variables. They had the same value, briefly. If they were different variables then they would have different memory addresses and they would act like two different objects. But... both a and b are for a fact mappings for the same memory address as seen form the following command. id(a) == id(b) True They are like the same object with 2 different names. This will depend on when the test is run: a = 6 b = a a is b # True b = 5 a is b # False The latter is false because the binding of b to the int 6 was broken in order to bind b to the int 5. Very surprising. a and b was *references* to the same memory address, it was like a memory address having 2 names to be addresses as. b = a name we use to address some memory location, do we agree on that? So, b = 6, must have changed the stored value of its mapped memory location, but given you example it seems its changing the mapping of b to some other memory address. I don't follow its act of course. I'm having trouble understanding your grammar in the above, but please re-read my note on the dual behavior of `=` here: http://mail.python.org/pipermail/python-list/2013-June/649990.html Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 17/6/2013 10:00 πμ, Steven D'Aprano wrote: On Mon, 17 Jun 2013 09:11:05 +0300, Νίκος wrote: everything work as expected but not the part when the counter of a filename gets increased when the file have been requested. I don't see how since: if filename: #update file counter cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) There isn'tmuch to say ehre. You already know the code that im using inside files.pu and the question is that this execute never gets to execute. # = # Make sure that ALL database records are filenames in existance # = filenames = [] # Switch filenames from (utf8 bytestrings = unicode strings) and trim them from their paths for utf8_filename in utf8_filenames: filenames.append( utf8_filename.decode('utf-8').replace( '/home/nikos/public_html/data/apps/', '' ) ) # Check the presence of a database file against the dir files and delete record if it doesn't exist cur.execute('''SELECT url FROM files''') data = cur.fetchall() # Delete spurious database records for rec in data: if rec not in filenames: cur.execute('''DELETE FROM files WHERE url = %s''', rec ) # Load'em for filename in filenames: try: # Check the presence of current filename against it's database presence cur.execute('''SELECT url FROM files WHERE url = %s''', filename ) data = cur.fetchone() if not data: # First time for file; primary key is automatic, hit is defaulted cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: print( repr(e) ) # = # Display ALL files, each with its own download button # = print('''body background='/data/images/star.jpg' centerimg src='/data/images/download.gif'brbr table border=5 cellpadding=5 bgcolor=green ''') try: cur.execute( '''SELECT * FROM files ORDER BY lastvisit DESC''' ) data = cur.fetchall() for row in data: (filename, hits, host, lastvisit) = row lastvisit = lastvisit.strftime('%A %e %b, %H:%M') print(''' form method=get action=/cgi-bin/files.py tr td center input type=submit name=filename value=%s /td td center font color=yellow size=5 %s /td td center font color=orange size=4 %s /td td center font color=silver size=4 %s /td /tr /form ''' % (filename, hits, host, lastvisit) ) print( '''/tablebrbr''' ) except pymysql.ProgrammingError as e: print( repr(e) ) sys.exit(0) After a spcific file gets selected then files.py is reloading grabbign the filename as a variable form and: # = # If user downloaded a file, thank the user !!! # = if filename: #update filename's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) but the execute never happesn. i ahve tested it if data: print soemthing but data is always empty. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 17/6/2013 12:07 μμ, Simpleton wrote: # Load'em for filename in filenames: try: # Check the presence of current filename against it's database presence cur.execute('''SELECT url FROM files WHERE url = %s''', filename ) data = cur.fetchone() if not data: # First time for file; primary key is automatic, hit is defaulted cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: print( repr(e) ) Also i just alternated the above code to: # Load'em for filename in filenames: try: # try to insert the file into the database cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: # Insertion failed, file already into database, skip this, go to next filename pass Isn't more compact and straightforward this way? but i have to set the url's type into unique type for the abpve to work? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 17/6/2013 12:07 μμ, Simpleton wrote: On 17/6/2013 10:00 πμ, Steven D'Aprano wrote: On Mon, 17 Jun 2013 09:11:05 +0300, Νίκος wrote: everything work as expected but not the part when the counter of a filename gets increased when the file have been requested. I don't see how since: if filename: #update file counter cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) There isn'tmuch to say ehre. You already know the code that im using inside files.pu and the question is that this execute never gets to execute. # = # Make sure that ALL database records are filenames in existance # = filenames = [] # Switch filenames from (utf8 bytestrings = unicode strings) and trim them from their paths for utf8_filename in utf8_filenames: filenames.append( utf8_filename.decode('utf-8').replace( '/home/nikos/public_html/data/apps/', '' ) ) # Check the presence of a database file against the dir files and delete record if it doesn't exist cur.execute('''SELECT url FROM files''') data = cur.fetchall() # Delete spurious database records for rec in data: if rec not in filenames: cur.execute('''DELETE FROM files WHERE url = %s''', rec ) # Load'em for filename in filenames: try: # Check the presence of current filename against it's database presence cur.execute('''SELECT url FROM files WHERE url = %s''', filename ) data = cur.fetchone() if not data: # First time for file; primary key is automatic, hit is defaulted cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: print( repr(e) ) # = # Display ALL files, each with its own download button # = print('''body background='/data/images/star.jpg' centerimg src='/data/images/download.gif'brbr table border=5 cellpadding=5 bgcolor=green ''') try: cur.execute( '''SELECT * FROM files ORDER BY lastvisit DESC''' ) data = cur.fetchall() for row in data: (filename, hits, host, lastvisit) = row lastvisit = lastvisit.strftime('%A %e %b, %H:%M') print(''' form method=get action=/cgi-bin/files.py tr td center input type=submit name=filename value=%s /td td center font color=yellow size=5 %s /td td center font color=orange size=4 %s /td td center font color=silver size=4 %s /td /tr /form ''' % (filename, hits, host, lastvisit) ) print( '''/tablebrbr''' ) except pymysql.ProgrammingError as e: print( repr(e) ) sys.exit(0) After a spcific file gets selected then files.py is reloading grabbign the filename as a variable form and: # = # If user downloaded a file, thank the user !!! # = if filename: #update filename's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) but the execute never happesn. i ahve tested it if data: print soemthing but data is always empty. So any ideas why the update statements never gets executed? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python API
On Monday, June 17, 2013 2:38:56 PM UTC+8, Ganesh Pandi wrote: Hi What are all the python api, u used in your python programming, we used more api but may we forgot those, so i just want to list down the api we familiar aboutplease add your replies... you should tell bwhich contents/b you are mainly on, then you can reference the official documents for that part. the web frontend, machine learning, image processing. different fields decides different APIs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 So 'a', is a reference to that memory location, so its more like a name to that memory location, yes? Instead of accessing a memory address with a use of an integer like 14858485995 we use 'a' instead. So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? I say this because here you said that: Instead, there is a namespace, which is anassociation between some name and some value: When you say that you mean that a is associated to some value as in memory location or to that memory location's address? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
ANN: Python Meeting Düsseldorf - 16.07.2013
[This announcement is in German since it targets a local user group meeting in Düsseldorf, Germany] ANKÜNDIGUNG Python Meeting Düsseldorf http://pyddf.de/ Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosphäre. Dienstag, 16.07.2013, 18:00 Uhr Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk Düsseldorfer Arcaden, Bachstr. 145, 40217 Düsseldorf Diese Nachricht ist auch online verfügbar: http://www.egenix.com/company/news/Python-Meeting-Duesseldorf-2013-07-16 NEUIGKEITEN * Sprint-Planung: Wir möchten im Sommer/Herbst gerne einen Sprint organisieren und suchen dafür Themen. Falls Ihr Themenvorschläge habt, wäre es schön, wenn Ihr diese auf dem nächsten Treffen kurz vorstellen könntet. Beispiele: - Progammieren eines Add-ons für XBMC - Progammieren eines Add-ons für Blender - Patch für einen oder mehrere Python Bugs schreiben * Neuer Veranstaltungsraum: Wir treffen uns im Bürgerhaus in den Düsseldorfer Arcaden. Da beim letzten Mal einige Teilnehmer Schwierigkeiten hatten, den Raum zu finden, hier eine kurze Beschreibung: Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der Düsseldorfer Arcaden. Über dem Eingang steht ein großes “Schwimm’in Bilk” Logo. Hinter der Tür direkt links zu den zwei Aufzügen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt. Google Street View: http://bit.ly/11sCfiw EINLEITUNG Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der Region wendet: * http://pyddf.de/ Einen guten Überblick über die Vorträge bietet unser YouTube-Kanal, auf dem wir die Vorträge nach den Meetings veröffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting Research, Düsseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ PROGRAMM Das Python Meeting Düsseldorf nutzt eine Mischung aus Open Space und Lightning Talks. Lightning Talks können vorher angemeldet werden, oder auch spontan während des Treffens eingebracht werden. Ein Beamer mit XGA Auflösung steht zur Verfügung. Folien bitte als PDF auf USB Stick mitbringen. Lightning Talk Anmeldung bitte formlos per EMail an i...@pyddf.de KOSTENBETEILIGUNG Das Python Meeting Düsseldorf wird von Python Nutzern für Python Nutzer veranstaltet. Um die Kosten zumindest teilweise zu refinanzieren, bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00 inkl. 19% Mwst, Schüler und Studenten zahlen EUR 5,00 inkl. 19% Mwst. Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen. ANMELDUNG Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung. Meeting Anmeldung bitte formlos per EMail an i...@pyddf.de WEITERE INFORMATIONEN Weitere Informationen finden Sie auf der Webseite des Meetings: http://pyddf.de/ Mit freundlichen Grüßen, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jun 17 2013) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2013-07-01: EuroPython 2013, Florence, Italy ... 14 days to go 2013-07-16: Python Meeting Duesseldorf ... 29 days to go : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 06/17/2013 05:34 AM, Simpleton wrote: So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? It might be partially equivalent inside the interpreter, but it's not something you should concern yourself with. And in general, no it's not safe to say, since Python is a reference-counted, garbage-collected object system and pointers in C certainly are not. I say this because here you said that: Instead, there is a namespace, which is anassociation between some name and some value: When you say that you mean that a is associated to some value as in memory location or to that memory location's address? In python just think of assignment as making a name *be* an object. And if you assign one name to another name, that makes both names be the same object. When names are unbound (either they go out of scope or you manually unbind them), the objects they are bound to are garbage collected. Forget about the details of how the interpreter might doing at a low level. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to automatically boot my computer at a specific time and play a podcast
On Sunday, June 16, 2013 12:06:08 PM C. N. Desrosiers wrote: Hi, I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python? Thanks in advance. CND Up to Jan 1, 2012 we had 6 computers that were connected to timers. The timers were set to come on at various times during the day. When the timer came on, the computer, on boot up, ran a .BAT file that called our screen saver which in turn launched another program. I don't know about Mac but this was all written on DOS machines. With a little research and I'm sure it could be done through the bios on a Mac. The screen saver gave us time to opt out of the call to another program. So, simply turning on a machine could launch an OS file that will call your python module. Another approach is building a python screen saver that reboots your computer at a specific time. On reboot, your OS calls a python screen saver with options, as mentioned. jd inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 This is backwards. If the interpreter puts 5 in a *permanent* 'memory location' (which is not required by the language!), then it can associate 'a' with 5 by associating it with the memory location. CPython does this, but some other computer implementations do not. So 'a', is a reference to that memory location, so its more like a name to that memory location, yes? Instead of accessing a memory address with a use of an integer like 14858485995 we use 'a' instead. So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? When you interpret Python code, do you put data in locations with integer addresses? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-15, Chris ???Kwpolska??? Warrick kwpol...@gmail.com wrote: On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: I suggested including the poster that you are replying to. In the name of all that's good and decent in the world, why on earth would you do that when replying to a mailing list??? They're already getting a reply. Sending them TWO identical replies is just rude. Mailman is intelligent enough not to send a second copy in that case. This message was sent with a CC, and you got only one copy. I don't want _any_ copies from from Mailman. I don't subscribe to whatever mailing list you're talking about. I'm reading this via an NNTP server. Keep replies in the group or on the list. -- Grant Edwards grant.b.edwardsYow! I just remembered at something about a TOAD! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 06/17/2013 01:23 AM, Chris Angelico wrote: On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. Take a look at issue http://bugs.python.org/issue16665 for an example of why the Python doc has some of the problems that it does. (Please change the subject line if you want to discuss the documentation rather than Nikos.) While the Python tutorial is a good answer for many people it is not the answer for everyone. Many people don't have a large block of time to sit down and go through it from beginning to end. Many people don't learn well reading a large volume of not-immediately-relevant material, trying to commit it to memory, and then trying to apply it all later, as opposed to looking up those aspects of python relevant to what they are attempting at that moment. (I am in that category.) All these problems are aggravated for people whose native language is not English. If the help files are too technical for you, you will need to improve your technical ability. (Though the PEPs shouldn't need to concern you, generally.) Live help is a VERY expensive service to offer, because it involves an expert's time dedicated to one single person. Luckily, in a group of volunteers, participants can individually decide how much their time is worth and answer if they want or not if they don't. The reality, regardless of whether you or I think the world should not be this way, is that Nikos has embarked on his website building project and telling him to drop it and come back after he has learned more is totally ineffectual noise. Collective help is far more efficient - that's why documentation exists, because it gets read by far more people than wrote it (at least, that's the theory). Yup. And it works well most of the time but occasionally not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On 2013-06-15, Nick the Gr33k supp...@superhost.gr wrote: On 15/6/2013 10:46 ??, Jarrod Henry wrote: Nick, at this point, you need to hire someone to do your work for you. The code is completely ready. OK. Good-bye then. -- Grant Edwards grant.b.edwardsYow! Th' MIND is the Pizza at Palace of th' SOUL gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 15 Jun 2013 15:40:35 GMT Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 15 Jun 2013 07:58:27 -0400, D'Arcy J.M. Cain wrote: I suggested including the poster that you are replying to. In the name of all that's good and decent in the world, why on earth would you do that when replying to a mailing list??? They're already getting a reply. Sending them TWO identical replies is just rude. You may disagree with my reasoning but I have presented it a few times. By the way, I did reply just to the list this time as you obviously disagree but I may forget in the future. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: RFD: rename comp.lang.python to comp.support.superhost
Op 15-06-13 19:51, Steven D'Aprano schreef: On Sat, 15 Jun 2013 18:43:42 +0100, Mark Lawrence wrote: A classic example of the pot calling the kettle black. If you're going to continue making unproductive, off-topic, inflammatory posts that prolong these already excessively large threads, Nikos won't be the only one kill-filed. If you have nothing helpful to say, send it to /dev/null. So you don't mind playing the Internet Police if it is about behaviour that bothers you? -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
Op 15-06-13 21:54, ru...@yahoo.com schreef: On 06/15/2013 12:18 PM, rusi wrote: On Jun 15, 10:52 pm, Steven D'Apranosteve +comp.lang.pyt...@pearwood.info wrote: On Sat, 15 Jun 2013 10:36:00 -0700, rusi wrote: With you as our spamming-guru, Onward! Sky is the limit! If you're going to continue making unproductive, off-topic, inflammatory posts that prolong these already excessively large threads, Nikos won't be the only one kill-filed. At least two people -- Alex and Antoon -- have told you that by supporting Nikos, when everyone else wants him off list, you are part of the problem. Nikos is only secondarily the problem, Steven not at all. The primary problem is a (relatively small) number of people who respond to every post by Nikos with a barrage of insults, demands, (what they think are) witty repartee, hints intended to make Nikos learn something, useless (to Nikos) links, new threads to discuss the Nikos problem, and other trash that is far more obnoxious that anything Nikos posts and just serves to egg him on. Sorry but this is IMO a false equivallence. It ignores the important distinction between action and reaction. Does this number of people post a barrage of insult to no matter who? And you may find those responses more obnoxious they propbably are the reactions of people who are utterly fed up and think that if nobody is concerned about their annoyance they don't have to b econcerned about the annoyance of others either. Steven's advice on how to deal with Nikos was probably the most sensible thing I've seen posted here on the subject. Most sensible for what purpose? As far as I can see Steven's advice will just prolong the cycle of Nikos continuing to ask for spoonfeeding, showing very litle signs of understanding and keeping to hop from one problem/bug to the next until the mailing list has finished his project at which point he will probably start something new. If nikos's project was a college project we would have told him he has to make his homework himself. But now he is earning money with it, you seem to find it acceptable his job is done for him. I suggest that if you can and want to answer Nikos' question, do so directly and with a serious attempt address what it is he seems not to get, or killfile him and shut the fuck up. I suggest that if you want this to continue being a hospitable place, you don't encourage asocial behaviour. His behaviour may not bother you so much, but that shouldn't be the norm because others are less bothered with the barrage of insults Nikos is now receiving than with Nikos vampirizing this list, because they consider those insults deserved. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to automatically boot my computer at a specific time and play a podcast
And as for launching iTunes and playing a Podcast, you should take a look at AppleScript. AppleScript is designed specifically for running and controlling Mac OS X applications—iTunes among them. (I once wrote a script to sync my iTunes play counts from last.fm, for example.) You might also look at the Automator program (I guess it's still included on most Macs). It does mostly the same thing as Applescript (automate Mac processes) but it's graphical and doesn't do quite as much. -MCL On Jun 16, 2013, at 3:44 PM, Petite Abeille wrote: On Jun 16, 2013, at 9:06 PM, C. N. Desrosiers cndesrosi...@gmail.commailto:cndesrosi...@gmail.com wrote: I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Under preferences, take a look at Energy Saver - Power Adapter - Schedule - Start up or wake. Alternatively, the command line utility pmset allows one to access the same functionalities. Is this sort of thing possible in Python? Sure. But why bother? All at one's finger tip already... -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Sun, Jun 16, 2013 at 2:39 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 15-06-13 21:54, ru...@yahoo.com schreef: On 06/15/2013 12:18 PM, rusi wrote: On Jun 15, 10:52 pm, Steven D'Apranosteve +comp.lang.pyt...@pearwood.**info comp.lang.pyt...@pearwood.info wrote: On Sat, 15 Jun 2013 10:36:00 -0700, rusi wrote: With you as our spamming-guru, Onward! Sky is the limit! If you're going to continue making unproductive, off-topic, inflammatory posts that prolong these already excessively large threads, Nikos won't be the only one kill-filed. At least two people -- Alex and Antoon -- have told you that by supporting Nikos, when everyone else wants him off list, you are part of the problem. Nikos is only secondarily the problem, Steven not at all. The primary problem is a (relatively small) number of people who respond to every post by Nikos with a barrage of insults, demands, (what they think are) witty repartee, hints intended to make Nikos learn something, useless (to Nikos) links, new threads to discuss the Nikos problem, and other trash that is far more obnoxious that anything Nikos posts and just serves to egg him on. Sorry but this is IMO a false equivallence. It ignores the important distinction between action and reaction. Does this number of people post a barrage of insult to no matter who? And you may find those responses more obnoxious they propbably are the reactions of people who are utterly fed up and think that if nobody is concerned about their annoyance they don't have to b econcerned about the annoyance of others either. Steven's advice on how to deal with Nikos was probably the most sensible thing I've seen posted here on the subject. Most sensible for what purpose? As far as I can see Steven's advice will just prolong the cycle of Nikos continuing to ask for spoonfeeding, showing very litle signs of understanding and keeping to hop from one problem/bug to the next until the mailing list has finished his project at which point he will probably start something new. If nikos's project was a college project we would have told him he has to make his homework himself. But now he is earning money with it, you seem to find it acceptable his job is done for him. I suggest that if you can and want to answer Nikos' question, do so directly and with a serious attempt address what it is he seems not to get, or killfile him and shut the fuck up. I suggest that if you want this to continue being a hospitable place, you don't encourage asocial behaviour. His behaviour may not bother you so much, but that shouldn't be the norm because others are less bothered with the barrage of insults Nikos is now receiving than with Nikos vampirizing this list, because they consider those insults deserved. -- Antoon Pardon -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list I'm with Antoon on this. If you look at this group, it almost completely revolves around the guy from Greece with 3 or 4 or 5 different email addresses. His area of interest is repetitive: 1. Get me out of the Unicode hell that is my own making 2. Do my linux sys admin for me 3. I can't be bothered with understanding what more there is to making software other than cutting and pasting code that other people are willing to write for me 4. Go back to [1] and start again. If you need to understand unicode and or hex notation, or binary notation (and most likely you will if you write code for a living), then go learn about those things. If you are unwilling to do that, then go away. If you think its best to help this person, and be kind to him, and encourage him to become a better citizen, please remember that being inviting to a person who ruins the party for everyone is not being respectful of everyone else. All the while monopolizing many threads From my perspective there seems to be some interesting people here with a wide array of experience and knowledge, whose understand and opinions I find fun and useful to read. All of that is drowned out by the freight train from superhost.gr -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 17/6/2013 2:58 μμ, Michael Torrie wrote: In python just think of assignment as making a name *be* an object. And if you assign one name to another name, that makes both names be the same object. When names are unbound (either they go out of scope or you manually unbind them), the objects they are bound to are garbage collected. Object here being the memory location, right? When we say a = 5 a = an easy way for calling that fixed memory location that holds our value, instead of calling it in binary format or in hex format. This is the direct object a is pointing too. Correct? 5 = *this* is the indirect object that a outputs when we print a. Are the above statements correct Michael? a = 5 b = a a --- memory address b --- memory address I like to think a and b as references to the same memory address -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 This is backwards. If the interpreter puts 5 in a *permanent* 'memory location' (which is not required by the language!), then it can associate 'a' with 5 by associating it with the memory location. CPython does this, but some other computer implementations do not. Please tell me how do i need to understand the sentence 'a' is being associated with number 5 in detail. Why don't we access the desired value we want to, by referencing to that value's memory location directly instead of using namespaces wich is an indirect call? i feel we have 3 things here a , memory address of a stored value, actual stored value So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? When you interpret Python code, do you put data in locations with integer addresses? I lost you here. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 16/6/2013 9:39 μμ, Antoon Pardon wrote: If nikos's project was a college project we would have told him he has to make his homework himself. This is where you all mistaken. You see, my website could be done ina CMS like (Joomla or Drupal) or even in DreamWeaver. I choosed Python because i like Python. Mny of my friends and clients told me hey man your website is very simple, how not Joomla-lize it with cool animation effects and stuff? Well, i could, but i dont want to because: 1. i want to learn Python 2. i want to have full control of my webisite, knowing each and every lien does, since i'm writing it. But now he is earning money with it, you seem to find it acceptable his job is done for him. No. I first try and inevitably i fail. Than i ask, and ask not only to be shown to the correct way of handling the code, but i want to be informed of how you thought of implementing the situation at hand. This way i learn from your experience and iam getting better and better every day as we speak, which in turn make me fond of Python increasingly. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 2013-06-17, Simpleton supp...@superhost.gr wrote: On 16/6/2013 9:39 , Antoon Pardon wrote: If nikos's project was a college project we would have told him he has to make his homework himself. This is where you all mistaken. You see, my website could be done ina CMS like (Joomla or Drupal) or even in DreamWeaver. I choosed Python because i like Python. Mny of my friends and clients told me hey man your website is very simple, how not Joomla-lize it with cool animation effects and stuff? Well, i could, but i dont want to because: 1. i want to learn Python 2. i want to have full control of my webisite, knowing each and every line does, since i'm writing it. But now he is earning money with it, you seem to find it acceptable his job is done for him. No. I first try and inevitably i fail. But failing _isn't_ inevitible. If you take the time to actually learn Python by reading the references people provide, by studying small examples, and by experimenting with Python code, there's no reason why you should fail. -- Grant Edwards grant.b.edwardsYow! MY income is ALL at disposable! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 17/6/2013 7:14 μμ, Grant Edwards wrote: But failing _isn't_ inevitible. If you take the time to actually learn Python by reading the references people provide, by studying small examples, and by experimenting with Python code, there's no reason why you should fail. I'am and i feel better expressing my questions to a live human being that read help file after help file to find some answer to a problem i have to deal with. Of course i spent you guys reply-time but many others(even experts) benefit from all this experience, not only me. Also what i have learned here the last month would have taken me way longer if i was researching for my self from doc=doc reference until i was able to understand something. I like things to be put up simple and i'am not trolling this group. I respect this group. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Mon, Jun 17, 2013 at 11:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 This is backwards. If the interpreter puts 5 in a *permanent* 'memory location' (which is not required by the language!), then it can associate 'a' with 5 by associating it with the memory location. CPython does this, but some other computer implementations do not. Please tell me how do i need to understand the sentence 'a' is being associated with number 5 in detail. Why don't we access the desired value we want to, by referencing to that value's memory location directly instead of using namespaces wich is an indirect call? i feel we have 3 things here a , memory address of a stored value, actual stored value So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? When you interpret Python code, do you put data in locations with integer addresses? I lost you here. -- What is now proved was at first only imagined! -- http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list Read and study this. Then come back and ask again. Don't think of physical representation of memory with actual binary addresses. Python is not assembler. Neither is it C (sometimes called high level assembler) http://docs.python.org/2/tutorial/classes.html#python-scopes-and-namespaces -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 This is backwards. If the interpreter puts 5 in a *permanent* 'memory location' (which is not required by the language!), then it can associate 'a' with 5 by associating it with the memory location. CPython does this, but some other computer implementations do not. Please tell me how do i need to understand the sentence 'a' is being associated with number 5 in detail. Why don't we access the desired value we want to, by referencing to that value's memory location directly instead of using namespaces wich is an indirect call? i feel we have 3 things here a , memory address of a stored value, actual stored value So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? When you interpret Python code, do you put data in locations with integer addresses? I lost you here. You're confusing the way in which the CPython interpreter is written with the way the Python language is defined. Yes, the CPython interpreter puts 5 into a numbered memory location when creating the object. But the Nikos Python Interpreter (which is a completely valid, although quite buggy, Python interpreter that uses your head to interpret the code) should not be using numbered memory locations. Forget about memory locations. Memory locations don't exist. Let's use the pen-and-paper Python interpreter. On the left side of the paper, we'll write down the names. On the rest of the paper, we'll write down the objects. When I do x =[], I make a new list (which means I write down [] somewhere in the middle of the page), I create the name x (which means I write down an x on the left side of the page), and then I draw an arrow pointing from the x to the []. (sorry if my drawing doesn't line up in your email/news client- I'll try to make it line up correctly with a monospace font) | x -- []| | | | | Now, When we do y = x, the right side of the equation is evaluated (which gives us the object currently bound to the name x) and it is then given the newly created name y | x -- []| | ^| | y || When we do x.append(3), the object that x refers to is modified. This is seen by both x and y because they point to the same object. | x -- [3] | | ^| | y || When I do x = [], a new object is created somewhere else on the page, and the name x is made to point to the new object. This changes the arrow. The name x is not in any way tied to the location of the [3] on the page. This doesn't impact y which is still pointing at the same spot it was before | x [] [3] | | ^| | y || That is how Python's object model works. In CPython, objects have specified memory locations but names do not. In IronPython and Jython, even that's not guaranteed- the garbage collector can move the objects around during their lifetime, so while you can trust that a name will always point to the correct object, you have no guarantee about where the object is located in the computer's memory. -- http://mail.python.org/mailman/listinfo/python-list
Natural Language Processing with Python .dispersion_plot returns nothing
I'm in the first chapter of Natural Language Processing with Python and am trying to run the example .dispersion_plot. I am using Python 2.7.4 (Anaconda) on Mac OSX 10.8. When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new prompt, just a blinking cursor under the last line I typed. Here is what I've been doing: [~]: python Python 2.7.4 |Anaconda 1.5.1 (x86_64)| (default, May 9 2013, 12:12:00) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. import numpy import matplotlib import nltk from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Type the name of the text or sentence to view it. Type: 'texts()' or 'sents()' to list the materials. text1: Moby Dick by Herman Melville 1851 text2: Sense and Sensibility by Jane Austen 1811 text3: The Book of Genesis text4: Inaugural Address Corpus text5: Chat Corpus text6: Monty Python and the Holy Grail text7: Wall Street Journal text8: Personals Corpus text9: The Man Who Was Thursday by G . K . Chesterton 1908 text4.dispersion_plot([citizens, democracy, freedom, duties, America]) ...and nothing. I can't paste it but my cursor is just blinking under my last command with no prompt. So far the other example commands from the chapter (e.g. .concordance) work fine, so I'm guessing the problem is something with numpy or matplotlib. I had a heck of a time getting matplotlib installed correctly (kept getting errors saying that it wasn't installed even when I had installed it), but since switching to the Anaconda distro, which had those prepackaged, I haven't gotten any module errors. Any advice?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Mon, 17 Jun 2013 14:39:56 + (UTC) Grant Edwards invalid@invalid.invalid wrote: I don't want _any_ copies from from Mailman. I don't subscribe to whatever mailing list you're talking about. I'm reading this via an NNTP server. Keep replies in the group or on the list. And that is part of the problem. I have always argued that gatewaying the mailing list to newgroups is wrong. If this was only a mailing list there are many things we could do to reduce abuse but because of the gateway they can't be done. Not that it matters to me any more. I have finally decided that this list is just more noise to signal than I care to deal with. If anyone has any comments for me you will have to Cc me as I am outa here. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 788 2246 (DoD#0082)(eNTP) | what's for dinner. IM: da...@vex.net, VOIP: sip:da...@vex.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Natural Language Processing with Python .dispersion_plot returns nothing
In 05bb0af7-a20b-4b89-92bb-ff25ebd69...@googlegroups.com sixtyfourbit davidcp...@gmail.com writes: When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new prompt, just a blinking cursor under the last line I typed. How long did you wait for results before interrupting the command? How large is text4? It might just take a while to process. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Updating a filename's counter value failed each time
Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --- if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) --- For some reason this never return any data, because for troubleshooting i have tried: - data = cur.fetchone() if data: print(something been returned out of this_ Since for sure the filename the user selected is represented by a record inside 'files' table why its corresponding counter never seems to get updated? Thank you. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Natural Language Processing with Python .dispersion_plot returns nothing
I let it run for 5-10 minutes. It's doing this no matter which text I try to run the dispersion plot on On Monday, June 17, 2013 12:38:58 PM UTC-4, John Gordon wrote: In 05bb0af7-a20b-4b89-92bb-ff25ebd69...@googlegroups.com sixtyfourbit davidcp...@gmail.com writes: When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new prompt, just a blinking cursor under the last line I typed. How long did you wait for results before interrupting the command? How large is text4? It might just take a while to process. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to automatically boot my computer at a specific time and play a podcast
On 17-6-2013 15:24, inq1ltd wrote: On Sunday, June 16, 2013 12:06:08 PM C. N. Desrosiers wrote: Hi, I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python? You can use the osascript utility to send commands to itunes, and invoke it from Python like this: import subprocess listname = My Playlist subprocess.call([osascript, -e, tell application \iTunes\ to play playlist \{0}\.format(listname)]) But that seems overkill (using Python to use Applescript to control iTunes)... Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 17/6/2013 7:23 μμ, Benjamin Kaplan wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: On 6/17/2013 7:34 AM, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location 2. the latter holds value 5 This is backwards. If the interpreter puts 5 in a *permanent* 'memory location' (which is not required by the language!), then it can associate 'a' with 5 by associating it with the memory location. CPython does this, but some other computer implementations do not. Please tell me how do i need to understand the sentence 'a' is being associated with number 5 in detail. Why don't we access the desired value we want to, by referencing to that value's memory location directly instead of using namespaces wich is an indirect call? i feel we have 3 things here a , memory address of a stored value, actual stored value So is it safe to say that in Python a == a ? ( stands for memory address) is the above correct? When you interpret Python code, do you put data in locations with integer addresses? I lost you here. You're confusing the way in which the CPython interpreter is written with the way the Python language is defined. Yes, the CPython interpreter puts 5 into a numbered memory location when creating the object. But the Nikos Python Interpreter (which is a completely valid, although quite buggy, Python interpreter that uses your head to interpret the code) should not be using numbered memory locations. Forget about memory locations. Memory locations don't exist. Let's use the pen-and-paper Python interpreter. On the left side of the paper, we'll write down the names. On the rest of the paper, we'll write down the objects. When I do x =[], I make a new list (which means I write down [] somewhere in the middle of the page), I create the name x (which means I write down an x on the left side of the page), and then I draw an arrow pointing from the x to the []. (sorry if my drawing doesn't line up in your email/news client- I'll try to make it line up correctly with a monospace font) | x -- []| | | | | Now, When we do y = x, the right side of the equation is evaluated (which gives us the object currently bound to the name x) and it is then given the newly created name y | x -- []| | ^| | y || When we do x.append(3), the object that x refers to is modified. This is seen by both x and y because they point to the same object. | x -- [3] | | ^| | y || When I do x = [], a new object is created somewhere else on the page, and the name x is made to point to the new object. This changes the arrow. The name x is not in any way tied to the location of the [3] on the page. This doesn't impact y which is still pointing at the same spot it was before | x [] [3] | | ^| | y || That is how Python's object model works. In CPython, objects have specified memory locations but names do not. In IronPython and Jython, even that's not guaranteed- the garbage collector can move the objects around during their lifetime, so while you can trust that a name will always point to the correct object, you have no guarantee about where the object is located in the computer's memory. EXCELLENT EXPLANATION, THANK YOU VERY MUCH. I AM SAVING THIS TO A .TXT FOR FUTURE REFERENCE. THAT'S WHY I ASK YOU GUYS FOR HUMAN LIKE EXPLANATIONS. THIS CANNOT BE FIND WITH SUCH SIMPLE WAY OF PUTTING THIS IN TECH DOCS. Something else please: The way some info(i.e. a Unicode string) is saved into the hdd , is the same way its being saved into the memory too? Same way exactly? While you said to me to forget about memory locations, and that's indeed made things easy to follow i still keep wondering, how Python internally keeping tracks of 'x' and 'y' names as well as their referenced
Re: Updating a filename's counter value failed each time
On 17/06/2013 17:39, Simpleton wrote: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --- if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) --- For some reason this never return any data, because for troubleshooting i have tried: - data = cur.fetchone() if data: print(something been returned out of this_ Since for sure the filename the user selected is represented by a record inside 'files' table why its corresponding counter never seems to get updated? You say for sure. Really? Then why isn't it working as you expect? When it comes to debugging, assumption is the mother of all -ups [insert relevant expletive for ]. Assume nothing. What is the value of 'filename'? What are the entries in the 'files' table? Print them out, for example: print(filename is, ascii(filename)) or write them into a log file and then look at them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Natural Language Processing with Python .dispersion_plot returns nothing
sixtyfourbit wrote: I'm in the first chapter of Natural Language Processing with Python and am trying to run the example .dispersion_plot. I am using Python 2.7.4 (Anaconda) on Mac OSX 10.8. When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new prompt, just a blinking cursor under the last line I typed. Here is what I've been doing: [~]: python Python 2.7.4 |Anaconda 1.5.1 (x86_64)| (default, May 9 2013, 12:12:00) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. import numpy import matplotlib import nltk from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent9 Type the name of the text or sentence to view it. Type: 'texts()' or 'sents()' to list the materials. text1: Moby Dick by Herman Melville 1851 text2: Sense and Sensibility by Jane Austen 1811 text3: The Book of Genesis text4: Inaugural Address Corpus text5: Chat Corpus text6: Monty Python and the Holy Grail text7: Wall Street Journal text8: Personals Corpus text9: The Man Who Was Thursday by G . K . Chesterton 1908 text4.dispersion_plot([citizens, democracy, freedom, duties, America]) ...and nothing. I can't paste it but my cursor is just blinking under my last command with no prompt. So far the other example commands from the chapter (e.g. .concordance) work fine, so I'm guessing the problem is something with numpy or matplotlib. I had a heck of a time getting matplotlib installed correctly (kept getting errors saying that it wasn't installed even when I had installed it), but since switching to the Anaconda distro, which had those prepackaged, I haven't gotten any module errors. Any advice?? The dispersion_plot() method uses pylab.show() to display the data (in another window). Only when you close that window the interactive interpreter becomes responsive again. If you didn't overlook that window: do you run into the same problem with import pylab pylab.plot([1, 2, 3], [3, 1, 2]) [matplotlib.lines.Line2D object at 0x2d713d0] pylab.show() ? If so, choose another backend. I've not tried, but it seems straight- forward, see http://matplotlib.org/faq/usage_faq.html#what-is-a-backend -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 17 June 2013 17:35, D'Arcy J.M. Cain da...@druid.net wrote: On Mon, 17 Jun 2013 14:39:56 + (UTC) Grant Edwards invalid@invalid.invalid wrote: I don't want _any_ copies from from Mailman. I don't subscribe to whatever mailing list you're talking about. I'm reading this via an NNTP server. Keep replies in the group or on the list. And that is part of the problem. I have always argued that gatewaying the mailing list to newgroups is wrong. If this was only a mailing list there are many things we could do to reduce abuse but because of the gateway they can't be done. There is a very simple solution used by many mailing lists which is to set the Reply-To header to point back to the mailing list. That way any old email client on any OS/computer/phone/website etc. has the required button to reply to the list without CCing anyone. It also reduces the chance of accidentally replying off-list. Anyone who wants to reply off-list or to deliberately CC someone (as I did here) can still do so but it will rarely happen accidentally. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
In kpne3k$1066$1...@news.ntua.gr Simpleton supp...@superhost.gr writes: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --- if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) --- For some reason this never return any data, because for troubleshooting i have tried: - data = cur.fetchone() if data: print(something been returned out of this_ An UPDATE statement isn't a query. There are no results to be fetched. If you want to get results, execute a query (usually a SELECT.) Also, that print statement is an obvious syntax error. Please post the actual code you're running; don't type it in from memory. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/6/2013 8:40 μμ, MRAB wrote: On 17/06/2013 17:39, Simpleton wrote: Hello again, something simple this time: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --- if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) --- For some reason this never return any data, because for troubleshooting i have tried: - data = cur.fetchone() if data: print(something been returned out of this_ Since for sure the filename the user selected is represented by a record inside 'files' table why its corresponding counter never seems to get updated? You say for sure. Really? Then why isn't it working as you expect? When it comes to debugging, assumption is the mother of all -ups [insert relevant expletive for ]. Assume nothing. What is the value of 'filename'? What are the entries in the 'files' table? Print them out, for example: print(filename is, ascii(filename)) or write them into a log file and then look at them. Yes i have tried to print it and correct. for example i have selected a filename just now from filename is Σκέψου έναν αριθμό.exe he is the actual filenames valeus from database: http://i.imgur.com/GxIMW4C.png Seems like the value of the database isnt being matched with the 'filename' var's value that why the update never return any data. i wonder why the update never happens! -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
In article kpne3k$1066$1...@news.ntua.gr you wrote: After a user selects a file from the form, that sleection of his can be found form reading the variable 'filename' If the filename already exists in to the database i want to update its counter and that is what i'm trying to accomplish by: --- if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) There are (single) quotes missing around (at least) the file name (the 'url' column) which I'm rather sure is a string - you need them around all strings you use in SQL statements. I don't know which database and interface you're using but I would guess that many have the ability to inserting quotes where neces- sary etc. E.g. with sqlite3 you would use cur.execute('UPDATE files SET hits = hits + 1, host = ?, lastvisit = ? ' 'WHERE url = ?', (host, lastvisit, filename) ) and the quotes required around (at least) the 'filename' string will be inserted automatically. Also take care to check the filename you insert - a malicous user might cobble together a file name that is actually a SQL statement and then do nasty things to your database. I.e. never insert values you received from a user without checking them. For some reason this never return any data, because for troubleshooting i have tried: data = cur.fetchone() There's nothing that your SQL statement (if correct) would return, so what do you expect to have returned by the fetchone() method? Perhaps there's something like the 'rowcount' property in sqlite3 which returns the number of rows modified by an INSERT or UPDATE. Since for sure the filename the user selected is represented by a record inside 'files' table why its corresponding counter never seems to get updated? I would guess because you forgot the uotes around string values in your SQL statement which thus wasn't executed. Regards, Jens -- \ Jens Thoms Toerring ___ j...@toerring.de \__ http://toerring.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 17/6/2013 8:42 μμ, Oscar Benjamin wrote: On 17 June 2013 17:35, D'Arcy J.M. Cain da...@druid.net wrote: On Mon, 17 Jun 2013 14:39:56 + (UTC) Grant Edwards invalid@invalid.invalid wrote: I don't want _any_ copies from from Mailman. I don't subscribe to whatever mailing list you're talking about. I'm reading this via an NNTP server. Keep replies in the group or on the list. And that is part of the problem. I have always argued that gatewaying the mailing list to newgroups is wrong. If this was only a mailing list there are many things we could do to reduce abuse but because of the gateway they can't be done. There is a very simple solution used by many mailing lists which is to set the Reply-To header to point back to the mailing list. That way any old email client on any OS/computer/phone/website etc. has the required button to reply to the list without CCing anyone. It also reduces the chance of accidentally replying off-list. Anyone who wants to reply off-list or to deliberately CC someone (as I did here) can still do so but it will rarely happen accidentally. Oscar Yes please anyone do so, so we dont get 2 notification in both our mail reader and news reader at the same time. just repley only to the list. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 06/17/2013 02:15 AM, Antoon Pardon wrote: Op 17-06-13 05:46, ru...@yahoo.com schreef: On 06/16/2013 02:04 PM, Steven D'Aprano wrote: Yes. Trying to start flame wars with Nikos is unacceptable behaviour. It is unproductive, it makes this a hostile, unpleasant place to be, it ruins the environment for the rest of the community, it's off topic, and it simply doesn't work to discourage trolls. The difficulty with trying to suppress such responses is that the flamers get just as much pleasure from having a target to unrestrainedly spew their pent up anger and vile at, as the troll gets from simulating that reaction. The result is a positive feedback loop. Well if asocial behaviour of one provokes asocial behaviour in others, you can't claim the problem is not the social behaviour of the first. Sure I can. If you have a photodetector that activates a bright light when it detects a flash, you can blame the first flash for the fact that the bright light is on all the time. Or you can say that stray flashes are to be expected now and then in the environment of this system and the fault is responding to them with a bright light. I could be wrong but I don't think Nikos is a pure troll -- someone motivated purely by provoking reaction and discord. He has a real website and his problems with Python seem like genuine problems many beginners have. He seems to have little knowledge, not much concern for anyone else but a lot of determination to get things working. I have certainly known people like that in the real world. Does that matter? I don't care what Nikos's motivation is. I care about the result or effect of his behaviour and that seems to differ very little from a troll. Intent is not magic. Bad behaviour with the best of intentions still results in annoyance. The only way it which intent makes a difference is when the person with good intentions, upon learning his behaviour is bothersome, tries to adapt his behaviour. As I said (and you disagree with below), I did see some attempts to adapt his behavior but it is not realistic to expect immediate acquiescence to every request made here, especially given that a lot of them were/are bullshit. I speculate that half of his bad behavior is simple I want now and don't care about your conventions. The rest is a reaction to we're the alphas, your a beta attitude expressed by many here and later, overt hostility directed at him. He has changed some things -- his posting method, he's made an effort to understand his encoding issues, etc.' I don't see that much change in his style. He just admitted not reading help files (because they are too technical for him). So essentialy he is asking we give him a beginners tutorial in everything he doesn't understand without much effort of him trying to understand things on his own and without much appreciation for the time of others. See my reply to ChrisA. My personal feeling is that he tends to ask on the list too quickly, but I suspect he also does more than you're giving him credit for. He seems to be naive (eg the password event), open and honest so when he says he has been trying to fix something for hours I am prone to believe him. I think his approach to fixing is to try making changes more or less at random, in part because he doesn't understand the docs (or doesn't look at them because they haven't made sense to him in the past) and in part because he hasn't developed any skill in debugging (a skill that I think most everyone here takes for granted but which doesn't come naturally to some people) and which also accounts for the poor formulation of his questions. I'm not willing to go though twelve gazillion previous posts to try and find examples of improved behavior so I'll leave it as my personal impression and that you disagree. So I think Steven's approach of responding to his questions, at least those that are coherent and don't require reading a dozen posts over several threads to piece together, with an actual attempt to help (not a bunch of obscure hints, links to wikipedia, and you're an idiot replies) is right. A respons that is in effect reinforcing bad bahaviour. If Nikos fails to respond with better questions, then those that do answer will get tired of trying to help and stop answering. In the meantime everyone else can just killfile or otherwise ignore him rather than egging him on by intentionally provoking him (unless of course you enjoy the results.) In the mean time you and steve can just killfile those you think are just egging him on. Unfortunately it is not a symmetrical situation. Nikos responds only in his own threads and is more killable that many of the eggers who both more numerous and respond in many other threads that are of interest. But then I seldom killfile people (always have found it trivially easy just to skip over annoying threads) so maybe I need to explore killfile
Re: Using Python to automatically boot my computer at a specific time and play a podcast
On 2013-06-16, C. N. Desrosiers wrote: I'm planning to buy a Macbook Air and I want to use it as a sort of alarm. I'd like to write a program that boots my computer at a specific time, loads iTunes, and starts playing a podcast. Is this sort of thing possible in Python? I would suggest leaving your computer on and using the sched and subprocess modules of the standard library. -- Real (i.e. statistical) tennis and snooker player rankings and ratings: http://www.statsfair.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: Also take care to check the filename you insert - a malicous user might cobble together a file name that is actually a SQL statement and then do nasty things to your database. I.e. never insert values you received from a user without checking them. Yes in generally user iput validation is needed always, but here here the filename being selected is from an html table list of filenames. But i take it you eman that someone might tried it to pass a bogus filename value from the url like: http://superhost.gr/cgi-bin/files.py?filename=Select.; Si that what you mean? But the comma inside the execute statement doesn't protect me from such actions opposed when i was using a substitute operator? I would guess because you forgot the uotes around string values in your SQL statement which thus wasn't executed. i tried you suggestions: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) seems the same as: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) since everything is tripled quoted already what would the difference be in %s opposed to plain %s ? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
Νίκος supp...@superhost.gr wrote: On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: Also take care to check the filename you insert - a malicous user might cobble together a file name that is actually a SQL statement and then do nasty things to your database. I.e. never insert values you received from a user without checking them. Yes in generally user iput validation is needed always, but here here the filename being selected is from an html table list of filenames. But i take it you eman that someone might tried it to pass a bogus filename value from the url like: http://superhost.gr/cgi-bin/files.py?filename=Select.; Si that what you mean? Well, you neer wrote where this filename is coming from. so all I could assume was that the user can enter a more or less random file name. If he only can select one from a list you put together there's probably less of a problem. But the comma inside the execute statement doesn't protect me from such actions opposed when i was using a substitute operator? I would guess because you forgot the uotes around string values in your SQL statement which thus wasn't executed. i tried you suggestions: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) seems the same as: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) since everything is tripled quoted already what would the difference be in %s opposed to plain %s ? As I wrote you need *single* quotes around strings in SQL statements. Double quotes won't do - this is SQL and not Python so you're dealing with a different lan- guage and thus different rules apply. The triple single quotes are seen by Python, but SQL needs its own. Regards, Jens -- \ Jens Thoms Toerring ___ j...@toerring.de \__ http://toerring.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/06/2013 19:32, Jens Thoms Toerring wrote: Νίκος supp...@superhost.gr wrote: On 17/6/2013 8:54 μμ, Jens Thoms Toerring wrote: Also take care to check the filename you insert - a malicous user might cobble together a file name that is actually a SQL statement and then do nasty things to your database. I.e. never insert values you received from a user without checking them. Yes in generally user iput validation is needed always, but here here the filename being selected is from an html table list of filenames. But i take it you eman that someone might tried it to pass a bogus filename value from the url like: http://superhost.gr/cgi-bin/files.py?filename=Select.; Si that what you mean? Well, you neer wrote where this filename is coming from. so all I could assume was that the user can enter a more or less random file name. If he only can select one from a list you put together there's probably less of a problem. But the comma inside the execute statement doesn't protect me from such actions opposed when i was using a substitute operator? I would guess because you forgot the uotes around string values in your SQL statement which thus wasn't executed. i tried you suggestions: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) seems the same as: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) since everything is tripled quoted already what would the difference be in %s opposed to plain %s ? As I wrote you need *single* quotes around strings in SQL statements. Double quotes won't do - this is SQL and not Python so you're dealing with a different lan- guage and thus different rules apply. The triple single quotes are seen by Python, but SQL needs its own. The query looks safe to me as he _is_ using a parametrised query. -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 21:06:16 +0300, Νίκος wrote: But the comma inside the execute statement doesn't protect me from such actions opposed when i was using a substitute operator? You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an error. I would guess because you forgot the uotes around string values in your SQL statement which thus wasn't executed. i tried you suggestions: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) seems the same as: cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) since everything is tripled quoted already what would the difference be in %s opposed to plain %s ? As already noted JT made an error in assuming you were using string substitution not passing parameters the quotes are not required will case errors. as to your problem you have already been advised that update does not generate any returned data. to see the data you need to issue a select. to make debugging easier I suggest you need to use an easier way to see what is happening in the database assuming you are using mysql then phpmyadmin may help also as i have previously suggested it would be wise to keep this system off the internet untill you are satisfied it is working correctly secure. -- If God had really intended men to fly, he'd make it easier to get to the airport. -- George Winters -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
MRAB pyt...@mrabarnett.plus.com wrote: On 17/06/2013 19:32, Jens Thoms Toerring wrote: As I wrote you need *single* quotes around strings in SQL statements. Double quotes won't do - this is SQL and not Python so you're dealing with a different lan- guage and thus different rules apply. The triple single quotes are seen by Python, but SQL needs its own. The query looks safe to me as he _is_ using a parametrised query. Perhaps - the OP never told which API (or database) he is using. What about some API that simply connects the first argument of exxecute() with the second with just a simple '%' to construct the string for the SQL state- ment? In that case there would be no single quotes a- round strings, or would there? Regards, Jens -- \ Jens Thoms Toerring ___ j...@toerring.de \__ http://toerring.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
In kpne3k$1066$1...@news.ntua.gr Simpleton supp...@superhost.gr writes: if form.getvalue('filename'): cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) Add an 'else' statement above that prints something, so you will at least know if the UPDATE statement is ever executed. Print the cur.rowcount attribute, which contains the number of rows that were affected by the update. If it's zero, that should tell you something. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/6/2013 10:19 μμ, John Gordon wrote: Print the cur.rowcount attribute, which contains the number of rows that were affected by the update. If it's zero, that should tell you something. #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/6/2013 10:05 μμ, Alister wrote: You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an error. Even if the query is somehting like: http://superhost.gr/cgi-bin/files.py?filename=Select.; From what exactly the comma protects me for? What id=f the user passes data to filename variable throgh url? Will comma understand that? How can it tell form a normal filename opposes to a select statemnt acting as a filename value? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
I recommend that all participants in this thread, especially Alex and Anton, research the term Pathological Altruism -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 22:30:57 +0300, Νίκος wrote: On 17/6/2013 10:05 μμ, Alister wrote: You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an error. Even if the query is somehting like: http://superhost.gr/cgi-bin/files.py?filename=Select.; From what exactly the comma protects me for? What id=f the user passes data to filename variable throgh url? Will comma understand that? How can it tell form a normal filename opposes to a select statemnt acting as a filename value? this is because the execute method is written to escape the contents of the parameter list. if you want more information you really do need to read either the documentation or a good tutorial which would explain things far better than I can otherwise prove it to yourself by creating a dummy database trying it Make sure you are NOT using your production database so you do not risk any real data -- Being a BALD HERO is almost as FESTIVE as a TATTOOED KNOCKWURST. -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 19:16:02 +, Jens Thoms Toerring wrote: MRAB pyt...@mrabarnett.plus.com wrote: On 17/06/2013 19:32, Jens Thoms Toerring wrote: As I wrote you need *single* quotes around strings in SQL statements. Double quotes won't do - this is SQL and not Python so you're dealing with a different lan- guage and thus different rules apply. The triple single quotes are seen by Python, but SQL needs its own. The query looks safe to me as he _is_ using a parametrised query. Perhaps - the OP never told which API (or database) he is using. What about some API that simply connects the first argument of exxecute() with the second with just a simple '%' to construct the string for the SQL state- ment? In that case there would be no single quotes a- round strings, or would there? Regards, Jens Do you know of any python DB module that acts this way? if you do then that module does not conform to the python DB-API (PEP 249) should be avoided. whilst erring on the side of caution is commendable, Nicos is having enough problems without confusing him further. -- Today you'll start getting heavy metal radio on your dentures. -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 22:28:47 +0300, Νίκος wrote: On 17/6/2013 10:19 μμ, John Gordon wrote: Print the cur.rowcount attribute, which contains the number of rows that were affected by the update. If it's zero, that should tell you something. #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 replase if cur.rowcount: print( database has been affected ) with print cur.rowcount() you can also use phpmyadmin to try your sql queries interactively to check the perform as expected before putting them into your code -- Warp 7 -- It's a law we can live with. -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 20:44:03 +, John Gordon wrote: In MtKvt.47400$ja6.35986@fx18.am4 Alister alister.w...@ntlworld.com writes: #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 replase if cur.rowcount: print( database has been affected ) with print cur.rowcount() rowcount isn't a method call; it's just an attribute. You don't need the parentheses. My bad, Sorry if I confused Nicos further . -- It's better to be wanted for murder that not to be wanted at all. -- Marty Winch -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
In MtKvt.47400$ja6.35986@fx18.am4 Alister alister.w...@ntlworld.com writes: #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 replase if cur.rowcount: print( database has been affected ) with print cur.rowcount() rowcount isn't a method call; it's just an attribute. You don't need the parentheses. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 20:26:57 +, Alister wrote: On Mon, 17 Jun 2013 22:30:57 +0300, Νίκος wrote: On 17/6/2013 10:05 μμ, Alister wrote: You are correct Nicos, passing the values as a parameter list does protect you from SQL injection JT has made an error. Even if the query is somehting like: http://superhost.gr/cgi-bin/files.py?filename=Select.; From what exactly the comma protects me for? What id=f the user passes data to filename variable throgh url? Will comma understand that? How can it tell form a normal filename opposes to a select statemnt acting as a filename value? this is because the execute method is written to escape the contents of the parameter list. if you want more information you really do need to read either the documentation or a good tutorial which would explain things far better than I can otherwise prove it to yourself by creating a dummy database trying it Make sure you are NOT using your production database so you do not risk any real data Some very crude code using sqlite to demonstrate the principle (sqlite uses ? as a wild card instead of %s): import sqlite3 as sql db=sql.connect(':memory:') makedb=CREATE TABLE `TEST` (data text) cursor=db.cursor() cursor.execute(makedb) gooddata=safe text baddata =');drop table TEST cursor.execute(INSERT INTO TEST VALUES (?),[baddata]) cursor.execute('SELECT * from TEST') print cursor.fetchall() cursor.execute(INSERT INTO TEST VALUES ('%s')%gooddata) cursor.execute('SELECT * from TEST') print cursor.fetchall() cursor.execute(INSERT INTO TEST VALUES ('%s')%baddata) cursor.execute('SELECT * from TEST') print cursor.fetchall() the 1st 2 inserts will both work reasonable data will be printed. the 2nd will fail because sqlite does not allow multiple commands to be chained, if this was run in mysql then the table test would be deleted -- For a male and female to live continuously together is... biologically speaking, an extremely unnatural condition. -- Robert Briffault -- http://mail.python.org/mailman/listinfo/python-list
Re: My son wants me to teach him Python
On Sun, 16 Jun 2013 15:33:29 -0700, Rick Johnson wrote: On Sunday, June 16, 2013 4:52:16 PM UTC-5, Chris Angelico wrote: Okay... I'm trying to get my head around what you've done here. Isn't it simply that you've made a way to, with what looks like a point-and-click interface, let the user type in a command line? [...] That's no more using a GUI than bringing up a terminal is. Yes, a Graphical Interface will need the occasional peck-peck input from the user, the only difference from a text based interface is the INFINITY multiplier. The Graphical Interface prefers the point and click, but NOT exclusively! The Graphical Interface allows you apply the most efficient method by which to solve a problem -- again, that might be peck-peck or point-click, OR, a combination of both. Depends on the situation really. You have now completed the circle back to where everone else has always been use the correct tool for the job I believe that most programmers would probably follow the aproch of :- 1) write the code to perform the task 2) write a wrapper to present the user with a suitable interface stage 2 could be either a GUI or a CLUE (Command Line User Interface :-) ) or possibly even both depending on the application. -- An age is called Dark not because the light fails to shine, but because people refuse to see it. -- James Michener, Space -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Tue, Jun 18, 2013 at 12:41 AM, ru...@yahoo.com wrote: On 06/17/2013 01:23 AM, Chris Angelico wrote: On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. I'm aware the docs aren't perfect. But there's a world of difference between: Here's my code, tell me what's wrong. TELL ME NOW!! and Having trouble understanding this function [link to docs] - I expect X but Y happens. That's what I take issue with. The implication behind Nikos's questions is that he *can't be bothered* reading the docs, which he has explicitly confirmed above. That's nothing to do with the problems the documentation has; if Python had perfect documentation, he still wouldn't read it. That is a problem. A major problem. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 6/17/2013 1:17 PM, Νίκος wrote: On Mon, Jun 17, 2013 at 8:55 AM, Simpleton supp...@superhost.gr wrote: On 17/6/2013 5:22 μμ, Terry Reedy wrote: When you interpret Python code, do you put data in locations with integer addresses? I lost you here. Memory in biological brains is not a linear series of bits, or characters. How we do associate things is still mostly a puzzle. Read about holographic memory. The way some info(i.e. a Unicode string) is saved into the hdd , is the same way its being saved into the memory too? Same way exactly? No. A unicode string is a sequence of abstract characters or codepoints. They must be encoded somehow to map them to linear byte memory. There are still (too) many encodings in use. Most cannot encode *all* unicode characters. CPython is unusual in using one of three different encodings for internal unicode strings. While you said to me to forget about memory locations, This is excellent advice. One of the *features* of Python is that one *can* forget about addresses. One of the *problems* of C is that many people *do* forget about memory locations, while virus writers study them carefully. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On 17/06/2013 21:44, John Gordon wrote: In MtKvt.47400$ja6.35986@fx18.am4 Alister alister.w...@ntlworld.com writes: #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 replase if cur.rowcount: print( database has been affected ) with print cur.rowcount() rowcount isn't a method call; it's just an attribute. You don't need the parentheses. Well, you do need parentheses, it's just that you need them around the 'print': if cur.rowcount: print(cur.rowcount) -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 17/06/2013 15:41, ru...@yahoo.com wrote: It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. It's extremely easy to change the Python documentation, either raise an issue on the bug tracker or send an email to IIRC docs at python dot org. The fastest time I've ever seen between an issue being raised and the change being implemented was literally minutes. If that isn't good enough, put up or shut up. -- Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green. Snooker commentator 'Whispering' Ted Lowe. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: My son wants me to teach him Python
On Sun, Jun 16, 2013 at 3:55 AM, Cameron Simpson c...@zip.com.au wrote: On 14Jun2013 20:12, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: | [...] PowerShell has been | available as a download on WinXP and standard on Win7 [PS 3 is a | download for Win7, stock on real Win8]. | While I'm not fluent in it, there are some commands I've gotten | rather engrained... | | get-childitem -recurse -filter *.ad* | select-string -pattern with | | finds all the Ada (GNAT convention .ads/.adb) files containing with | statements. And pattern probably is a regex so I could fine tune it to | just the package withs by using a start of line marker... Hmm. find . -name '*.ad*' | xargs grep with on almost any UNIX system. There's any number of variations on that depending on exactly what you want. I'm not going to get sucked into a UNIX/Windows bickerfest here, but your PowerShell example isn't winning me over. Sound like they reinvented the wheel. Again, years later:-( As I understand it, PowerShell is intended primarily for automation and scripting, not for interactive console use. -- http://mail.python.org/mailman/listinfo/python-list
Problems with Python documentation [Re: Don't feed the troll...]
On Mon, 17 Jun 2013 07:41:54 -0700, rurpy wrote: On 06/17/2013 01:23 AM, Chris Angelico wrote: On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. This is very reasonable. And nobody -- well, at least not me, and probably not Chris -- expects that reading the documentation will suddenly cause the light to shine for every beginner who reads it. Often the official docs are written with an expected audience who already knows the language well. But in context, Nikos has been programming Python long enough, and he's been told often enough, that his FIRST stop should be the documentation, and us second. Not what he does now, which is to make us his first, second, third, fourth, fifth, sixth, seventh and eighth stops. (Are you paying attention Nikos?) But speaking more generally, yes, you are right, the docs are not a panacea. If they were, mailing lists like this, and websites like StackOverflow, would not exist. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Mon, 17 Jun 2013 14:34:57 +0300, Simpleton wrote: On 17/6/2013 9:51 πμ, Steven D'Aprano wrote: Now, in languages like Python, Ruby, Java, and many others, there is no table of memory addresses. Instead, there is a namespace, which is an association between some name and some value: global namespace: x -- 23 y -- hello world First of all thanks for the excellent and detailed explanation Steven. As for namespace: a = 5 1. a is associated to some memory location No. a is associated to an object, the int 5, which may be free to move in memory (PyPy does this), or may be at a fixed memory location (CPython does this). But the association is with the object, not the memory location. The object is a data structure that contains a type (int), a value (5), and various methods (e.g. bit_length, to_bytes). 2. the latter holds value 5 So 'a', is a reference to that memory location, so its more like a name to that memory location, yes? Instead of accessing a memory address with a use of an integer like 14858485995 we use 'a' instead. No. We're talking about what the Python interpreter does, not what you do. Whether you are programming in C or Python, you still refer to variables by name: a = 5 but what goes on inside the interpreter or compiler is different. So is it safe to say that in Python a == a ? ( stands for memory address) Absolutely not. is the above correct? I say this because here you said that: Instead, there is a namespace, which is anassociation between some name and some value: When you say that you mean that a is associated to some value as in memory location or to that memory location's address? No. This has nothing to do with memory locations. Namespaces are dicts. Write down a dict: {a: Hello world} Do you see a memory location there? There is no memory location. There is the name, a, and the object it is associated with, Hello world. Either the dict, or the string, may move around memory if the underlying memory manager allows it. Obviously any object in Python must be *somewhere* in memory at any specific moment, but that is irrelevant to understanding Python code. It is no more relevant than saying that a dict {'a': 5} is just made up of bits. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Mon, 17 Jun 2013 09:31:53 +0200, Antoon Pardon wrote: Op 16-06-13 22:04, Steven D'Aprano schreef: On Sun, 16 Jun 2013 20:16:34 +0200, Antoon Pardon wrote: You are trying to get it both ways. On the one hand you try to argue that there are no boundaries I have never, ever argued that there are no boundaries. I have repeatedly made it clear to Nikos when I thought he was behaving improperly. And I've done the same to others when they've acted improperly. That doesn't mean much. People can and do contradict themselves. So the fact that you made it clear to Nikos that he behaved improperly doesn't contradict you arguing somewhere else in a way that strongly suggest there are no boudaries. Except that I have never, ever argued or suggested or even hinted that there are no boundaries. The most you might legitimately accuse me of is failing to be sufficiently vigilant at enforcing boundaries, according to *your* idea of what is sufficient. But I'll take note that you assert there are boundaries. So I'll take it that there is nothing wrong with playing Internet Police and taking people to task who transgress this boundaries? There is an enormous difference between doing what I, and others, have done, which is to *politely* and *fairly* tell Nikos when he has transgressed, and what the flame-warriors have done, which is just fire off invective and insults. Not long ago I got taken to task, politely, off-list for responding to Ranting Rick with sarcasm. Sometimes the momentary pleasure of a flame outweighs the knowledge that it probably isn't doing any good and may be doing harm. I get that and don't hold it against anyone if they succumb to temptation once in a while. (Those like Peter Otten, who have been regulars here for *years* while still showing the patience of a saint, never fail to astonish me. If I could be even half as good.) But continuing to flame after being asked not to, and defending flamers, that crosses the line from spirit is willing, flesh is weak into *willfully bad* territory. Contrast Chris Angelico's recent email telling Nikos that he *actually should feel bad* about not reading the documentation. That is reasonable. It's not just a stream of insults. It doesn't just try to bully him into going away or shutting up in order to avoid being shouted at. If Nikos fails to learn from it, that is Nikos' failure, not Chris'. One thing I would like to make clear, is that I find you making it clear he behaviour is improper, to be inadequate for the reason that it ignores the possibility that you are playing a troll game. Oh my, that's funny. But seriously, don't do that. I won't put up with that sort of thing. You rarely contribute in this community, and now here you are trying to take the moral high ground by defending flaming and criticising those who give actual helpful, on-topic advice. I won't be called a troll by you. Do it again, and you're plonked. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
Στις 18/6/2013 1:22 πμ, ο/η MRAB έγραψε: On 17/06/2013 21:44, John Gordon wrote: In MtKvt.47400$ja6.35986@fx18.am4 Alister alister.w...@ntlworld.com writes: #update file's counter if cookie does not exist cur.execute('''UPDATE files SET hits = hits + 1, host = %s, lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) ) if cur.rowcount: print( database has been affected ) indeed every time i select afilename the message gets printed bu then again noticing the database via phpmyadmin the filename counter is always remaining 0, and not added by +1 replase if cur.rowcount: print( database has been affected ) with print cur.rowcount() rowcount isn't a method call; it's just an attribute. You don't need the parentheses. Well, you do need parentheses, it's just that you need them around the 'print': if cur.rowcount: print(cur.rowcount) Okey print( cur.rowcount ) shows each time a select a fialenme from the html table for downlaod that update affected 1 row. Checking the database records instantly shown that in fact the counter was increased by +1 Runing files.py turn all counter values to 0. So, update works, its the reload of files.py the deleets the values. # Delete those database records that do not exist as filenames inside the path for rec in data: if rec not in filenames: cur.execute('''DELETE FROM files WHERE url = %s''', rec ) # Load'em for filename in filenames: try: # try to insert the file into the database cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.ProgrammingError as e: # Insertion failed, file already into database, skip this, go to next filename pass These lines i dont how but they manage not to maintain the counter's value -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Natural Language Processing with Python .dispersion_plot returns nothing
On Mon, 17 Jun 2013 09:31:18 -0700, sixtyfourbit wrote: I'm in the first chapter of Natural Language Processing with Python and am trying to run the example .dispersion_plot. I am using Python 2.7.4 (Anaconda) on Mac OSX 10.8. When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new prompt, just a blinking cursor under the last line I typed. Here is what I've been doing: [...] ...and nothing. I can't paste it but my cursor is just blinking under my last command with no prompt. I expect that the plot is shown in a graphical window opened somewhere on screen, perhaps *under* the terminal window where you can't see it. Or maybe even a dialog box showing an error. Until that window or dialog is closed, the dispersion_plot command hasn't finished and Python will just wait forever. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
On Mon, 17 Jun 2013 19:39:16 +0300, Simpleton wrote: Hello again, something simple this time: Have you read these links yet? http://sscce.org/ http://www.catb.org/esr/faqs/smart-questions.html Especially the first one. Until you read it, and follow it's advice, I will not answer your question. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
Στις 18/6/2013 2:09 πμ, ο/η Steven D'Aprano έγραψε: {a: Hello world} Do you see a memory location there? There is no memory location. There is the name, a, and the object it is associated with, Hello world. Either the dict, or the string, may move around memory if the underlying memory manager allows it. Obviously any object in Python must be *somewhere* in memory at any specific moment, but that is irrelevant to understanding Python code. It is no more relevant than saying that a dict {'a': 5} is just made up of bits. Okey, the easy part was to understand how humans in high level need to understand namespaces and assignment (which is not copying but instead referencing another name to the same object). But i would like to know, what happens internally within the python compiler, because obviously memory is involved. The way some info(i.e. a Unicode string) is saved into the hdd , is the same way its being saved into the memory too? Same way exactly? While you said to me to forget about memory locations, and that's indeed made things easy to follow i still keep wondering, how Python internally keeping tracks of 'x' and 'y' names as well as their referenced objects (i.e. number 6). After all the way i understand memory is as a series of bits like: 0100010100001011010101001000100101001001111101001010010 So from the above binary form: what is 'x', what is 'y', how's 'x' and 'y' differ from the actually memory locations that are bound too, and of course what is the actual value. Its 3 things for me to consider, even in Python id internal level detail. I want to understand this. names, memory addresses, memory address's actual values -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
Finally i made it!! Here it is: # = # Have 1:1 mapping of files - database records, delete spurious # = filenames = [] # Turn files from bytestrings = strings and trim them from their paths for utf8_filename in utf8_filenames: filenames.append( utf8_filename.decode('utf-8').replace( '/home/nikos/public_html/data/apps/', '' ) ) # Create a database entry for each file for filename in filenames: try: # Try to insert the file into the database cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, %s, %s)''', (filename, host, lastvisit) ) except pymysql.IntegrityError as e: # Insertion failed, so, file already exist into database, skip this, go to next pass # Delete those database records that do not correspond to files cur.execute('''SELECT url FROM files''') data = cur.fetchall() for rec in data: if rec[0] not in filenames: cur.execute('''DELETE FROM files WHERE url = %s''', rec[0] ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
Στις 18/6/2013 2:30 πμ, ο/η Dennis Lee Bieber έγραψε: In the case of MySQLdb -- IT will wrap each argument with quotes, along with escaping any special characters. Even if the query is something like: http://superhost.gr/cgi-bin/files.py?filename=Select.; From what exactly the comma protects me for? What id=f the user passes data to filename variable through url? Will comma understand that? How can it tell form a normal filename opposes to a select statement acting as a filename value? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Tue, 18 Jun 2013 02:26:39 +0300, Νίκος wrote: Στις 18/6/2013 2:09 πμ, ο/η Steven D'Aprano έγραψε: {a: Hello world} Do you see a memory location there? There is no memory location. There is the name, a, and the object it is associated with, Hello world. Either the dict, or the string, may move around memory if the underlying memory manager allows it. Obviously any object in Python must be *somewhere* in memory at any specific moment, but that is irrelevant to understanding Python code. It is no more relevant than saying that a dict {'a': 5} is just made up of bits. Okey, the easy part was to understand how humans in high level need to understand namespaces and assignment (which is not copying but instead referencing another name to the same object). But i would like to know, what happens internally within the python compiler, because obviously memory is involved. Depends which Python compiler. CPython, IronPython, PyPy, Jython, Nuitka, Cython, ... ? They all operate differently on the inside. Only the high-level Python code has to be the same. Jython works according to the JRE, the Java Runtime Environment. There is masses of information about that on the Internet, google for it. IronPython works according to the .Net runtime environment. Again, google for it. PyPy is a VERY complex but powerful JIT compiler. You can read about it on the PyPy blog. Start here: http://morepypy.blogspot.com/ There's not a lot of documentation on how CPython works internally. You have to read the C source code. You will need to understand about garbage collectors, memory management, the difference between the stack and the heap, etc. It's a big area to study. Don't expect anyone to spend the days or weeks it will take to explain the whole thing. The way some info(i.e. a Unicode string) is saved into the hdd , is the same way its being saved into the memory too? Same way exactly? No. Unicode strings can be stored on disk in any encoding you like. Python stores string in memory as objects, which might look something like this: [Type=str, size=42, data=...] only more complicated. And subject to change -- anything you learn that holds for Python 3.3 might not apply for 3.2 or 3.4. In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. In Python 3.3, the data will be stored in either Latin-1, UTF-4, or UTF-8, depending on the contents of the string. While you said to me to forget about memory locations, and that's indeed made things easy to follow i still keep wondering, how Python internally keeping tracks of 'x' and 'y' names as well as their referenced objects (i.e. number 6). Good question, but I don't have a good answer. It has to do with the Python's memory manager, and the garbage collector. I don't know how they work. After all the way i understand memory is as a series of bits like: 0100010100001011010101001000100101001001111101001010010 So from the above binary form: what is 'x', what is 'y', how's 'x' and 'y' differ from the actually memory locations that are bound too, and of course what is the actual value. Its 3 things for me to consider, even in Python id internal level detail. I want to understand this. names, memory addresses, memory address's actual values Start here: https://duckduckgo.com/html/?q=how%20computers%20work -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 06/17/2013 03:43 PM, Chris Angelico wrote: On Tue, Jun 18, 2013 at 12:41 AM, ru...@yahoo.com wrote: On 06/17/2013 01:23 AM, Chris Angelico wrote: On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. I'm aware the docs aren't perfect. But there's a world of difference between: Here's my code, tell me what's wrong. TELL ME NOW!! and Having trouble understanding this function [link to docs] - I expect X but Y happens. I'm not sure he even thinks in those terms. He seems to have a hard time isolating misbehaving code to a particular function's behavior. I could speculate that it doesn't occur to him to lookup the function, or it hard to find (I had lots of problems finding stuff in the Python docs at first because the difference between builtins, other functions, methods, classes (look like functions when called) was not clear to me and when I did find the right place the doc was often in terms I didn't understand), or that he does but can't get a clear idea or gets the wrong idea about how it behaves, or... Figuring out how beginners think is something that talented teachers are good at and (from my observations) almost nobody here is. That's what I take issue with. The implication behind Nikos's questions is that he *can't be bothered* reading the docs, which he has explicitly confirmed above. He didn't confirm that at all! You are seeing what you want to see rather than what is there. He said he didn't read them because (see the quoted text above!), [they] seem too technical for me, not I can't be bothered. I agree the poor problem descriptions and the help me now tone (in other messages) is irritating. But I also realize I don't work for him and have no obligation to respond. So if it is something I can help with and I feel like it and no one else has posted anything useful, I might try. If I don't feel like it a quick click of the mouse moves me to the next topic. What is a waste of time is a hey, rtfm at this link, dickwad response. It doesn't help Nikos. It sends the message to everyone else that aggressive responses are ok And it likely prods Nikos (or whomever) to respond in kind. (A link in conjunction with some help though one hopes will be constructive.) That's nothing to do with the problems the documentation has; [they] seem too technical for me doesn't necessarily imply a problem with the docs (although it could) but it does imply their usefulness to Nikos is going to be limited until he gains a better understanding of some of the basic concepts and terminology of Python. And to anticipate the obvious, I am not advocating the docs be written to address Nikos' level of understanding, only that if people with much better understanding also find problems with them, that it is not surprising that Nikos has even more trouble with them, quite possibly finding them not useful at all. if Python had perfect documentation, he still wouldn't read it. If your crystal ball is that good, could you try using it to solve some of Nikos' problems? Now in the end you may turn out to be right and Nikos is playing everyone here to get as much free help as possible and those willing to help him are getting suckered. Still, until that becomes clear to me personally I'd rather err of the side of helping him when I can than not. And in either case abusive posts don't help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that was a typo. Do you perhaps UCS-2 or UCS-4 In Python 3.3, the data will be stored in either Latin-1, UTF-4, or UTF-8, depending on the contents of the string. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On 06/17/2013 04:22 PM, Mark Lawrence wrote: On 17/06/2013 15:41, ru...@yahoo.com wrote: It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. It's extremely easy to change the Python documentation, either raise an issue on the bug tracker or send an email to IIRC docs at python dot org. Really? Did you bother to read the link I included? Ironic that you are one of the people criticizing Nikos for not reading anything. The fastest time I've ever seen between an issue being raised and the change being implemented was literally minutes. If that isn't good enough, put up or shut up. Perhaps you missed this? http://bugs.python.org/issue1397474 While the lower bound may be minutes, the upper bound is a hell of a lot longer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with Python documentation [Re: Don't feed the troll...]
On Mon, Jun 17, 2013 at 6:50 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 17 Jun 2013 07:41:54 -0700, rurpy wrote: On 06/17/2013 01:23 AM, Chris Angelico wrote: On Mon, Jun 17, 2013 at 3:04 PM, Ferrous Cranus supp...@superhost.gr wrote: The only thing i'm feeling guilty is that instead of reading help files and PEP's which seem too technical for me, i prefer the live help of an actual expert human being. This is definitely a reason to feel guilty. You are asking people to provide live help for free, rather than simply reading the documentation. It is NOT a matter of simply reading the documentation. I have posted here several times as have many others about some of the problems the documentation has, especially for people who don't already know Python. This is very reasonable. And nobody -- well, at least not me, and probably not Chris -- expects that reading the documentation will suddenly cause the light to shine for every beginner who reads it. Often the official docs are written with an expected audience who already knows the language well. But in context, Nikos has been programming Python long enough, and he's been told often enough, that his FIRST stop should be the documentation, and us second. Not what he does now, which is to make us his first, second, third, fourth, fifth, sixth, seventh and eighth stops. (Are you paying attention Nikos?) But speaking more generally, yes, you are right, the docs are not a panacea. If they were, mailing lists like this, and websites like StackOverflow, would not exist. I read the python docs. I've gone through the tutorials. If not the first time, or the second, I get that Aha moment with additional reads. Some people say they learn better by other methods than reading. In that case, google like crazy because python has lots of pycon stuff online in video form, and there is the google course. and many others. If people interaction is what you need, find, and visit your local meetup or user group. Lots of places have them. If you don't have one near you, maybe you could start one so you would have local help and back and forth (fourth?). I think its great to read a question here and get a link for an answer. gives me somewhere to go explore more. If you reject these ways of learning for the single method of asking.. fix my code. Then you will never get good at this craft anyway. Its not the answers that are important, its discovering how to find the answers that is really important. The old give a man a fish, vs teach a man to fish truism -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Tue, 18 Jun 2013 00:41:53 +, Steven D'Aprano wrote: In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. In Python 3.3, the data will be stored in either Latin-1, UTF-4, or UTF-8, depending on the contents of the string. UTF-4? UTF-8? Whatever crack I was smoking, it obviously was *bad* crack. That should be UTF-8 or UTF-16. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Mon, 17 Jun 2013 21:06:57 -0400, Dave Angel wrote: On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that was a typo. Do you perhaps UCS-2 or UCS-4 Yes, that would be better. UCS-2 is identical to UTF-16, except it doesn't support non-BMP characters and therefore doesn't have surrogate pairs. UCS-4 is functionally equivalent to UTF-16, as far as I can tell. (I'm not really sure what the difference is.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On Tue, 18 Jun 2013 02:38:20 +, Steven D'Aprano wrote: On Tue, 18 Jun 2013 00:41:53 +, Steven D'Aprano wrote: In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. In Python 3.3, the data will be stored in either Latin-1, UTF-4, or UTF-8, depending on the contents of the string. UTF-4? UTF-8? Whatever crack I was smoking, it obviously was *bad* crack. That should be UTF-8 or UTF-16. Good lord, that crack is worse than I thought. UTF-16 and UTF-32. Bloody hell. I am ashamed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
While you said to me to forget about memory locations, and that's indeed made things easy to follow i still keep wondering, how Python internally keeping tracks of 'x' and 'y' names as well as their referenced objects (i.e. number 6). There is an excellent blog post about CPython internals: http://tech.blog.aknin.name/category/my-projects/pythons-innards/ but it might be difficult to follow if you cannot at least read C. It explains how python virtual machine works internally, how the opcodes are evaluated, how the three scopes globals, locals and builins find its place (and how names are bind). As far as I understand names are keys in the scope dictionaries, which are exposed in the python level as locals(), globals() and the builtin's. This is how Python tracks names and their values. To be more precise, when you do: a = 1 def f(): ... b=2 in the first line 'a' is added to the globals() dictionary with value 1, and in the third line 'b' with value 2 is added to the local dictionary of f. It is also all explained in the python docs, and it reflects how python is implemented (at least CPython). After all the way i understand memory is as a series of bits like: 0100010100001011010101001000100101001001111101001010010 So from the above binary form: what is 'x', what is 'y', how's 'x' and 'y' differ from the actually memory locations that are bound too, and of course what is the actual value. 'x' and 'y' are just strings which are written somewhere in the computer's memory. Its 3 things for me to consider, even in Python id internal level detail. I want to understand this. names, memory addresses, memory address's actual values Names and values are not connected through their memory addresses but because they live in a higher structure, name is a key and value is a value of a dictionary (which is also represented in some way at the C level, namely by PyDictObject ... but for this you need to first learn C, but please read and understand the Python docs - there is already a lot there for you ... Best regards, Marcin -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
On 06/17/2013 10:42 PM, Steven D'Aprano wrote: On Mon, 17 Jun 2013 21:06:57 -0400, Dave Angel wrote: On 06/17/2013 08:41 PM, Steven D'Aprano wrote: SNIP In Python 3.2 and older, the data will be either UTF-4 or UTF-8, selected when the Python compiler itself is compiled. I think that was a typo. Do you perhaps UCS-2 or UCS-4 Yes, that would be better. UCS-2 is identical to UTF-16, except it doesn't support non-BMP characters and therefore doesn't have surrogate pairs. UCS-4 is functionally equivalent to UTF-16, Perhaps you mean UTF-32 ? as far as I can tell. (I'm not really sure what the difference is.) Now you've got me curious, by bringing up surrogate pairs. Do you know whether a narrow build (say 3.2) really works as UTF16, so when you encode a surrogate pair (4 bytes) to UTF-8, it encodes a single Unicode character into a single UTF-8 sequence (prob. 4 bytes long) ? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Jun 18, 2:19 am, Simpleton supp...@superhost.gr wrote: I like things to be put up simple and i'am not trolling this group. I respect this group. There are a number of things you could to do confirm this: 1. Stop changing your name. 2. Stop bumping your threads if no one responds. 3. Stop exaggerating the benefit your threads have for others. 4. Stop posting code chunks and saying What now? Show what you've tried to debug the problem. 5. Stop ignoring requests to modify your behaviour while simultaneously demanding that others here do. 6. Read the links people provide you and then ask further questions using the content of those links as a basis. tl;dr Stop acting like a troll and we'll stop perceiving you as such. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams
On Jun 16, 2:09 pm, Larry Hudson org...@yahoo.com wrote: On 06/15/2013 03:10 PM, alex23 wrote: (Sorry for the ugly url, it's a Google translation of a french language page) Somewhat OT, but have you ever looked at tinyurl.com? Very useful for this sort of thing. From past comments on this list, people can be reticent to click on URL shortener links as it's not immediately obvious where it will take them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Updating a filename's counter value failed each time
Στις 18/6/2013 4:42 πμ, ο/η Dennis Lee Bieber έγραψε: Do you ever COMMIT the changes. cur.execute(update anything set something = whatever where that = this) without doing a con.commit() is just going to rollback the changes. committing the changes inst necessary neither is disconnecting from the database, this are done automatically. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
[issue15955] gzip, bz2, lzma: add option to limit output size
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15955 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16043] xmlrpc: gzip_decode has unlimited read()
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16043 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com