<div dir="ltr">Hello <br>Help for datetime module<br><br>Source code is :<br><h1><div class="codeShade"><code>
<font color="#7f0055"><b>from </b></font><font color="#000000">datetime </font><font color="#7f0055"><b>import </b></font><font color="#000000">datetime</font><br>
<font color="#000000">d = datetime</font><font color="#000000">(</font><font color="#000000">datetime.now</font><font color="#000000">()</font><font color="#000000">.year, datetime.now</font><font color="#000000">()</font><font color="#000000">.month, datetime.now</font><font color="#000000">()</font><font color="#000000">.day,</font><font color="#990000">11</font><font color="#000000">, </font><font color="#990000">59</font><font color="#000000">, </font><font color="#990000">0 </font><font color="#000000">)</font><br>


<font color="#000000">print d</font></code></div></h1><br><br><div class="gmail_quote">On Mon, Feb 1, 2010 at 3:44 PM,  <span dir="ltr"><<a href="mailto:python-list-request@python.org">python-list-request@python.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div style="font-size: 12px; color: rgb(153, 153, 153); font-family: 'Lucida Grande',Helvetica,Arial,sans-serif;">

Junk Score: 2 out of 10 (below <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/mail-screening" target="_blank">your Auto Allow threshold</a>)
| <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1488077305_3972850" target="_blank">Approve sender</a> | <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1488077305_3972850&disp=b" target="_blank">Block sender</a> | <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1488077305_3972850&disp=b&dom" target="_blank">Block domain</a>


  
  <img src="" style="margin-left: 5px;" width="10"><img src=""><br>
</div><br>Send Python-list mailing list submissions to<br>
        <a href="mailto:python-list@python.org">python-list@python.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:python-list-request@python.org">python-list-request@python.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:python-list-owner@python.org">python-list-owner@python.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Python-list digest..."<br>
<br>Today's Topics:<br>
<br>
   1. Re: whassup? builtins? python3000? Naah can't be right?<br>
      (Andrej Mitrovic)<br>
   2. gmtime (gazza)<br>
   3. Re: A performance issue when using default value (keakon)<br>
   4. Re: HTML Parser which allows low-keyed local changes?<br>
      (Stefan Behnel)<br>
   5. how long a Str can be used in this python code segment?<br>
      (Stephen.Wu)<br>
   6. Re: gmtime (Gary Herron)<br>
   7. Re: how long a Str can be used in this python code segment?<br>
      (Chris Rebert)<br>
   8. Re: how long a Str can be used in this python code segment?<br>
      (Gary Herron)<br>
   9. Re: Keyboard input (Dennis Lee Bieber)<br>
  10. Re: how long a Str can be used in this python code segment?<br>
      (Stephen.Wu)<br>
  11. Re: how long a Str can be used in this python code segment?<br>
      (Stefan Behnel)<br>
  12. Re: PEP 3147 - new .pyc format (Daniel Fetchinson)<br>
<br><br>---------- Forwarded message ----------<br>From: Andrej Mitrovic <<a href="mailto:andrej.mitrovich@gmail.com">andrej.mitrovich@gmail.com</a>><br>To: <br>Date: Sun, 31 Jan 2010 20:01:57 -0800 (PST)<br>Subject: Re: whassup? builtins? python3000? Naah can't be right?<br>

Hey, it's really simple! Just like the excerpt from the Learning<br>
Python book says:<br>
<br>
"Really, the built-in scope is just a built-in module called builtins,<br>
but<br>
you have to import builtins to query built-ins because the name<br>
builtins is not itself<br>
built-in...."<br>
<br>
:)<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: gazza <<a href="mailto:burslem2001@yahoo.com">burslem2001@yahoo.com</a>><br>To: <br>Date: Sun, 31 Jan 2010 13:27:46 -0800 (PST)<br>Subject: gmtime<br>Hi,<br>


<br>
I am trying to discover how to obtain the correct time of say CST/<br>
America and EST/America in python?<br>
<br>
Any help on this would be appreciated.<br>
<br>
<br>
Thanks,<br>
Garyc<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: keakon <<a href="mailto:keakon@gmail.com">keakon@gmail.com</a>><br>To: <br>Date: Sun, 31 Jan 2010 21:20:28 -0800 (PST)<br>Subject: Re: A performance issue when using default value<br>

