Re: Else statement executing when it shouldnt

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:48 AM, Thomas Boell wrote: > On Wed, 23 Jan 2013 02:42:27 +1100 > Chris Angelico wrote: > >> On Wed, Jan 23, 2013 at 2:39 AM, Thomas Boell wrote: >> > Huh?! I would have expected all your examples to raise a SyntaxError or >> > Ind

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:59 AM, Ferrous Cranus wrote: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique > number with INT!!! That's all i want!! But i cannot make it work :( Either you are deliberately trolling, or you have a major comprehension problem. Please go back

Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 4:57 AM, Peter Steele wrote: > In fact, I have used scapy in the past, but I am working in a restricted > environment and don't have this package available. It provides tones more > than I really need anyway, and I figured a simple raw socket send/receive > can't be *tha

Re: Using filepath method to identify an .html page

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 2:04 PM, rusi wrote: > Considering that you've fried the of all the poor "out- > of-my-control' double-posting GG users, what punishment shall we find > for you? > > Heres an idea: Use GG yourself. > It will help the group/mailing list by reducing 5-fold double-posting > t

Re: Failed to import a "pyd: File When python intepreter embed in C++ project

2013-01-22 Thread Chris Angelico
On Wed, Jan 23, 2013 at 1:43 PM, wrote: > I create a pyd File named "testPyd" with boostPython,and then I import the > testPyd module into "test.py", it works perfect! > But when I embeded the python interpreter into my C++ project and run the > "test.py", it comes out a "ImportErr: no module n

Re: Arent these snippets equivalent?

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 8:56 AM, Coolgg wrote: > Is this: > > while True: > data = fp.read(4096) > if not data: > break > ... > > not equivalent to this: > > data = fp.read (4096) > while data: > ...{handle the chunk here} > data = fp.read (4096) They should do the sam

Re: Arent these snippets equivalent?

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 9:47 AM, Roy Smith wrote: > while getchar() as c: >putchar(c) > > That would give people (including me) the use case they're after most of > the time (call a function, assign the return value, and test it). It's > way less klunky than: > > while True: >c = getchar(

Re: Uniquely identifying each & every html template

2013-01-23 Thread Chris Angelico
On Wed, Jan 23, 2013 at 11:38 PM, Dave Angel wrote: > You think it's an accident that md5 size is roughly equivalent to 39 decimal > digits? Or that the ones that haven't been proven insecure are much larger > than that? The sha512 hash is roughly equivalent to 154 decimal digits. Proving a has

Re: urllib2 FTP Weirdness

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 7:07 AM, Nick Cash wrote: > Python 2.7.3 on linux > > This has me fairly stumped. It looks like > urllib2.urlopen("ftp://some.ftp.site/path";).read() > will either immediately return '' or hang indefinitely. But > response = urllib2.urlopen("ftp://some.ftp.s

Re: Uniquely identifying each & every html template

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 11:09 AM, Dave Angel wrote: > I certainly can't disagree that it's easy to produce a very long hash that > isn't at all secure. But I would disagree that longer hashes > *automatically* reduce chances of collision. Sure. But by and large, longer hashes give you a better c

Re: Decrease for loop by one

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 3:39 PM, Milter Skyler wrote: > I made an array to check if the random integer already exists and then I send > it to the else statement at which point I want to decrease x by 1 so that it > doesn't count as one of the loops. In other languages this works... A Python 'fo

Re: Retrieving the full command line

2013-01-23 Thread Chris Angelico
On Thu, Jan 24, 2013 at 3:49 PM, Steven D'Aprano wrote: > Note however that there is an ambiguity between calling "python -mspam" > and calling a script literally named "-mspam". But that same ambiguity > exists in the shell, so I don't consider it a problem. You cannot call a > script named -mspa

Re: Python to send Midi commands to iPad via USB

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 9:31 PM, wrote: > What I have to do is to write a Python application that will send MIDI > commands to an iPad application. > All I know is that the iPad application can be connected to an external Midi > deck through a usb cable and be controlled. > So I think I would c

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 9:37 PM, inshu chauhan wrote: > For me I think the programme is logically correct, but its giving me results > which are strange. > It is Printing " Different Class" even when sp[9] is equal to sp[10] and > "Same class" when sp[9] is not equal to sp[10]. and sp[9] and sp

Re: mysql solution

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:04 PM, Ferrous Cranus wrote: > I;am now convinced the hash solution isn't reversible and also isn't unique. > I'am trying the database oriented solution. Glad you've listened to at least some of what you've been told. But if you want to be taken seriously on this list,

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 8:43 PM, Hazard Seventyfour wrote: > Hello, > > I new in this python and decided to learn more about it, so i can make an own > script :), > > for all senior can you suggest me the best, friendly and easy use with nice > GUI editor for me, and have many a good features su

Re: mysql solution

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:25 PM, Lele Gaifax wrote: > The simplest way is to execute a SELECT just after the insertion, doing > a > > SELECT pin FROM counters WHERE page = %s > > I don't use MySQL, so I can't say if it supports "INSERT ... RETURNING ..." > SQL syntax: should it, then you could

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:01 PM, inshu chauhan wrote: > Yeah I tried printing, there were trailing white spaces, so i used strip() > and IT Worked !!! :) Awesome! Keep repr() in mind, it's a great way to check what's really there. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:16 PM, Tobias M. wrote: > Chris Angelico wrote: >> The other thing you may want to consider, if the values are supposed >> to be integers, is to convert them to Python integers before >> comparing. > > I thought of this too and I wo

