Re: Question about `list.insert`

2014-02-07 Thread Peter Otten
cool-RR wrote: > I'm curious. If I append an item to a list from the left using > `list.insert`, will Python always move the entire list one item to the > right (which can be super-slow) or will it check first to see whether it > can just allocate more memory to the left of the list and put the it

Re: python and matlab

2014-02-07 Thread Sturla Molden
Rustom Mody wrote: > What Sturla is probably saying is that the matmab-python imp-mismatch is > so high that jumping across is almost certainly not worth the trouble. I am saying that the abundance of Python packages for numerical and scientific computing (NumPy et al.) and their quality is now

Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Johannes Bauer
Hi group, I'm using Python 3.3.2+ (default, Oct 9 2013, 14:50:09) [GCC 4.8.1] on linux and have found what is very peculiar behavior at best and a bug at worst. It regards the mimetypes module and in particular the guess_all_extensions and guess_extension functions. I've found that these do not

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Asaf Las
On Friday, February 7, 2014 8:06:36 PM UTC+2, Johannes Bauer wrote: > Hi group, > > I'm using Python 3.3.2+ (default, Oct 9 2013, 14:50:09) [GCC 4.8.1] on > linux and have found what is very peculiar behavior at best and a bug at > worst. It regards the mimetypes module and in particular the > gu

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Mark Lawrence
On 07/02/2014 19:17, Asaf Las wrote: btw, had seen this after own post - example usage includes mimetypes.init() before call to module functions. From http://docs.python.org/3/library/mimetypes.html#module-mimetypes third paragraph "The functions described below provide the primary interface

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Johannes Bauer
On 07.02.2014 20:09, Asaf Las wrote: > it might be you could try to query using sequence below : > > import mimetypes > mimetypes.init() > mimetypes.guess_extension("text/html") > > i got only 'htm' for 5 consequitive attempts Doesn't change anything. With this: #!/usr/bin/python3 import mime

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Peter Otten
Asaf Las wrote: > On Friday, February 7, 2014 8:06:36 PM UTC+2, Johannes Bauer wrote: >> Hi group, >> >> I'm using Python 3.3.2+ (default, Oct 9 2013, 14:50:09) [GCC 4.8.1] on >> linux and have found what is very peculiar behavior at best and a bug at >> worst. It regards the mimetypes module an

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Asaf Las
btw, had seen this after own post - example usage includes mimetypes.init() before call to module functions. -- https://mail.python.org/mailman/listinfo/python-list

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Asaf Las
On Friday, February 7, 2014 9:40:06 PM UTC+2, Peter Otten wrote: > As Johannes mentioned, this depends on the hash seed: > $ PYTHONHASHSEED=0 python3 -c 'print({".htm", ".html", ".shtml"}.pop())' > .html > $ PYTHONHASHSEED=1 python3 -c 'print({".htm", ".html", ".shtml"}.pop())' > .htm > $ PYTHONHAS

Re: Python 2.7.6 help with white spaces?

2014-02-07 Thread Dante Signal31
2014-02-07 6:55 GMT+01:00 Ben Finney : > Scott W Dunning writes: > > > > * Please don't top-post. Trim the quoted material to the parts > > > relevant for your response, and respond inline like a normal > > > discussion. > > > > Oh, ok sorry about that. Like this? > > Yes. You also need to prese

Re: Python 2.7.6 help with white spaces?

2014-02-07 Thread Mark Lawrence
On 07/02/2014 20:45, Dante Signal31 wrote: Just one more solution for original question, surely not the best but only to cover all possibilities: print("{0}:{1}".format(minutes,seconds)) -- Dante Fancy wasting two whole characters when this will suffice print("{}:{}".format(minutes,seco

anyone have a nagare based website up I can see? comment on experience of using?

2014-02-07 Thread johannes falcone
looks cool http://www.nagare.org/trac/wiki/NagareFeatures -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7.6 help with white spaces?

2014-02-07 Thread Asaf Las
On Friday, February 7, 2014 11:11:37 PM UTC+2, Mark Lawrence wrote: > > Fancy wasting two whole characters when this will suffice > > print("{}:{}".format(minutes,seconds)) :) > > > Mark Lawrence H, got error: File "", line 1 print("{}:{}".format(minutes,seconds)) :)

Re: how to reduce bugs due to incorrect indentation

2014-02-07 Thread Roel Schroeven
Chris Angelico schreef: But none of this would solve the OP's original issue. Whether it's a tab or spaces, unexpectedly indenting a line of code is a problem. I had misread. I thought the problem was that the OP did want to indent, but accidentally used the tab key instead of the space bar to

