Re: Guido on python3 for beginners

2016-02-17 Thread Steven D'Aprano
On Wednesday 17 February 2016 19:51, Rustom Mody wrote: > I hope someone can help me find this link: There is some record that Guido > has said that python3 is probably a bit harder on noobs than python2. > > Does anyone know/have that link? I can't say that I've seen it. I know that Raymond He

Re: Python keyword args can be any string

2016-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2016 06:55 pm, Mark Lawrence wrote: > On 18/02/2016 05:42, Steven D'Aprano wrote: >> Today I learned that **kwargs style keyword arguments can be any string: >> >> py> def test(**kw): >> ... print(kw) >> ... >> py> kwargs = {&

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-18 Thread Steven D'Aprano
code through a system that strips out leading whitespace?" "Then don't do that. What if you pass the source code through a system that strips out braces?" -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-18 Thread Steven D'Aprano
print("Read %s from the file." % value) data.append(int(value)) # Confirm the numbers read in are the same as those written out. if data != numbers: print("mismatch in values") # Print the sorted values. print(sorted(data)) # = cut = Does this help? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido on python3 for beginners

2016-02-18 Thread Steven D'Aprano
less, for the first 10 or 15 years, Apple used a mix of Pascal and assembly to write not just the operating system but a whole lot of applications for the Macintosh. Anyone who says that Pascal is a toy language is just ignorant. [1] Except in the trivial sense that the more you have to learn, the longer it will take. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread Steven D'Aprano
On Fri, 19 Feb 2016 01:14 pm, BartC wrote: > On 19/02/2016 00:30, Steven D'Aprano wrote: [...] >> "Then don't do that. What if you pass the source code through a system >> that strips out braces?" > > Python doesn't use braces, so that'

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread Steven D'Aprano
orial, not the reference manual. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How the heck does async/await work in Python 3.5

