Re: datetime question

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 6:25 PM, alex23 wrote: > On 12/11/2013 2:49 PM, Grant Edwards wrote: >> >> Don't forget that there are also some differences between American and >> Imperial whitespace. Since it's ASCII whitespace, you should probably >> assume American... > > sys.getsizeof(' ') > 34

Re: datetime question

2013-11-11 Thread alex23
On 12/11/2013 2:49 PM, Grant Edwards wrote: Don't forget that there are also some differences between American and Imperial whitespace. Since it's ASCII whitespace, you should probably assume American... >>> sys.getsizeof(' ') 34 >>> sys.getsizeof(u' ') 52 bad by design -- https://mail.python

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 6:01 PM, Frank-Rene Schäfer wrote: > A tuple is immutable but it may contain mutable objects. In larger > hierarchies of objects it may become less obvious whether down > the lines, there is some mutable object somewhere in the data tree. > > One can define a recursive func

[RELEASED] Python 3.3.3 release candidate 2

2013-11-11 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I'm quite happy to announce the Python 3.3.3 release candidate 2. Python 3.3.3 includes several security fixes and over 150 bug fixes compared to the Python 3.3.2 release. This release fully supports OS X 10.

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Frank-Rene Schäfer
A tuple is immutable but it may contain mutable objects. In larger hierarchies of objects it may become less obvious whether down the lines, there is some mutable object somewhere in the data tree. One can define a recursive function to check for immutability manually. However first, it may not be

Re: To whoever hacked into my Database

2013-11-11 Thread rurpy
On 11/11/2013 06:16 PM, Ned Batchelder wrote: > On Monday, November 11, 2013 5:47:28 PM UTC-5, ru...@yahoo.com wrote: >> On 11/08/2013 11:08 AM, Chris Angelico wrote: >>> On Sat, Nov 9, 2013 at 4:11 AM, wrote: On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote: > I never ignore advices. I r

Re: To whoever hacked into my Database

2013-11-11 Thread rurpy
On 11/11/2013 04:49 PM, Joel Goldstick wrote: > On Mon, Nov 11, 2013 at 5:47 PM, wrote: >> On 11/08/2013 11:08 AM, Chris Angelico wrote: >>> On Sat, Nov 9, 2013 at 4:11 AM, wrote: On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote: > I never ignore advices. > I read all answers as car

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 4:42 PM, Rick Johnson wrote: > On Monday, November 11, 2013 5:11:52 PM UTC-6, Chris Angelico wrote: >> On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson >> > 1. i believe win32 file paths require a qualifying volume >> > letter. >> They do not; omitting the drive letter makes t

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2013-11-11 Thread swatkins
> sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0) which unfortunately doesn't work! I guess will resort to python3 -u, although I don't want stdout to be unbuffered. -- https://mail.python.org/mailman/listinfo/python-list

Re: Buffering of sys.stdout and sys.stderr in python3 (and documentation)

2013-11-11 Thread swatkins
It's surprising and broken that stderr should be buffered in python3. python3 calls setvbuf(3) on stderr at startup to achieve this chuckle-headed behavior. It makes stderr line buffered if on a terminal, and fully buffered if redirected to a log file. A fully buffered stderr is a very bad id