Re: Python to send Midi commands to iPad via USB

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:48 PM, wrote: > Thanks for your help Chris! > forgive my ignorance, but I am not sure what you mean. > I've installed pmidi and what I get is: > > ~$ pmidi -p 128:0 No.19.mid > Could not open file No.19.mid > > Doesn't that mean that the iPad is not seen? Heya! That wa

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 10:58 PM, Tobias M. wrote: > Chris Angelico wrote: >> >> I'd not consider the performance, but the correctness. If you're >> expecting them to be integers, just cast them, and specifically >> _don't_ catch ValueError. Any non-in

Re: Python to send Midi commands to iPad via USB

2013-01-24 Thread Chris Angelico
On Thu, Jan 24, 2013 at 11:25 PM, wrote: > I think I am not lucky :-( > > $ aplaymidi -l > PortClient name Port name > 14:0Midi Through Midi Through Port-0 > > I get the same either the iPad is connected or not. > So I guess is not recognized. >

Re: mysql solution

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 12:31 AM, Ferrous Cranus wrote: > Τη Πέμπτη, 24 Ιανουαρίου 2013 1:16:51 μ.μ. UTC+2, ο χρήστης Chris Angelico > έγραψε: >> Glad you've listened to at least some of what you've been told. But if >> you want to be taken seriously on this lis

Re: anyone can make a Python bindings of VLC-Qt ?

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 1:25 AM, iMath wrote: > > anyone can make a Python bindings of VLC-Qt ? > https://github.com/ntadej/vlc-qt > accurately, can anyone make a PyQt bindings of VLC-Qt ? Yes, someone can. Ideally, someone who knows C++, Python, VLC, and Qt, and has the time to port the code

Re: mysql solution

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 2:19 AM, Duncan Booth wrote: > Ferrous Cranus wrote: > >> I can do that but then i have to use that pin column's value in my >> next statement. >> >> cursor.execute( '''UPDATE visitors SET hits = hits + 1, useros = %s, >> browser = %s, date = %s WHERE pin = %s AND host = %

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 2:54 AM, rusi wrote: > - last expression with _ (underscore) Small terminology quibble: That's not last expression, but last non-None result. >>> 1+2 3 >>> _ 3 >>> _,None (3, None) >>> _ (3, None) >>> _[1] >>> _ (3, None) Otherwise, agree totally. Get to know the interac

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 7:25 AM, Tim Chase wrote: > On 01/24/13 13:34, Leonard, Arah wrote: >>> >>> All true (especially the holy wars bit!). OP didn't (as far as >>> I can see) even say which OS he is using. Anyway, my suggestion >>> is generally that people use the editor with which they are >>>

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 11:20 AM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> It's usually fine to have int() complain about any non-numerics in the >> string, but I must confess, I do sometimes yearn for atoi() semantics: >> atoi("123asd") =

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 12:03 PM, Oscar Benjamin wrote: > On 24 January 2013 11:35, Chris Angelico wrote: >> >> It's usually fine to have int() complain about any non-numerics in the >> string, but I must confess, I do sometimes yearn for atoi() semantics: >> atoi

Re: using split for a string : error

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 12:33 PM, Oscar Benjamin wrote: > I have solved similar situations with > sorted(filenames, key=lambda s: (len(s), s)) > which is better than lexicographical ordering for sorting integer > strings. It gets the _Int file wrong in this case (but I consider it > luck that

Re: The best, friendly and easy use Python Editor.

2013-01-25 Thread Chris Angelico
On Sat, Jan 26, 2013 at 4:35 AM, Leonard, Arah wrote: >>> >>> It's just a text file after all. >>> >> >> True indeed, let's not worry about trivial issues like indentation, mixing >> tabs and spaces or whatever. Notepad anybody? :) >> > > Hey, I didn't say Notepad was the *best* tool for the job

Re: Formatting a column's value output

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 4:51 AM, Ferrous Cranus wrote: > print ( " %s " > % item ) > > In the aboce code wheb 'URL' is to be typed out be print i need it to be > formatted as a link, so the viewer can click on it. > > Is this possible please? Easy, just make a t

Re: Formatting a column's value output

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 8:07 AM, Ferrous Cranus wrote: > That code works, but it creates links for both the URL and hits columns! > Only the URL must be linked not the hits column! 1) Trim your quotes. I can't be bothered doing your trimming for you, so I'm now under-quoting. 2) Quit using Googl