2016-02-19 Thread Steven D'Aprano
efore :-( Can somebody explain Brett's explanation? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido on python3 for beginners

2016-02-19 Thread Steven D'Aprano
complete so it can do anything Python or C can do: (=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc but the learning curve is steep enough that it will be frustrating rather than interesting. https://en.wikipedia.org/wiki/Malbolge -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-20 Thread Steven D'Aprano
them for later use, or process them as you go. If they're floating point numbers, change the call to int() to a call to float(). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido on python3 for beginners

2016-02-20 Thread Steven D'Aprano
e the same opjects. I believe there are other 3.x backports > like this. There's also codecs.open(). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: I can't install python on my pc

2016-02-20 Thread Steven D'Aprano
u are out of disk space. You need to delete some files, or put in a bigger hard drive. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How the heck does async/await work in Python 3.5

2016-02-20 Thread Steven D'Aprano
g in this thread makes me sad for *literally every programming language in existence except for Erlang and maybe one or two others*, which altogether about six people use in total..." :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: can try expect have if else.

2016-02-22 Thread Steven D'Aprano
" """ logging.info("Dataset create.Started !!!") try: touch_file("/nfs_mount", "inode_fixcrc.txt") except (IOError, OSError) as e: logging.error(e) sys.stderr.write("Dataset create failed...Exiting !!!") sys.exit(EXIT_STATUS_ERROR) logging.info("Dataset create.Done !!!") -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-22 Thread Steven D'Aprano
ine? What's that? Programs ran in batch mode, and 'interactive' meant that you could easily slip out one punched card, replace it with a different one, and run the program again. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-22 Thread Steven D'Aprano
r should be able to read a bunch of ints or floats from a text file without working up a sweat, but beginners may find this tricky. So I think you are right: there is a narrow, but useful, niche of semi-structured textual data that BASIC and VB support that Python doesn't support out of the box. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Steven D'Aprano
gt; Cloning will be a practical issue when you clone virtual machines, for > example. This is certainly a practical issue that people have to be aware of. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Steven D'Aprano
t would be difficult. Here's one I just made now: {00010203-0405-0607-0809-0a0b0c0d0e0f} And another: {836313e2-3b8a-53f2-9b90-0c9ade199e5d} They weren't hard to spoof :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Steven D'Aprano
will have (once Guido formally approves it) a new module, "secrets", for securely generating (pseudo)random tokens like this: import secrets filename = secrets.token_hex(16) https://www.python.org/dev/peps/pep-0506/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Steven D'Aprano
rdened against attack. Even uuid4 may not be suitable for security, since it may use a cryptographically weak PRNG such as Mersenne Twister. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Steven D'Aprano
e also: http://www.2uo.de/myths-about-urandom/ for a good explanation of how random and urandom actually work on Linux. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Make a unique filesystem path, without creating the file

2016-02-23 Thread Steven D'Aprano
On Tue, 23 Feb 2016 05:54 pm, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Tue, 23 Feb 2016 06:32 am, Marko Rauhamaa wrote: >>> Under Linux, /dev/random is the way to go when strong security is >>> needed. Note that /dev/random is a scarce resource on

Re: Make a unique filesystem path, without creating the file

2016-02-24 Thread Steven D'Aprano
If you're going to do so, please do so in the next few days (or write to me off list to ask for an extension) because I intend to ask Guido for a ruling early next week. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: HELP

2016-02-24 Thread Steven D'Aprano
o the question "Add icons?" There were no other messages, so I thought it was installed successfully. When I double-click the Python icon, I get a Yellow Screen Of Death. I expected the interpreter to run. In case it helps, I took a picture of the YSOD and posted it on imgur here: http:// ... Thanks in advance." -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Steven D'Aprano
On Thursday 25 February 2016 12:07, Dan Stromberg wrote: > Could people please compare and contrast the two ways of doing imports > in the Subject line? from module import data; print(data) import module; print(module.data) > I've long favored the latter, but I'm working in a code base that >

Re: Make a unique filesystem path, without creating the file

2016-02-24 Thread Steven D'Aprano
On Wednesday 24 February 2016 18:20, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Tue, 23 Feb 2016 05:54 pm, Marko Rauhamaa wrote: >>> However, when you are generating signing or encryption keys, you >>> should use /dev/random. >> >> And t

How to read from a file to an arbitrary delimiter efficiently?

2016-02-24 Thread Steven D'Aprano
I have a need to read to an arbitrary delimiter, which might be any of a (small) set of characters. For the sake of the exercise, lets say it is either ! or ? (for example). I want to read from files reasonably efficiently. I don't mind if there is a little overhead, but my first attempt is 100

Re: Make a unique filesystem path, without creating the file

2016-02-25 Thread Steven D'Aprano
On Thursday 25 February 2016 17:54, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Wednesday 24 February 2016 18:20, Marko Rauhamaa wrote: >>> Steven D'Aprano : >>>> And that is where you repeat something which is rank superstition. >>> &g

Re: Pyraf problem

2016-02-25 Thread Steven D'Aprano
at the bash prompt? python -c "import sys; print(sys.path)" Do you see the path to pyraf in Python's path? (Python does not use the same path as bash.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-25 Thread Steven D'Aprano
y on that special > behaviour of ‘os’. If I need ‘os.path’, I import it explicitly so no > reader needs to guess:: > > import os > import os.path As I have shown above, the fact that os.path is importable at all is the special case. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: The Real-Time Use of Python in Data Science World!

2016-02-27 Thread Steven D'Aprano
tising, it falls just slightly on the "acceptable" side of the line. But I wouldn't be surprised if some people disagree. I think it would be more acceptable to me if the sender labelled the subject line as "Advertising". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Redmonk popularity rankings place Python at #4

2016-02-27 Thread Steven D'Aprano
/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

[Off-topic] Requests author discusses MentalHealthError exception

2016-02-27 Thread Steven D'Aprano
The author of Requests, Kenneth Reitz, discusses his recent recovery from a MentalHealthError exception. http://www.kennethreitz.org/essays/mentalhealtherror-an-exception-occurred Although the connection to Python is only quite slim, I found it fascinating to read. -- Steven -- https

Re: Bug in Python?

2016-02-27 Thread Steven D'Aprano
to handle duck-typed lists too, anything with a list-like interface. It is okay if the optimized C version only works with actual lists, and falls back to a slower Python version for anything else. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread Steven D'Aprano
On Thu, 25 Feb 2016 06:30 pm, Chris Angelico wrote: > On Thu, Feb 25, 2016 at 5:50 PM, Steven D'Aprano > wrote: >> >> # Read a chunk of bytes/characters from an open file. >> def chunkiter(f, delim): >> buffer = [] >> b = f.read(1) &

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-27 Thread Steven D'Aprano
On Thu, 25 Feb 2016 06:37 pm, Wolfgang Maier wrote: > On 25.02.2016 07:50, Steven D'Aprano wrote: >> I have a need to read to an arbitrary delimiter, which might be any of a >> (small) set of characters. For the sake of the exercise, lets say it is >> either ! or ? (for

Re: Error in Tree Structure

2016-02-27 Thread Steven D'Aprano
#x27;), (u'on', 'IN'), Tree( 'DATE', [ (u'Saturday', 'NNP') ] ), (u'protested', 'VBD'), (u'tax', 'NN'), (u'hikes', 'NNS'), (u'imposed', 'VBN'), (u'by', 'IN'), (u'their', 'PRP$'), (u'cash-strapped', 'JJ'), (u'government,', 'NN'), (u'which', 'WDT'), (u'they', 'PRP'), (u'accused', 'VBD'), (u'of', 'IN'), (u'failing', 'VBG'), (u'to', 'TO'), (u'provide', 'VB'), (u'basic', 'JJ'), (u'services.', 'NN'), (u'(cm-kjd)', 'NN') ] ) ] If you format your giant list so you can see the structure, then you will likely find where there is a problem. Perhaps you have: - missing or too many [ ( ) or ] - a missing or extra comma - a missing or extra quotation marks - unexpected symbols like inside the list -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-27 Thread Steven D'Aprano
On Sat, 27 Feb 2016 10:18 pm, [email protected] wrote: > I have some VB forms with more than a hundred objects. https://www.appnovation.com/sites/default/files/attachments/yourproduct.jpg Your users probably hate you... *wink* -- Steven -- https://mail.python.org/mail

Re: Everything good about Python except GUI IDE?

2016-02-27 Thread Steven D'Aprano
http://livecode.com/ If only I could get the Linux installer to actually, you know, *work*. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Steven D'Aprano
On Sun, 28 Feb 2016 07:44 pm, Chris Angelico wrote: > On Sun, Feb 28, 2016 at 5:34 PM, Steven D'Aprano > wrote: [...] >> Drag-and-drop GUI builders have the same advantages over code as Python >> has over languages with distinct compile/execute steps: rapid >

Re: list index out of range Error , need to fix it or ignore it

2016-02-28 Thread Steven D'Aprano
m) and leave your machine unusable. You should create a user with the minimum privileges needed to get the work done. At the very least, you should TEST your code while running as an unprivileged user. It is very dangerous to run buggy code as root. Who knows what it will do? > 2. But if the

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Steven D'Aprano
has complained about the > lack of imagery or funny animation. You don't know if they haven't complained because they don't miss them, or haven't complained because they fell asleep and are too embarrassed to complain "your presentation put me to sleep due to the lack of dancing cows". :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Steven D'Aprano
; to find out which idiot changed the line ending of my file to \r. But that should be treated as a metadata change, not a change to the content. I know it isn't "really" metadata, it's "actually" content, but regardless, it should be *treated* as metadata. Who is the boss here? The user of the tool, or the tool? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Steven D'Aprano
entire document. Text styles are toggled: just hit Ctrl-I (or is it Ctrl-Shift-I, it's been a while since I've used Word) to toggle italic on and off. Even if the current paragraph defaults to italic, you can still toggle it off that way. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Steven D'Aprano
om games". > Imagine if the Python bug tracker required you to send, not a > patch file, but the entire source file that has the edit you want. How > would you manage those sorts of edits? Patch files are for the convenience of the code reviewer, not the person making the change. It's *less* work for me to email or upload the entire .py file than to create a patch and email that, but it's harder for the guy who wants to see what changes I've made before applying them. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Steven D'Aprano
ld imply that your production code is modifying already-imported modules, then wanting to import them again. Why would anyone in their right mind do that? Possibly because they lost a bet? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: General computer language, syntax question.

2016-03-01 Thread Steven D'Aprano
can also test for empty lists just as easily: py> if alist: ... print("not empty") ... else: ... print("empty") ... not empty py> blist = [] py> if blist: ... print("not empty") ... else: ... print("empty") ... empty -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: common mistakes in this simple program

2016-03-01 Thread Steven D'Aprano
versions. Unless you have an extremely strong reason for > wanting to stay to Python 2.6, you should update your Python version. Python 2.6 is still fully supported by Red Hat. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: usage of try except for review.

2016-03-01 Thread Steven D'Aprano
tially be replaced with "pass" and your program will continue to > work. http://import-that.dreamwidth.org/676.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-01 Thread Steven D'Aprano
On Tue, 1 Mar 2016 09:38 am, Larry Martell wrote: > But what is reality? Reality is that which, when you stop believing in it, doesn't go away. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything good about Python except GUI IDE?

2016-03-01 Thread Steven D'Aprano
On Sun, 28 Feb 2016 11:38 pm, BartC wrote: > On 28/02/2016 06:34, Steven D'Aprano wrote: > >> GUI elements are by definition graphical in nature, and like other >> graphical elements, manipulation by hand is superior to command-based >> manipulation. Graphica

Re: Everything good about Python except GUI IDE?

2016-03-01 Thread Steven D'Aprano
ask me to add more cocaine. People cannot get enough of Javascript, no matter what it does to the security and stability of their browser, no matter how many pop-ups it launches or how much spyware and malware it installs, or how many times it kills their browser. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: usage of try except for review.

2016-03-01 Thread Steven D'Aprano
s not needed it just gives an message I > have still included for the sake of try block If the except block is not needed, then you should not use try. > 2. If a failure’s are encountered the error by assert condition the > errors are now displayed on the screen , how do I redirect it to log > file using logging error Don't use assert like that. > 3. my function def has 1000 but Iam using 3600 in the calling fnx etc > , Time out value are overwritten ? I don't understand the question. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Steven D'Aprano
ymodule There are better ways to manage your Python path than to manually insert paths into sys.path like that. What version of Python are you using? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-01 Thread Steven D'Aprano
lievable reinterpretation that would change the facts as we know them. A thousand years from now, the sun will still appear to be rising in the east. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Steven D'Aprano
On Tue, 1 Mar 2016 10:39 pm, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano > wrote: >> I cannot imagine why you would want to reload() in production code. That >> would imply that your production code is modifying already-imported >> mo

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Steven D'Aprano
I don't have to open a dozen applications, wait for them to load, authenticate into half a dozen different systems. They're already open. About once a year, or every 18 months or so, I need to reboot to go into Windows. If not for that, and the occasional kernel update, I'd probab

Re: Everything good about Python except GUI IDE?

2016-03-01 Thread Steven D'Aprano
On Wed, 2 Mar 2016 05:06 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 28 Feb 2016 11:38 pm, BartC wrote: >>> It's the GUI users who are the Neanderthals, having to effectively >>> point at things with sticks. Or have to physically move that r

Re: Everything good about Python except GUI IDE?

2016-03-01 Thread Steven D'Aprano
On Wed, 2 Mar 2016 05:07 am, Chris Angelico wrote: > On Wed, Mar 2, 2016 at 3:44 AM, Steven D'Aprano > wrote: >> A better analogy is: >> >> When I add cocaine to my stew, the result is a appallingly bad for those >> who eat it. Do you have any idea how rough

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
Python 2.7, I think that the interpreter caches small ints from -1 to 255. But do not rely on this, because it is just an optimization and can and will change from version to version. You should never use `is` to test for equality. Use == to test for equality. Use `is` *only* to test for object identity ("the same object"). -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
ct, but of returning an ID number. Let's look at IDs in IronPython: >>> a, b, c = [], 1, "Hello world!" >>> print id(a), id(b), id(c), id(None) 43 44 45 0 And in Jython: >>> a, b, c = [], 1, "Hello world!" >>> print id(a), id(b

Re: What arguments are passed to the __new__ method ?

2016-03-02 Thread Steven D'Aprano
: '__main__', '__metaclass__': , '__new__': , '__init__': } **Initialising Meta instance Now let me create a new MyClass instance: instance = MyClass() which prints: **Calling Meta instance ^^Creating new instance of ^^Initialising MyClass instance <__ma

