Re: Dictionaries

2014-02-08 Thread worthingtonclinton
greatly appreciated guys. thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Dictionaries

2014-02-08 Thread Frank Millman
wrote in message news:891d3696-4e4e-44cc-a491-6b8fef47f...@googlegroups.com... > why in a for loop can i access values for a dict that i did not address in > the for loop. > > example: > > a = {blah:blah} > b = {blah:blah} > > for x in a: > >print a[x] > >#here's what i don't understand

Re: Dictionaries

2014-02-08 Thread Gary Herron
On 02/08/2014 11:07 PM, worthingtonclin...@gmail.com wrote: why in a for loop can i access values for a dict that i did not address in the for loop. example: a = {blah:blah} b = {blah:blah} for x in a: print a[x] #here's what i don't understand print b[x]

Dictionaries

2014-02-08 Thread worthingtonclinton
why in a for loop can i access values for a dict that i did not address in the for loop. example: a = {blah:blah} b = {blah:blah} for x in a: print a[x] #here's what i don't understand print b[x] # it would print the value for dict b even though it wasn't ca

Re: Python 2.7.6 help with modules

2014-02-08 Thread Larry Hudson
On 02/08/2014 05:21 PM, Scott W Dunning wrote: I figured it out! Thanks Chris! Taking it one step at a time with the five digit number really helped me to see how to break it all up! Are you a teacher? I appreciate the help and the patients! I like that you don’t just give me the answer t

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote in message news:ld4pon$ni9$1...@ger.gmane.org... > Frank Millman wrote: > > Here you can watch the key calculation at work: > d = {'1': 'abc', '2': 'xyz', '3': 'pqr'} def sortkey(value): > ... key = d.get(value) > ... print "value:", value,

Re: python and matlab

2014-02-08 Thread pavlovevidence
On Thursday, February 6, 2014 5:30:54 AM UTC-8, Sam Adams wrote: > is it able to utilize functions written in Python in Matlab? If it's on Windows, and if it's pure-Python 2.x code, the easiest solution would be to use Iron Python or Jython. Matlab can call Java and .NET code natively. -- http

Re: Python 2.7.6 help with modules

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 5:00 PM, Scott W Dunning wrote: > On Feb 8, 2014, at 6:46 PM, Chris Angelico wrote: > > That's certainly effective. It's going to give you the right result. I > would be inclined to start from the small end and strip off the > seconds first, then the minutes, etc, because t

Re: Python 2.7.6 help with modules

2014-02-08 Thread Scott W Dunning
On Feb 8, 2014, at 6:46 PM, Chris Angelico wrote: > That's certainly effective. It's going to give you the right result. I > would be inclined to start from the small end and strip off the > seconds first, then the minutes, etc, because then you're working with > smaller divisors (60, 60, 24, 7 i