Even this style is 41 times faster than h2():<br>
<br>
def i2(x=[]):<br>
  y = x<br>
  if not y: # add this line<br>
    y = []  # add this line<br>
  y.append(1)<br>
  return y + []<br>
<br>
print Timer('i2()','from __main__ import f2, g2, h2, i2').timeit<br>
(TIMES)<br>
<br>
Time: 0.00742356919664<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Stefan Behnel <<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>><br>To: <br>Date: Mon, 01 Feb 2010 09:34:28 +0100<br>Subject: Re: HTML Parser which allows low-keyed local changes?<br>

Robert, 31.01.2010 20:57:<br>
> I tried lxml, but after walking and making changes in the element tree,<br>
> I'm forced to do a full serialization of the whole document<br>
> (etree.tostring(tree)) - which destroys the "human edited" format of the<br>
> original HTML code. makes it rather unreadable.<br>
<br>
What do you mean? Could you give an example? lxml certainly does not<br>
destroy anything it parsed, unless you tell it to do so.<br>
<br>
Stefan<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: "Stephen.Wu" <<a href="mailto:54wutong@gmail.com">54wutong@gmail.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>

Date: Mon, 1 Feb 2010 01:17:09 -0800 (PST)<br>Subject: how long a Str can be used in this python code segment?<br>tmp=file.read() (very huge file)<br>
if targetStr in tmp:<br>
    print "find it"<br>
else:<br>
    print "not find"<br>
file.close()<br>
<br>
I checked if file.read() is huge to some extend, it doesn't work, but<br>
could any give me some certain information on this prolbem?<br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Gary Herron <<a href="mailto:gherron@islandtraining.com">gherron@islandtraining.com</a>><br>To: "<a href="mailto:python-list@python.org">python-list@python.org</a>" <<a href="mailto:python-list@python.org">python-list@python.org</a>><br>

Date: Mon, 01 Feb 2010 01:23:31 -0800<br>Subject: Re: gmtime<br>gazza wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I am trying to discover how to obtain the correct time of say CST/<br>
America and EST/America in python?<br>
<br>
Any help on this would be appreciated.<br>
<br>
<br>
Thanks,<br>
Garyc<br>
  <br>
</blockquote>
The datetime module should give you all you need.<br>
<br>
Gary Herron<br>
<br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Chris Rebert <<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>><br>To: "Stephen.Wu" <<a href="mailto:54wutong@gmail.com">54wutong@gmail.com</a>><br>

Date: Mon, 1 Feb 2010 01:26:55 -0800<br>Subject: Re: how long a Str can be used in this python code segment?<br>On Mon, Feb 1, 2010 at 1:17 AM, Stephen.Wu <<a href="mailto:54wutong@gmail.com">54wutong@gmail.com</a>> wrote:<br>


> tmp=file.read() (very huge file)<br>
> if targetStr in tmp:<br>
>    print "find it"<br>
> else:<br>
>    print "not find"<br>
> file.close()<br>
><br>
> I checked if file.read() is huge to some extend, it doesn't work, but<br>
> could any give me some certain information on this prolbem?<br>
<br>
If the file's contents is larger than available memory, you'll get a<br>
MemoryError. To avoid this, you can read the file in by chunks (or if<br>
applicable, by lines) and see if each chunk/line matches.<br>
<br>
Cheers,<br>
Chris<br>
--<br>
<a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Gary Herron <<a href="mailto:gherron@islandtraining.com">gherron@islandtraining.com</a>><br>To: <br>Date: Mon, 01 Feb 2010 01:29:20 -0800<br>Subject: Re: how long a Str can be used in this python code segment?<br>

Stephen.Wu wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
tmp=file.read() (very huge file)<br>
if targetStr in tmp:<br>
    print "find it"<br>
else:<br>
    print "not find"<br>
file.close()<br>
<br>
I checked if file.read() is huge to some extend, it doesn't work, but<br>
could any give me some certain information on this prolbem?<br>
<br>
  <br>