Speaking of Javascript [was Re: Everything good about Python except GUI IDE?]

2016-03-02 Thread Steven D'Aprano
Speaking of Javascript exploits: http://thedailywtf.com/articles/bidding-on-security This is a real exploit, and Ebay have refused to fix it. Yay them! More here: http://blog.checkpoint.com/2016/02/02/ebay-platform-exposed-to-severe-vulnerability/ -- Steven -- https://mail.python.org

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
your point is broadly correct: you trust the language to do what it promises, or you look for evidence that it doesn't and report a bug if you find it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
on.org/3/reference/expressions.html#is-not In this case, "same object" carries the normal English meaning of "same" and the normal computer science meaning of "object" in the sense of "Object Oriented Programming". There's no mystery here, no circular definition.

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 05:12 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> In this case, "same object" carries the normal English meaning of >> "same" and the normal computer science meaning of "object" in the >> sense of "Objec

Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Thu, 3 Mar 2016 08:49 am, Mark Lawrence wrote: > On 02/03/2016 17:23, Steven D'Aprano wrote: >> On Thu, 3 Mar 2016 01:11 am, Marko Rauhamaa wrote: >> >>> What is missing is the rules that are obeyed by the "is" operator. >> >> I think what i

Re: Continuing indentation

2016-03-02 Thread Steven D'Aprano
ou write your code like this? x = ++ ++ -- ++ -- --1 y = (2), 3 s = "Hello world!" . upper() -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Continuing indentation