Re: looking for advice python

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 9:26 AM, wrote: > miles = int(string_miles) > gas = int(string_gas) > > #used to calculate mpg through division > mpg = miles/gas > > print(float(string_miles)) > print(float(string_gas)) > print('Your miles per gallon is', format(mpg,'.2f')) Welcome aboard! You turn you

Re: Formatting a column's value output

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 10:29 AM, alex23 wrote: > 5) Please stop writing code for his _commercial web hosting service_ > for free. You mean, stop asking us to write &c.? With that edit, yes, I agree. One of the difficulties on this list is that we don't have two-dimensional people. Even our wors

Re: Python Programming - 28 hours training in New York for $3999

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 3:38 AM, Juhani Karlsson wrote: > Or take this course for free and buy 500 lunches. > Your choice. You spend $8 on lunch? Wow, that's taking TANSTAAFL a long way... ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: The utter mess of current timezone definitions (was: Comparing offset-aware and offset-naive datetimes?)

2013-01-26 Thread Chris Angelico
On Sun, Jan 27, 2013 at 4:25 PM, Ben Finney wrote: >> but I happen to know its offset is 0 (i.e. GMT). > > As further fuel for your hatred: GMT is not the same thing as UTC+0, and > never has been. (See the definitions of those two separate timezones for > more; Wikipedia's articles are probably a

Re: Formatting a column's value output

2013-01-27 Thread Chris Angelico
On Sun, Jan 27, 2013 at 8:04 PM, Ferrous Cranus wrote: > Okey, so far BUT i want the url linking to happen only for the URL column's > value, and not for the hits column too. How do i apply the url link to the > URL column's value only? Step 1: Learn to read documentation. Step 2: Learn to writ

Re: Formatting a column's value output

2013-01-27 Thread Chris Angelico
On Sun, Jan 27, 2013 at 8:16 PM, Ferrous Cranus wrote: > Τη Κυριακή, 27 Ιανουαρίου 2013 11:08:15 π.μ. UTC+2, ο χρήστης Chris Angelico > έγραψε: >> On Sun, Jan 27, 2013 at 8:04 PM, Ferrous Cranus >> wrote: >> >> > Okey, so far BUT i want the url linking to happe

Re: Reading file issue

2013-01-28 Thread Chris Angelico
On Mon, Jan 28, 2013 at 10:47 PM, loial wrote: > I am parseing a file to extract data, but am seeing the file being updated > even though I never explicitly write to the file. It is possible that another > process is doing this at some later time, but I just want to check that > opening the fil

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
sting in your actual code, please? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] while conditional in list comprehension ??

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 12:33 AM, Wolfgang Maier wrote: > Why not extend this filtering by allowing a while statement in addition to > if, as in: > > [n for n in range(1,1000) while n < 400] The time machine strikes again! Check out itertools.takewhile - it can do pretty much that: import iterto