Re: Creating a function for a directory

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 5:11:52 PM UTC-6, Chris Angelico wrote: > On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson > > 1. i believe win32 file paths require a qualifying volume > > letter. > They do not; omitting the drive letter makes the path relative to the > current drive (and since it doesn'

Re: To whoever hacked into my Database

2013-11-11 Thread Gregory Ewing
Ned Batchelder wrote: I don't know how best to make things better overall. I know that overlooking Nikos' faults won't do it. If everyone who reached the point where they don't think they can help any more would simply say so in a calm manner and then walk away, that would make things better o

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 3:46 PM, Rick Johnson wrote: > But python modules can't be interfaces because interfaces > should protect internal data, prevent external forces from > meddling with internal state (EXCEPT via the rules of a > predefined "contract"), hide dirty details from the caller, > an

Re: datetime question

2013-11-11 Thread Grant Edwards
On 2013-11-11, Mark Lawrence wrote: > On 11/11/2013 23:21, mm0fmf wrote: >> On 11/11/2013 19:39, Ethan Furman wrote: >>> On 11/11/2013 11:19 AM, Denis McMahon wrote: On Mon, 11 Nov 2013 11:57:36 +0200, ?? ?? wrote: >> lastvisit = ( datetime.utcnow()

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 8:47:09 PM UTC-6, Tim Daneliuk wrote: > I think this is certainly the use case most people would > suggest. But I think you may have missed the real reason > most modern designers object to inter-module globals: The > presence of such entities almost always means the c

Reading c struct via python

2013-11-11 Thread Lakshmipathi.G
Hi - We have C code which writes following struct into berkeley db ("my_db.db"). struct my_info { unsigned long int i, e; int o; char *f; char *s; }; How to read this via Python? Google search gave this code --- $ cat pybsd2.py from bsddb import db fruitDB = db.DB() fruitDB.open('

Re: Where to handle try-except - close to the statement, or in outer loop?

2013-11-11 Thread Terry Reedy
On 11/11/2013 8:34 PM, Victor Hooi wrote: I have a general question regarding try-except handling in Python. In Python, try-except can unapologetically be used as as alternate conditional-execution control-flow construct. if : else: can often be re-written try: except : Some

Re: PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Tim Daneliuk
On 11/11/2013 08:06 PM, Rick Johnson wrote: Globals are justified when they are used to communicate information between scopes that otherwise were meant to be mutually exclusive. I think this is certainly the use case most people would suggest. But I think you may have missed the real reason

Re: UTF-32 decoder optimization in Python 3.4

2013-11-11 Thread Terry Reedy
On 11/11/2013 4:41 PM, Mark Lawrence wrote: From http://docs.python.org/dev/whatsnew/3.4.html#optimizations "The UTF-32 decoder is now 3x to 4x faster.". Does anybody have any references to this work? All I can find is the 3.3 what's new which refers to PEP 393 (Flexible String Representation)

PyMyth: Global variables are evil... WRONG!

2013-11-11 Thread Rick Johnson
PyMyth: Global variables are evil... WRONG! Python's Global Hysteria: How many times have your heard or read the phrase: "Global variables are evil"? Well if you've been a mem

Re: Where to handle try-except - close to the statement, or in outer loop?

2013-11-11 Thread Steven D'Aprano
On Mon, 11 Nov 2013 17:34:21 -0800, Victor Hooi wrote: > Hi, > > I have a general question regarding try-except handling in Python. > > Previously, I was putting the try-handle blocks quite close to where the > errors occured: > > A somewhat contrived example: > > if __name__ == "__main__"

Re: When I send email as HTML, why do erroneous whitespaces get introduced to the HTML source and a few < > chars get converted to < and > ???

2013-11-11 Thread Richard Balbat
On Saturday, November 9, 2013 2:29:00 AM UTC-5, dieter wrote: > rich writes: > Dieter, you were right!!! I broke up the string by inserting CRLF before I > reached 72 chars / line. Problem solved! > > > > I have the following script that reads in an HTML file containing a table > > then sends i

Re: datetime question

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 12:59 PM, Dennis Lee Bieber wrote: > Of course, I'm spoiled... My /watch/ has a dial for UTC, along with > one > for 24-hour indication (one hand, range 1 to 24) Heh. Mine doesn't, so I bought myself a second watch and set it to UTC. So my left hand has local time

Re: Getting globals of the caller, not the defining module

2013-11-11 Thread Terry Reedy
On 11/11/2013 7:02 AM, sg...@hotmail.co.uk wrote: (Sorry for posting through GG, I'm at work.) On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote: Suppose I have a function that needs access to globals: # module A.py def spam(): g = globals() # this gets globals from A

Re: Where to handle try-except - close to the statement, or in outer loop?

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 12:34 PM, Victor Hooi wrote: > Would I wrap all of the calls in a try-except block? > > try: > my_pet.feed() > my_pet.shower() > except IOError as e: > # Do something to handle exception? > It really depends more on how you go about recoveri

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Joshua Landau
On 11 November 2013 22:21, Chris Angelico wrote: > On Tue, Nov 12, 2013 at 7:50 AM, Joshua Landau wrote: >> The obvious way to me is a binary search: > > Which makes an O(log n) search where I have an O(1) lookup. The > startup cost of denormalization doesn't scale, so when the server > keeps run

Re: توقيت وموعد اذاعة مباراة الزمالك ووادى دجلة فى نهائى كأس مصر اليوم السبت 9/11/2013 والقنوات الناقلة

2013-11-11 Thread alex23
On 12/11/2013 6:32 AM, Tony the Tiger wrote: May your woman betray you, your son be gay, and your daughter screw pigs for a living. Now go eat some pork and choke on it, like a good little terrorist. This is completely unacceptable and has no place on this list. -- https://mail.python.org/mail

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Steven D'Aprano
Hi Frank-Rene, and welcome. Comments below. On Mon, 11 Nov 2013 21:47:45 +0100, Frank-Rene Schäfer wrote: > I prepared a PEP and was wondering what your thoughts are about it: > > PEP: > Title: ``isimmutable(Obj)`` and/or ``ImmutableNester`` [...] > * Python-Version: 2.

Re: Programa no modo gráfico

2013-11-11 Thread Elias de Oliveira
Also, we have a huge community in Brazil. If you want to write in Portuguese, you could use the official python-brasil list: https://groups.google.com/forum/#!forum/python-brasil []`s 2013/11/8 Izar Tarandach > You can find many resources for GUI programming in Python here: > https://wiki.pyth

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:44 AM, Joel Goldstick wrote: > Sorry for incorect answer. Those guys nailed it Your answer wasn't incorrect, because it didn't give any false information. Bob and I saw the problem itself and gave advice, but you gave useful general advice on how to find the problem, whi

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 11:17 AM, Steven D'Aprano wrote: > On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote: > >> On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote: >>> I prepared a PEP and was wondering what your thoughts are about it: >> >> The best place to discuss

Where to handle try-except - close to the statement, or in outer loop?

2013-11-11 Thread Victor Hooi
Hi, I have a general question regarding try-except handling in Python. Previously, I was putting the try-handle blocks quite close to where the errors occured: A somewhat contrived example: if __name__ == "__main__": my_pet = Dog('spot', 5, 'brown') my_pet.feed() my

Re: To whoever hacked into my Database

2013-11-11 Thread Ned Batchelder
On Monday, November 11, 2013 5:47:28 PM UTC-5, ru...@yahoo.com wrote: > On 11/08/2013 11:08 AM, Chris Angelico wrote: > > On Sat, Nov 9, 2013 at 4:11 AM, wrote: > >> On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote: > >>> I never ignore advices. > >>> I read all answers as carefully as i can. > >>

Stop feeding the Ferrous Cranus troll

2013-11-11 Thread Chuck Quast
http://www.politicsforum.org/images/flame_warriors/flame_62.php why are any of you replying? -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating a function for a directory

2013-11-11 Thread Steven D'Aprano
On Mon, 11 Nov 2013 14:51:45 -0800, Rick Johnson wrote: > 2. Never, ever, *EVER* write data to disc before confirming the paths > your passing are pointing to the location you intended to write the > data. Use os.path.exists(path) to test your paths BEFORE trying to write > data. This is subject

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Mark Lawrence
On 12/11/2013 00:17, Steven D'Aprano wrote: On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote: On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote: I prepared a PEP and was wondering what your thoughts are about it: The best place to discuss proposals for changes t

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Steven D'Aprano
On Mon, 11 Nov 2013 12:55:56 -0800, Ned Batchelder wrote: > On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote: >> I prepared a PEP and was wondering what your thoughts are about it: > > The best place to discuss proposals for changes to the Python language > and library is t

Re: To whoever hacked into my Database

2013-11-11 Thread Mark Lawrence
On 11/11/2013 23:49, Joel Goldstick wrote: On Mon, Nov 11, 2013 at 5:47 PM, wrote: Lets get this right folks once and for all. Let's carry on welcoming Nikos with open arms as he's such a wonderful benefactor to the community, but ban people such as Matt who had the audacity to write abou

Re: PyWart: Python modules are not so "modular" after all!

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 1:34:54 AM UTC-6, Steven D'Aprano wrote: > import sys > sys.modules["mymodule"] = any_object_you_like() Thanks for this great advice! I'm not particularly fond of injecting names and objects in this manner due to the "surprise factor", especially when the names are go

Re: To whoever hacked into my Database

2013-11-11 Thread Joel Goldstick
On Mon, Nov 11, 2013 at 5:47 PM, wrote: > On 11/08/2013 11:08 AM, Chris Angelico wrote: >> On Sat, Nov 9, 2013 at 4:11 AM, wrote: >>> On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote: I never ignore advices. I read all answers as carefully as i can. But nevertheless sometimes i fe

Re: datetime question

2013-11-11 Thread Mark Lawrence
On 11/11/2013 23:21, mm0fmf wrote: On 11/11/2013 19:39, Ethan Furman wrote: On 11/11/2013 11:19 AM, Denis McMahon wrote: On Mon, 11 Nov 2013 11:57:36 +0200, Νίκος Αλεξόπουλος wrote: lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S' )# MySQL datetime

Re: datetime question

2013-11-11 Thread mm0fmf
On 11/11/2013 19:39, Ethan Furman wrote: On 11/11/2013 11:19 AM, Denis McMahon wrote: On Mon, 11 Nov 2013 11:57:36 +0200, Νίκος Αλεξόπουλος wrote: lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S' )# MySQL datetime format Someone has an idea what t

Re: datetime question

2013-11-11 Thread Joel Goldstick
On Mon, Nov 11, 2013 at 5:49 PM, wrote: > On Friday, November 8, 2013 3:06:33 PM UTC-7, Joel Goldstick wrote: >> rurpy? can you help? > > No, sorry. For your future reference, if there is a > question I can help with (have the technical knowledge, > haven't seen a good answer yet, have time, et

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson wrote: > On Monday, November 11, 2013 4:26:46 PM UTC-6, Matt wrote: > >> So I want to take the file, "desktop/test.txt" and write >> it to "desktop/newfolder/test.txt". I tried the below >> script, and it gave me: "IOError: [Errno 2] No such file >> or

Re: Creating a function for a directory

2013-11-11 Thread Matt
Thank you guys so much. Brain fart moment. I appreciate it -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating a function for a directory

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 4:26:46 PM UTC-6, Matt wrote: > So I want to take the file, "desktop/test.txt" and write > it to "desktop/newfolder/test.txt". I tried the below > script, and it gave me: "IOError: [Errno 2] No such file > or directory: 'desktop/%s.txt'". Any suggestions would be > gre

Re: datetime question

2013-11-11 Thread rurpy
On Friday, November 8, 2013 3:06:33 PM UTC-7, Joel Goldstick wrote: > rurpy? can you help? No, sorry. For your future reference, if there is a question I can help with (have the technical knowledge, haven't seen a good answer yet, have time, etc) I will post my attempt at an answer. So lack

Re: To whoever hacked into my Database

2013-11-11 Thread rurpy
On 11/08/2013 11:08 AM, Chris Angelico wrote: > On Sat, Nov 9, 2013 at 4:11 AM, wrote: >> On 11/08/2013 03:05 AM, Νίκος Αλεξόπουλος wrote: >>> I never ignore advices. >>> I read all answers as carefully as i can. >>> But nevertheless sometimes i feel things should have been better >>> implemented

Re: Creating a function for a directory

2013-11-11 Thread Mark Lawrence
On 11/11/2013 22:26, Matt wrote: So I want to take the file, "desktop/test.txt" and write it to "desktop/newfolder/test.txt". I tried the below script, and it gave me: "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any suggestions would be great. def firstdev(file):

Re: Creating a function for a directory

2013-11-11 Thread Joel Goldstick
Sorry for incorect answer. Those guys nailed it On Nov 11, 2013 5:43 PM, "bob gailer" wrote: > On 11/11/2013 5:26 PM, Matt wrote: > >> So I want to take the file, "desktop/test.txt" and write it to >> "desktop/newfolder/test.txt". I tried the below script, and it gave me: >> "IOError: [Errno 2] N

Re: Creating a function for a directory

2013-11-11 Thread bob gailer
On 11/11/2013 5:26 PM, Matt wrote: So I want to take the file, "desktop/test.txt" and write it to "desktop/newfolder/test.txt". I tried the below script, and it gave me: "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any suggestions would be great. def firstdev(file):

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:26 AM, Matt wrote: > So I want to take the file, "desktop/test.txt" and write it to > "desktop/newfolder/test.txt". I tried the below script, and it gave me: > "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any > suggestions would be great. > > > > d

Re: Creating a function for a directory

2013-11-11 Thread Joel Goldstick
On Mon, Nov 11, 2013 at 5:26 PM, Matt wrote: > So I want to take the file, "desktop/test.txt" and write it to > "desktop/newfolder/test.txt". I tried the below script, and it gave me: > "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any > suggestions would be great. Its bett

Creating a function for a directory

2013-11-11 Thread Matt
So I want to take the file, "desktop/test.txt" and write it to "desktop/newfolder/test.txt". I tried the below script, and it gave me: "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any suggestions would be great. def firstdev(file): in_file = open("desktop/%s.txt")

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Mark Janssen
On Mon, Nov 11, 2013 at 3:32 AM, Chris Angelico wrote: > On Mon, Nov 11, 2013 at 10:17 PM, Steven D'Aprano > wrote: >> On Mon, 11 Nov 2013 21:39:27 +1100, Chris Angelico wrote: >>> denormalizes it into a lookup table by creating 70 entries quoting the >>> first string, 15 quoting the second, 5, a

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 7:50 AM, Joshua Landau wrote: > The obvious way to me is a binary search: Which makes an O(log n) search where I have an O(1) lookup. The startup cost of denormalization doesn't scale, so when the server keeps running for two years or more, it's definitely worth processing

UTF-32 decoder optimization in Python 3.4

2013-11-11 Thread Mark Lawrence
From http://docs.python.org/dev/whatsnew/3.4.html#optimizations "The UTF-32 decoder is now 3x to 4x faster.". Does anybody have any references to this work? All I can find is the 3.3 what's new which refers to PEP 393 (Flexible String Representation) optimizations as a result of work done by

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread random832
> A built-in function 'isimmutable()' shall tell efficiently whether the > object > of concern is mutable or not. What's the benefit over attempting to hash() the object? copy.deepcopy already has special case for int, string, and tuples (including tuples that do and do not have mutable members)

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Ned Batchelder
On Monday, November 11, 2013 3:47:45 PM UTC-5, Frank-Rene Schäfer wrote: > I prepared a PEP and was wondering what your thoughts are about it: The best place to discuss proposals for changes to the Python language and library is the Python-Ideas mailing list: https://mail.python.org/mailman/list

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Joshua Landau
On 11 November 2013 10:39, Chris Angelico wrote: > On Mon, Nov 11, 2013 at 9:09 PM, wrote: >> Regarding the "select" statement, I think the most "Pythonic" approach is >> using dictionaries rather than nested ifs. >> Supposing we want to decode abbreviated day names ("mon") to full names >> ("

Re: datetime question

2013-11-11 Thread Grant Edwards
On 2013-11-11, Ethan Furman wrote: > On 11/11/2013 11:19 AM, Denis McMahon wrote: >> On Mon, 11 Nov 2013 11:57:36 +0200, ?? ?? wrote: >> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S' )# MySQL datetime format >> >>

'isimmutable' and 'ImmutableNester'

2013-11-11 Thread Frank-Rene Schäfer
I prepared a PEP and was wondering what your thoughts are about it: PEP: Title: ``isimmutable(Obj)`` and/or ``ImmutableNester`` Version: Last-Modified: Author: Frank-Rene Schaefer, fsch...@users.sourceforge.net * BDFL-Delegate: * Discussions-To: f

Re: dateutil.relativedelta.WE and friends?

2013-11-11 Thread Skip Montanaro
damn gmail. Please ignore the drivel below (and this top post)... Skip On Mon, Nov 11, 2013 at 2:33 PM, Skip Montanaro wrote: > I found a rather inscrutable use of dateutil recurrence rules in > StackOverflow which generates a series of dates corresponding to the > third Wednesday of the month:

dateutil.relativedelta.WE and friends?

2013-11-11 Thread Skip Montanaro
I found a rather inscrutable use of dateutil recurrence rules in StackOverflow which generates a series of dates corresponding to the third Wednesday of the month: import dateutil.rrule as dr import dateutil.relativedelta as drel dt = datetime.datetime(2012, 1, 1, 0, 0) rule = dr

Re: datetime question

2013-11-11 Thread Ethan Furman
On 11/11/2013 11:19 AM, Denis McMahon wrote: On Mon, 11 Nov 2013 11:57:36 +0200, Νίκος Αλεξόπουλος wrote: lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S' )# MySQL datetime format Someone has an idea what to add to this line to automatically adjust

Re: datetime question

2013-11-11 Thread Denis McMahon
On Mon, 11 Nov 2013 11:57:36 +0200, Νίκος Αλεξόπουλος wrote: >> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( >> '%y-%m-%d %H:%M:%S' )# MySQL datetime format > Someone has an idea what to add to this line to automatically adjust > itself if DST happens? Yes, but the sc

Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-11 Thread 88888 Dihedral
On Sunday, November 10, 2013 4:56:38 PM UTC+8, Jorgen Grahn wrote: > On Sun, 2013-11-10, Chris Angelico wrote: > > > On Sun, Nov 10, 2013 at 11:41 AM, Roy Smith wrote: > > >> On 09/11/2013 22:58, Chris Angelico wrote: > > >>> > > > >>> > * Some languages are just fundamentally bad. I do not re

Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-11 Thread Ethan Furman
On 11/11/2013 01:28 AM, wxjmfa...@gmail.com wrote: * Some languages are just fundamentally bad. The flexible string representation is a perfect exemple. Argh! He escaped! *chase* *scuffle* *stuff* *stuff* *stuff* Whew. Safely back in the troll bin. Okay, back to my day. -- ~Ethan~ --

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread MRAB
On 11/11/2013 16:43, jonas.thornv...@gmail.com wrote: Here is the example file i have tried. #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial This program draws three rectangles filled with different colors. author: Jan Bodar last modified: January 2011 website: www.zetc

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread jonas . thornvall
Den måndagen den 11:e november 2013 kl. 17:43:12 UTC+1 skrev Chris “Kwpolska” Warrick: > On Mon, Nov 11, 2013 at 5:38 PM, wrote: > > > But i have no luck runn the Tkinter example file i downloaded in idel, it > > still says no module called Tkinter. > > IDLE* > > > === > > > Traceback (most

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread Chris “Kwpolska” Warrick
On Mon, Nov 11, 2013 at 5:38 PM, wrote: > But i have no luck runn the Tkinter example file i downloaded in idel, it > still says no module called Tkinter. IDLE* > === > Traceback (most recent call last): > File "D:\Python33\test2.py", line 16, in > from Tkinter import Tk, Canvas, Frame, B

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread Mark Lawrence
On 11/11/2013 16:38, jonas.thornv...@gmail.com wrote: I have installed Python 3.3, and i want to add a library with some basic functions like canvas and basic geomteric objects, fonts etc. Preferably something similar to the Javascript canvas. I've looked for graphic packages, and from what i

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread jonas . thornvall
Here is the example file i have tried. #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode Tkinter tutorial This program draws three rectangles filled with different colors. author: Jan Bodar last modified: January 2011 website: www.zetcode.com """ from Tkinter import Tk, Canvas, Frame, BOTH

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread Tim Golden
On 11/11/2013 16:38, jonas.thornv...@gmail.com wrote: > === Traceback (most recent call last): File "D:\Python33\test2.py", > line 16, in from Tkinter import Tk, Canvas, Frame, BOTH > ImportError: No module named 'Tkinter' === In addition, I really don't recommend running your test scripts strai

Re: Install Tkinter for Windows 7 64-bit

2013-11-11 Thread Tim Golden
On 11/11/2013 16:38, jonas.thornv...@gmail.com wrote: > I have installed Python 3.3, and i want to add a library with some > basic functions like canvas and basic geomteric objects, fonts etc. > Preferably something similar to the Javascript canvas. > > I've looked for graphic packages, and from w

Install Tkinter for Windows 7 64-bit

2013-11-11 Thread jonas . thornvall
I have installed Python 3.3, and i want to add a library with some basic functions like canvas and basic geomteric objects, fonts etc. Preferably something similar to the Javascript canvas. I've looked for graphic packages, and from what i can see something called Tkinter may be what i look for

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Neil Cerutti
> On Saturday, November 9, 2013 8:27:02 AM UTC-5, Joshua Landau wrote: > The C switch statement is very limited. The select statement > in the dialect of BASIC I regularly use is more flexible. > It's more concise on long if chains because it elides the "end > if"s. But the use of indentation for

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread rusi
On Monday, November 11, 2013 7:31:07 PM UTC+5:30, Roy Smith wrote: > > On Saturday, November 9, 2013 10:30:26 AM UTC-6, rusi wrote: > > > print ( {"mon":"mondays suck", > > > "tue":"at least it's not monday", > > > "wed":"humpday" > > > }.get(day_of_week,"its some other d

Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-11 Thread Mark Lawrence
On 11/11/2013 09:28, wxjmfa...@gmail.com wrote: * Some languages are just fundamentally bad. The flexible string representation is a perfect exemple. Again, a short explanation: This FSR splits unicode in chunks. Two immediate consequences: - It's necessary to keep track of "each individual

Re: datetime question

2013-11-11 Thread Joel Goldstick
So this is a physics joke. The engineers and physicists at the conference went to dinner. They ordered wine with dinner. The wait person asked: "Would you like the small liter, or the large liter?" -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python

Re: datetime question

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 1:14 AM, Roy Smith wrote: > We've got a data supplier who (for reasons I cannot fathom), runs their > network in local time. Every time we talk to them about problems, it's > a mess just trying to figure out what time we're talking about. We say, > "we saw a latency spike

Re: datetime question

2013-11-11 Thread Roy Smith
In article , Joel Goldstick wrote: > Why not display UTC? If it is so important to you to display local > time, why do you think that your host's local time is something that > is useful for a visitor? In general, it makes sense to run servers (and log everything) in UTC, and display local ti

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Roy Smith
> On Saturday, November 9, 2013 10:30:26 AM UTC-6, rusi wrote: > > print ( {"mon":"mondays suck", > > "tue":"at least it's not monday", > > "wed":"humpday" > > }.get(day_of_week,"its some other day") > > ) In article <8618d47d-518c-4f35-a879-57fad7525...@googlegrou

Re: Implementing a multivibrator function with python

2013-11-11 Thread Antoon Pardon
Op 11-11-13 10:41, JL schreef: > I am trying to implement a multivibrator function with python. This is how it > works; > > - An trigger event happens > - Upon receiving the event, a variable goes high for 5secs, then go low. > - If the event happens again before the 5secs expire, the high durat

Re: fd leak in parent process for logger.

2013-11-11 Thread Roy Smith
In article , ravindrapa...@gmail.com wrote: > Hi All, >I have server process which spawns a process for each request. Where >parent process is leaking fd for logger. Please find example code. You've got a lot of code here. The first thing to do when trying to debug a problem l

Re: datetime question

2013-11-11 Thread Joel Goldstick
On Mon, Nov 11, 2013 at 4:57 AM, Νίκος Αλεξόπουλος wrote: > Στις 8/11/2013 11:11 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: > >> Is there someway to write the following line even better with the >> ability to detect daylight saving time by itself so i don't have to >> alter the line manually when time chan

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Chris Angelico
On Mon, Nov 11, 2013 at 10:53 PM, Robert Kern wrote: > Heh. I've done pretty much exactly the same thing to implement an engine[1] > to draw from the random tables on Abulafia[2] which have nearly the same > structure. It scales up reasonably well beyond d100s. It's certainly not a > technique I w

Re: Getting globals of the caller, not the defining module

2013-11-11 Thread sg552
(Sorry for posting through GG, I'm at work.) On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote: > Suppose I have a function that needs access to globals: > > # module A.py > def spam(): > g = globals() # this gets globals from A > introspect(g) > > As written, spam() o

Re: Help - Exercise Decision

2013-11-11 Thread Kennedy Salvino
My teacher asked .. I will try to do as you said. -- https://mail.python.org/mailman/listinfo/python-list

Re: Help - Exercise Decision

2013-11-11 Thread Kennedy Salvino
Em domingo, 10 de novembro de 2013 19h56min45s UTC-3, Kennedy Salvino escreveu: > I'm trying to make a ranking of 3 numbers and say which the greatest and > consider whether there is a tie between them, I am not able to make the > conditions of draws. > > > > Code in PT-BR: http://pastebin.

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Robert Kern
On 2013-11-11 10:39, Chris Angelico wrote: A 'minor weapon' is based on a roll of a 100-sided dice. If it's 01 to 70, "+1 weapon: 2,000gp [weapon]"; if it's 71 to 85, "+2 weapon: 8,000gp [weapon]"; if 86 to 90, "Specific weapon [minor specific weapon]"; and if 91 to 100, "Special ability [minor

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Chris Angelico
On Mon, Nov 11, 2013 at 10:17 PM, Steven D'Aprano wrote: > On Mon, 11 Nov 2013 21:39:27 +1100, Chris Angelico wrote: >> denormalizes it into a lookup table by creating 70 entries quoting the >> first string, 15 quoting the second, 5, and 10, respectively. > > Ewww :-( > > Imagine having to print o

Re: Getting globals of the caller, not the defining module

2013-11-11 Thread Chris Angelico
On Mon, Nov 11, 2013 at 10:25 PM, Steven D'Aprano wrote: > But since spam is supposed to introspect as much information as possible, > I don't really want to do that. What (if anything) are my other options? You're playing with introspection, so I'd look at poking around in the stack trace. It'll

Getting globals of the caller, not the defining module

2013-11-11 Thread Steven D'Aprano
Suppose I have a function that needs access to globals: # module A.py def spam(): g = globals() # this gets globals from A introspect(g) As written, spam() only sees its own globals, i.e. those of the module in which spam is defined. But I want spam to see the globals of the caller. #

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Steven D'Aprano
On Mon, 11 Nov 2013 21:39:27 +1100, Chris Angelico wrote: > My code to handle that starts out with this array: > > "minor weapon":({ > 70,"+1 weapon: 2,000gp [weapon]", > 85,"+2 weapon: 8,000gp [weapon]", > 90,"Specific weapon [minor specific weapon]", 100,"Special ability > [mino

Re: Implementing a multivibrator function with python

2013-11-11 Thread Terry Reedy
On 11/11/2013 4:41 AM, JL wrote: I am trying to implement a multivibrator function with python. This is how it works; - An trigger event happens - Upon receiving the event, a variable goes high for 5secs, then go low. - If the event happens again before the 5secs expire, the high duration will

Re: Implementing a multivibrator function with python

2013-11-11 Thread Dave Angel
On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL wrote: - If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. This works like a retriggerable multivibrator for those who are into electronics. More precisely a retriggerable monostable multivibr

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread Chris Angelico
On Mon, Nov 11, 2013 at 9:09 PM, wrote: > Regarding the "select" statement, I think the most "Pythonic" approach is > using dictionaries rather than nested ifs. > Supposing we want to decode abbreviated day names ("mon") to full names > ("Monday"): That's an obvious mapping, though. If you're

Re: New user's initial thoughts / criticisms of Python

2013-11-11 Thread lorenzo . gatti
Regarding the "select" statement, I think the most "Pythonic" approach is using dictionaries rather than nested ifs. Supposing we want to decode abbreviated day names ("mon") to full names ("Monday"): day_abbr='mon' day_names_mapping={ 'mon':'Monday', 'tue':'Tuesday', 'wed':'Wednesd

Re: datetime question

2013-11-11 Thread Νίκος Αλεξόπουλος
Στις 8/11/2013 11:11 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Is there someway to write the following line even better with the ability to detect daylight saving time by itself so i don't have to alter the line manually when time changes? lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime(

  1   2   >