2016-03-02 Thread Steven D'Aprano
ries of boolean-joined conditions and giving the > combined condition a single name is often a major improvement in > readability. Not primarily for code-layout reasons, but because it > forces you to name the concept (e.g. "continue_playing" here.) If you only use "continue_playing" in exactly one place, then it doesn't deserve a name. You wouldn't write: the_index = x + 1 value = sequence[the_index] would you? > Names are important! Too important to waste on every single-use expression. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-02 Thread Steven D'Aprano
" We can be absolutely certain that Kenneth weighs less than the entire universe. We don't even need a set of scales. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: A mistake which almost went me mad

2016-03-03 Thread Steven D'Aprano
is a problem with the module time.py. It is much easier to debug problems when you can see the error messages! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: looking into python...

2016-03-03 Thread Steven D'Aprano
is to create a package, compress it into a zip file, and run that zip file with the Python interpreter installed on your system. Since it relies on there being an external Python interpreter, it's not exactly stand-alone, but it may be close enough for what you're doing. Python packages are dead-simple: create a directory called "foo", and put a file inside it called "__init__.py". It can even be an empty file. That's a package. Obviously there is more to it than that, but that's the basics. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-03 Thread Steven D'Aprano
om.au/2006/02/william-blake-schizophrenic.html http://www.litkicks.com/Blake/ I don't know if Kenneth is significantly like Blake in any way. Not all mental illnesses are the same. > Likewise... > > On Thursday, March 3, 2016 at 8:05:27 AM UTC+5:30, Chris Angelico wrote: >> On Thu, Ma

