use python / qt with cygwin
Hello, Do you know if it is possible to use python + qt bindings in cygwin ? I've looked inside kde / cygwin. There is a package named qt-gcc-3 but I did'nt find the qt bindings for python :/ Is there a way to do that ? Or am I obliged to use tkinter to make user interfaces when I'm with python / cygwin ? Regards, blureD. -- http://mail.python.org/mailman/listinfo/python-list
Re: Organization of GUIs
On Dec 3, 2:44 pm, Michael Mossey wrote: > complete VISIBILITY and control of messages ... is most important: being able to SEE messages (filtered on from, to, ...) in a running system really helps to understand it. Hierarchy does help structure messages coarse/fine, but visibility is orthogonal to structure (you can have visible democracy, blind hierarchy, in real life too.) Visibility has to be built in from the beginning -- wrap all connect() s in a visconnect() that can trace. Dietmar's shell sounds Right; anyone know of such in PyQt ? cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Total maximal size of data
On Jan 25, 8:05 pm, Alexander Moibenko wrote: > I have a simple question to which I could not find an answer. > What is the [total maximal] size of list including size of its elements? Beware, sys.getsizeof(alist) is 4*len(alist) + a bit, regardless of alists's contents ?! See http://stackoverflow.com/questions/2117255/python-deep-getsizeof-list-with-contents cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Most "active" coroutine library project?
On Sep 23, 10:58 pm, Brian Hammond wrote: > On Aug 25, 12:51 am, Denis wrote: > > > You can also atgevent > > >http://pypi.python.org/pypi/gevent > > Please, please document this! There are a lot of people who would > love to use this but give up when they don't find a guide or something > similar. I've actually started doing that recently, check out http://gevent.org Feedback is appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available
On Oct 7, 2:16 am, "Sridhar Ratnakumar" wrote: > ... > This release includes a new packaging tool by activestate called Python > Package Manager (PyPM).PyPM- currently in beta - is the package Sridhar, folks, the ActivePython FAQ says "While you can install most packages registered in PyPI using the PyPM client, some packages may not yet be available in the ActiveState repository" Does that mean that PyPM installs ONLY from the activestate repository and not from url or .tar.gz or dir/ ? cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: ActivePython 2.6.3.7 (and PyPM) is now available
On Oct 16, 2:23 pm, srid wrote: > > Does that mean that PyPM installs ONLY from the activestate repository > > and not from url or .tar.gz or dir/ ? > > This is correct. Although it may change in the future. Note that Sridhar, activestate folks, if you want people to switch to PyPM, make it UNIFORM and COMPATIBLE. "Use tool A for this, tool B for that" => FearUncertaintyandDoubt => reduced market share (at least for people who don't enjoy FearUncertaintyandDoubt) cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient running median
Folks, approximate medians -- would you settle for 49 - 51 % ? -- open up new possibilities, and there's quite a lot of work on that, for huuuge datasets. A class of problems: from a data stream X1 X2 ... you want, every so often, a histogram / quantile summary / distribution estimator such that H approximates the distribution of X, so median of H(t) ~ median of some of X. Some parameters of this class: NH, size of H: 100 => H(p) ~ pth percentile of X A, how often you want H window, drop or age old data runtime, memory of course accuracy -- in theory, in practice A histogram viewer in which you can change buckets, colors, zoom, in REALTIME sounds tantalizing -- fast loop >> fast algorithm + slow loop. Anyone know of one off-the -shelf, python or anything else ? Refs: Manku et al., Approximate medians in one pass with limited memory, 1998, 10p under http://infolab.stanford.edu/~manku/papers.html nice tree pictures they optimize mem (NH * Nbuf) not runtime, and don't window Suri +, Quantiles on Streams, 2006, 5p, http://www.cs.ucsb.edu/~suri/psdir/ency.pdf ~ 20 refs zzz cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient running median
Yet another link: http://en.wikipedia.org/wiki/Median_filter --> Perreault + Hebert, Median Filtering in Constant Time, nice 6-page paper + 400 lines well-documented C code: http://nomis80.org/ctmf.html (for 2d images, dropping to 1d must be possible :) They're also in opencv, which I haven't tried -- http://www.intel.com/technology/computing/opencv http://code.google.com/p/ctypes-opencv http://code.google.com/p/opencv-cython cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient running median
Based on Perreault + Hebert, here's python code for a rather different algorithm: - for quantized e.g. 8-bit data - runs faster for wider windows / slowly changing medians - no heaps, no trees: the only import is numpy, and even that's not essential http://stackoverflow.com/questions/1309263/rolling-median-algorithm-in-c cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQT4 user group
For detailed questions, try http://stackoverflow.com/questions/tagged/pyqt or pyqt4 (the " or " may have to be escaped as "%20or%20" in some browsers.) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check if any item from a list of strings is in a big string?
Matt, how many words are you looking for, in how long a string ? Were you able to time any( substr in long_string ) against re.compile ( "|".join( list_items )) ? (REs are my method of choice, but different inputs of course give different times -- see google regex speed site:groups.google.com / site:stackoverflow.com .) cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check if any item from a list of strings is in a big string?
Sure, Aho-Corasick is fast for fixed strings; but without real numbers / a concrete goal > > Matt, how many words are you looking for, in how long a string ? a simple solution is good enough, satisficing. Matt asked "how to make that function look nicer?" but "nice" has many dimensions -- bicycles are nice for some tasks, Ferraris for others. Bytheway http://en.wikipedia.org/wiki/Aho-Corasick_algorithm has a link to a Python implementation, also http://en.wikipedia.org/wiki/Worse_is_Better is fun. -- http://mail.python.org/mailman/listinfo/python-list
Re: Most "active" coroutine library project?
You can also at gevent http://pypi.python.org/pypi/gevent On Aug 23, 10:02 pm, Phillip B Oldham wrote: > I've been taking a look at the multitude of coroutine libraries > available for Python, but from the looks of the projects they all seem > to be rather "quiet". I'd like to pick one up to use on a current > project but can't deduce which is the most popular/has the largest > community. > > Libraries I looked at include: cogen, weightless, eventlet and > circuits (which isn't exactly coroutine-based but it's event-driven > model was intriguing). > > Firstly, are there any others I've missed? And what would the > consensus be on the which has the most active community behind it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question -- plural of class name?
On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote: > FooEntry is a class. How would you describe a list of these in a > docstring? > > "A list of FooEntries" > > "A list of FooEntrys" > > "A list of FooEntry's" > > "A list of FooEntry instances" > > The first one certainly sounds the best, but it seems wierd to change > the spelling of the class name to make it plural. I wouldn't use an apostrophe for pluralisation. The Normal pluralisation of FooEntry would be FooEntries. Who are you expecting to read the docstring? English majors, grammar nazis, wikipedia editors, programmers, or all 4? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: in need of some help regarding my rock paper scissors game
On Sun, 12 May 2013 20:33:44 +0100, Alex Norton wrote: > 'Traceback (most recent call last): File "C:\Users\Me\Desktop\testy.py", > line 174, in bWater.clicked.connect( water_clicked ) AttributeError: > 'int' > object has no attribute 'clicked'' appears when i run the module. It looks to me as if bWater is an integer value and doesn't have a .clicked attribute. Where is bWater assigned, and what is it assigned to? If you have a clickable "water" widget of some sort in your gui, what is the click handler for that widget defined as? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A computer programmer, web developer and network admin resume
On Wed, 22 May 2013 01:15:27 +, i...@databaseprograms.biz wrote: > If you would like this in text format instead, please let me know. What if we don't want it at all? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Myth Busters: % "this old style of formatting will eventually be removed from the language"
On Tue, 21 May 2013 23:26:58 -0400, Ned Batchelder wrote: > On 5/21/2013 10:26 PM, Carlos Nepomuceno wrote: >> "Since str.format() is quite new, a lot of Python code still uses the % >> operator. However, because this old style of formatting will eventually >> be removed from the language, str.format() should generally be used." >> Is this tutorial outdated or this still an issue? > That tutorial is out of date. %-formatting isn't being removed. Indeed, removing %-formatting could break a substantial amount of live code, with potentially significant maintenance effort in the user community simply to make existing code work with the new interpreter. The effect of this on corporations using python code translates into "business risk", and the next step is "we can avoid the business risk by migrating our python scripts to some other language." For the designers and maintainers of any language to arbitrarily[1] (in the eyes of the user base) remove a widely used feature that would have a major effect on the user base could kill off a language, simply because many users will not want to take the risk of it happening again, even if they can easily automate the upgrade from removed obsolete language feature to new shiny language feature. [1] Some portion of the user base will always consider any such change that causes them headaches and additional effort as having been arbitrary, no matter how well the language designers and maintainers explain the need to break the old scripts. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: file I/O and arithmetic calculation
On Thu, 23 May 2013 01:13:19 +0900, Keira Wilson wrote: > I would appreciate if someone could write a simple python code for the > purpose below: Didn't have your data, so couldn't verify it completely, but try this: import re def v(s): l=len(s) t=0. for i in range(l): t=t+(abs(ord(s[i]))*1.) return t/(l*1.) for n in range(5): m="c:/test/"+str(n+1)+".txt" f=open(m,"r") d=[] t=0. for l in range(10): d=d+[re.findall(r"[0-9.eE+-]+",f.readline())] t=t+v(d[l][0]) f.close() c=t/10. if c==50.: t=0. for u in range(10): t=t+v(d[0][u]) r=t/10. print "%s C1: %f R1: %f"%(m,c,r) -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: file I/O and arithmetic calculation
On Thu, 23 May 2013 07:17:58 -0700, Keira Wilson wrote: > Dear all who involved with responding to my question - Thank you so much > for your nice code which really helped me. Hold on a sec? Someone posted code that gave the correct answer to a homework question? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create new python file with increament number, if doesn't exist?
On Mon, 27 May 2013 02:27:59 -0700, Avnesh Shakya wrote: > I want to create a new python file like 'data0.0.5', but if it is > already exist then it should create 'data0.0.6', if it's also exist > then next like 'data0.0.7'. I have done, but with range, please give > me suggestion so that I can do it with specifying range. Try and put your description into the sequence of instructions you want the computer follow. For this problem, my sequence of instructions would be: 1) Find the highest numbered existing file that matches the filename data0.0.[number] 2) Create a new file that is one number higher. Now the solution is easy. Find the list of filenames in the directory that match a suitable regular expression, take the numeric value of a substring of the filename for each file and find the highest, add one to it, then create the new file name. Something like the following (untested) with the relevant imports etc: nfn="data0.0."+str(max([int(f[8:])for f in os.listdir(p)if re.match ('^data0.0.[0-9]+$',f)])+1) -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to compare two json file line by line using python?
On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote: >how to compare two json file line by line using python? Actually I am >doing it in this way.. Oh what a lot of homework you have today. Did you ever stop to think what the easiest way to compare two json datasets is? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()
On Mon, 27 May 2013 14:29:38 -0700, Bryan Britten wrote: > Try to not sigh audibly as I ask what I'm sure are two asinine > questions. > > 1) How is this approach different from twtrDict = [json.loads(line) for > line in urllib.urlopen(urlStr)]? > > 2) How do I tell how many JSON objects are on each line? Your code at (1) creates a single list of all the json objects The code you replied to loaded each object, assumed you did something with it, and then over-wrote it with the next one. As for (2) - either inspection, or errors from the json parser. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Future standard GUI library
On Tue, 28 May 2013 08:21:25 +1000, Chris Angelico wrote: > I'll use XML when I have to, but if I'm inventing my own protocol, > nope. There are just too many quirks with it. How do you represent an > empty string named Foo? > > or equivalently > > How do you represent an empty list named Foo? The same way. How do you > represent an empty dict/mapping named Foo? Lemme look up my > documentation... ah, the same way. Does this seem right to > you? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a file in /etc/ as a non-root user
On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: > Any Idea how to create a file in /etc as non-root user?Can i use umask > or chmod...confused If you don't have root access, you probably shouldn't be trying to write in /etc. If you need to write in /etc, explain to the sysadmin why you need root access. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: AES 128 bits
On Tue, 04 Jun 2013 07:52:17 +0800, usman mjoda wrote: > Good day everyone, I need assistance for python codes of aes 128 bits > key that can be run on SAGE Application. Thanks google pycrypto -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting to a third party site with injected HTML
On Sun, 09 Jun 2013 10:09:17 -0700, guytamir1 wrote: > i'm not really sure how to approach this problem.. > hints :) Let me restate the problem for you: You want to display a web page to a visitor that exists on a third party website, with some of your own html inserted into it. Setting aside the multitude of ethical, moral, legal and copyright issues, the only technical solution I can see that doesn't involve hacking the third party website is to scrape the third party website using eg curl, modify the html using your scripting environment of choice (I'll assume python) either using some form of dom manipulation or string manipulation, and then server the modified page to the visitor. so pycurl and pydom might be good places to start. Don't forget that you may need to rewrite urls in the scraped document for things such as anchors, images, css, javascript etc to point them back at the host server, or some script on your server that can obtain and serve the appropriate resources. Alternatively, how about displaying the third party website in an iframe within your own document? Although that's not really pythonic, just htmlic. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Sorting a set works, sorting a dictionary fails ?
On Mon, 10 Jun 2013 03:42:38 -0700, Νικόλαος Κούρας wrote: > for key in sorted( months.values() ): > print(''' >%s > ''' % (months[key], key) ) > == > > please tell me Uli why this dont work as expected to. Because inside the for loop, your value 'key' is an item from the sorted list of the values part of months. When you use months[key], you're trying to look up in months based on the value part, not the key part. Calling it key is confusing you. Try this: things = { "a":1, "b":3, "c":2 } for thing in sorted( things.values() ): print thing >> Prints 1, 2, 3 for thing in sorted( things.keys() ): print thing >> Prints a, b, c Now although things["b"] is a valid reference because "b" is a key in a key - value pair, things[3] is not a valid reference, because 3 is not a key in a key - value pair. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Tue, 11 Jun 2013 13:20:52 -0700, Νικόλαος Κούρας wrote: > The above if structure works correctly *only* if the user sumbits by > form: > > name, month, year or month, year > > If, he just enter a year in the form and sumbit then, i get no error, > but no results displayed back. > > Any ideas as to why this might happen? Yes, I know exactly why this is happening. It is for one of two reasons. You may determine which one using the following secret code which I stole from the illuminati in 1836: import random reason = { 1: "Input data is not as expected by coder", 2: "Flow control logic not performing as coder expects", 3: "Badger Badger Badger Badger Badger Badger Badger Badger Mushroom", 4: "Please try again", 5: "Snake", 6: "Grumpy cat says fix your own damn code", 7: "I'll be back" } print reason[ random.choice( reason.keys() ) ] Note - this only has a small chance of actually doing what you want (ie giving a possibly accurate answer), but it sounds as if that's a level of precision you're used to working with anyway. On a slightly more serious note, if you can't apply yourself to debugging a case of "the program logic isn't doing what I expect" for some value of program logic that you coded, that may be a hint that: a) you don't actually understand what the program logic is doing b) you shouldn't be writing logic so complex that you can't see how to debug it c) your logic is overly convoluted and complex d) all of the above So perhaps you need to scrub the logic altogether, and start again taking smaller steps. You could also perhaps do with a lesson in De Morgan's theorem: not a and not b and not c = not ( a or b or c ) not a or not b or not c = not ( a and b and c ) and sometimes the alternative form is easier to understand Now, looking at your code here are two important questions: (1) What is the initial values of name, month and year? (2) Which block is actually being executed? Bear in mind that if a branch other than one you expect to be executed is executing, the fail condition might not be what you think it is. Specifically, is it possible that the code is executing the wrong branch and tripping up when it tries to generate or perhaps execute the sql statement empty strings, or just not getting any result from the sql because of the empty strings? Hint - take the code from the current file, apply a liberal smattering of print statements, and test it for various values of month, year and name. def test(name, month, year): print "name, month, year ::", name, month, year if not re.search( '=', name ) and not re.search( '=', month ) and not re.search( '=', year ): print "branch 1" elif not re.search( '=', month ) and not re.search( '=', year ): print "branch 2" elif not re.search( '=', year ): print "branch 3" else: print "branch 4" # testing logic for 8 possible input conditions test("=", "=", "=") test("=", "=", "x") test("=", "x", "=") test("=", "x", "x") test("x", "=", "=") test("x", "=", "x") test("x", "x", "=") test("x", "x", "x") -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a Super Simple WWW Link, Copy, & Paste into Spreadsheet Program
On Thu, 13 Jun 2013 12:28:09 -0700, buford.lumbar wrote: > Hi, I'm new to Python. Would someone be able to write me and/or to show > me how to write a simple program that: > > 1-follows a hyperlink from MS Excel to the internet (one of many links > like this, http://www.zipdatamaps.com/76180, for e.g.) and then, > > 2-copies some data (a population number, e.g. 54195) and then, > > 3-pastes that data back into the same MS Excel spreadsheet, into the > adjacent cell. Why do you want to do this in python? I thought visual basic (or a variant thereof) was the preferred coding environment for such things in ms office? A quick google finds me vb code to download a url into a string - presumably once you've done that you can find the value you want to scrape into your spreadsheet. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Wed, 12 Jun 2013 11:54:25 +0300, Νικόλαος Κούρας wrote: > So, i must tell: > > for i, month in enumerate(months): > print(' %s ' % (i, month) ) > > to somehow return '==' instead of 0 but don't know how. You could test for (month == 0) instead of re.search('=', month)? Or you could try using "==" instead of i when i is 0 for i, month in enumerate(months): if i != 0: print(' %s ' % (i, month) ) else: print(' %s ' % ("==", month) ) But if you couldn't work either of these solutions out on your own, perhaps the really important question you need to be asking yourself right now is "should I even be trying to code this in python when my basic knowledge of python coding is so poor?" -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A few questiosn about encoding
On Fri, 14 Jun 2013 16:58:20 +0300, Nick the Gr33k wrote: > On 14/6/2013 1:14 μμ, Cameron Simpson wrote: >> Normally a character in a b'...' item represents the byte value >> matching the character's Unicode ordinal value. > The only thing that i didn't understood is this line. > First please tell me what is a byte value Seriously? You don't understand the term byte? And you're the support desk for a webhosting company? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Fri, 14 Jun 2013 12:32:56 +0300, Nick the Gr33k wrote: > I'mm not trolling man, i just have hard time understanding why numbers > acts as strings. It depends on the context. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Eval of expr with 'or' and 'and' within
On Sat, 15 Jun 2013 10:04:41 +0300, Nick the Gr33k wrote: > I called my self 'Ferrous Cranus'(this is what a guy from a forum > initially called me for being hard-headed :-) ) because i'm indeed > hardheaded and if i believe that 1 thing should have worked in some way > i cant change my mind easily that it works in another fashon(only if the > counter-arguments are strong). Then you need to stop trying to write python code, because you refuse to accept how python works, and python is not going to change for you! -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pattern Search Regular Expression
On Sat, 15 Jun 2013 10:05:01 +, Steven D'Aprano wrote: > On Sat, 15 Jun 2013 02:42:55 -0700, subhabangalore wrote: > >> Dear Group, >> >> I am trying to search the following pattern in Python. >> >> I have following strings: >> >> (i)"In the ocean" (ii)"On the ocean" (iii) "By the ocean" (iv) "In >> this group" (v) "In this group" (vi) "By the new group" >>. >> >> I want to extract from the first word to the last word, where first >> word and last word are varying. >> >> I am looking to extract out: >> (i) the (ii) the (iii) the (iv) this (v) this (vi) the new >> . >> >> The problem may be handled by converting the string to list and then >> index of list. > > No need for a regular expression. > > py> sentence = "By the new group" > py> words = sentence.split() > py> words[1:-1] > ['the', 'new'] > > Does that help? I thought OP wanted: words[words[0],words[-1]] But that might be just my caffeine deprived misinterpretation of his terminology. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pattern Search Regular Expression
On Sat, 15 Jun 2013 11:55:34 +0100, Mark Lawrence wrote: > >>> sentence = "By the new group" > >>> words = sentence.split() > >>> words[words[0],words[-1]] > Traceback (most recent call last): >File "", line 1, in > TypeError: list indices must be integers, not tuple > > So why would the OP want a TypeError? Or has caffeine deprivation > affected your typing skills? :) Yeah - that last: words[words[0],words[-1]] should probably have been: first_and_last = [words[0], words[-1]] or even: first_and_last = (words[0], words[-1]) Or even: first_and_last = [sentence.split()[i] for i in (0, -1)] middle = sentence.split()[1:-2] -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pattern Search Regular Expression
On Sat, 15 Jun 2013 13:41:21 +, Denis McMahon wrote: > first_and_last = [sentence.split()[i] for i in (0, -1)] middle = > sentence.split()[1:-2] Bugger! That last is actually: sentence.split()[1:-1] It just looks like a two. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: > In both situations we still have 2 memory units holding values, so hows > that different? Consider that each named variable is a pointer to a memory location that holds a value. This is one of the ways in that a typed compiled language and an untyped scripted language may differ in their treatment of data items (or variables). Consider the following C and Python code: C: int a, b; b = 6; a = b; In C, this places the numeric value 6 into the memory location identified by the variable "b", then copies the value from the location pointed to by "b" into the location pointed to by "a". b is a pointer to a memory location containing the value 6 a is a pointer to another memory location also containing the value 6 Python: b = 6 a = b In Python, this first puts the value 6 in in a memory location and points "b" at that memory location, then makes "a" point to the same memory location as "b" points to. b is a pointer to a memory location containing the value 6 a is a pointer to the same memory location Do you understand the difference? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On Sat, 15 Jun 2013 22:38:38 +0300, Nick the Gr33k wrote: > PLEASE take a look, its not a huge code First, you need to start writing your code to less than 80 columns if you're going to keep posting it to usenet. I'm sure I'm not the only person who can't be bothered to unwrap it. Secondly, the code you posted only tells part of the story - it's obviously missing either relevant imports or defined functions or possibly both. Third, it would help to see examples of (a) what you expect it to generate, and (b) what it actually generates. You obviously have a web server available to you - you could put both code (just append .txt to the filename) and screenshots from your browser there with no difficulty at all and just include links. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Why 'files.py' does not print the filenames into a table format?
On Sun, 16 Jun 2013 11:35:12 +0300, Nick the Gr33k wrote: > TB behaves for me the same way. Any line > 80 chars gets a newline. Why > this is happening? Why not post up to 256 chars in a single line? Because this is usenet. Read the RFCs if you must know! -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Sun, 16 Jun 2013 11:07:12 +0300, Nick the Gr33k wrote: > On 16/6/2013 9:32 πμ, Denis McMahon wrote: >> On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote: >> >>> In both situations we still have 2 memory units holding values, so >>> hows that different? >> >> Consider that each named variable is a pointer to a memory location >> that holds a value. This is one of the ways in that a typed compiled >> language and an untyped scripted language may differ in their treatment >> of data items (or variables). >> >> Consider the following C and Python code: >> >> C: >> >> int a, b; >> b = 6; >> a = b; >> >> In C, this places the numeric value 6 into the memory location >> identified by the variable "b", then copies the value from the location >> pointed to by "b" into the location pointed to by "a". >> >> b is a pointer to a memory location containing the value 6 a is a >> pointer to another memory location also containing the value 6 >> >> Python: >> >> b = 6 >> a = b >> >> In Python, this first puts the value 6 in in a memory location and >> points "b" at that memory location, then makes "a" point to the same >> memory location as "b" points to. >> >> b is a pointer to a memory location containing the value 6 a is a >> pointer to the same memory location >> >> Do you understand the difference? >> > Yes and thank you for explaining in detail to me. > So Python economies(saves) system's memory. Good job Python! No. Don't read that into it. For example, in Python a = 6 b = a c = 6 a and b point to one memory location that contains the value 6 c points to a different memory location that contains the value 6 Python doesn't point all the variables that have the same value at the same location. > A pointer = a variable that has as a value a memory address a variable = > a memory address that has as a value the actual value we want to store. These are really C terms, not Python terms. Stop thinking that C is behaving like Python. > Is this how the thing works? No. Python is an interpreted language. C is a compiled language. They present very different feature sets to the user. You need to understand this, and at the moment you're not doing so. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
On Sun, 16 Jun 2013 12:59:00 +0300, Nick the Gr33k wrote: > Whats the difference of "interpreting " to "compiling" ? OK, I give up! -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python game
On Wed, 19 Jun 2013 13:18:49 -0700, jacksonkemp1234 wrote: > windowSurface.blit(playerImage, player) > for bear in bears: > windowSurface.blit(bearImage, bear) Try changing this to draw the bears first, then the player. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python game
On Wed, 19 Jun 2013 13:18:49 -0700, jacksonkemp1234 wrote: > if moveDown and player.right < WINDOW_WIDTH: > player.right += MOVE_SPEED Should this be moveRight instead of moveDown? -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Need explanation of this error
On Mon, 01 Jul 2013 02:13:50 -0700, prerit86 wrote: > I'm new to Python and trying to run a already written code. Can someone > please explain the error below? And if possible, how do I resolve this? > ImportError: DLL load failed: The specified module could not be found. You're missing the dll that provides some function that you're trying to use. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python adds an extra half space when reading from a string or list
On Mon, 01 Jul 2013 21:18:26 +0200, Antoon Pardon wrote: > I am not baiting Nikos. Your opinion, mine differs. > all I have done in the last two weeks that involves Nikos as a > subject is the "Don't feed the troll thread" Calling him a troll is baiting. Please stop. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python adds an extra half space when reading from a string or list
On Mon, 01 Jul 2013 20:42:48 +0200, Antoon Pardon wrote: > How about the following comprimise. > Let me know what you think about this. How about you just ignore him. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: python adds an extra half space when reading from a string or list
On Tue, 02 Jul 2013 10:16:37 +0200, Antoon Pardon wrote: > I would like people to have that in mind when they try to tell others to > just ignore the behaviour that bothers them. Maybe it would help them to > be a bit more patient to those who have trouble following the advise. It's quite clear that you're more interested in having arguments and slinging insults than you are in discussing python. I'm here to discuss python. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing Text file
On Tue, 02 Jul 2013 13:28:33 -0700, sas429s wrote: > Ok here is a snippet of the text file I have: > I hope this helps.. > . > Thanks for your help ok ... so you need to figure out how best to distinguish the filename, then loop through the file, remember each filename as you find it, and when you find lines containing your target text, print the current value of filename and the target text line. filenames might be distinguished by one or more of the following: They always start in column 0 and nothing else starts in column 0 They never contain spaces and all other lines contain spaces or are blank They always contain at least one / characters They always terminate with a . followed by one or more characters All the characters in them are lower case Then loop through the file in something like the following manner: open input file; open output file; for each line in input file: { if line is a filename: { thisfile = line; } elif line matches search term: { print thisfile in output file; print line in output file; } } close input file; close output file; (Note this is an algorithm written in a sort of pythonic manner, rather than actual python code - also because some newsreaders may break indenting etc, I've used ; as line terminators and {} to group blocks) -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python script help
On Tue, 30 Jul 2013 07:49:04 -0700, cool1574 wrote: > Hello, I am looking for a script that will be able to search an online > document (by giving the script the URL) and find all the downloadable > links in the document and then download them automatically. > I appreciate your help, Why use Python? Just: wget -m url -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythons for .Net
On Sunday, July 24, 2016 at 11:30:09 PM UTC-5, Steven D'Aprano wrote: > Yes, I said Pythons plural :-) > > For those wanting to use Python on .Net or Mono, there is some good news. > > Firstly, the venerable old "Python for .Net" project is still alive, and now > supports up to Python 3.5 on .Net or Mono. PythonNet, as this is known, > integrates the regular CPython interpreter with .Net or Mono. > > Secondly, we can also expect that IronPython will have a new lease of life. > Continuing on the work of their predecessor, Jeff Hardy, the IronPython > project now has two tech leads who will carry it forward: Alex Earl and > Benedikt Eggers. > > https://thelasttechie.com/2016/07/24/its-back-python-for-net/ > > > IronPython is a reimplementation of Python, written in C# as managed code > for .Net. It doesn't use a GIL, and is sometimes considered a little faster > than CPython, so this is good news for the Python ecosystem. > > IronPython: > http://ironpython.net/ > > Python for .Net: > https://github.com/pythonnet/pythonnet > http://pythonnet.github.io/ > https://pypi.python.org/pypi/pythonnet > > > > > -- > Steven > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Hello Steven, I'm one of the contributors to pythonnet. We strive for compatibility with IronPython, but also have a simplified embedding interface and support Python 3 + C-Extensions such as numpy, scipy, sklearn. If anyone is interested in learning pythonnet, then try it out from PYPI or github and use this tutorial: https://pythonnet.github.io/readme.html There is also a mailing list and a tag on stackoverflow: https://mail.python.org/mailman/listinfo/pythondotnet http://stackoverflow.com/questions/tagged/python.net Finally if anyone can contact Christian Heimes (Python Core Developer), then please ask him to reply on request to update the license to MIT: https://github.com/pythonnet/pythonnet/issues/234 He is the only contributor that prevents updating to MIT license. -- https://mail.python.org/mailman/listinfo/python-list
Re: Pythons for .Net
On Saturday, September 3, 2016 at 8:53:18 PM UTC-5, Steve D'Aprano wrote: > On Sat, 3 Sep 2016 12:34 pm, Denis Akhiyarov wrote: > > > Finally if anyone can contact Christian Heimes (Python Core Developer), > > then please ask him to reply on request to update the license to MIT: > > > > https://github.com/pythonnet/pythonnet/issues/234 > > > > He is the only contributor that prevents updating to MIT license. > > > I have emailed him off-list. > > Thanks for the information on PythonNet, Denis. > > > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Emailing and twitter did not help either. -- https://mail.python.org/mailman/listinfo/python-list
Re: announcing fython
On Sunday, October 2, 2016 at 10:57:57 AM UTC-5, nicolases...@gmail.com wrote: > >One problem with using very similar syntax for distinct languages is that it > >can get confusing. > > The first inspiration for Fython was to be close to Fortran, while improving > the syntax. The project is in the early days, so all suggestions are welcome. > Some difference to the Python language are inevitable though, as Fython is a > compiled language. > > >does an actual Fortran compiler need to be invoked? > > Yes, this is done in the background. > > > >And do you need to install one, or is it all included? > > A Fortran compiler must be avalaible on the machine. > A free often used compiler is gfortran. > > > >If so, at what point in the above example is it invoked? > >Is it every time you run that Python code, or will the load() used a cached > >copy of the compiled mean.fy? > > The compiler is invoked whenever the Fython sources are new or have changed. > A cached copy is used to avoid unnessecary compilation. Have you looked at f2py? You can write Fortran and then use it Python by just wrapping it with f2py. Actually this is a project bundled in numpy. There is also fortran magic for Jupyter notebooks. f90wrap extends f2py to support modern Fortran. -- https://mail.python.org/mailman/listinfo/python-list
Re: Build desktop application using django
Have a look at automatic web app builder using Django or Flask called Wooey based Gooey. https://github.com/wooey/Wooey -- https://mail.python.org/mailman/listinfo/python-list
Re: What are your opinions on .NET Core vs Python?
On Sunday, January 29, 2017 at 4:00:27 PM UTC-6, Gregory Ewing wrote: > Joseph L. Casale wrote: > >>.NET is a library that can be used from many languages, including Python. > > > > No. > > Yes: > > http://pythonnet.sourceforge.net/ > > "Python for .NET is a package that gives Python programmers nearly seamless > integration with the .NET Common Language Runtime (CLR) and provides a > powerful > application scripting tool for .NET developers. Using this package you can > script .NET applications or build entire applications in Python, using .NET > services and components written in any language that targets the CLR (Managed > C++, C#, VB, JScript)." > > -- > Greg This is outdated location. pythonnet (python for .NET) is on GitHub since 2014. https://github.com/pythonnet/pythonnet We just released v2.2.2 with Python 3.6 support and transition to MIT license. Download from PYPI using pip or from Anaconda using conda: https://pypi.python.org/pypi/pythonnet/2.2.2 https://anaconda.org/pythonnet/pythonnet -- https://mail.python.org/mailman/listinfo/python-list
Re: Enumerating all 3-tuples
On 2018-03-10 02:13, Steven D'Aprano wrote: But I've stared at this for an hour and I can't see how to extend the result to three coordinates. I can lay out a grid in the order I want: 1,1,1 1,1,2 1,1,3 1,1,4 ... 2,1,1 2,1,2 2,1,3 2,1,4 ... 1,2,1 1,2,2 1,2,3 1,2,4 ... 3,1,1 3,1,2 3,1,3 3,1,4 ... 2,2,1 2,2,2 2,2,3 2,2,4 ... ... and applying Cantor's diagonal order will give me what I want, but damned if I can see how to do it in code. If you want this exact order, it can be reproduced in the following way. The triples can be viewed as a pair of a pair and a natural number: (1,1),1 (1,1),2 (1,1),3 ... (2,1),1 (2,1),2 (2,1),3 ... (1,2),1 (1,2),2 (1,2),3 ... . . . . . . . . . Decomposing this by the diagonals yields 1: (1,1),1 2: (2,1),1 (1,1),2 3: (1,2),1 (2,1),2 (1,1),3 . . . Notice that the first elements of each pair (i.e. the inner pairs) are given by the (inverse of the) original Cantor pairing function, in decreasing order. The second elements are just the natural numbers. Naming the inverse c, we can rewrite the above like this: 1: c(1),1 2: c(2),1 c(1),2 3: c(3),1 c(2),2 c(1),3 . . . Rewriting this to spell out the mapping between the natural numbers and the pairs, we get 1 -> c(1),1 2 -> c(2),1 3 -> c(1),2 4 -> c(3),1 5 -> c(2),2 6 -> c(1),3 . . . Squinting a bit, this might seem familiar. This is exactly the same as the original pairing function, except for an additional application of c to the first element of the pair! 1 -> 1,1 2 -> 2,1 3 -> 1,2 4 -> 3,1 5 -> 2,2 6 -> 1,3 This leads fairly naturally to the implementation. from itertools import accumulate, count def c(i): """ Inverse of the Cantor pairing function, mapping N → N×N. """ assert i >= 1 # partial sums of the series 1 + 2 + 3 + ... sums = accumulate(count(1)) n = 0 while True: m = next(sums) if m < i: n += 1 else: r = m - i break return r + 1, n - r + 1 def c3(i): """ Inverse of the Cantor pairing function generalization to triples, mapping N → N×N×N. """ n, m = c(i) return c(n) + (m,) Applying c3 to the natural numbers gives the sequence you wanted: s = map(c3, count(1)) pprint([next(s) for _ in range(10)]) [(1, 1, 1), (2, 1, 1), (1, 1, 2), (1, 2, 1), (2, 1, 2), (1, 1, 3), (3, 1, 1), (1, 2, 2), (2, 1, 3), (1, 1, 4)] -- Denis Kasak -- https://mail.python.org/mailman/listinfo/python-list
Re: Enumerating all 3-tuples
On 2018-03-13 23:56, Denis Kasak wrote: On 2018-03-10 02:13, Steven D'Aprano wrote: But I've stared at this for an hour and I can't see how to extend the result to three coordinates. I can lay out a grid in the order I want: 1,1,1 1,1,2 1,1,3 1,1,4 ... 2,1,1 2,1,2 2,1,3 2,1,4 ... 1,2,1 1,2,2 1,2,3 1,2,4 ... 3,1,1 3,1,2 3,1,3 3,1,4 ... 2,2,1 2,2,2 2,2,3 2,2,4 ... ... and applying Cantor's diagonal order will give me what I want, but damned if I can see how to do it in code. [snip] The triples can be viewed as a pair of a pair and a natural number: (1,1),1 (1,1),2 (1,1),3 ... (2,1),1 (2,1),2 (2,1),3 ... (1,2),1 (1,2),2 (1,2),3 ... . . . . . . . . . [snip] def c3(i): """ Inverse of the Cantor pairing function generalization to triples, mapping N → N×N×N. """ n, m = c(i) return c(n) + (m,) In fact, extending this idea further, we can view the grid as a Cartesian product of two sets: the natural numbers and an arbitrary enumerable set. In your intended grid layout, the natural numbers were put (in their usual ordering) on the horizontal axis and the 2-tuples given by the pairing function on the vertical axis. However, diagonalizing this grid allows us to enumerate the Cartesian product itself, which means we can repeat the process by using this enumeration as the new vertical axis. Therefore, this process generalizes naturally to an arbitrary number of dimensions: def cr(i, d=2): """ Inverse of the Cantor pairing function generalization to d-tuples, mapping N → N^d. """ if d == 1: return i elif d == 2: return c(i) else: n, m = c(i) return cr(n, d-1) + (m,) >>> def first_ten(d): ...return [cr(i, d) for i in range(1, 11)] >>> for d in range(2, 5): ... pprint(first_ten(d)) [(1, 1), (2, 1), (1, 2), (3, 1), (2, 2), (1, 3), (4, 1), (3, 2), (2, 3), (1, 4)] [(1, 1, 1), (2, 1, 1), (1, 1, 2), (1, 2, 1), (2, 1, 2), (1, 1, 3), (3, 1, 1), (1, 2, 2), (2, 1, 3), (1, 1, 4)] [(1, 1, 1, 1), (2, 1, 1, 1), (1, 1, 1, 2), (1, 1, 2, 1), (2, 1, 1, 2), (1, 1, 1, 3), (1, 2, 1, 1), (1, 1, 2, 2), (2, 1, 1, 3), (1, 1, 1, 4)] -- Denis Kasak -- https://mail.python.org/mailman/listinfo/python-list
RE: ironpython not support py3.6
Either wait for IronPython 3.6, use COM interop, pythonnet, subprocess, or things like gRPC. Based on PyPy experience, it is probably 1-2 years of sponsored development to get a working IronPython 3.6. -- https://mail.python.org/mailman/listinfo/python-list
RE: ironpython not support py3.6
To: Schachner, Joseph From: denis.akhiya...@gmail.com Either wait for IronPython 3.6, use COM interop, pythonnet, subprocess, or things like gRPC. Based on PyPy experience, it is probably 1-2 years of sponsored development to get a working IronPython 3.6. --- BBBS/Li6 v4.10 Toy-3 * Origin: Prism bbs (1:261/38) -- https://mail.python.org/mailman/listinfo/python-list
RE: ironpython not support py3.6
To: Schachner, Joseph From: "denis akhiyarov" To: Schachner, Joseph From: denis.akhiya...@gmail.com Either wait for IronPython 3.6, use COM interop, pythonnet, subprocess, or things like gRPC. Based on PyPy experience, it is probably 1-2 years of sponsored development to get a working IronPython 3.6. -+- BBBS/Li6 v4.10 Toy-3 + Origin: Prism bbs (1:261/38) --- BBBS/Li6 v4.10 Toy-3 * Origin: Prism bbs (1:261/38) -- https://mail.python.org/mailman/listinfo/python-list
Cloud platform with GPU
Good day all, I am looking for a good cloud platform to do all my python development for machine learning with GPU availability, so far I have used Amazon ec2, google colab, kaggle etc but none of them was very satisfactory. Anyone has good experience with other options? please share and TIA Denis -- https://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
CBFalconer wrote: > Mike Schilling wrote: >> "Mike Meyer" <[EMAIL PROTECTED]> wrote in message >>> "Mike Schilling" <[EMAIL PROTECTED]> writes: >>>> "l v" <[EMAIL PROTECTED]> wrote in message >>>>> Xah Lee wrote: >>>>> >>>>>> (circa 1996), and email should be text only (anti-MIME, circa 1995), >>>>> >>>>> I think e-mail should be text only. I have both my email and >>>>> news readers set to display in plain text only. It prevents >>>>> the marketeers and spammers from obtaining feedback that my >>>>> email address is valid. A surprising amount of information >>>>> can be obtained from your computer by allowing HTML and all >>>>> of it's baggage when executing on your computer. Phishing >>>>> comes to my mind first and it works because people click the >>>>> link without looking to see where the link really takes them. >>>> >>>> A formatting-only subset of HTML would be useful for both e-mail >>>> and Usenet posts. >>> >>> Used to be people who wanted to send formatted text via email >>> would use rich text. It never really caught on. But given that >>> most of the people sending around formatted text are using >>> point-n-click GUIs to create the stuff, the main advantage of >>> HTML - that it's easy to write by hand - isn't needed. >> >> But the other advantage, that it's an existing and popular >> standard, remains. > > However, for both e-mail and news, it is totally useless. It also > interferes with the use of AsciiArt, while opening the recipient to > the dangers above. And HTML has the tendency to make e-mail and Usenet posts unnecessarily bigger, which will continue to be a bugger until broadband links become common enough. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
Mike Schilling wrote: > > I see a difference between "X would be useful for A, B, and C" and "Y will > always be the only proper way." > > Don't you? Y would not be useful because of the bandwidth it consumes, the malware it would introduce, the additional time spent focusing on the format rather than quality of the content and, frankly, because it's useless. As Rich already said, if one wants to look at neatly formatted content, one can always visit the web. Usenet is meant to be an information-sharing facility, and I cannot see *any* reason why it should be exposed to all the disadvantages stated in numerous places in thread to gain a pale "advantage" such as flashy content. We already have a World Wide Web, no need to make Usenet it's clone. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
Mike Schilling wrote: > > Threaded mail-readers too, screen-based editors , spell-checkers, all > useless frills. Interestingly enough, I have explained my opinion in the part of the post you have trimmed. On the other hand, things you mentioned are far from being useless. They introduce no intrinsical slowdown due to increased bandwidth consumation, nor potential security problems. They have no downsides I can possibly think of and have many advantages. They are useful. HTML on Usenet is not. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
John Bokma wrote: > > You can't be sure: errors in the handling of threads can cause a buffer > overflow, same for spelling checking :-D Yes, they can, provided they are not properly coded. However, those things only interact locally with the user and have none or very limited interaction with the user on the other side of the line. As such, they can hardly be exploitable. > Some people never use them, and hence they use memory and add risks. On a good newsreader the memory use difference should be irrelevantly small, even if one does not use the features. I would call that a nitpicky argument. Also, the risk in question is not comparable because of the reasons stated above. The kind of risk you are talking about happens with /any/ software. To stay away from that we shouldn't have newsreaders (or any other software, for that matter) in the first place. > Of course can HTML be useful on Usenet. The problem is that it will be much > more often abused instead of used. No, you missed the point. I am arguing that HTML is completely and utterly /useless/ on Usenet. Time spent for writing HTML in Usenet posts is comparable to that spent on arguing about coding style or writing followups to Xah Lee. It adds no further insight on a particular subject, but _does_ add further delays, spam, bandwidth consumation, exploits, and is generally a pain in the arse. It's redundant. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
John Bokma wrote: > Ulrich Hobelmann <[EMAIL PROTECTED]> wrote: > >> John Bokma wrote: >>> http://www.phpbb.com/mods/ >> >> Great. How can I, the user, choose, how to use a mod on a given web >> server? > > Ask the admin? And that is, in your opinion, completely comparable to running your own, private client? Is the admin obliged to install the mod? Is the admin even reachable? >> What if the web server runs another board than PHPBB? > > Check if there is a mod, and ask the admin. See above. >>> Does the user want this? And with a user stylesheet you can change it >>> quite radically :-) >> >> The look, not the feel. > > Wild guess: (signed) javascript and iframes? on your local computer? > > Otherwise: fetch HTML, parse it, restructure it, and have the > application run a local webserver. Python, Perl, piece of cake. You seem to be forgetting that we are mainly talking about end users here who most probably will not have the sufficient expertise to do all that. And even if they do, it's still time consuming. -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
John Bokma wrote: > > so use Lynx :-) > > One forum I visit is about scorpions. And really, it talks a bit easier > about scorpions if you have an image to look at :-D. > > In short: Usenet = Usenet, and www = www. Why some people want to move > people from www to Usenet or vice versa is beyond me. If 80% of the current > Usenet users stop posting, Usenet is not going to die :-D Agreed. This is actually your first post with which content I agree totally. From your other posts I got the impression that you are one of those people that are trying to make Usenet and WWW more similar to one another. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: Jargons of Info Tech industry
T Beck wrote: > > Wasn't the point... I never said they were. HTML is at version 4.0(I > think?) now, AND we've added extra layers of stuff you can use > alongside of it. The internet is a free-flowing evolving place... to > try to protect one little segment like usenet from ever evolving is > just ensuring it's slow death, IMHO. > > That's all... HTML is at version 4.01 to be precise, but that is precisely off-topic. This discussion has being going on for long enough. It is held in a large crosspost to newsgroups that have nothing to do with HTML or the evolution of Usenet. The bottom line is that most Usenet users like it the way it is now, and it certainly serves it's purpose. The Web and Usenet should not mix as they are two distinct entities and merging them would lose some of their distinctive qualities, making the Internet a poorer place. I suggest letting the matter rest or taking it to a more appropriate newsgroup. -- Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime question
On Tue, 12 Nov 2013 12:47:58 +, Andy Lawton wrote: > (I think "Europe/Kiev" is Greece but I don't know) I suspect Nick is really in a coding sweatshop in "Asia/Mumbai" -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: datetime question
On Tue, 12 Nov 2013 17:57:55 +0200, Ferrous Cranus wrote: > or perhaps by confiruing the timezone of the server to use Greece's > TimeZone by issuing a linux command? If you have that degreee of control over the server, yes, but UTC is always safer, because if you need to move your server to a different site (eg disaster recovery) UTC is still UTC. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Chinese Zodiac - python project
On Tue, 12 Nov 2013 14:04:08 -0800, edmundicon wrote: > Greetings everyone! This is my first post on this forum :) > > TL;DR: I want to convert the gregorian years into Chinese years, and > deal with the fact that the Chinese new years are different each > gregorian year. If I manage to do that, I'll know which year the user is > born in Chinese years and can then give him a personal description based > upon that year! > > I started to learn Python programming language 2 months ago (noob), but > I like it and I feel like if I keep learning I might become a great > programmer one day! > > I recently started a small Python project in which my mission is to give > a personal description to a user based upon the year he / she is born in > the Chinese Zodiac and I have run into some trouble. For instance, if > someone is born on the 15'th January 1990, he is actually born 1989 > because the Chinese new year occurred on the 27:th January that year. > > I have a text file which shows when the Chinese new years in gregorian > years (normal years), starting from 1900-01-31 to 2007-02-18. It goes > like this: > 1900-1-31 1901-2-19 1902-2-08 1903-1-29 1904-2-16 1905-2-04 1906-1-25 > ...(and so on) > 2007-02-18 ( I can't see the logic behind this really) > > The Chinese calendar is divided into cycles of 60 years each, and each > year has a combination of an animal and an element. There are 12 animals > and 5 elements, the animals changes each year, and the elements every > other year. The current cycle was initiated in the year of 1984 which > was the year of the Wood Rat. The personal descriptions for each > combination has conveniently also been provided in text files. > > The animals are in this order: > > Rat Ox Tiger Rabbit Dragon Snake Horse Sheep Monkey Rooster Dog Boar > > And the elements are: > > Wood Fire Earth Metal Water > > I have already created a modulus method which takes the input year (the > gregorian year you were born) and gives you an element and an animal, > for example if you type "1990" you are given Metal Horse. The problem I > now have is to convert the gregorian years into Chinese years, and deal > with the fact that the Chinese new years are different each gregorian > year. If I manage to do that, I'll know which year the user is born in > Chinese years and can then give him a personal description based upon > that year! > > Any advice will be greatly appreciated! Have a nice day :) Here is one suggestion Write a function to convert a gregorian date into the number of days since 1st January 1900 (we'll call 1st january 1900 your epoch). You will need to take leap years into account. Convert the users date of birth using this function. Convert your chinese new year dates using this function. You now have the simple task of comparing the users date of birth as daynumber_since_epoch with the start date of each chinese year as daynumber_since_epoch. You may wish to create a list of tuples where each tuple has start_day, end_day, year_name: years = [(0,30,"stone pig"),(31,414,"stone weasel") ... ] You should be able to automate creating this list. You could then search through the list of tuples with a function such as: yearname( birthdate ): foreach thing in years if birthdate is in the range specified by the thing return the yearname from the thing return "constipated program" (this is obviously not written as python code, you have to do that bit yourself) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Some python newb help please?
On Tue, 12 Nov 2013 14:14:42 -0800, lrwarren94 wrote: > http://pastebin.com/6QZTvx6Z Work through your code very very carefully. You're doing something in each if branch that you probably only want to do once in each execution of the while loop. If you can't figure it out, I'll post a corrected version next week. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Chinese Zodiac - python project
On Wed, 13 Nov 2013 16:44:03 -0800, edmundicon wrote: > Den tisdagen den 12:e november 2013 kl. 23:50:03 UTC+1 skrev Denis > McMahon: >> On Tue, 12 Nov 2013 14:04:08 -0800, edmundicon wrote: >> >> >> >> > Greetings everyone! This is my first post on this forum :) >> >> >> > >> > TL;DR: I want to convert the gregorian years into Chinese years, and >> >> > deal with the fact that the Chinese new years are different each >> >> > gregorian year. If I manage to do that, I'll know which year the user >> > is >> >> > born in Chinese years and can then give him a personal description >> > based >> >> > upon that year! >> >> >> > >> > I started to learn Python programming language 2 months ago (noob), >> > but >> >> > I like it and I feel like if I keep learning I might become a great >> >> > programmer one day! >> >> >> > >> > I recently started a small Python project in which my mission is to >> > give >> >> > a personal description to a user based upon the year he / she is born >> > in >> >> > the Chinese Zodiac and I have run into some trouble. For instance, if >> >> > someone is born on the 15'th January 1990, he is actually born 1989 >> >> > because the Chinese new year occurred on the 27:th January that year. >> >> >> > >> > I have a text file which shows when the Chinese new years in >> > gregorian >> >> > years (normal years), starting from 1900-01-31 to 2007-02-18. It goes >> >> > like this: >> >> > 1900-1-31 1901-2-19 1902-2-08 1903-1-29 1904-2-16 1905-2-04 1906-1-25 >> >> > ...(and so on) >> >> > 2007-02-18 ( I can't see the logic behind this really) >> >> >> > >> > The Chinese calendar is divided into cycles of 60 years each, and >> > each >> >> > year has a combination of an animal and an element. There are 12 >> > animals >> >> > and 5 elements, the animals changes each year, and the elements every >> >> > other year. The current cycle was initiated in the year of 1984 which >> >> > was the year of the Wood Rat. The personal descriptions for each >> >> > combination has conveniently also been provided in text files. >> >> >> > >> > The animals are in this order: >> >> >> > >> > Rat Ox Tiger Rabbit Dragon Snake Horse Sheep Monkey Rooster Dog Boar >> >> >> > >> > And the elements are: >> >> >> > >> > Wood Fire Earth Metal Water >> >> >> > >> > I have already created a modulus method which takes the input year >> > (the >> >> > gregorian year you were born) and gives you an element and an animal, >> >> > for example if you type "1990" you are given Metal Horse. The problem >> > I >> >> > now have is to convert the gregorian years into Chinese years, and >> > deal >> >> > with the fact that the Chinese new years are different each gregorian >> >> > year. If I manage to do that, I'll know which year the user is born >> > in >> >> > Chinese years and can then give him a personal description based upon >> >> > that year! >> >> >> > >> > Any advice will be greatly appreciated! Have a nice day :) >> >> >> >> Here is one suggestion >> >> >> >> Write a function to convert a gregorian date into the number of days >> >> since 1st January 1900 (we'll call 1st january 1900 your epoch). You >> will >> >> need to take leap years into account. >> >> >> >> Convert the users date of birth using this function. >> >> >> >> Convert your chinese new year dates using this function. >> >> >> >> You now have the simple task of comparing the users date of birth as >> >> daynumber_since_epoch with the start date of each chinese year as >> >> daynumber_since_epoch. >> >> >> >> You may wish to create a list of tuples where each tuple has start_day, >> >> end_day, year_name: >> >> >> >> years = [(0,30,"stone pig"),(31,414,"stone weasel") ... ] >> >> >> >> You shou
Re: Trying tcompile an use the Python 3.4a
On Wed, 13 Nov 2013 16:17:22 +0200, Ferrous Cranus wrote: > root@secure [/home/nikos/www/cgi-bin]# python3 -V Python 3.4.0a4 Let me just check. Nobody is so stupid as to run alpha software on a production server[1] are they? [1] In this context, "production server" means any system facing the public internet upon which python code is executed in response to inputs from the public internet. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: understanding someone else's program
On Fri, 15 Nov 2013 03:05:04 -0800, C. Ng wrote: > Hi all, > > Please suggest how I can understand someone else's program where - > documentation is sparse - in function A, there will be calls to function > B, C, D and in those functions will be calls to functions R,S,T > and so on so forth... making it difficult to trace what happens to a > certain variable > > Am using ERIC4 IDE. You just have to work through it working out what each line does. Start with the inputs and give them sensible names, after all you presumably know where they come from and what they represent. Then you can see what operations are being performed on the input data, and presumably if you have enough knowledge in any relevant fields, may be able to determine that, for example, when the input 'x' is actually a temp in fahrenheit, then the math operation 'x=(x-32)*5/9' is really "convert temp from fahrenheit to centigrade". As you do this add relevant comments to the code. Eventually you'll have code with sensible variable names and comments that hopefully describe what it does. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Question regarding 2 modules installed via 'pip'
On Sat, 16 Nov 2013 17:49:17 +0100, YBM wrote: > Le 16.11.2013 16:43, Ferrous Cranus a écrit : >> root@secure [~]# which python3 /usr/bin/python3 >> root@secure [~]# cd /usr/bin/python3 -bash: cd: /usr/bin/python3: Not a >> directory >> root@secure [~]# which pip /usr/bin/pip >> root@secure [~]# cd /usr/bin/pip -bash: cd: /usr/bin/pip: Not a >> directory >> WHAT THE FUCK IS GOING ON WITH THIS DAMN CentOS 6.4? >> WHY CANT I JUST CD INTO HESE DAMN FOLDERS? > What don't you understand in what bash told you with "Not a directory" ? He doesn't understand error messages until he's posted them on usenet and had them explained to him. I think his default state of mind is "I'm perfect, therefore I can't have made a mistake, so the software must be broken." Then he posts the error messages here and we all laugh at his ineptitude. I would answer his question, but I foreswore helping him days ago now, you just get too much abuse because (in his opinion) your answer includes excessive whitespace. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On Tue, 19 Nov 2013 11:27:08 -0800, bradleybooth12345 wrote: > On Tuesday, November 19, 2013 6:40:18 PM UTC, bradleyb...@gmail.com > wrote: >> "Write a program that calculates how many positive integers less than N >> are not divisible by 2,3 or 5. >> "The collatz process . >> Any help would be appreciated > Think they just needed a starting point really to be honest as they > can't get there head round it. First of all there seems to be two problems, not 1. Here are some steps for each of the calculations. Any resemblance of these steps to actual program code is due to my not bothering to obfuscate the statement and function names more than I did. 1) Find all the numbers less than n that are not divisible by a, b, or c. ask the user for x; assign the value 0 to some other variable i; while i is not greater than than x do the following [ if i is not divisible by a and i is not divisible by b and i is not divisible by c then display i to the user; add 1 to i; ] 2) Find the collatz sequence for x. ask the user for initial x; while x is not 1 { if x is divisible by 2 [ new x = perform even number collatz math on x; ] otherwise [ new x = perform odd number collatz math on x; ] display new x to the user; } -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !
On Fri, 22 Nov 2013 18:22:29 +0530, Bharath Kummar wrote: > Could you please help me with my current research ? Am implementing the > concept in python language. > My doubts are : > 1) Is it possible to Retrieve the address of a variable in python ? > 2) Is it possible to Delete the Address of the Variable and create a > new dynamic address inside the compiler/interpreter itself ? > 3) Is it easy to find the Binary equivalence of a given Alphanumeric > String ? > 4) Is it possible to count the number of 1's in the Binary equivalence > ? > Could you PLEASE provide me with the codes (codes only for the asked > queries) ? The codes are: 1) 7373a28109a7c4473a475b2137aa92d5 2) f2fae9a4ad5ded75e4d8ac34b90d5c9c 3) 935544894ca6ad7239e0df048b9ec3e5 4) b1bc9942d029a4a67e4b368a1ff8d883 Please contact your local government eavesdropping agency for assistance on decoding the codes. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On Wed, 20 Nov 2013 11:38:14 +, Duncan Booth wrote: > Denis McMahon wrote: >> 1) Find all the numbers less than n that are not divisible by a, b, or >> c. >> ask the user for x; >> assign the value 0 to some other variable i; >> while i is not greater than than x do the following [ >> if i is not divisible by a and i is not divisible by b and i is not >> divisible by c then display i to the user; >> add 1 to i; >> ] > The question didn't ask to find all the numbers, it asked to count how > many there are. My post was intended as a demonstration of how you can convert a problem into a sequence of steps that can then be programmed into a computer. Any resemblance to the posted question may have been accidental. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !
On Sat, 23 Nov 2013 02:18:03 +, Steven D'Aprano wrote: > On Sat, 23 Nov 2013 01:55:44 +0000, Denis McMahon wrote: >> On Fri, 22 Nov 2013 18:22:29 +0530, Bharath Kummar wrote: >>> Could you PLEASE provide me with the codes (codes only for the asked >>> queries) ? >> The codes are: >> 1) 7373a28109a7c4473a475b2137aa92d5 2) f2fae9a4ad5ded75e4d8ac34b90d5c9c >> 3) 935544894ca6ad7239e0df048b9ec3e5 4) b1bc9942d029a4a67e4b368a1ff8d883 >> Please contact your local government eavesdropping agency for >> assistance on decoding the codes. > I'm not an expert on Indian English, but I understand that in that > dialect it is grammatically correct to say "the codes", just as in UK > and US English it is grammatically correct to say "the programs". Sorry, I should obviously have replied to the OP as follows: We don't write your python code for you, we help you to fix your python code. Please post the code you have developed to solve your problem, and explain what you expect it to do, and then we will try and explain to you why it's doing what it does instead of what you want it to. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Cracking hashes with Python
On Tue, 26 Nov 2013 02:30:03 -0800, TheRandomPast wrote: >>for value in values: > print value ..^^^ so change this to: crackMD5Hash( value ) >> import hashlib >> def crackMD5Hash(): Nah def crackMD5Hash( hash ): print "cracking hash:", hash some code goes here ... print "original string was:", result Algorithms for cracking md5 hashes is not a python topic, but rather a cryptography topic. When you find an algorithm to use, then if you have trouble converting it into code we may be able to help with that bit. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Cracking hashes with Python
On Tue, 26 Nov 2013 14:18:33 +, TheRandomPast . wrote: > - Teacher has taught us nothing about MD5. This being the script he > wanted us to write came as a surprise to everyone but complaints about > projects are constantly ignored. This particular teacher is complained > about for this reason every year but nothing ever changes. ok forget about python for a minute. write down the steps you need to follow to solve the problem in plain english. 1) Get the list of hashes from a website 2) Brute force the hashes using a dictionary But 2 needs a dictionary: 1) Load a dictionary 2) Get the list of hashes from a website 3) Brute force the hashes using a dictionary So you need a function to load the dictionary (from a local file?), a function to get the list of hashes, a function to try and brute force a hash using the dictionary, and some logic to tie it all together. global data: list of words, list of hashes load_dictionary ( file ) read the words from the file get_hashes( url ) read the hashes from the url brute_force() do every hash in hashes do every word in words if md5( word ) is hash solved this hash! load_dictionary( "dictionary file name" ) get_hashes( "http://www.website.tld/path/file.ext"; ) brute_force() -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Cracking hashes with Python
On Wed, 27 Nov 2013 12:40:41 +, TheRandomPast . wrote: > And dictionary is working, as is the brute force however the issue I > have having is with my chklength() as no matter how many characters I > input it skips the !=32 and goes straight to asking the user to chose > either Brute Force or Dictionary. I want an error to be shown if the > hash is less than or more than 32 characters but at present this > chklength() doesn't work as I thought it would. > > Can anyone point out an obvious error that I am missing? Yes - you don't need to type in the hashes by hand at all. You have code to read the hashes from a web page as strings. Read the hashes from the web into a list of hashes. Read the dictionary file into a list of words. for each word in the dictionary compare the hashed word with the list of hashes, and if you get a match, output the word and the hash. If you have code to get the hash strings from the web url, it is nuts to output them to the screen and then type them back in to the cracking program when you can just add the code to get them from the web to the cracking program. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: The input and output is as wanted, but why error?
On Tue, 03 Dec 2013 07:48:43 -0800, geezle86 wrote: > I am trying to solve this problem: > > http://codeforces.com/problemset/problem/71/A That's not a problem, it's a url. > The input and output is as wanted, but my answer keep rejected, here is > my source code http://txt.do/1smv That's not source code, it's a url. > Please, I need help. As my newsreader isn't a web browser, I can't help. Sorry. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: interactive help on the base object
On Sun, 08 Dec 2013 23:48:57 +, Mark Lawrence wrote: >>> >>> help(object) >>> Help on class object in module builtins: >>> >>> class object >>> | The most base type >> '''The default top superclass for all Python classes. >> Its methods are inherited by all classes unless overriden. >> ''' > Terry's suggestion above remains odds on favourite on the grounds that > there have been no other suggestions. I'll give it another day, then > raise a tracker issue, unless the overwhelming smell of pot that has > been drifting around this thread knocks me unconscious. """ The root class for all Python classes. Its methods are inherited by all classes unless overriden. """ -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Experiences/guidance on teaching Python as a first programming language
On Tue, 10 Dec 2013 20:35:47 -0500, Dennis Lee Bieber wrote: > On Tue, 10 Dec 2013 18:25:48 +1300, Gregory Ewing > declaimed the following: >>That's like saying that when teaching woodwork we shouldn't let people >>use hammers, we should make them use rocks to bang nails in, because it >>will make them better carpenters in the long run. > NAILS > Nails were verboten in my high school wood working class... > We used dowels and glue; chisels to carve dove-tails; etc. We were allowed to use screws, but they had to be brass, not steel, we had to drill appropriate clearance and pilot holes, and countersink where appropriate. And god help you if you deformed the slot in a brass screw head by over tightening - I think that may have been why they made us use brass ones only, so that such damage was easier to spot and more likely to happen. And yes, I can dovetail, mortise and tenon, dowel etc etc etc. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: min max from tuples in list
On Wed, 11 Dec 2013 23:25:53 -0800, Robert Voigtländer wrote: > I have a list like this: > > a = [(52, 193), .. (36, 133)] # iterate over the list of tuples # creates a dictionary n0:[n1a, n1b, n1c ... ] # from tuples (n0,n1a), (n0,n1b), (n0,n1c) ... b = {} for x in a: if x[0] in b: pass else: b[x[0]] = [] if x[1] not in b[x[0]]: b[x[0]].append( x[1] ) # iterate over the dictionary # create the list of result tuples (n0, n1min, n1max) . c = [ (x, min(y), max(y) ) for x,y in b.iteritems() ] print c There may be a more efficient test for whether b[x[0]] eists than trapping keyError. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: accessing a page which request an openID authentication
On Fri, 13 Dec 2013 02:32:49 -0800, uni.mail.2014 wrote: > I have a page that request an openID authentication And your Python question is? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: want to run proxy in python
On Fri, 13 Dec 2013 03:39:44 -0800, Jai wrote: > hey , will u guide me how to run proxies from python http://lmgtfy.com/?q=ip+address+spoofing -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: New to Python, Help to get script working?
On Sat, 14 Dec 2013 20:51:59 -0800, Mark wrote: > I have successfully installed python 3.3 for windows, pip and > livestreamer that is needed for it to work. They are in my scripts > folder. I either do not understand the script or it no longer works. It > is more than likely my error. I get errors on line 19 and cant get it to > work at all. If you're getting the "not enough goats and chickens sacrificed error", sacrifice more goats and chickens. (Hint - it would help if you told us what the error was, and displayed at least the line the error occurs on and the preceding 10 lines or so) -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Want guidance to set proxy please help
On Sun, 15 Dec 2013 20:29:55 -0800, Jai wrote: > so , i need some step to set proxy so that my ip is not blocked by them This sounds like you're attempting to access a site other than for legitimate purposes. You probably want some 1337 script kiddies forum, not a serious programming newsgroup. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Wrapping around a list in Python.
On Mon, 16 Dec 2013 15:59:32 +1100, Ben Finney wrote: > shengjie.sheng...@live.com writes: > >> Hi guys, I am trying to create a fixed list which would allow my values >> to be wrapped around it. > > This doesn't make a lot of sense to me, but I assume you have a purpose > in mind for this. What is the purpose? Perhaps it will help the > explanation if we know what it's for. > >> For example i have 10 values : 0,1,2,3,4,5,6,7,8,9 > > Does this mean the input is a list, ‘[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]’? Or > do you mean something else? What is the input? > >> I need to create a list which contains 4 numbers and when the number >> exceeds the list, it would overwrite the first value. > >> [0,1,2,3] >> [4,1,2,3] >> [5,4,1,2] > > That's three different lists. What is the input in each case? Under what > circumstances would you expect each one to be produced? I suspect the OP means: first input is 0, list = [ 0 ] next input is 1, list = [ 0, 1 ] next input is 2, list = [ 0, 1, 2 ] next input is 3, list = [ 0, 1, 2, 3 ] next input is 4, list = [ 4, 1, 2, 3 ] next input is 5, list = [ 5, 4, 1, 2 ] But this is a bit daft, because he starts by appending, and when he hits overflow he starts prepending. What I think he should do is use collections.dequeue and a couple of helper functions to add and get data items. For a queue moving from position 0 to position 3 (left to right): from collections import deque q = dequeue([]) def add_to_queue( item, q ): if len( q ) is 4: q.pop() q.appendleft( item ) def get_next( q ): if len( q ) > 0: return q.pop() return None To move from position 3 to position 0 (right to left), swap pop and appendleft for popleft and append. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Web Server for Python
On Mon, 16 Dec 2013 19:20:20 -0800, Mura Zalukhu wrote: > Could you give me the best tutorial / web for python. For example how to > make a connection with database. Which database? Which version of Python? Google may help. So will the Python on-line documentation. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Struggling for inspiration with lists
Hi I have a list of data that presents as: timestamp: value Timestamps are used solely to determine the sequence of items in the list. I want to find the longest repeated sequence of values in the list. Example, in the following list: data = { 0: "d", 1: "x", 2: "y", 3: "t", 4: "d", 5: "y", 77: "g"' 78: "h", 79: "x", 80: "y", 206: "t", 210: "d", 211: "x" } I would pull out the sequence x-y-t-d (starting at 1 and 79) I need to keep the timestamp / data association because I need to generate output that identifies (a) the longest repeated sequence (b) how many elements in the longest repeated sequence (c) at what timestamps each occurrence started. I'm not sure of the best way, programatically, to aproach this task, which means I'm unsure whether eg a list of tuples ( time, data ) or an OrderedDict keyed on the timestamp is the best starting point. I can make a list of tuples using: d = [ (k,v) for k,v in data ] and with the list of tuples, I can do something like: d.sort( key=lambda tup: tup[0] ) max_start_a = 0 max_start_b = 0 max_len = 0 i = 0 while i < len( d ): j = i + 1 while j < len( d ): o = 0 while j+o < len( d ) and d[i+o][1] == d[j+o][1]: o += 1 if o > max_len: max_len = 0 max_start_a = i max_start_b = j j += 1 i += 1 print d[max_start_a][0], d[max_start_b][0], max_len Is there a better way to do this? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: HOW TO HANDLE CAPTCHA WHILE PARSING A WEB SITE
On Wed, 18 Dec 2013 16:38:00 +, Mark Lawrence wrote: > On 18/12/2013 09:37, Jai wrote: >> RIGHT NOW NOW I AM WORKING WITH MECHANIZE MODULE . BUT UNABLE TO >> SUBMIT CAPTACHA AUTOMATICALLY . DO U HAVE ANY IDEA PLEASE SHARE WITH ME > Ditto the Chris Angelico answer to your earlier request. +1 -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: how to handle captcha through machanize module or any module
On Wed, 18 Dec 2013 04:56:17 -0800, Jai wrote: > please do replay how to handle captcha through machanize module The purpose of a captcha is to prevent automated scraping of data. Many of us may choose, or even need, to use captcha. What on earth makes you think for one minute that we'll help you bypass them. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Variables in a loop, Newby question
On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: > In this script i want to read the temperatures and make them available > to other scripts. The "global" keyword doesn't do that. "global" is used inside a function definition in python to tell the function that it is working with a global (to the program unit) variable. If you want this process to provide data to other processes, you might want to look at using a socket so they can request it as needed. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Variables in a loop, Newby question
On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote: > On 25Dec2013 02:54, Denis McMahon wrote: >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote: >> > In this script i want to read the temperatures and make them >> > available to other scripts. [...] >> If you want this process to provide data to other processes, you might >> want to look at using a socket so they can request it as needed. > > Or just write it to a file for another process to open and read... That can cause io sync errors, eg if another process has the file opened for read when you try to write, or you are writing when they try to read. For inter process communication, sockets are generally better than files. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a list with holes
On Fri, 03 Jan 2014 10:41:21 -0500, Larry Martell wrote: > The holes would be between the items I put in. In my example above, if I > assigned to [10] and [20], then the other items ([0..9] and [11..19]) > would have None. >>> dic = { 10:6, 20:11} >>> dic.get(10) 6 >>> dic.get(14) >>> dic.get(27,"oh god there's nothing here") "oh god there's nothing here" >>> dic.get(99,None) >>> dic.get(168,False) False >>> dic.get(20,"Boo Yah") 11 >>> So a standard dictionary does this returning None (or any other default value you care to pass it) as long as you use the dict.get(key[,default]) method rather than dict[key] to return the value. See also: http://stackoverflow.com/questions/6130768/return-none-if-dictionary-key- is-not-available -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a list with holes
On Fri, 03 Jan 2014 20:18:06 -0500, Roy Smith wrote: > In article , > Larry Martell wrote: > > >> Thanks, but I know all that about dicts. I need to use a list for >> compatibility with existing code. > > Generalizing what I think the situation is, "A dict is the best data > structure for the parsing phase, but I need a list later to hand off to > legacy interfaces". > > No problem. Parse the data using a dict, then convert the dict to a > list later. I haven't been following all the details here, but just > wanted to point out that using different data structures to hold the > same data at different phases of a program is a perfectly reasonable > approach. Indeed, assuming the requirement is to have a list of some length n units representing integer keys into a range of values from start to end, and he creates a dict initially: list = [ dict.get(x,None) for x in range(start,end + 1) ] Examples: >>> dic = {1:"fred", 9:"jim", 15:"susan", 25:"albert" } >>> l = [ dic.get(x,None) for x in range(1,20) ] >>> l ['fred', None, None, None, None, None, None, None, 'jim', None, None, None, None, None, 'susan', None, None, None, None] >>> l = [ dic.get(x,None) for x in range(-10,50) ] >>> l [None, None, None, None, None, None, None, None, None, None, None, 'fred', None, None, None, None, None, None, None, 'jim', None, None, None, None, None, 'susan', None, None, None, None, None, None, None, None, None, 'albert', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None] >>> len(l) 60 then the value of l[offset] will either be None or some string depending on the offset into the list -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Dos cursor and input management.
On Sun, 05 Jan 2014 20:25:11 +1100, Sean Murphy wrote: > The module must work under dos for now. Eventually Mac. Do you mean a windows command line terminal window, or some *nix shell? As far as I know, dos as an operating system hasn't been around since version 6.22 or thereabouts, although I believe ms windows provides a dos shell like interface on top of the windows os. I'm not aware that any version of python is supported on dos, but I may be wrong, there may be some 15 year old hardware running dos somewhere that also has a working python install. I associate dos with machines of the pre-pentium era, although I suspect that might not be quite accurate either. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list