Re: Doubt in line_profiler documentation
Abhiram R writes: [...] > https://github.com/rkern/line_profiler > > The definition for the time column says - > > "Time: The total amount of time spent executing the line in the timer's > units. In the header information before the tables, you will see a line > 'Timer unit:' giving the conversion factor to seconds. It may be different > on different systems." > For example, if the timer unit is :* 3.20802e-07 s* > and a particular instruction's time column says its value is 83.0, is the > time taken 83.0*3.20802e-07 s? Or is there more to it? That's it. > If my understanding is correct however, why would there be a need for > this? What could be the cause of this - " It may be different on > different systems "? Time is a complicated thing on a computer, and is only measured with a certain precision (or "resolution"). This precision may vary from system to system. It is customary to mention the resolution when profiling, because the resolution is usually coarse wrt processor frequency (typically 1 microsecond, around 3000 processor cycles at 3Ghz). So profiling very short running pieces of code is highly inaccurate. You can look at the code used in rkern, at https://github.com/rkern/line_profiler/blob/master/timers.c You'll see that on Windows it uses QueryPerformanceCounter() [*] and QueryPerformanceFrequency(). On Unix it uses gettimeofday(), which has a fixed/conventional resolution. By the way, the use of gettimeofday() is strange since this function is now deprecated... clock_gettime() should be used instead. It has an associated clock_getres() as well. -- Alain. [*] WTF is wrong with these microsoft developpers? Clocks and performance counters are totally different things. what's the need for confusing terms in the API? -- https://mail.python.org/mailman/listinfo/python-list
error from Popen only when run from cron
I have a script that does this: subprocess.Popen(['service', 'some_service', 'status'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) When I run it from the command line it works fine. When I run it from cron I get: subprocess.Popen(['service', 'some_service', 'status'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory Anyone have any clue as to what file it's complaining about? Or how I can debug this further? -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
On Sun, Jan 28, 2018 at 2:58 AM, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > > Anyone have any clue as to what file it's complaining about? Or how I > can debug this further? Looks like you're trying to invoke a process without a full path? It could be because cron jobs execute in a restricted environment. Two things to try: 1) Dump out os.environ to a file somewhere (maybe in /tmp if you don't have write permission). See if $PATH is set to some really short value, or at least to something different from what you see when you run it outside of cron. 2) Replace the word "service" with whatever you get from running "which service" on your system. On mine, it's "/usr/sbin/service". See what that does. Might not solve your problem, but it's worth a try. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
On 2018-01-27, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > > Anyone have any clue as to what file it's complaining about? Or how I > can debug this further? Try using the complete path of the executable. Cron jobs run with a pretty limited set of environment variables and may not have the PATH value you expect. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
If you have your script set $PATH and $HOME, you can test it with: env - ./my-script The difference between running a script from the command line, and running a script from cron, is often environment variables. env - clears the environment. On Sat, Jan 27, 2018 at 7:58 AM, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > > Anyone have any clue as to what file it's complaining about? Or how I > can debug this further? > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
On Sat, Jan 27, 2018 at 11:09 AM, Chris Angelico wrote: > On Sun, Jan 28, 2018 at 2:58 AM, Larry Martell > wrote: >> I have a script that does this: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> >> When I run it from the command line it works fine. When I run it from >> cron I get: >> >> subprocess.Popen(['service', 'some_service', 'status'], >> stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >> File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ >> errread, errwrite) >> File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child >> raise child_exception >> OSError: [Errno 2] No such file or directory >> >> Anyone have any clue as to what file it's complaining about? Or how I >> can debug this further? > > Looks like you're trying to invoke a process without a full path? It > could be because cron jobs execute in a restricted environment. Two > things to try: > > 1) Dump out os.environ to a file somewhere (maybe in /tmp if you don't > have write permission). See if $PATH is set to some really short > value, or at least to something different from what you see when you > run it outside of cron. > > 2) Replace the word "service" with whatever you get from running > "which service" on your system. On mine, it's "/usr/sbin/service". See > what that does. > > Might not solve your problem, but it's worth a try. Thanks! Using the full path fixed the issue. -- https://mail.python.org/mailman/listinfo/python-list
Re: error from Popen only when run from cron
On Sat, 27 Jan 2018 10:58:36 -0500, Larry Martell wrote: > I have a script that does this: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > > When I run it from the command line it works fine. When I run it from > cron I get: > > subprocess.Popen(['service', 'some_service', 'status'], > stdout=subprocess.PIPE, stderr=subprocess.STDOUT) > File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ > errread, errwrite) > File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory > > Anyone have any clue as to what file it's complaining about? Or how I > can debug this further? Cron provides this as $PATH: /usr/bin;/usr/sbin >From within a terminal enter: whereis service If service is not in Cron's $PATH, that is your problem. Adding the complete path to 'service' in the script should fix things. If service is in Cron's $PATH, I have no further ideas. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Data-structure for multiway associativity in Python
I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python. [c1, c2,..., cn] is a list of strings (for my own implementation, but could be any other type for the generic problem). There will be many hundreds, if not thousands, of such lists with no shared member. The method getAssocList(e) will return lists of the lists for which e is an element. Here a hash may be a way to go, but need help in figuring it out. Also, can there be a faster and more memory efficient solution other than hashes? -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Text Strip() now working constantly.
Hi Python Group,
I am not sure if I am doing this correctly however, I believe I found a bug
that involves the striping of a text string.
I have attached a JPG that clearly illustrate the issue.
I am currently using 2.7.13
In short:
Given a string.
'cm_text.data'
if you try and strip '.data'
the return string will be
'cm_tex'
which drops the last 't'
however, given other text.
'om_ol.data'
the same strip '.data' will return
'om_ol' which is correct!
As for a work around right now I am doing the following.
string_abc = 'some_text.data'
string_next = string_abc.strip('data')
string_final = string_next.strip('.')
Please see the JPG.
Sorry if this has been filed before, if I have filed this incorrectly could
you please provide me a better avenue for future reference.
Regards,
-George J Shen
--
https://mail.python.org/mailman/listinfo/python-list
Re:Please Help
np.uint8 is unsigned int, range 0~255 >>> np.uint8(256) 0 At 2018-01-27 12:33:22, "" wrote: >import numpy as np >x=np.unit8([250) >print(x) >y=np.unit8([10]) >print(y) >z=x+y >print(z) > > >output > >[250] >[10] >[4] > >My question how is z [4] >-- >https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Text Strip() now working constantly.
On Sun, Jan 28, 2018 at 4:25 AM, George Shen wrote: > Hi Python Group, > > I am not sure if I am doing this correctly however, I believe I found a bug > that involves the striping of a text string. If you're implying that it's a bug in Python, no it isn't. If you're trying to understand the bug in your own code, you've come to the right place :) > I have attached a JPG that clearly illustrate the issue. Attachments aren't carried on this list; text is better anyway. > I am currently using 2.7.13 > > In short: > Given a string. > 'cm_text.data' > if you try and strip '.data' > the return string will be > 'cm_tex' Correct. In fact, the strip function does not remove a substring; it removes a set of characters. It's most commonly used for removing any whitespace from the ends of a string. It faithfully removed every ".", "d", "a", and "t" from your string - including the one at the end of "text". If you know for sure that the name WILL end with ".data", you can simply ask Python to remove the last five characters: >>> 'cm_text.data'[:-5] 'cm_text' That may better suit what you're doing. By the way, you may wish to consider migrating to Python 3, as Python 2.7 is a decade old and not getting any further enhancements. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Data-structure for multiway associativity in Python
It's possible, but not common, to do association lists in Python.
They're pretty inefficient in just about any language.
I'm not totally clear on what you need, but it might be a good thing
to do a list of sets - if you're looking for an in-memory solution.
On Sat, Jan 27, 2018 at 10:33 AM, Dennis Lee Bieber
wrote:
> On Sat, 27 Jan 2018 10:01:47 -0800 (PST), qrious
> declaimed the following:
>
>>
>>
>>I need a data structure and a corresponding (hopefully fast) mechanism
>>associated with it to do the following. While I am looking for the concept
>>first, my preference for implementation of this will be in Python.
>>
>>[c1, c2,..., cn] is a list of strings (for my own implementation, but could
>>be any other type for the generic problem). There will be many hundreds, if
>>not thousands, of such lists with no shared member.
>>
>>The method getAssocList(e) will return lists of the lists for which e is an
>>element.
>>
>>Here a hash may be a way to go, but need help in figuring it out. Also, can
>>there be a faster and more memory efficient solution other than hashes?
>
>
> Don't know about speed or memory but...
>
> SQLite3 (*n* is primary key/auto increment; _n_ is foreign key)
>
> LoL(*ID*, description)
>
> anL(*ID*, _LoL_ID_, cx)
>
> select LoL.description, anL.cx from LoL
> inner join anL on anL.LoL_ID = LoL.ID
> where anL.cx like "%e%"
>
> {note: using like and wildcards means e is anywhere in the cx field;
> otherwise just use
>
> anL.cx = "e"
> }
> --
> Wulfraed Dennis Lee Bieber AF6VN
> [email protected]://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: Text Strip() now working constantly.
Hi, I'm a begginer in Python, i have a question...
can we use replace method to do it.
E.g. a='cm_text.data'
a.replace('.data', ''), this will return output as 'cm_text'.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Data-structure for multiway associativity in Python
On 2018-01-27 18:01, qrious wrote: I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python. [c1, c2,..., cn] is a list of strings (for my own implementation, but could be any other type for the generic problem). There will be many hundreds, if not thousands, of such lists with no shared member. The method getAssocList(e) will return lists of the lists for which e is an element. Here a hash may be a way to go, but need help in figuring it out. Also, can there be a faster and more memory efficient solution other than hashes? You could build a dict where the key is the element and the value is a list of those lists that contain that element. The 'defaultdict' class is useful for that. from collections import defaultdict assoc_dict = defaultdict(list) for lst in list_of_lists: for elem in lst: assoc_dict[elem].append(lst) # Optionally convert to a plain dict once it's built. assoc_dict = dict(assoc_dict) -- https://mail.python.org/mailman/listinfo/python-list
Re: Text Strip() now working constantly.
On Sun, Jan 28, 2018 at 5:46 AM, wrote:
> Hi, I'm a begginer in Python, i have a question...
>
> can we use replace method to do it.
>
> E.g. a='cm_text.data'
> a.replace('.data', ''), this will return output as 'cm_text'.
Yep! That works too. Be aware, though, that it might replace ".data"
in the middle of the string, too. If you know for sure that that won't
happen, then go for it!
BTW, when you reply to someone else's message, it's best to include a
bit of the original text and then type your reply below it - like I do
in this message. That way, people get enough context to understand
what's going on.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Please help on print string that contains 'tab' and 'newline'
HI I am a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like it print as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
HI I have a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like to print it as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet How can I do this in python print ? Thanks On Sat, Jan 27, 2018 at 3:15 PM, Jason Qian wrote: > HI > >I am a string that contains \r\n\t > >[Ljava.lang.Object; does not exist*\r\n\t*at > com.livecluster.core.tasklet > > >I would like it print as : > > [Ljava.lang.Object; does not exist > tat com.livecluster.core.tasklet > > > -- https://mail.python.org/mailman/listinfo/python-list
How to embed a native JIT compiler to a django app?
Hi, I want to compile a Django application into a C source file and embed a JIT compiler into the binary. Is there any way of doing this with llvm/clang? Regards, Etienne -- Etienne Robillard [email protected] https://www.isotopesoftware.ca/ -- https://mail.python.org/mailman/listinfo/python-list
Welcome the 3.8 and 3.9 Release Manager - Łukasz Langa!
As Ned just announced, Python 3.7 is very soon to enter beta 1 and thus feature freeze. I think we can all give Ned a huge round of applause for his amazing work as Release Manager for Python 3.6 and 3.7. Let’s also give him all the support he needs to make 3.7 the best version yet. As is tradition, Python release managers serve for two consecutive releases, and so with the 3.7 release branch about to be made, it’s time to announce our release manager for Python 3.8 and 3.9. By unanimous and enthusiastic consent from the Python Secret Underground (PSU, which emphatically does not exist), the Python Cabal of Former and Current Release Managers, Cardinal Ximénez, and of course the BDFL, please welcome your next release manager… Łukasz Langa! And also, happy 24th anniversary to Guido’s Python 1.0.0 announcement[1]. It’s been a fun and incredible ride, and I firmly believe that Python’s best days are ahead of us. Enjoy, -Barry [1] https://groups.google.com/forum/?hl=en#!original/comp.lang.misc/_QUzdEGFwCo/KIFdu0-Dv7sJ signature.asc Description: Message signed with OpenPGP -- https://mail.python.org/mailman/listinfo/python-list
Sentiment analysis using sklearn
I am attempting to understand how scikit learn works for sentiment analysis and came across this blog post: https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn The corresponding code is at this location: https://gist.github.com/bonzanini/c9248a239bbab0e0d42e My question is while trying to predict, why does the curr_class in Line 44 of the code need a classification (pos or neg) for the test data? After all, am I not trying to predict it? Without any initial value of curr_class, the program has a run time error. Any help will be greatly appreciated. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
On 1/27/18 3:15 PM, Jason Qian via Python-list wrote: HI I am a string that contains \r\n\t [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet I would like it print as : [Ljava.lang.Object; does not exist tat com.livecluster.core.tasklet It looks like you are doing something that is a little bit, and perhaps a lot, more complicated than printing a string. Can you share the code that is trying to produce that output? --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
On 1/27/2018 3:15 PM, Jason Qian via Python-list wrote:
HI
I am a string that contains \r\n\t
[Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet
I would like it print as :
[Ljava.lang.Object; does not exist
tat com.livecluster.core.tasklet
Your output does not match the input. Don't add, or else remove, the *s
if you don't want to see them. Having '\t' print as ' t' makes no sense.
In IDLE
>>> print('[Ljava.lang.Object; does not exist*\r\n\t*at
com.livecluster.core.tasklet')
[Ljava.lang.Object; does not exist*
*at com.livecluster.core.tasklet
IDLE ignores \r, other display mechanisms may not. You generally should
not use it.
Pasting the text, with the literal newline embedded, does not work in
Windows interactive interpreter, so not testing this there.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list
Re: Sentiment analysis using sklearn
On 1/27/2018 4:05 PM, qrious wrote: I am attempting to understand how scikit learn works for sentiment analysis and came across this blog post: https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn The corresponding code is at this location: https://gist.github.com/bonzanini/c9248a239bbab0e0d42e My question is while trying to predict, why does the curr_class in Line 44 of the code need a classification (pos or neg) for the test data? After all, am I not trying to predict it? Without any initial value of curr_class, the program has a run time error. In order for the 'bot' to classify new samples, by learning the difference between positive and negative samples, it needs to be trained on existing samples that are 'correctly' classified. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Sentiment analysis using sklearn
On Sat, Jan 27, 2018 at 1:05 PM, qrious wrote: > I am attempting to understand how scikit learn works for sentiment analysis > and came across this blog post: > > https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn > > The corresponding code is at this location: > > https://gist.github.com/bonzanini/c9248a239bbab0e0d42e > > My question is while trying to predict, why does the curr_class in Line 44 of > the code need a classification (pos or neg) for the test data? After all, am > I not trying to predict it? Without any initial value of curr_class, the > program has a run time error. I'm a real neophyte when it comes to modern AI, but I believe the intent is to divide your inputs into "training data" and "test data" and "real world data". So you create your models using training data including correct classifications as part of the input. And you check how well your models are doing on inputs they haven't seen before with test data, which also is classified in advance, to verify how well things are working. And then you use real world, as-yet-unclassified data in production, after you've selected your best model, to derive a classification from what your model has seen in the past. So both the training data and test data need accurate labels in advance, but the real world data trusts the model to do pretty well without further labeling. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
Thanks for taking look this.
1. Python pass a function to c side as callback, and print out the message.
def handleError(message, code):
print('** handleError **')
* print('exception ' + str(message))*
2. On c side : send stack trace back to python by calling the callback
function
Callback::Callback(InvocationER rcb)
:
_rcb(rcb)
{
}
void Callback::handleError(Exception &e, int taskId) {
*(_rcb)((char*)e.getStackTrace().c_str(), taskId);*
}
So, the source of the string is std::string. On the python side is byte
array.
Ljava.lang.Object; does not exist*\r\n\t*at com
Thanks
On Sat, Jan 27, 2018 at 4:20 PM, Ned Batchelder
wrote:
> On 1/27/18 3:15 PM, Jason Qian via Python-list wrote:
>
>> HI
>>
>> I am a string that contains \r\n\t
>>
>> [Ljava.lang.Object; does not exist*\r\n\t*at
>> com.livecluster.core.tasklet
>>
>>
>> I would like it print as :
>>
>> [Ljava.lang.Object; does not exist
>>tat com.livecluster.core.tasklet
>>
>
> It looks like you are doing something that is a little bit, and perhaps a
> lot, more complicated than printing a string. Can you share the code that
> is trying to produce that output?
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
Thanks for taking look this.
The source of the string is std::string from our c code as callback .
On the python side is shows as bytes.
Is there way we can reformat the string that replace \r\n with newline, so
python can correctly print it ?
Thanks
On Sat, Jan 27, 2018 at 5:39 PM, Terry Reedy wrote:
> On 1/27/2018 3:15 PM, Jason Qian via Python-list wrote:
>
>> HI
>>
>> I am a string that contains \r\n\t
>>
>> [Ljava.lang.Object; does not exist*\r\n\t*at
>> com.livecluster.core.tasklet
>>
>>
>> I would like it print as :
>>
>> [Ljava.lang.Object; does not exist
>>tat com.livecluster.core.tasklet
>>
>
> Your output does not match the input. Don't add, or else remove, the *s
> if you don't want to see them. Having '\t' print as ' t' makes no sense.
>
> In IDLE
>
> >>> print('[Ljava.lang.Object; does not exist*\r\n\t*at
> com.livecluster.core.tasklet')
> [Ljava.lang.Object; does not exist*
> *at com.livecluster.core.tasklet
>
> IDLE ignores \r, other display mechanisms may not. You generally should
> not use it.
>
> Pasting the text, with the literal newline embedded, does not work in
> Windows interactive interpreter, so not testing this there.
>
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
there are 0D 0A 09 %c %d 116 *%c %d 13%c %d 10%c %d 9* %c %d 97 On Sat, Jan 27, 2018 at 9:05 PM, Dennis Lee Bieber wrote: > On Sat, 27 Jan 2018 20:33:58 -0500, Jason Qian via Python-list > declaimed the following: > > > Ljava.lang.Object; does not exist*\r\n\t*at com > > > > Does that source contain > > 0x0d 0x0a 0x09 > > > or is it really > > 0x5c 0x72 0x5c 0x61 0x5c 0x74 > \r\n\t > > as individual characters? > > > >>> bks = chr(0x5c) > >>> ar = "r" > >>> en = "n" > >>> te = "t" > >>> > >>> strn = "".join([bks, ar, bks, en, bks, te]) > >>> strn > '\\r\\n\\t' > >>> print strn > \r\n\t > >>> cstr = "\r\n\t" > >>> cstr > '\r\n\t' > >>> print cstr > > > >>> > > -- > Wulfraed Dennis Lee Bieber AF6VN > [email protected]://wlfraed.home.netcom.com/ > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Sending Email using examples From Tutorials
I am having difficulty getting the python script to send an email to work. Here is the code I use from among a number of other examples which I used. The only changes I made were the email addresses, so I can see the result if it works. If you have any suggestions, please email your reply also to [email protected]. Python Script used: import smtplib server = smtplib.SMTP('localhost') server.sendmail('[email protected]', """To: [email protected] From: [email protected] Beware the Ides of March. """) server.quit() when running this I get the following message. Please help: Traceback (most recent call last): File "D:\ProgramDev\PythonDev\sendemail.py", line 3, in server = smtplib.SMTP('localhost') File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 251, in __init__ (code, msg) = self.connect(host, port) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 335, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 306, in _get_socket self.source_address) File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 722, in create_connection raise err File "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it -- https://mail.python.org/mailman/listinfo/python-list
Re: Sending Email using examples From Tutorials
>
> import smtplib
> server = smtplib.SMTP('localhost')
> server.sendmail('[email protected]',
> """To: [email protected]
> From: [email protected]
>
> Beware the Ides of March.
> """)
> server.quit()
>
> when running this I get the following message. Please help:
>
> Traceback (most recent call last):
> File "D:\ProgramDev\PythonDev\sendemail.py", line 3, in
> server = smtplib.SMTP('localhost')
> File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py",
> line 251, in __init__
> (code, msg) = self.connect(host, port)
> File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py",
> line 335, in connect
> self.sock = self._get_socket(host, port, self.timeout)
> File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py",
> line 306, in _get_socket
> self.source_address)
> File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py",
> line 722, in create_connection
> raise err
> File
> "C:\Users\Admin\AppData\Local\Programs\Python\Python36-32\lib\socket.py",
> line 713, in create_connection
> sock.connect(sa)
> ConnectionRefusedError: [WinError 10061] No connection could be made
> because the target machine actively refused it
Your code is fine, but to send mail you need a SMTP server that accepts
connections. With:
server = smtplib.SMTP('localhost')
your code is saying that you have an SMTP server listening on your
localhost. I don't think you do.
--
https://mail.python.org/mailman/listinfo/python-list
Compression of random binary data
If it is then show him this 387,420,489 = 00110011 00111000 00110111 00101100 00110100 00110010 0011 00101100 00110100 00111000 00111001 9^9 = ⬇️ (^ = to the power of) = 387,420,489 But 9^9 = 00111001 0100 00111001 -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
On Sun, Jan 28, 2018 at 4:26 PM, wrote: > If it is then show him this > > 387,420,489 > = > 00110011 00111000 00110111 00101100 00110100 00110010 0011 00101100 > 00110100 00111000 00111001 > > 9^9 = ⬇️ (^ = to the power of) > = 387,420,489 > > But > > 9^9 > = > 00111001 0100 00111001 I have no idea what you're responding to or how this has anything to do with the thread you're replying to, but I would advise you to look into the difference between exponentiation and exclusive-or. Even so, I don't know what result you got. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data
387,420,489 is a number with only 2 repeating binary sequences In binary 387,420,489 is expressed as 00110011 00111000 00110111 00101100 00110100 00110010 0011 00101100 00110100 00111000 00111001 387,420,489 can be simplified to 9*9 or nine to the power of nine In binary 9*9 is represented by 00111001 00101010 00111001 9*9 and 387,420,489 are the same thing they are both a representation of numbers or data, yet in binary 9*9 is 64 bits shorter than 387,420,489 Not a solution just help. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data (Posting On Python-List Prohibited)
I have it in my head, just need someone to write the program for me, I know nothing about data compression or binary data other than 1s and 0s and that you can not take 2 number without a possible value more or less than them selves and compress them, I have been working for 1 1/2 years on a solution, just need help with programming. If someone could get ahold of me when I am sober I could probably explain it a lot better, but I said fuck it I’ll show everyone a possibility instead of trying to do it on my own. -- https://mail.python.org/mailman/listinfo/python-list
Re: Compression of random binary data (Posting On Python-List Prohibited)
Lawrence D’Oliveiro In other words yes, I just need to be sober first. -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
In python 3. X Use. Decode and. Encode On 28 Jan 2018 1:47 am, "Jason Qian via Python-list" wrote: > HI > >I am a string that contains \r\n\t > >[Ljava.lang.Object; does not exist*\r\n\t*at > com.livecluster.core.tasklet > > >I would like it print as : > > [Ljava.lang.Object; does not exist > tat com.livecluster.core.tasklet > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help on print string that contains 'tab' and 'newline'
On Saturday, January 27, 2018 at 8:16:58 PM UTC, Jason Qian wrote:
> HI
>
>I am a string that contains \r\n\t
>
>[Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet
>
>I would like it print as :
>
> [Ljava.lang.Object; does not exist
> tat com.livecluster.core.tasklet
Unless I've missed something just call print on the string.
>>> print('[Ljava.lang.Object; does not exist*\r\n\t*at
>>> com.livecluster.core.tasklet')
[Ljava.lang.Object; does not exist*
*at com.livecluster.core.tasklet
--
Kindest regards.
Mark Lawrence.
--
https://mail.python.org/mailman/listinfo/python-list
Re: [python-committers] Welcome the 3.8 and 3.9 Release Manager - Łukasz Langa!
On Sat, Jan 27, 2018 at 2:02 PM, Barry Warsaw wrote: > please welcome your next release manager… > > Łukasz Langa! Congrats, Łukasz! (or condolences? ) -eric -- https://mail.python.org/mailman/listinfo/python-list
Re: Sentiment analysis using sklearn
On Saturday, January 27, 2018 at 2:45:30 PM UTC-8, Terry Reedy wrote: > On 1/27/2018 4:05 PM, qrious wrote: > > I am attempting to understand how scikit learn works for sentiment analysis > > and came across this blog post: > > > > https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn > > > > The corresponding code is at this location: > > > > https://gist.github.com/bonzanini/c9248a239bbab0e0d42e > > > > My question is while trying to predict, why does the curr_class in Line 44 > > of the code need a classification (pos or neg) for the test data? After > > all, am I not trying to predict it? Without any initial value of > > curr_class, the program has a run time error. > > In order for the 'bot' to classify new samples, by learning the > difference between positive and negative samples, it needs to be trained > on existing samples that are 'correctly' classified. > > > -- > Terry Jan Reedy The training samples already do that. I think Dan's reply below makes sense. -- https://mail.python.org/mailman/listinfo/python-list
Re: Sentiment analysis using sklearn
On Saturday, January 27, 2018 at 5:21:15 PM UTC-8, Dan Stromberg wrote: > On Sat, Jan 27, 2018 at 1:05 PM, qrious wrote: > > I am attempting to understand how scikit learn works for sentiment analysis > > and came across this blog post: > > > > https://marcobonzanini.wordpress.com/2015/01/19/sentiment-analysis-with-python-and-scikit-learn > > > > The corresponding code is at this location: > > > > https://gist.github.com/bonzanini/c9248a239bbab0e0d42e > > > > My question is while trying to predict, why does the curr_class in Line 44 > > of the code need a classification (pos or neg) for the test data? After > > all, am I not trying to predict it? Without any initial value of > > curr_class, the program has a run time error. > > I'm a real neophyte when it comes to modern AI, but I believe the > intent is to divide your inputs into "training data" and "test data" > and "real world data". > > So you create your models using training data including correct > classifications as part of the input. > > And you check how well your models are doing on inputs they haven't > seen before with test data, which also is classified in advance, to > verify how well things are working. > > And then you use real world, as-yet-unclassified data in production, > after you've selected your best model, to derive a classification from > what your model has seen in the past. > > So both the training data and test data need accurate labels in > advance, but the real world data trusts the model to do pretty well > without further labeling. Dan, Thanks and I was also thinking along this line: 'So both the training data and test data need accurate labels in advance'. It makes sense to me. For this part: 'the real world data trusts the model to do pretty well without further labeling', the question is: how do I do this using sklearn library functions? Is there some code example for using the actual data that needs prediction? -- https://mail.python.org/mailman/listinfo/python-list