Re: yield in try/finally case

2016-03-03 Thread Steven D'Aprano
n. In any case, PEP 255 is obsolete: that is no longer a limitation of yield. # Python 2.7 py> def gen(): ... try: ... yield 1 ... finally: ... yield 2 ... py> it = gen() py> next(it) 1 py> next(it) 2 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

[Still off-top] Physics [was Requests author discusses MentalHealthError exception]

2016-03-03 Thread Steven D'Aprano
ation by Einstein: E = m*c**2. Even tiny amounts of energy (say, the light and heat released from a burning match) involve a correspondingly tiny reduction in mass. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: list reversal error

2016-03-03 Thread Steven D'Aprano
On Fri, 4 Mar 2016 09:51 am, [email protected] wrote: > i have list of strings "data" and i am trying to build reverse list data1 Use a slice with a negative step-size and defaults for the start and end positions. data1 = data[::-1] -- Steven -- https://mail.pytho

Re: Continuing indentation

2016-03-03 Thread Steven D'Aprano
t is None or self.some_condition() or len(some_sequence) > 100 or some_other_condition or page_count < 5 ): do_processing() Looks fine to me. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Continuing indentation

2016-03-03 Thread Steven D'Aprano
place to break around a binary operator is after the > operator, not before it. > http://pep8.org/#maximum-line-length PEP 8 is wrong :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Continuing indentation