Re: [Python-ideas] while conditional in list comprehension ??

2013-01-28 Thread Chris Angelico
Argh, sorry folks. Hit the wrong list. :( On Tue, Jan 29, 2013 at 12:55 AM, Chris Angelico wrote: > On Tue, Jan 29, 2013 at 12:33 AM, Wolfgang Maier > wrote: >> Why not extend this filtering by allowing a while statement in addition to >> if, as in: >> >> [n for n

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:12 AM, inshu chauhan wrote: > where f1 contains something like : > > 297, 404, , > 298, 404, , .. > 299, 404, . > . .. > 295, 452, > > and f2 contains something like : > > 7 > . 2 > 2 > .7 > > and what I want to be written in th

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:24 AM, inshu chauhan wrote: >> In that case, Dave's suggestion to read into a list and iterate over >> the list is to be strongly considered. But I'm not entirely sure what >> your goal is here. Are you trying to make the Cartesian product of the >> two files, where you h

Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:37 AM, Dave Angel wrote: > What you want is the zip() function > > for l,s in zip(f1, f2): > #you now have one line from each file, > # which you can then validate and process > > Note, this assumes that when a line is "bad" from either file, you're going > to a

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 12:21 AM, iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns [] ? > please explain it in detail ! That's a list comprehension. If you're familiar with functional programming, it's like a map operation. Since the input list (near the end of the com

Re: environment fingerprint

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 10:33 AM, Jabba Laci wrote: > if md5: > md5 = hashlib.md5() > md5.update(text) > return md5.hexdigest() Simpler: if md5: return hashlib.md5(text).hexdigest() ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: [os.path.join(r'E:\Python', name) for name in []] returns []

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 12:56 PM, iMath wrote: > 在 2013年1月29日星期二UTC+8下午9时33分26秒,Steven D'Aprano写道: >> iMath wrote: > why [os.path.join(r'E:\Python', name) for name in []] returns >> [] ? Because you are iterating over an empty list, []. That list >> comprehension is the equivalent of: result = [

Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 1:55 PM, Daniel W. Rouse Jr. wrote: > I am currently using "Learning Python" by Mark Lutz and David Ascher, > published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations > insufficient and the number of examples to be sparse. I do understand some > ANSI C progra

Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 2:42 PM, Daniel W. Rouse Jr. wrote: > "Chris Angelico" wrote in message > news:mailman.1197.1359515470.2939.python-l...@python.org... >> Have you checked out the online documentation at >> http://docs.python.org/ ? That might have what you

Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 5:14 PM, Daniel W. Rouse Jr. wrote: > To me, this looks like an array. Is tuple just the Python name for an array? Not quite. An array is closer to a Python list - a tuple can be thought of as a "frozen list", if you like. Lists can be added to, removed from, and changed i

Re: Reading data from 2 different files and writing to a single file

2013-01-30 Thread Chris Angelico
On Wed, Jan 30, 2013 at 9:43 PM, inshu chauhan wrote: > I actually dont want nested loops but cant find another way to achieve what > I want, But for these files I am sure that they have equal lengths, thats > why I am taking the risk of using nested loops.. Can you suggest any > different way to

Re: looping versus comprehension

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 1:58 AM, Robin Becker wrote: > however, when I tried an experiment in python 2.7 using the script below I > find that the looping algorithms perform better. A naive loop using list += > list would appear to be an O(n**2) operation, but python seems to be doing > better than

Re: help

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 8:16 AM, wrote: > Hi everyone! I don't mean to intrude, but ive heard great things about this > group and ive stumped myself with my python code. Hi! As others have said, this is no intrusion, but it'd help a lot if you posted your errors and used a more useful subject l

Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 6:55 AM, Jorge Alberto Diaz Orozco wrote: > I want to use a reliable UDP connection like you say, a TCP like connection > but over UDP. thaks for your recomendation, if I get good results I promise > to share them. To get something reliable over UDP, you're going to need

Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 11:04 AM, Jorge Alberto Diaz Orozco wrote: > I have restrictions in my system that does not allow me to use TCP, so I want > to make a pipe over UDP imitating TCP behavior. > I have control over both endpoints, and I´m writing both of them. > I just don´t want to re-invent

Re: pyrudp

2013-01-30 Thread Chris Angelico
On Thu, Jan 31, 2013 at 3:26 PM, wrote: > Now, the good news is that because UDP-based protocols all run in user memory > space (as opposed to TCP that runs privileged in kernel space) it is > relatively straightforward for non-privledged users to write and test UDP > transport schemes and thi

Re: confusion with decorators

2013-01-31 Thread Chris Angelico
On Fri, Feb 1, 2013 at 12:25 AM, Jason Swails wrote: > On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano > wrote: >> >> On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote: >> >> > Hello, >> > >> > I was having some trouble understanding decorators and inheritance and >> > all that. This is w

Re: Help the visibility of Python in computational science

2013-01-31 Thread Chris Angelico
On Fri, Feb 1, 2013 at 12:05 PM, wrote: > "Brian" is a package I wrote (with several others) to do simulations of > spiking neural networks in Python. Read the article if you want to know > more! :) Ah, I don't need to read it. You're simulating a brain; the rest is mere appendix! (couldn't res

Re: Help the visibility of Python in computational science

2013-01-31 Thread Chris Angelico
On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano wrote: > dg.google.gro...@thesamovar.net wrote: > >> If you could take one minute to make sure you >> are signed in to your Google+ account > > Which Google+ account would that be? I have so few. > It's a thing non-nerds do, Steven. You wouldn't und

Re: Cheat Engine In Python

2013-01-31 Thread Chris Angelico
On Fri, Feb 1, 2013 at 6:21 PM, wrote: > Why there isn't any replys ? . Because you posted it only a couple of hours ago, for one :) My initial guess is: No. Feel free to disprove me by searching on Google and finding one. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Best approach to OO Style (only slightly off topic)?

2013-02-01 Thread Chris Angelico
On Sat, Feb 2, 2013 at 1:24 AM, Steve Simmons wrote: > At this point, I began to wonder what a 'correctly structured' OO program > should look like. Should I separate GUI logic from 'business' logic? Should > everything be in one class? Should my main() be carrying the high level > logic? Anyin

Re: CamelCase vs. all-lowercase package names

2013-02-01 Thread Chris Angelico
On Sat, Feb 2, 2013 at 2:04 AM, Rhubarb Sin wrote: > PEP-8 calls for "short, all-lowercase names" for packages: > > http://www.python.org/dev/peps/pep-0008/#package-and-module-names > > On the other hand, The Hitchhiker's Guide to Packaging 1.0, under > "Background," declares "come up with a Camel

Re: Floating point calculation problem

2013-02-02 Thread Chris Angelico
On Sat, Feb 2, 2013 at 9:27 PM, Schizoid Man wrote: > The quantity s is input with the following line: s = input("Enter s: ") > > To get rid of the compile error, I can cast this as a float: s = > float(input("Enter s: ")) > > However, then the result returned by the method is wrong. Why does

Re: Floating point calculation problem

2013-02-02 Thread Chris Angelico
On Sat, Feb 2, 2013 at 10:14 PM, Schizoid Man wrote: > Scratch that, I'm not sure which result is right now, so need to look at the > full calculations in details. What would be the difference between > raw_input() and float(input())? > > Thanks again. Depends on what you type in. raw_input() ta

Re: Floating point calculation problem

2013-02-02 Thread Chris Angelico
t. Other than that, I can't see any obvious reason for there to be a difference. Can you put together a simple script that demonstrates the problem and post it, along with the exact input that you're giving it, and the different outputs? Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Floating point calculation problem

2013-02-02 Thread Chris Angelico
On Sat, Feb 2, 2013 at 10:51 PM, Schizoid Man wrote: >> If your input has no decimal point in it, eval (or input) will return >> an integer, not a float. Other than that, I can't see any obvious >> reason for there to be a difference. Can you put together a simple >> script that demonstrates the p

String interning in Python 3 - missing or moved?

2012-01-23 Thread Chris Angelico
Python 2 can intern 'str' (bytes) strings (with the eponymous builtin, and with C API functions), though not unicode. Python 3 does not have that builtin, nor the C API; I can't find any support for either str or bytes. Has it been moved, or is interning as a concept deprecated? I don't have a us

Re: String interning in Python 3 - missing or moved?

2012-01-23 Thread Chris Angelico
On Tue, Jan 24, 2012 at 1:25 PM, Chris Rebert wrote: > The former, into `sys`: > http://docs.python.org/dev/library/sys.html#sys.intern > Search the "What's New"s in the future. > http://docs.python.org/release/3.1.3/whatsnew/3.0.html#builtins Doh, should have checked. Thanks! ChrisA -- http://

Re: String interning in Python 3 - missing or moved?

2012-01-23 Thread Chris Angelico
On Tue, Jan 24, 2012 at 3:18 PM, Terry Reedy wrote: > I think that the devs decided that interning is a minor internal > optimization that users generally should not fiddle with (especially how > that so much is done automatically anyway*), while having it a builtin made > it look like something t

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-23 Thread Chris Angelico
On Tue, Jan 24, 2012 at 4:57 PM, Rick Johnson wrote: > > Here is a grep from the month of September 2011... Is it? Interesting. I met that month yesterday (she was shopping in Oakleigh, don't ask) and she knew nothing about it. Oh, did you mean "Here is the result of using the grep(1) utility on

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-23 Thread Chris Angelico
On Tue, Jan 24, 2012 at 5:53 PM, Ian Kelly wrote: > On Mon, Jan 23, 2012 at 10:57 PM, Rick Johnson > wrote: >> >> Here is a grep > > A grep?  What is a grep? According to the damage type table on Aardwolf MUD, a grep is a type of slash - at least, it's resisted by the same armor value that resis

Re: Looking under Python's hood: Will we find a high performance or clunky engine?

2012-01-24 Thread Chris Angelico
On Tue, Jan 24, 2012 at 5:44 PM, alex23 wrote: > On Jan 24, 4:56 am, 8 Dihedral > wrote: >> I know manny python programmers just abandon the list comprehension >> in non-trivial processes. > > Really? Observation of the python mailing list indicates the opposite: > people seem inclined to use

Re: [GENERAL] [RFE] auto ORDER BY for SELECT

2012-01-24 Thread Chris Angelico
On Mon, Jan 23, 2012 at 11:17 PM, Douglas Eric wrote: > I suggest to change this behavior. If one makes a SELECT statement without > any ORDER BY, it would be > clever to automatically sort by the first primary key found in the query, if > any. > The present behavior would still be used in case of

Re: [GENERAL] [RFE] auto ORDER BY for SELECT

2012-01-24 Thread Chris Angelico
Whoops. Wrong list. *sigh* At least there's some variety - it's not Savoynet this time. Disregard the mad guy in the corner, he's not saying anything useful anyway... ChrisA On Tue, Jan 24, 2012 at 7:29 PM, Chris Angelico wrote: > On Mon, Jan 23, 2012 at 11:17 PM, Douglas

Re: String interning in Python 3 - missing or moved?

2012-01-24 Thread Chris Angelico
On Tue, Jan 24, 2012 at 7:17 PM, Stefan Behnel wrote: > If you want to encourage them to fill up their memory with user provided > data in a non-erasable way, then sure, that would certainly keep an > attacker from having to figure out hash collisions in order to bring down a > system. Sending *an

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Chris Angelico
On Wed, Jan 25, 2012 at 3:26 AM, Martin P. Hellwig wrote: > Having said that,  I do like to bring to your attention that her Majesty, > never ratified the 'Declaration of Independence'. :-) Oh, stop it. It's high time we got rid of these silly distinctions of English and American. Rick's right -

Re: windows and home path

2012-01-24 Thread Chris Angelico
On Wed, Jan 25, 2012 at 3:36 AM, Andrea Crotti wrote: > I just would like to be able to write somewhere in a place that should > always exist, > why Windows you're so annoying :(? Can you use the current directory, and rely on the user running your program from a viable default? ChrisA -- http:

Re: dynamically creating classes from text

2012-01-24 Thread Chris Angelico
On Wed, Jan 25, 2012 at 4:22 AM, T H wrote: > I’m new to python, sorry if my question is a bit naive, I was > wondering if it is possible to parse some text (ie. from a text file > or say html) and then dynamically create a class? Presuming that your class name comes from somewhere (eg the name o

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Chris Angelico
On Wed, Jan 25, 2012 at 8:13 AM, Blockheads Oi Oi wrote: > On 24/01/2012 20:03, Joshua Landau wrote: >> A simple version number doesn't imply huge breakages. Try "English2 v1.0"! >> >> In fact, why would a perfect language need a version number? >> > It would be difficult to maintain Python withou

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Chris Angelico
On Thu, Jan 26, 2012 at 2:01 PM, Rick Johnson wrote: > I believe we'll just have to "agree to disagree" on the issue of > pretty. However, let's take a step back and view this issue from a > global perspective. Ask yourself: > > Q: "Am i choosing my words carefully, or just blindly imitating other

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-25 Thread Chris Angelico
On Thu, Jan 26, 2012 at 4:14 PM, Steven D'Aprano wrote: > In the > same way that a native English speaker would never make the mistake of > using "organ" to refer to an unnamed mechanical device, so she would > never use "gadget" to refer to an unnamed body part. I dunno... every Sunday I press k

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Thu, Jan 26, 2012 at 2:19 AM, lh wrote: > Third, length. Well 5000 lines eh... I'm nowhere near that guess I can > stick with one file. Of all the source files I have at work, the largest is about that, 5K lines. It gets a little annoying at times (rapid deployment requires GCC to do its magic

Re: Distributing methods of a class across multiple files

2012-01-26 Thread Chris Angelico
On Fri, Jan 27, 2012 at 1:11 AM, Roy Smith wrote: > So, I'd say the driving principle should be that a function should do > one thing.  Every function should have an elevator talk.  You should be > able to get on an elevator with a function and when you ask it, "So, > what do you do?", it should b

PyPI - how do you pronounce it?

2012-01-27 Thread Chris Angelico
Hopefully this will be a step up from Rick's threads in usefulness, but I'm aware it's not of particularly great value! How do you pronounce PyPI? Is it: * Pie-Pie? * Pie-Pip, but without the last p? (same as above but short i) * Pie-Pea-Eye? * Something else? I've been saying Pie-Pea-Eye myself,

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Chris Angelico
On Sat, Jan 28, 2012 at 8:57 PM, Steven D'Aprano wrote: > Obviously that's pronounced Fin-tim-lin-bin-whin-bim-lim-bus-stop-F'tang- > F'tang-Olé-Biscuitbarrel. Ah, it's of British origin then. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: PyPI - how do you pronounce it?

2012-01-28 Thread Chris Angelico
On Sun, Jan 29, 2012 at 8:23 AM, Ben Finney wrote: > Steven D'Aprano writes: >> > * Pie-Pie? >> >> Or that one. > > What flavour is it? https://www.youtube.com/watch?v=tKB4h9gvmm0> Concrete! Flavour of the month. Thanks for the responses, all. Looks like Pie-Pea-Eye has consensus (with hon ment

Re: object aware of others

2012-01-28 Thread Chris Angelico
On Sun, Jan 29, 2012 at 2:48 PM, Lee Chaplin wrote: > I am trying to create an object that is aware of other objects created > before itself, and when found, then copy some attributes from them, > something like: If you're looking only at other objects of the same class, the easiest way is to mai

Re: object aware of others

2012-01-28 Thread Chris Angelico
On Sun, Jan 29, 2012 at 4:12 PM, Terry Reedy wrote: > On 1/28/2012 11:02 PM, Chris Angelico wrote: >> >> If you're looking only at other objects of the same class, the easiest >> way is to maintain a list every time one is created. Then you just >> iterate o

Re: [Python-Dev] #include "Python.h"

2012-01-29 Thread Chris Angelico
and proper division of code into multiple source files, that's not a significant concern. In any case, the worst that can happen is overly-large intermediate (.o or .obj) files; by the time the final binary is built, any duplicates will have to have been "folded down" to one anyway. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: PyPI - how do you pronounce it?

2012-01-30 Thread Chris Angelico
On Mon, Jan 30, 2012 at 11:12 PM, Neil Cerutti wrote: > > The British pronunciation of Beauchamp created a minor incident > at Yeoman of the Guard auditions this weekend. What about Sir Richard "Chumley", the "Left Tenant" of the Tower? Although this is now quite off-topic for this list... Chri

Re: except clause syntax question

2012-01-31 Thread Chris Angelico
On Wed, Feb 1, 2012 at 9:03 AM, Duncan Booth wrote: > Abitrarily nested tuples of exceptions cannot contain loops so the code > simply needs to walk through the tuples until it finds a match. Is this absolutely guaranteed? The C API for CPython provides: (Py2) http://docs.python.org/c-api/tuple.h

Re: except clause syntax question

2012-01-31 Thread Chris Angelico
On Wed, Feb 1, 2012 at 12:12 PM, Ian Kelly wrote: > Incidentally, I *think* that any correctly written C code attempting > to nest a tuple inside itself would make the reference count of the > tuple be at least 2 at the time of the call, and so it would fail. Good, nice that that's certain :) Mi

Re: How can I verify if the content of a variable is a list or a string?

2012-02-01 Thread Chris Angelico
On Wed, Feb 1, 2012 at 12:11 PM, Andres Soto wrote: > > okok, my mistake is that I was using string in place of str. Thank you!! > regards Tip: In the interactive interpreter, enter: >>> type("spam") In Python 2, it'll say "type" not "class", but same diff. It tells you there what the type is.

Re: SnakeScript? (CoffeeScript for Python)

2012-02-02 Thread Chris Angelico
On Fri, Feb 3, 2012 at 9:53 AM, andrea crotti wrote: > Mm I don't think it's what the OP is asking (unless I misunderstood...). > I think he wants to compile some syntax TO Python. > But I don't really see why you would something like this (if not for fun). > > Then how are you going to maintain t

Re: copy on write

2012-02-02 Thread Chris Angelico
On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano wrote: > No matter what Python did, somebody would complain. +1 This is, I think, the ultimate truth of the matter. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-03 Thread Chris Angelico
On Sat, Feb 4, 2012 at 7:14 AM, Andrew Berg wrote: > It's a rare occurrence, but sometimes my script will terminate and I get > this: > > Traceback (most recent call last): >  File "C:\path\to\script\script.py", line 992, in Do you call on potentially-buggy external modules? I'd be curious to se

Re: Script randomly exits for seemingly no reason with strange traceback

2012-02-04 Thread Chris Angelico
On Sun, Feb 5, 2012 at 3:32 AM, Andrew Berg wrote: > On 2/3/2012 9:15 PM, Chris Angelico wrote: >> Do you call on potentially-buggy external modules? > It imports one module that does little more than define a few simple > functions. There's certainly no (intentional) interpr

Re: Help about dictionary append

2012-02-05 Thread Chris Angelico
27;,'04')} >... > and I get and error that TUPLE object has no attribute Append !!! > > But how to add new Values to a dictionary then ? ... but instead of using parentheses and creating a Tuple, use square brackets and create a List: mydict = {'Name':['Name

<    12   13   14   15   16   17   18   19   20   21   >