Vedr: What does """ means in python?

2014-02-08 Thread Gisle Vanem
  Gisle V. "Computers are useless. They can only give answers" --Pablo Picasso Chris Angelico wrote: > For SQL? Ignore the extra spaces, it's a free-form language. The only > reason to consider dedent() would be if you're worried about how your > log files will look. The actual execution of

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 4:17 PM, Skybuck Flying wrote: > Anything that needs to be super reliable. > > My experience so far with Python versus Delphi has shown that Python > requires way more time to debug than Delphi. > > The reason for this is the interpreter versus the compiler. > > Delphi's com

Re: Sorting dictionary by datetime value

2014-02-08 Thread Larry Hudson
On 02/07/2014 11:06 PM, Igor Korot wrote: 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

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Skybuck Flying
" I got to know about Python a few months ago and today, I want to develop only using Python because of its code readability. This is not a healthy bias. To play my own devil's advocate, I have a question. What are the kinds of software that are not advisable to be developed using Python? " A

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 3:08 PM, Michael Torrie wrote: > On 02/08/2014 05:11 PM, Chris Angelico wrote: >> On Sun, Feb 9, 2014 at 10:54 AM, Sam wrote: >>> I got to know about Python a few months ago and today, I want to develop >>> only using Python because of its code readability. This is not a h

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Asaf Las
On Sunday, February 9, 2014 5:43:47 AM UTC+2, Steven D'Aprano wrote: > Nevertheless, although security by obscurity is ineffective[1], Python > supports it. You can ship only the .pyc files. For added obscurity, you > could put the .pyc files in a .zip file and ship that. For even more > obscuri

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Michael Torrie
On 02/08/2014 05:11 PM, Chris Angelico wrote: > On Sun, Feb 9, 2014 at 10:54 AM, Sam wrote: >> I got to know about Python a few months ago and today, I want to develop >> only using Python because of its code readability. This is not a healthy >> bias. To play my own devil's advocate, I have a q

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Steven D'Aprano
On Sat, 08 Feb 2014 21:53:00 -0500, Roy Smith wrote: > In article , > Sam wrote: > >> I got to know about Python a few months ago and today, I want to >> develop only using Python because of its code readability. This is not >> a healthy bias. To play my own devil's advocate, I have a question.

Re: Finding size of Variable

2014-02-08 Thread Rustom Mody
On Sunday, February 9, 2014 8:46:50 AM UTC+5:30, Ned Batchelder wrote: > On 2/8/14 10:09 PM, David Hutto wrote: > > Maybe I'll just roll my fat, bald, troll arse out from under the bridge, > > and comment back, off list, next time. > I'm not sure what happened in this thread. It might be that you

Re: Finding size of Variable

2014-02-08 Thread Ned Batchelder
On 2/8/14 10:09 PM, David Hutto wrote: Maybe I'll just roll my fat, bald, troll arse out from under the bridge, and comment back, off list, next time. I'm not sure what happened in this thread. It might be that you think Rustom Mody was referring to you when he said, "BTW: In my book this

Re: Finding size of Variable

2014-02-08 Thread David Hutto
Maybe I'll just roll my fat, bald, troll arse out from under the bridge, and comment back, off list, next time. -- https://mail.python.org/mailman/listinfo/python-list

Re: Finding size of Variable

2014-02-08 Thread Ned Batchelder
On 2/8/14 9:56 PM, David Hutto wrote: On Sat, Feb 8, 2014 at 8:25 PM, Rustom Mody mailto:rustompm...@gmail.com>> wrote: On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote: > One could argue that if you're parsing a particular file, a very large one, that those 9 b

Re: Finding size of Variable

2014-02-08 Thread David Hutto
On Sat, Feb 8, 2014 at 9:59 PM, Chris Angelico wrote: > On Sun, Feb 9, 2014 at 1:56 PM, David Hutto > wrote: > >> > >> Yes... There are cases when python is an inappropriate language to > use... > >> So??? > > > > > > I didn't say she couldn't optimize in another language, and was just > > prot

Re: Finding size of Variable

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 1:56 PM, David Hutto wrote: >> >> Yes... There are cases when python is an inappropriate language to use... >> So??? > > > I didn't say she couldn't optimize in another language, and was just > prototyping in Python. I just said she was optimizing her python > code...dufus.

Re: Finding size of Variable

2014-02-08 Thread David Hutto
On Sat, Feb 8, 2014 at 8:25 PM, Rustom Mody wrote: > On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote: > > One could argue that if you're parsing a particular file, a very large > one, that those 9 bytes can go into the optimization of parsing > aforementioned file. Of, course w

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Roy Smith
In article , Sam wrote: > I got to know about Python a few months ago and today, I want to develop only > using Python because of its code readability. This is not a healthy bias. To > play my own devil's advocate, I have a question. What are the kinds of > software that are not advisable to

Re: Python 2.7.6 help with modules

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 1:07 PM, Scott W Dunning wrote: > > On Feb 8, 2014, at 6:46 PM, Chris Angelico wrote: > > I had no idea > that, in a group of half a dozen nerds, nobody would recognize this > broken text: "In brightest day, in blackest night / No evil .. > sight / Let worship

Re: Python 2.7.6 help with modules

2014-02-08 Thread Scott W Dunning
On Feb 8, 2014, at 6:46 PM, Chris Angelico wrote: > No, I'm not a teacher by profession, but I was homeschooled, and since > I'm the second of seven children [1], I got used to teaching things to > my siblings. Also, every week I run a Dungeons and Dragons campaign > online, which requires simila

Re: Python 2.7.6 help with modules

2014-02-08 Thread Scott W Dunning
On Feb 7, 2014, at 11:29 PM, Chris Angelico wrote > Close! But if you print out foo and bar, you'll see that you're naming > them backwards in the second one. The last digit is the remainder > (modulo), the rest is the quotient. So, this is more like what you’re talking about? >>> first = numbe

Re: Python 2.7.6 help with modules

2014-02-08 Thread Scott W Dunning
I figured it out! Thanks Chris! Taking it one step at a time with the five digit number really helped me to see how to break it all up! Are you a teacher? I appreciate the help and the patients! I like that you don’t just give me the answer that you break it down and help me so that I can f

Re: Python 2.7.6 help with modules

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 12:46 PM, Scott W Dunning wrote: > On Feb 8, 2014, at 5:56 PM, Chris Angelico wrote: >> >> Carry on with that method - work out the number of minutes, and then >> the "hours_etc" which has the rest. Then do the same to split off >> hours, and then days. See how you go! > >

Re: Python 2.7.6 help with modules

2014-02-08 Thread Scott W Dunning
On Feb 8, 2014, at 5:56 PM, Chris Angelico wrote: > > Carry on with that method - work out the number of minutes, and then > the "hours_etc" which has the rest. Then do the same to split off > hours, and then days. See how you go! I did it similar to that but I went backwards. I started with n

Re: Python 2.7.6 help with modules

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 12:21 PM, Scott W Dunning wrote: > I figured it out! Thanks Chris! Taking it one step at a time with the five > digit number really helped me to see how to break it all up! Are you a > teacher? I appreciate the help and the patients! I like that you don’t just > give

Re: Finding size of Variable

2014-02-08 Thread Rustom Mody
On Sunday, February 9, 2014 4:15:50 AM UTC+5:30, David Hutto wrote: > One could argue that if you're parsing a particular file, a very large one, > that those 9 bytes can go into the optimization of parsing aforementioned > file. Of, course we have faster processors, so why care? > Because it go

Re: Python 2.7.6 help with modules

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 11:28 AM, Scott W Dunning wrote: > So, this is more like what you’re talking about? > first = number / 10 second = number % 10 last = first %10 rest = second / 10 > > I feel stupid saying this and it’s probably because of the variables I’m > using but I’

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 10:54 AM, Sam wrote: > I got to know about Python a few months ago and today, I want to develop only > using Python because of its code readability. This is not a healthy bias. To > play my own devil's advocate, I have a question. What are the kinds of > software that are

Re: What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Denis McMahon
On Sat, 08 Feb 2014 15:54:30 -0800, Sam wrote: > I got to know about Python a few months ago and today, I want to develop > only using Python because of its code readability. This is not a healthy > bias. To play my own devil's advocate, I have a question. What are the > kinds of software that are

What are the kinds of software that are not advisable to be developed using Python?

2014-02-08 Thread Sam
I got to know about Python a few months ago and today, I want to develop only using Python because of its code readability. This is not a healthy bias. To play my own devil's advocate, I have a question. What are the kinds of software that are not advisable to be developed using Python? -- http

Using asyncio for serial port

2014-02-08 Thread james . time4tea
Hiya I'm looking at using asyncio for creating an socket <-> serial protocol bridge, but looking at the current implementation of asyncio it looks to be quite socket specific. I can't see any way to get it to support a simple serial device. Any advice on where to proceed would be very much ap

Re: ur'foo' syntax under Python 3

2014-02-08 Thread Lele Gaifax
Thank you Peter and Mark for the links. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-lis

Re: Finding size of Variable

2014-02-08 Thread David Hutto
On Sat, Feb 8, 2014 at 8:17 AM, Mark Lawrence wrote: > On 08/02/2014 02:48, Steven D'Aprano wrote: > >> 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 se

Re: What does """ means in python?