2016-03-05 Thread Steven D'Aprano
quot;better", and performing UI testing to determine which style is better, is a lot of hard work for marginal gain. It's much more fun to just flame each other :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Steven D'Aprano
raise ValueError("%s: unallowed cmd string" % st) Obviously you don't write that out in full each time, you factor it into a method or function. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: [Still off-topic] Physics

2016-03-05 Thread Steven D'Aprano
actice. But what it actually "means" in theory is anyone's guess. And so, on the principle that an analogy that is utterly wrong in a technical sense but understandable is better than a complicated and complex explanation that is utterly incomprehensible, I'm going to stick to talking about mass/energy conversions :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-06 Thread Steven D'Aprano
I estimate that the latest 3.x version is probably about 10% slower overall, although different benchmarks show different speeds. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.5.1 (32-bit)_20160306131105

2016-03-06 Thread Steven D'Aprano
On Sun, 6 Mar 2016 04:32 pm, 程仿 wrote: > when I am installing Python 3.5.1 (32-bit),some problems occurred.I hope > you could offer me some help.This file may contain some information about > the error. What file? Please COPY AND PASTE the text of the error message into your email. -

Re: Reason for not allowing import twice but allowing reload()

2016-03-06 Thread Steven D'Aprano
(assuming it is not modified across two different invocation > during the program execution). > > An argument here could be: to code module B in such a way that those > initializations don't happen again, but just once - check before resetting > etc. during the import. How would you do that? How could a .py file know if it has already been loaded? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regarding installation of python-3.5.1

2016-03-06 Thread Steven D'Aprano
On Sun, 6 Mar 2016 05:35 pm, Roshan S Sontakke wrote: > Gud afternoon sir my self Roshan sontakke I have down loaded a setup of > python-3.5.1 but nt able to install it gives an error message Shall we guess what the error message says, or would you like to tell us? -- Steven --

Re: Phyton

2016-03-06 Thread Steven D'Aprano
those using Python 2. Python 2 is here for the long haul. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-06 Thread Steven D'Aprano
On Monday 07 March 2016 14:27, Veek. M wrote: > 1. What are the rules for using __del__ besides: 'don't use it'. __del__ needs to be defined in a class to be called. It will be called *at some point* when the instance is about to be garbage collected. There is no guarantee when that will be: it

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-07 Thread Steven D'Aprano
On Monday 07 March 2016 17:13, Veek. M wrote: > import foo > class Bar(object): > def __del__(self, foo=foo): > foo.bar()# Use something in module foo > > ### Why the foo=foo? import foo, would increment the ref-count for > object 'foo' Yes. And then at shutdown, the module globals