</blockquote>
<br>
Python has no specific limit on string size other than memory size and perhaps 32 bit address space and so on.  However, if your file size is even a fraction of that size, you should not attempt to read it all into memory at once.  Is there not a way to process your file in batches of a reasonable size?<br>


<br>
Gary Herron<br>
<br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Dennis Lee Bieber <<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>

Date: Mon, 01 Feb 2010 01:31:25 -0800<br>Subject: Re: Keyboard input<br>On 31 Jan 2010 22:40:55 GMT, Steven D'Aprano<br>
<<a href="mailto:steve@REMOVE-THIS-cybersource.com.au">steve@REMOVE-THIS-cybersource.com.au</a>> declaimed the following in<br>
gmane.comp.python.general:<br>
<br>
> On Sun, 31 Jan 2010 14:10:34 -0800, Dennis Lee Bieber wrote:<br>
><br>
> > On Sun, 31 Jan 2010 11:51:46 +0000, "Mr.SpOOn" <<a href="mailto:mr.spoon21@gmail.com">mr.spoon21@gmail.com</a>><br>
> > declaimed the following in gmane.comp.python.general:<br>
> ><br>
> >> 2010/1/29 Gabriel Genellina <<a href="mailto:gagsl-py2@yahoo.com.ar">gagsl-py2@yahoo.com.ar</a>>:<br>
> >> ><br>
> >> > That's strange. If you're using Linux, make sure you have the<br>
> >> > readline package installed.<br>
> >><br>
> >> I'm using Linux. Ubuntu. I checked on synaptic and I have<br>
> >> readline-common. Do you mean something else?<br>
> >><br>
> >     But was your Python /built/ using readline?<br>
><br>
><br>
> How do you ensure that it is?<br>
<br>
        Well... I think the practice on the Linux variants is to set various<br>
options when building Python locally. I'm on WinXP and rely upon the<br>
packagers to build with everything available <G> (and may need to check<br>
the documentation of those builds as described by the packagers)<br>
<br>
        It may mean ensuring not only that the runtime library is present,<br>
but that the development library (C-language header files, etc.) are<br>
installed.<br>
--<br>
        Wulfraed         Dennis Lee Bieber               KD6MOG<br>
        <a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>   <a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: "Stephen.Wu" <<a href="mailto:54wutong@gmail.com">54wutong@gmail.com</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>

Date: Mon, 1 Feb 2010 01:33:09 -0800 (PST)<br>Subject: Re: how long a Str can be used in this python code segment?<br>On Feb 1, 5:26 pm, Chris Rebert <<a href="mailto:c...@rebertia.com">c...@rebertia.com</a>> wrote:<br>


> On Mon, Feb 1, 2010 at 1:17 AM, Stephen.Wu <<a href="mailto:54wut...@gmail.com">54wut...@gmail.com</a>> wrote:<br>
> > tmp=file.read() (very huge file)<br>
> > if targetStr in tmp:<br>
> >    print "find it"<br>
> > else:<br>
> >    print "not find"<br>
> > file.close()<br>
><br>
> > I checked if file.read() is huge to some extend, it doesn't work, but<br>
> > could any give me some certain information on this prolbem?<br>
><br>
> If the file's contents is larger than available memory, you'll get a<br>
> MemoryError. To avoid this, you can read the file in by chunks (or if<br>
> applicable, by lines) and see if each chunk/line matches.<br>
><br>
> Cheers,<br>
> Chris<br>
> --<a href="http://blog.rebertia.com" target="_blank">http://blog.rebertia.com</a><br>
<br>
actually, I just use file.read(length) way, i just want to know what<br>
exactly para of length I should set, I'm afraid length doesn't equal<br>
to the amount of physical memory after trials...<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Stefan Behnel <<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>><br>To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Mon, 01 Feb 2010 10:45:28 +0100<br>