Re: Python 2.7.6 help with white spaces?

2014-02-07 Thread Mark Lawrence
On 07/02/2014 21:45, Asaf Las wrote: On Friday, February 7, 2014 11:11:37 PM UTC+2, Mark Lawrence wrote: Fancy wasting two whole characters when this will suffice print("{}:{}".format(minutes,seconds)) :) Mark Lawrence H, got error: File "", line 1 print("{}:{}".format(minutes

Re: how to reduce bugs due to incorrect indentation

2014-02-07 Thread Roel Schroeven
msus...@gmail.com schreef: On Thursday, February 6, 2014 12:29:36 PM UTC-8, Roel Schroeven wrote: My suggestion: configure your editor to insert the appropriate amount of spaces instead of a tab when you press the tab key. You misunderstood the problem, but managed to start a Tab war! :-)

Re: Using virtualenv to bypass sudoer issues

2014-02-07 Thread Cameron Simpson
On 06Feb2014 18:32, Jean-Michel Pichavant wrote: > Assuming I have a debian workstation for which I don't have any > sudo rights, in order to be able to install / remove python packages, > should I be using virtualenv ? Is it a suited solution ? It is well suited. You can also do far simpler (an

Re: Finding size of Variable

2014-02-07 Thread Steven D'Aprano
On Thu, 06 Feb 2014 05:51:54 -0800, wxjmfauth wrote: > Sorry, I'm only pointing you may lose memory when working with short > strings as it was explained. I really, very really, do not see what is > absurd or obsure in: > sys.getsizeof('abc' + 'EURO') > 46 sys.getsizeof(('abc' + 'EURO')

Re: Using virtualenv to bypass sudoer issues

2014-02-07 Thread Asaf Las
On Saturday, February 8, 2014 3:18:02 AM UTC+2, Cameron Simpson wrote: > On 06Feb2014 18:32, Jean-Michel Pichavant wrote: > > > Assuming I have a debian workstation for which I don't have any > > sudo rights, in order to be able to install / remove python packages, > > should I be using virtualen

Re: Using virtualenv to bypass sudoer issues

2014-02-07 Thread Cameron Simpson
On 07Feb2014 19:03, Asaf Las wrote: > On Saturday, February 8, 2014 3:18:02 AM UTC+2, Cameron Simpson wrote: > > On 06Feb2014 18:32, Jean-Michel Pichavant wrote: > > > > > Assuming I have a debian workstation for which I don't have any > > > sudo rights, in order to be able to install / remove p

Re: Finding size of Variable

2014-02-07 Thread Ethan Furman
On 02/07/2014 06:48 PM, Steven D'Aprano wrote: That is not a trade-off that the core developers have chosen to make, and I agree with them. Even though you haven't broken all the build-bots yet, you can still stop saying "them". ;) -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/pyth

Re: Using virtualenv to bypass sudoer issues

2014-02-07 Thread Asaf Las
On Saturday, February 8, 2014 5:32:22 AM UTC+2, Cameron Simpson wrote: > On 07Feb2014 19:03, Asaf Las wrote: > > Persuming you are asking about "just make a lib directory and point > $PYTHONPATH at it" instead of virtualenv, in principle yes. > But it is more work; virtualenv is essentially a wel

Python 2.7.6 help with modules

2014-02-07 Thread Scott W Dunning
I have a question that was a part of my homework and I got it correct but the teacher urged me to do it using the % sign rather than subtracting everything, for some reason I’m having issues getting it to calculate correctly. I’ll put the question below, and what I originally had and below that

Re: Python 2.7.6 help with modules

2014-02-07 Thread Rustom Mody
On Saturday, February 8, 2014 10:14:10 AM UTC+5:30, Scott W Dunning wrote: > I have a question that was a part of my homework and I got it correct but the > teacher urged me to do it using the % sign rather than subtracting > everything, for some reason I'm having issues getting it to calculate

Re: Python 2.7.6 help with modules

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 3:44 PM, Scott W Dunning wrote: > - This is what I’ve been working with. I get the correct answers for > minutes and seconds then it goes to shit after that. > > seconds = raw_input("Enter the number of seconds:") > seconds = int(seconds) > minutes = seconds/60 > seconds =

Re: Python 2.7.6 help with modules

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 3:44 PM, Scott W Dunning wrote: > I have a question that was a part of my homework and I got it correct but > the teacher urged me to do it using the % sign rather than subtracting > everything, for some reason I’m having issues getting it to calculate > correctly. Oh by th