Re: Struggeling with collections

2016-03-07 Thread Steven D'Aprano
On Monday 07 March 2016 19:24, Faling Dutchman wrote: > Hey folks, > > I am just starting off in python, but have good knowledge of both Java and > C#. Now is the problem that I need to have multiple instances of one > dictionary, that is not a problem if you know how many, but now, it is an > un

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread Steven D'Aprano
27;'.join(blob)) If your software can decode that, it will be a miracle. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread Steven D'Aprano
t, here you want to use it as an interface to this library and let the library do the heavy lifting". That's what Python is designed for. But that's not what Bart is saying. I'm impressed that pure Python code running in CPython is even *usable* for whatever sort of image p

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread Steven D'Aprano
;> translation of your C algorithm, > > I'm using it because this kind of file reading in Python is a mess. If I > do a read, will I get a string, a byte sequence object, a byte-array, or > array-array, or what? Calling it "a mess" is an exaggeration. There is a change between Python 2 and 3: - in Python 2, reading from a file gives you bytes, that is, the so-called "str" type, not unicode; - in Python 3, reading from a file in binary mode gives you bytes, that is, the "bytes" type; reading in text mode gives you a string, the "str" type. How is this a mess? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: fnmatch() vs. glob.glob()

2016-03-07 Thread Steven D'Aprano
ps://pymotw.com/2/glob/ https://pymotw.com/2/fnmatch/ But I shall give you a hint: the glob module imports the fnmatch module, and uses it to perform the matching. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-07 Thread Steven D'Aprano
On Tuesday 08 March 2016 12:41, BartC wrote: > On 08/03/2016 01:19, Steven D'Aprano wrote: >> On Tue, 8 Mar 2016 07:19 am, BartC wrote: >> >>> I don't have to hand a jpeg file that it can't >>> decode. >> >> Run this under Python 2: >

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Steven D'Aprano
On Tue, 8 Mar 2016 10:53 pm, BartC wrote: > On 08/03/2016 02:12, Steven D'Aprano wrote: >> On Tue, 8 Mar 2016 09:39 am, BartC wrote: > >>> I'm using it because this kind of file reading in Python is a mess. If I >>> do a read, will I get a string,

Re: Question

2016-03-08 Thread Steven D'Aprano
ble >> "D:\Users\Jon Ribbens\Documents\Python\test\Scripts\python.exe" could not >> be run: [WinError 5] Access is denied > > Ah, I probably never tried using it inside a user dir. On Windows I > typically do development in a path close to the drive root, e.g. > C:\dev. Am I missing something? It looks to me like a straight forward permissions error? I don't know how difficult that is to solve on Windows, but I don't think it has anything to do with the path itself, only the permissions of the path. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Steven D'Aprano
t it's worth, the core developers are aware that CPython's startup time has been increasing, and that it is large enough to impact the feeling of snappiness and responsiveness for command line tools. They are actively working on this to keep it as low as possible. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Steven D'Aprano
possible for the user to diagnose the problem. You even exit with an exit code of 0 ("success") in order to confuse any scripts they use. Brilliant! I love helpful tools like that! How many years did you say you have been programming? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Steven D'Aprano
t difficult to make > the code easily work between Python 2 and 3 and handle bytes. Any ideas > there? Use a single byte slice: the_bytes[i:i+1] which works identically in Python 2 and 3. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Steven D'Aprano
endings. In text mode, on Windows, Python *may* stop reading at a Ctrl-Z character and treat it as End Of File. I think. I can across this once, many years ago, but I no longer have access to Python on Windows to verify if that is still the case. There's more, but that's the basics to g

<    54   55   56   57   58   59   60   61   62   63   >