Subject: Re: how long a Str can be used in this python code segment?<br>Stephen.Wu, 01.02.2010 10:17:<br>
> tmp=file.read() (very huge file)<br>
> if targetStr in tmp:<br>
>     print "find it"<br>
> else:<br>
>     print "not find"<br>
> file.close()<br>
><br>
> I checked if file.read() is huge to some extend, it doesn't work, but<br>
> could any give me some certain information on this prolbem?<br>
<br>
Others have already pointed out that reading the entire file into memory is<br>
not a good idea. Try reading chunks repeatedly instead.<br>
<br>
As it appears that you simply try to find out if a file contains a specific<br>
byte sequence, you might find acora interesting:<br>
<br>
<a href="http://pypi.python.org/pypi/acora" target="_blank">http://pypi.python.org/pypi/acora</a><br>
<br>
Also note that there are usually platform optimised tools available to<br>
search content in files, e.g. grep. It's basically impossible to beat their<br>
raw speed even with hand-tuned Python code, so running the right tool using<br>
the subprocess module might be a solution.<br>
<br>
Stefan<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Daniel Fetchinson <<a href="mailto:fetchinson@googlemail.com">fetchinson@googlemail.com</a>><br>To: Python <<a href="mailto:python-list@python.org">python-list@python.org</a>><br>

Date: Mon, 1 Feb 2010 11:14:42 +0100<br>Subject: Re: PEP 3147 - new .pyc format<br>> PEP 3147 has just been posted, proposing that, beginning in release<br>
> 3.2 (and possibly 2.7) compiled .pyc and .pyo files be placed in a<br>
> directory with a .pyr extension. The reason is so that compiled<br>
> versions of a program can coexist, which isn't possible now.<br>
><br>
> Frankly, I think this is a really good idea, although I've got a few<br>
> comments.<br>
><br>
> 1. Apple's MAC OS X should be mentioned, since 10.5 (and presumably<br>
> 10.6) ship with both Python release 2.3 and 2.5 installed.<br>
><br>
> 2. I think the proposed logic is too complex. If this is installed in<br>
> 3.2, then that release should simply store its .pyc file in the .pyr<br>
> directory, without the need for either a command line switch or an<br>
> environment variable (both are mentioned in the PEP.)<br>
><br>
> 3. Tool support. There are tools that look for the .pyc files; these<br>
> need to be upgraded somehow. The ones that ship with Python should, of<br>
> course, be fixed with the PEP, but there are others.<br>
><br>
> 4. I'm in favor of putting the source in the .pyr directory as well,<br>
> but that's got a couple more issues. One is tool support, which is<br>
> likely to be worse for source, and the other is some kind of algorithm<br>
> for identifying which source goes with which object.<br>
<br>
I also think the PEP is a great idea and proposes a solution to a real<br>
problem. But I also hear the 'directory clutter' argument and I'm<br>
really concerned too, having all these extra directories around (and<br>
quite a large number of them indeed!). How about this scheme:<br>
<br>
1. install python source files to a shared (among python<br>
installations) location /this/is/shared<br>
2. when python X.Y imports a source file from /this/is/shared it will<br>
create pyc files in its private area /usr/lib/pythonX.Y/site-packages/<br>
Time comparison would be between /this/is/shared/x.py and<br>
/usr/lib/pythonX.Y/site-packages/x.pyc, for instance.<br>
<br>
Obviously pythonX.Y needs to know the path to /this/is/shared so it<br>
can import modules from there, but this can be controlled by an<br>
environment variable. There would be only .py files in<br>
/this/is/shared.<br>
<br>
Linux distro packagers would only offer a single python-myapp to<br>
install and it would only contain python source, and the<br>
version-specific pyc files would be created the first time the<br>
application is used by python. In /usr/lib/pythonX.Y/site-packages<br>
there would be only pyc files with magic number matching python X.Y.<br>
<br>
So, basically nothing would change only the location of py and pyc<br>
files would be different from current behavior, but the same algorithm<br>
would be run to determine which one to load, when to create a pyc<br>
file, when to ignore the old one, etc.<br>
<br>
What would be wrong with this setup?<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<br>
--<br>
Psss, psss, put it down! - <a href="http://www.cafepress.com/putitdown" target="_blank">http://www.cafepress.com/putitdown</a><br>
<br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br></div>