Re: Python 2.7.6 help with modules

2014-02-07 Thread Asaf Las
On Saturday, February 8, 2014 7:05:49 AM UTC+2, Rustom Mody wrote: > On Saturday, February 8, 2014 10:14:10 AM UTC+5:30, Scott W Dunning wrote: > > > I have a question that was a part of my homework > > and I got it correct but the teacher urged me to do it using the > > % sign rather than subtr

Re: Python 2.7.6 help with modules

2014-02-07 Thread Scott W Dunning
On Feb 7, 2014, at 10:10 PM, Chris Angelico wrote: > It might be easiest to think in terms of a single "divide into > quotient and remainder" operation. Let's leave aside > weeks/days/hours/minutes/seconds and split a number up into its > digits. (This is actually not as useless as you might thi

Re: Python 2.7.6 help with modules

2014-02-07 Thread Rustom Mody
On Saturday, February 8, 2014 10:35:49 AM UTC+5:30, Rustom Mody wrote: > On Saturday, February 8, 2014 10:14:10 AM UTC+5:30, Scott W Dunning wrote: > > > I have a question that was a part of my homework and I got it correct but > > the teacher urged me to do it using the % sign rather than subtra

Re: Python 2.7.6 help with modules

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 4:53 PM, Scott W Dunning wrote: > So, if I use the five digit # 5, bar = 5000, and foo = 0 because there > is no remainder after dividing by 10? Does it make a difference weather foo > or bar are written first? That's correct. It'll be more visible if you use a five-di

Re: Python 2.7.6 help with modules

2014-02-07 Thread Scott W Dunning
On Feb 7, 2014, at 10:10 PM, Chris Angelico wrote: > > You should be able to get this to the point of writing out five > separate values, which are the original five digits. Each one is worth > 10 of the previous value. At every step, do both halves of the > division. What do you mean by at ea

Re: Python 2.7.6 help with modules

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 4:55 PM, Scott W Dunning wrote: > On Feb 7, 2014, at 10:10 PM, Chris Angelico wrote: > > > You should be able to get this to the point of writing out five > separate values, which are the original five digits. Each one is worth > 10 of the previous value. At every step, do

Re: Python 2.7.6 help with modules

2014-02-07 Thread Scott W Dunning
> > On Feb 7, 2014, at 10:10 PM, Chris Angelico wrote: >> >> number = int(raw_input("Enter a five-digit number: ")) >> >> Now we begin to split it up: >> >> foo = number % 10 >> bar = number / 10 >> Ok, so it this what you’re talking about? number = int(raw_input(“Enter a five digit number:

Re: Python 2.7.6 help with modules

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 5:27 PM, Scott W Dunning wrote: > Ok, so it this what you’re talking about? > > > number = int(raw_input(“Enter a five digit number:)) > foo = number % 10 > bar = number / 10 > > digit = foo / 10 > rem = bar % 10 > Close! But if you print out foo and bar, you'll see that yo

Sorting dictionary by datetime value

2014-02-07 Thread Igor Korot
Hi, ALL, I'm trying to do a very easy task: sort python dictionary by value where value is a datetime object. When trying to do that in Python shell everthing works as expected. C:\Documents and Settings\Igor.FORDANWORK>python Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Inte

Re: Sorting dictionary by datetime value

2014-02-07 Thread Chris Angelico
On Sat, Feb 8, 2014 at 6:06 PM, Igor Korot wrote: sorted(a.items(), key=a.get) > [('1', datetime.datetime(2012, 12, 28, 12, 15, 30, 100)), ('3', > datetime.datetim > e(2012, 12, 28, 12, 16, 44, 100)), ('2', datetime.datetime(2012, 12, 28, 12, > 17, > 29, 100))] > > However, trying to

What is the most pythonic way to build up large strings?

2014-02-07 Thread cstrutton11
I am writing a couple of class methods to build up several lines of html. Some of the lines are conditional and most need variables inserted in them. Searching the web has given me a few ideas. Each has its pro's and cons. The best I have come up with is: def output_header_js(self, jquery=T

Re: Possible bug with stability of mimetypes.guess_* function output

2014-02-07 Thread Peter Otten
Asaf Las wrote: > On Friday, February 7, 2014 9:40:06 PM UTC+2, Peter Otten wrote: >> You never see ".shtml" as the guessed extension because it is not in the >> original mimetypes.types_map dict, but instead programmaticaly read from >> a file like /etc/mime.types and then added to a list of ext