2014-02-08 Thread Chris Angelico
On Sun, Feb 9, 2014 at 6:55 AM, Walter Hurry wrote: > When I asked (here) about this a while ago, some kind soul suggested > textwrap.dedent. > > Any advice as to the pros and cons of the respective approaches (esp. for > SQL)? For SQL? Ignore the extra spaces, it's a free-form language. The on

Re: What does """ means in python?

2014-02-08 Thread Walter Hurry
Roy Smith wrote: > In article <72a7dd52-7619-4520-991e-20db7ce55...@googlegroups.com>, > Sam wrote: > >> For string, one uses "" to represent string. Below is a code fragment that >> uses """ instead. >> >> cursor.execute("""SELECT name, phone_number >> FROM coworkers >>

Re: ur'foo' syntax under Python 3

2014-02-08 Thread Peter Otten
Lele Gaifax wrote: > I'm using Python 3.3, and I was surprised to realize that it does not > support the old Python 2 syntax ur"literal-raw-unicode-strings". > > Is there any trick to write such literals in a Python2+3 compatible > source? > > Is there a rationale behind the invalid syntax or is

Re: ur'foo' syntax under Python 3

2014-02-08 Thread Mark Lawrence
On 08/02/2014 19:38, Lele Gaifax wrote: Hi all, I'm using Python 3.3, and I was surprised to realize that it does not support the old Python 2 syntax ur"literal-raw-unicode-strings". Is there any trick to write such literals in a Python2+3 compatible source? Is there a rationale behind the inv

ur'foo' syntax under Python 3

2014-02-08 Thread Lele Gaifax
Hi all, I'm using Python 3.3, and I was surprised to realize that it does not support the old Python 2 syntax ur"literal-raw-unicode-strings". Is there any trick to write such literals in a Python2+3 compatible source? Is there a rationale behind the invalid syntax or is it just a glitch? thank

Re: Python3, __slots__ and serialization

2014-02-08 Thread Ned Batchelder
On 2/8/14 1:29 PM, Ned Batchelder wrote: On 2/8/14 1:06 PM, Eric Jacoboni wrote: Hi, Say i want create a class with a __slots__ tuple in order to prevent creation of new attributes from outside the class. Say i want to serialize instances of this class... With pickle, all is ok : i can dump an

Re: Python3, __slots__ and serialization

2014-02-08 Thread Ned Batchelder
On 2/8/14 1:06 PM, Eric Jacoboni wrote: Hi, Say i want create a class with a __slots__ tuple in order to prevent creation of new attributes from outside the class. Say i want to serialize instances of this class... With pickle, all is ok : i can dump an object to a file, then reload it. With P

Python3, __slots__ and serialization

2014-02-08 Thread Eric Jacoboni
Hi, Say i want create a class with a __slots__ tuple in order to prevent creation of new attributes from outside the class. Say i want to serialize instances of this class... With pickle, all is ok : i can dump an object to a file, then reload it. With PyYAML, i can dump an object to a file, but

urllib2: correct way how to add a header to the *initial* request?

2014-02-08 Thread Matěj Cepl
Hi, this is probably a dumb question but I just cannot find a way how to create AuthHandler which would add Authorization header to the FIRST request. The only thing I see in urllib2.py are various http_error handler which add Authorization header to the ADDITIONAL request which handles the er

urllib2: correct way how to add a header to the *initial* request?

2014-02-08 Thread Matěj Cepl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, this is probably a dumb question but I just cannot find a way how to create AuthHandler which would add Authorization header to the FIRST request. The only thing I see in urllib2.py are various http_error handler which add Authorization header

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

2014-02-08 Thread Eric S. Johansson
On 2/8/2014 3:35 AM, Rustom Mody wrote: On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru...@gmail.com wrote: 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 gi

Re: Using virtualenv to bypass sudoer issues

2014-02-08 Thread Jussi Piitulainen
Glenn Hutchings writes: > On 06/02/14 17: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 de

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

2014-02-08 Thread Dave Angel
cstrutto...@gmail.com Wrote in message: > > I didn't realize I could use formatting with triple quoted strings. I will > look into that. > You probably realize this, but formatting does not work on literals of any kind. It works on str objects, which can be created by any kind of litera

.pyc file import errors

2014-02-08 Thread dejmail
hi everyone I have a Flask app (in virtualenv, installed with --no-site-packages) running on Apache 2.4 with mod_wsgi, python2.7. When I leave it up to Apache to activate the Virtualenv, and I perform the URL request, I start getting alot of errors in the logs. It seems to want to create .pyc

Re: Sorting dictionary by datetime value

2014-02-08 Thread Tim Chase
On 2014-02-08 19:29, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot > wrote: > >> Try this: > >> > >> sorted_items = sorted(my_dict.keys(), key=my_dict.get) > > > > This code fail. > > Actually, it's a list of keys - notice that I changed > my_dict.items() into my_dict.keys()?

Re: What does """ means in python?

2014-02-08 Thread Roy Smith
In article <72a7dd52-7619-4520-991e-20db7ce55...@googlegroups.com>, Sam wrote: > For string, one uses "" to represent string. Below is a code fragment that > uses """ instead. > > cursor.execute("""SELECT name, phone_number > FROM coworkers > WHERE name=%s

What does """ means in python?

2014-02-08 Thread Sam
For string, one uses "" to represent string. Below is a code fragment that uses """ instead. cursor.execute("""SELECT name, phone_number FROM coworkers WHERE name=%s AND clue > %s LIMIT 5""", (name, clue_th

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

2014-02-08 Thread Mark Lawrence
On 08/02/2014 10:11, cstrutto...@gmail.com wrote: On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote: note, due to strings are immutable - for every line in sum operation above you produce new object and throw out older one. you can write one string spanned at multiple lines in v

Re: Finding size of Variable

2014-02-08 Thread Mark Lawrence
On 08/02/2014 02:48, Steven D'Aprano wrote: 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

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

2014-02-08 Thread Rustom Mody
On Saturday, February 8, 2014 4:58:03 PM UTC+5:30, Asaf Las wrote: > Check this approach if it suits you: > str_t= '' \ > ''.format('bella', 'donna') > print(str_t) Many people prefer this >>> str_t= ( '' ... '' ... ) >>> str_t '' Which is to say use the fact that adjacent strin

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

2014-02-08 Thread Roy Smith
In article <3157d511-48d1-4e4d-be4c-2c461fc17...@googlegroups.com>, Rustom Mody wrote: > On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru...@gmail.com wrote: > > I am writing a couple of class methods to build up several lines of html. > > Some of the lines are conditional and most nee

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 1:42:30 PM UTC+2, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las wrote: > > > Hi Chris > > The doc says > > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > MySQL driver written in Python which does not depend on MySQL C > > client lib

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las wrote: > Hi Chris > The doc says > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > MySQL driver written in Python which does not depend on MySQL C > client libraries and implements the DB API v2.0 specification (PEP-249). Ah. And that links

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 1:25:15 PM UTC+2, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 10:09 PM, Asaf Las wrote: > > > I used this one from Oracle and it was OK for simple test case and > > supports from 2.6 till 3.3: > > http://dev.mysql.com/doc/connector-python/en/index.html > > https:/

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

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 11:56:46 AM UTC+2, cstru...@gmail.com wrote: > On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote: > > > > > > > > note, due to strings are immutable - for every line in sum operation > > > > > > above you produce new object and throw out older on

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 10:09 PM, Asaf Las wrote: > I used this one from Oracle and it was OK for simple test case and > supports from 2.6 till 3.3: > http://dev.mysql.com/doc/connector-python/en/index.html > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > > yet there is page to bunch

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 10:52:36 AM UTC+2, Sam wrote: > I am writing my first python script to access MySQL database. > With reference to > http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects > Why is it advisable to use _mysql and not MySQLdb module directly? I used this o

Re: how to reduce bugs due to incorrect indentation

2014-02-08 Thread Jurko Gospodnetić
Hi, On 7.2.2014. 2:20, msus...@gmail.com wrote: Based on the responses I arrived to the conclusion that there is no better solution than trying to be careful and have good testing suites. It would be possible to disable the Tab key completely ...[snipped]... Maybe a coloring of the background

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

2014-02-08 Thread Steven D'Aprano
On Sat, 08 Feb 2014 01:56:46 -0800, cstrutton11 wrote: > On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote: >> note, due to strings are immutable - for every line in sum operation >> above you produce new object and throw out older one. you can write >> one string spanned at multiple

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

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 10:39:06 AM UTC+2, Peter Otten wrote: > Asaf Las wrote: > > On Saturday, February 8, 2014 9:51:48 AM UTC+2, Peter Otten wrote: > >> At least the mimetypes already defined in the module could easily produce > >> the same guessed extension consistently. > > imho one work

Re: Using virtualenv to bypass sudoer issues

2014-02-08 Thread Glenn Hutchings
On 06/02/14 17: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 depends on whether you need to share the install

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

2014-02-08 Thread cstrutton11
On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote: > > note, due to strings are immutable - for every line in sum operation > > above you produce new object and throw out older one. you can write > > one string spanned at multiple lines in very clear form. > > /Asaf I think I

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

2014-02-08 Thread cstrutton11
On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote: > > note, due to strings are immutable - for every line in sum operation > > above you produce new object and throw out older one. you can write > > one string spanned at multiple lines in very clear form. > I get what your s

Re: datetime formatting output

2014-02-08 Thread Igor Korot
Thank you Chris. On Sat, Feb 8, 2014 at 1:10 AM, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 8:06 PM, Igor Korot wrote: > > P.S.: Maybe its a problem with the datetime module which formats the > > datetime incorrectly? > > No, I'm pretty sure datetime.datetime really is meant to be working

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

2014-02-08 Thread cstrutton11
On Saturday, February 8, 2014 3:35:34 AM UTC-5, Rustom Mody wrote: > On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru...@gmail.com wrote: > > > 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

Re: datetime formatting output

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 8:06 PM, Igor Korot wrote: > P.S.: Maybe its a problem with the datetime module which formats the > datetime incorrectly? No, I'm pretty sure datetime.datetime really is meant to be working with microseconds. I'm not very familiar with MySQLdb, haven't used it in years; it

Fwd: datetime formatting output

2014-02-08 Thread Igor Korot
-- Forwarded message -- From: Igor Korot Date: Sat, Feb 8, 2014 at 1:06 AM Subject: Re: datetime formatting output To: Chris Angelico Chris, On Sat, Feb 8, 2014 at 12:45 AM, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 7:40 PM, Igor Korot wrote: > > I am reading data from

Re: What is the recommended python module for SQL database access?

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 7:55 PM, Sam wrote: > Is MySQLdb the recommended python module for SQL database access? Are there > other modules? What I want in a module is to be able to write readable and > maintainable code. > As long as you use some module that speaks the Python Database API (PEP 24

Re: Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 7:52 PM, Sam wrote: > I am writing my first python script to access MySQL database. With reference > to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects > > Why is it advisable to use _mysql and not MySQLdb module directly? Other way around. It's advisab

What is the recommended python module for SQL database access?

2014-02-08 Thread Sam
Is MySQLdb the recommended python module for SQL database access? Are there other modules? What I want in a module is to be able to write readable and maintainable code. -- https://mail.python.org/mailman/listinfo/python-list

Why use _mysql module and not use MySQLdb directly?

2014-02-08 Thread Sam
I am writing my first python script to access MySQL database. With reference to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects Why is it advisable to use _mysql and not MySQLdb module directly? -- https://mail.python.org/mailman/listinfo/python-list

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

2014-02-08 Thread Peter Otten
cstrutto...@gmail.com wrote: > 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 i

Re: datetime formatting output

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 7:40 PM, Igor Korot wrote: > I am reading data from the DB (mySQL) where the datetime field is stored as: > > 2012-12-12 23:59:59.099 > > When I retrieve this date I am successfully see under debugger the dateteime > object with (2012, 12, 12, 23, 59, 59, 099) > > However as

datetime formatting output

2014-02-08 Thread Igor Korot
Hi, ALL, I am reading data from the DB (mySQL) where the datetime field is stored as: 2012-12-12 23:59:59.099 When I retrieve this date I am successfully see under debugger the dateteime object with (2012, 12, 12, 23, 59, 59, 099) However as you can see from my previous post this date shows up i

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

2014-02-08 Thread Rustom Mody
On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru...@gmail.com wrote: > 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'

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

2014-02-08 Thread Peter Otten
Asaf Las wrote: > On Saturday, February 8, 2014 9:51:48 AM UTC+2, Peter Otten wrote: >> >> At least the mimetypes already defined in the module could easily produce >> the same guessed extension consistently. > > imho one workaround for OP could be to supply own map file in init() thus > ensure

Re: Sorting dictionary by datetime value

2014-02-08 Thread Igor Korot
Thank you. That worked. And no, I didn't notice that change. :( On Sat, Feb 8, 2014 at 12:29 AM, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot wrote: > >> Try this: > >> > >> sorted_items = sorted(my_dict.keys(), key=my_dict.get) > >> for key in sorted_items: > >> prin

Re: Sorting dictionary by datetime value

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 7:25 PM, Igor Korot wrote: >> Try this: >> >> sorted_items = sorted(my_dict.keys(), key=my_dict.get) >> for key in sorted_items: >> print my_dict[key], key > > > This code fail. > sorted_item is a list of tuples. And so iterating the list in the for loop I > will get a t

Fwd: Sorting dictionary by datetime value

2014-02-08 Thread Igor Korot
-- Forwarded message -- From: Igor Korot Date: Sat, Feb 8, 2014 at 12:25 AM Subject: Re: Sorting dictionary by datetime value To: Chris Angelico Chris, On Fri, Feb 7, 2014 at 11:58 PM, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 6:53 PM, Igor Korot wrote: > > Chris, > >

Re: Sorting dictionary by datetime value

2014-02-08 Thread Peter Otten
Frank Millman wrote: > > "Chris Angelico" wrote in message > news:captjjmqdusdfc1elbu6lf5-up__lae-63ii0uuvaggnem9u...@mail.gmail.com... >> 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', >>

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

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 9:51:48 AM UTC+2, Peter Otten wrote: > > At least the mimetypes already defined in the module could easily produce > the same guessed extension consistently. imho one workaround for OP could be to supply own map file in init() thus ensure unambiguous mapping across

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
"Frank Millman" wrote in message news:ld4ocf$9rg$1...@ger.gmane.org... > > "Chris Angelico" wrote in message > news:captjjmqdusdfc1elbu6lf5-up__lae-63ii0uuvaggnem9u...@mail.gmail.com... >> On Sat, Feb 8, 2014 at 6:06 PM, Igor Korot wrote: >> sorted(a.items(), key=a.get) >>> [('1', datetim

Re: Sorting dictionary by datetime value

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 7:03 PM, Frank Millman wrote: > I am using python3. I don't know if that makes a difference, but I cannot > get it to work. > d = {1: 'abc', 2: 'xyz', 3: 'pqr'} sorted(d.items(), key=d.get) > Traceback (most recent call last): > File "", line 1, in > TypeError:

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

2014-02-08 Thread Asaf Las
On Saturday, February 8, 2014 9:41:53 AM UTC+2, cstru...@gmail.com wrote: > 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'

Re: Sorting dictionary by datetime value

2014-02-08 Thread Chris Angelico
On Sat, Feb 8, 2014 at 6:53 PM, Igor Korot wrote: > Chris, > > On Fri, Feb 7, 2014 at 11:09 PM, Chris Angelico wrote: >> 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

Re: Sorting dictionary by datetime value

2014-02-08 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmqdusdfc1elbu6lf5-up__lae-63ii0uuvaggnem9u...@mail.gmail.com... > 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,