Re: txtorcon 23.5.0

2023-05-19 Thread Jack Dangler


On 5/19/23 08:42, Benjamin Schollnick wrote:



*Top-posting? Really?


In that case, yes, because the conversion did not depend on what was 
originally said.  Unlike this conversation.


Actually, a very cursory look through the intarweb would have yielded 
this -


And that’s the point, if you want to me to consider your package, I 
should have some idea that it’s worth me investing more time into 
seeing if it can help me.  As I mentioned simply stating that it was a 
“Tor Control management API” would have been enough for me to say 
“That’s not helpful to me”.  On the other hand if it said “Django 
management API/Tool”, I would have gone to the git repository and 
investigated.


Effectively, posting a release notification is an *advertisement for 
the package*, as well as a notice saying “*Here’s some updates”.*

*
*
When done correctly, it can bring more people to use your package / 
software…


While there are one or two graphical package managers (yumex and 
yumex-dnf that I know of), have a go at the cli manager(s) that may 
live on your distro and see if you can get pkg info about it. If 
you're not sure which one(s) you have, try these - Yum, Dnf, Rpm,Apt, 
Apt-Get, Deb, pacman, dpkg, and zypper for starters. *dpkg is my 
go-to pkgmgr of choice...


Also, the names of many linux-centric utility plugins, extensions, 
and other goodies, while seemingly cryptic, are usually a prominent 
clue as to what the package is used for. The world of *NIX has never 
been for the faint of heart, but there are lots of very helping hands 
in its communities... :)


This has nothing to do with package managers, this has to do with “Why 
should I use this package” or “Should I use this package / software”. 
 If the release notes are being send to people that don’t already have 
the package then it’s worth the couple of sentences or a short 
paragraph to allow someone that is unfamiliar with the package to be 
able to see if they should investigate the package.


Cryptic names maybe cute, but if they are not descriptive, then they 
are not really that helpful other than being unique.


- Benjamin

Yeah - um - I get the impression that there is so much going on that 
either I'm not qualified to respond to it, or I'd have to charge by the 
hour to unravel it, I'm just gonna leave this right here...

--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter (related)~

2023-05-19 Thread Jack Dangler



On 5/18/23 21:11, Grant Edwards wrote:

On 2023-05-19, Cameron Simpson  wrote:

On 18May2023 12:06, Jack Dangler  wrote:

I thought the OP of the tkinter thread currently running may have
needed to install the tkinter package (since I had the same missing
component error message), so I tried to install the package on to my
Ubu laptop -

pip install tkinter
Defaulting to user installation because normal site-packages is not
writeable
ERROR: Could not find a version that satisfies the requirement tkinter
(from versions: none)
ERROR: No matching distribution found for tkinter

Is there an alternate path to installing this?

Usually tkinter ships with Python because it is part of the stdlib.

On some platforms eg Ubuntu Linux the stdlib doesn't come in completely
unless you ask - a lot of stdlib packages are apt things you need to ask
for. On my Ubunut here tkinter comes from python3-tk. So:

  $ sudo apt-get install python3-tk

And in general, on Linux systems, you'll be better off in the long run
if you use the distro's package manager to install Python packages
instead of using pip. If there is no distro package, you're usually
also better off using 'pip install --user' so that pip isn't messing
about with directories that are normally managed by the distro's
package manager.

When I do have to resort to using pip in install something, I always
do a --dry-run first and make a note of any dependancies that pip is
going to try to install -- so I can install those using the package
manager if possible.

--
Grant


Grant

Great suggestion! I didn't know that --dry-run was available... I'll 
have to look at that arg...


Jack

--
https://mail.python.org/mailman/listinfo/python-list


Re: txtorcon 23.5.0

2023-05-19 Thread Jack Dangler


On 5/19/23 06:41, Benjamin Schollnick wrote:
Meejah,  > > Sorry, but, would you please consider adding a short description 
to this of what txtorcon is. > It’s great that your announcing the 
update, and highlighting the changes…if I used it, I’d be upgrading it. 
> > But I have absolutely no idea why I would want to investigate using 
it, because there is no description of the package. > > Well, that’s not 
100% true. From my knowledge of twisted, I know it’s network based, and 
that’s it. I can’t tell if it’s a server, or client application. > > 
Even just simply adding your 10,000 feet summary: > > txtorcon is an 
implementation of the control-spec 
 
for Tor  using the Twisted 
 networking library for Python 
. > > would have been extremely helpful. > > I hope 
you will take this as the creative criticism that I am offering it as. > 
> - Benjamin > > >> On May 18, 2023, at 9:37 PM, mee...@meejah.ca 
wrote: >> >>

I'm happy to announce txtorcon 23.5.0 with the following changes:

 * twisted.web.client.Agent instances now use the same HTTPS policy
   by default as twisted.web.client.Agent.  It is possible to
   override this policy with the tls_context_factory= argument, the
   equivalent to Agent's contextFactory=
   (Thanks to Itamar Turner-Trauring)
 * Added support + testing for Python 3.11.
 * No more ipaddress dependency

You can download the release from PyPI or GitHub (or of
course "pip install txtorcon"):

https://pypi.python.org/pypi/txtorcon/23.5.0
https://github.com/meejah/txtorcon/releases/tag/v23.5.0

Releases are also available from the hidden service:

http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon-23.5.0.tar.gz
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon-23.5.0.tar.gz.asc

You can verify the sha256sum of both by running the following 4 lines
in a shell wherever you have the files downloaded:

cat <93fd80a9dd505f698d0864fe93db8b6a9c1144b5feb91530820b70ed8982651c 
dist/txtorcon-23.5.0.tar.gz
987f0a91184f98cc3f0a7eccaa42f5054063744d6ac15e325cfa666403214208 
dist/txtorcon-23.5.0-py3-none-any.whl

EOF

thanks,
meejah

--  >> https://mail.python.org/mailman/listinfo/python-list >



*Top-posting? Really?

Actually, a very cursory look through the intarweb would have yielded 
this -


https://txtorcon.readthedocs.io/en/latest/introduction.html

as well as this -

https://github.com/meejah/txtorcon

While there are one or two graphical package managers (yumex and 
yumex-dnf that I know of), have a go at the cli manager(s) that may live 
on your distro and see if you can get pkg info about it. If you're not 
sure which one(s) you have, try these - Yum, Dnf, Rpm,Apt, Apt-Get, Deb, 
pacman, dpkg, and zypper for starters. *dpkg is my go-to pkgmgr of choice...


Also, the names of many linux-centric utility plugins, extensions, and 
other goodies, while seemingly cryptic, are usually a prominent clue as 
to what the package is used for. The world of *NIX has never been for 
the faint of heart, but there are lots of very helping hands in its 
communities... :)


Jack
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter (related)~

2023-05-18 Thread Jack Dangler



On 5/18/23 12:33, Mats Wichmann wrote:

On 5/18/23 10:06, Jack Dangler wrote:

I didn't want to hijack another thread...

I thought the OP of the tkinter thread currently running may have 
needed to install the tkinter package (since I had the same missing 
component error message), so I tried to install the package on to my 
Ubu laptop -


install python3-tk to get the distro package.


Thanks, Mats! apt worked... I'll have another run at the original thread 
and see where that takes me.

--
https://mail.python.org/mailman/listinfo/python-list


Tkinter (related)~

2023-05-18 Thread Jack Dangler

I didn't want to hijack another thread...

I thought the OP of the tkinter thread currently running may have needed 
to install the tkinter package (since I had the same missing component 
error message), so I tried to install the package on to my Ubu laptop -


pip install tkinter
Defaulting to user installation because normal site-packages is not 
writeable
ERROR: Could not find a version that satisfies the requirement tkinter 
(from versions: none)

ERROR: No matching distribution found for tkinter

Is there an alternate path to installing this?

Thanks for any help you can provide...

Jack

--
https://mail.python.org/mailman/listinfo/python-list


Re: What kind of "thread safe" are deque's actually?

2023-03-29 Thread Jack Dangler



On 3/29/23 13:13, Chris Angelico wrote:

On Thu, 30 Mar 2023 at 01:52, Jack Dangler  wrote:


On 3/29/23 02:08, Chris Angelico wrote:

On Wed, 29 Mar 2023 at 16:56, Greg Ewing via Python-list
 wrote:

On 28/03/23 2:25 pm, Travis Griggs wrote:

Interestingly the error also only started showing up when I switched from 
running a statistics.mean() on one of these, instead of what I had been using, 
a statistics.median(). Apparently the kind of iteration done in a mean, is more 
conflict prone than a median?

It may be a matter of whether the GIL is held or not. I had a look
at the source for deque, and it doesn't seem to explicitly do
anything about locking, it just relies on the GIL.

So maybe statistics.median() is implemented in C and statistics.mean()
in Python, or something like that?


Both functions are implemented in Python, but median() starts out with
this notable line:

  data = sorted(data)

which gives back a copy, iterated over rapidly in C. All subsequent
work is done on that copy.

The same effect could be had with mean() by taking a snapshot using
list(q) and, I believe, would have the same effect (the source code
for the sorted() function begins by calling PySequence_List).

In any case, it makes *conceptual* sense to do your analysis on a copy
of the queue, thus ensuring that your stats are stable. The other
threads can keep going while you do your calculations, even if that
means changing the queue.

ChrisA

Sorry for any injected confusion here, but that line "data =
sorted(data)" appears as though it takes the value of the variable named
_data_, sorts it and returns it to the same variable store, so no copy
would be created. Am I missing something there?

The variable name "data" is the parameter to median(), so it's
whatever you ask for the median of. (I didn't make that obvious in my
previous post - an excess of brevity on my part.)

The sorted() function, UNlike list.sort(), returns a sorted copy of
what it's given. I delved into the CPython source code for that, and
it begins with the PySequence_List call to (effectively) call
list(data) to get a copy of it. It ought to be a thread-safe copy due
to holding the GIL the entire time. I'm not sure what would happen in
a GIL-free world but most likely the lock on the input object would
still ensure thread safety.

ChrisA

Aah - thanks, Chris! That makes much more sense.
--
https://mail.python.org/mailman/listinfo/python-list


Re: What kind of "thread safe" are deque's actually?

2023-03-29 Thread Jack Dangler



On 3/29/23 02:08, Chris Angelico wrote:

On Wed, 29 Mar 2023 at 16:56, Greg Ewing via Python-list
 wrote:

On 28/03/23 2:25 pm, Travis Griggs wrote:

Interestingly the error also only started showing up when I switched from 
running a statistics.mean() on one of these, instead of what I had been using, 
a statistics.median(). Apparently the kind of iteration done in a mean, is more 
conflict prone than a median?

It may be a matter of whether the GIL is held or not. I had a look
at the source for deque, and it doesn't seem to explicitly do
anything about locking, it just relies on the GIL.

So maybe statistics.median() is implemented in C and statistics.mean()
in Python, or something like that?


Both functions are implemented in Python, but median() starts out with
this notable line:

 data = sorted(data)

which gives back a copy, iterated over rapidly in C. All subsequent
work is done on that copy.

The same effect could be had with mean() by taking a snapshot using
list(q) and, I believe, would have the same effect (the source code
for the sorted() function begins by calling PySequence_List).

In any case, it makes *conceptual* sense to do your analysis on a copy
of the queue, thus ensuring that your stats are stable. The other
threads can keep going while you do your calculations, even if that
means changing the queue.

ChrisA
Sorry for any injected confusion here, but that line "data = 
sorted(data)" appears as though it takes the value of the variable named 
_data_, sorts it and returns it to the same variable store, so no copy 
would be created. Am I missing something there?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Upgrading Python on Ubuntu 22.04.1 LTS

2023-02-01 Thread Jack Dangler

If you're not familiar with snap, lookup 'snap' 'ubuntu' ...

On 2/1/23 13:13, Thomas Passin wrote:

On 2/1/2023 12:36 PM, אורי wrote:

Thank you all.

I'm not familiar with snap update but I did `sudo apt update` & `sudo 
apt

upgrade`, but about one or two months ago.

אורי
u...@speedy.net


You can probably install it from the deadsnakes repository:

sudo add-apt-repository ppa:deadsnakes/ppa

More than likely it will have your package.  See

https://github.com/deadsnakes




On Wed, Feb 1, 2023 at 7:33 PM Jack Dangler  wrote:


Ari

Have you tried running a snap update?

Regards

יַעֲקֹב

On 2/1/23 11:31, אורי wrote:

Hi,

I have a server with Ubuntu 22.04.1 LTS and the Python version there
is Python 3.10.6. Is there a safe way to upgrade to the latest 
version of

Python 3.10 (3.10.9)? I tried with the OS update and upgrade but the

Python

version remained the same.

Thanks,
אורי
u...@speedy.net

--
https://mail.python.org/mailman/listinfo/python-list




--
https://mail.python.org/mailman/listinfo/python-list


Re: Upgrading Python on Ubuntu 22.04.1 LTS

2023-02-01 Thread Jack Dangler

Ari

Have you tried running a snap update?

Regards

יַעֲקֹב

On 2/1/23 11:31, אורי wrote:

Hi,

I have a server with Ubuntu 22.04.1 LTS and the Python version there
is Python 3.10.6. Is there a safe way to upgrade to the latest version of
Python 3.10 (3.10.9)? I tried with the OS update and upgrade but the Python
version remained the same.

Thanks,
אורי
u...@speedy.net

--
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Jack Dangler



On 4/24/22 13:59, Greg wrote:

I am trying to get Hello World to appear under my directory. The files of

*C:\Users\gd752>cd C:\google-python-exercises> python hello.py*
*The system cannot find the path specified.*

*C:\Users\gd752>cd C:\google-python-exercises>*
*The syntax of the command is incorrect.*

I installed version 3.10. I am stuck and could use some help.
Thx,


[image: directory pic.png]


Have you tried

python3 hello.py

--
https://mail.python.org/mailman/listinfo/python-list


Re: code issue

2022-04-21 Thread Jack Dangler



On 4/21/22 13:09, Chris Angelico wrote:

On Fri, 22 Apr 2022 at 03:02, Tola Oj  wrote:

for i in range(1, n+1):
 if i % 3 == 0 and i % 5 == 0:
 print("Fizzbuzz")
 elif i % 3 == 0:
 print("Fizz")
 elif i % 5 == 0:
 print("Buzz")
 else:
 print(i)
 print(i, sep='\n')

fizzbuzz(13)

This can't be your complete code, because it won't run like this. Have
a very careful read through of your code, and consider adding some
extra print statements to see what's happening; but if you're asking
for help, you'll definitely need to post the entire program.

ChrisA
fizzbuzz is one of Angela Yu's lab assignments in her py course.If you 
ask her, she'll gladly tell you where you are going wrong and even 
supply an entirely correct version, if you want it...

--
https://mail.python.org/mailman/listinfo/python-list


Re: googletrans in python

2022-04-04 Thread Jack Dangler



On 4/12/21 15:24, Karsten Hilbert wrote:

Am Mon, Apr 12, 2021 at 12:48:23PM -0400 schrieb Quentin Bock:


Can someone explain the basics of googletrans in python?
I want to make a program that translates stories into English, but I'm not
sure how to get a translation printed. Also, is this needed to be done in
an HTML file inside python?
If so can someone provide basic code for a translation and how that should
be written and work?

You might want to post the entire homework assignment verbatim.

That way people might better understand which part of it to
help you with in what way.

As to your description of what you want to achieve -- what
did you already try ?

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B


A quick google run turns up a lot of stuff with various interfaces, Pypi 
being one of the more consistent. However, if the more technical 
theorist or stoic documentation sites don't help you, this one seems to 
at least take a more 'tutorial' approach -


https://medium.com/mlearning-ai/translate-famous-quotes-one-language-to-another-for-fun-using-googletrans-644956e3313a

Do post an update to how you are getting on. Many more people will be 
responsive to the work once you dig in...


Jack

--
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-10 Thread Jack Dangler



On 3/10/22 08:03, Marco Sulla wrote:

On Thu, 10 Mar 2022 at 04:50, Michael Torrie  wrote:

On 3/9/22 13:05, Marco Sulla wrote:

So my laziness pays. I use only LTS distros, and I update only when
there are security updates.
PS: any suggestions for a new LTS distro? My Lubuntu is reaching its
end-of-life. I prefer lightweight debian-like distros.

Maybe Debian itself?

I tried Debian on a VM, but I found it too much basical. A little
example: it does not have the shortcut ctrl+alt+t to open a terminal
that Ubuntu has. I'm quite sure it's simple to add, but I'm starting
to be old and lazy...
or why not get a cloud desktop running whatever distro you want and you 
don't have to do anything

--
https://mail.python.org/mailman/listinfo/python-list


Re: Coding help

2022-02-24 Thread Jack Dangler



On 2/23/22 17:02, Richard Pullin via Python-list wrote:

I know next to nothing about computer coding nor Python.

However, I am working on a mathematical challenge in which coding is
required to calculate and generate different potential solutions.

Can anyone help? If so, please private message me and we can discuss in
more detail.

Many thanks,
Richard


Sure

What do you have in mind?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Logging user activity

2022-02-08 Thread Jack Dangler



On 2/7/22 5:09 PM, Peter J. Holzer wrote:

On 2022-02-06 23:30:41 -0800, blessy carol wrote:

I have this task where I have to create log files to record user
activity whenever they make an entry or view something. Also, I have
to create Database log file whenever someone accessed or manipulated
the data in the database. The code is written python and used django
framework. I've connected django with oracle cloud database. So now I
want to if the basic logging details can be used to store the record
of these activities in the log file in the server.

There are three places where you can do that in a centralized manner:

1. In the database itself. AFAIK Oracle has an audit system, but I've
never used it.
2. At the Django ORM layer. Django has the ability to log all database
queries it makes
3. At the web request level. Your web server (probably) already logs
every request but not necessarily the information you are interested
in. But you could write a piece of middleware for your Django which
extracts log-worthy information and logs that.

The first two options are probably too low-level, and especially the
second is really hard to interpret in an automated manner (which is what
you probably want to do - otherwise why log in the first place?)

So I'd try the third option. But it really depends a lot on the
structure of your application on whether it's feasible to extract all
the data you need at that point. It's possible that you will have to go
through all the views in your app, see what data they are requesting and
altering and craft appropriate log messages for each.

 hp


Short of a long lesson on why software developers should always think of 
logging/monitoring components to everything they write, I'll just offer 
this. It's worth the read and should put you in a good position to 
complete your task.


https://www.askpython.com/django/django-logging

If you're after something that you're being paid to do, look into 
Splunk! It's a robust package that offers logging and correlation of 
data on nearly any level of complication/sophistication your customers need.


Hope this helps.

Regards

Jack

--
https://mail.python.org/mailman/listinfo/python-list


Re: CODING PAGE ACCESS

2021-08-09 Thread Jack Dangler

Or open a terminal and type 'python3' ...

Or open an editor, type in a py program, save it as "myfirstcode.py" and 
then at the console type 'python3 ./myfirstcode.py' and hit return...


There are a number of choices to get there - that's the tenet of Linux. 
It's all about choice.


On 8/7/21 3:31 PM, MRAB wrote:

On 2021-08-07 04:34, MICHAEL J W SMITH via Python-list wrote:

I downloaded python. I selected it from the start menu. I clicked on:-
Python 3-9New
I got:-
IDLE (Python 3.9 64-bit)
Python 3.9 (64-bit)
Python 3.9 Manuals (64-bit)
Python 3.9 Module Docs (64-bit)
I wish to access the page where I do coding.I would appreciate help, 
either directly, or with information as to where I can get help.Thank 
you so much!



The Manual contains a tutorial.

You can use IDLE to use Python interactively or edit programs.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Ann: New Python curses book

2021-04-11 Thread Jack Dangler



On 4/10/21 4:29 PM, Russell via Python-list wrote:

I believe this is it:
https://www.amazon.com/dp/B091CL3DTK/ref=cm_sw_su_dp

But for some reason the ASIN is different.

William Ray Wing  wrote:

I???ve ordered the book (physical volume). It will fulfill a need I???ve had 
for some time.  Unfortunately, it is only available in the UK store, so the 
shipping cost by far outweighs the book???s cost.  Hope for other???s sake, it 
migrates to the other Amazon stores fairly quickly.

Thanks,
Bill


On Mar 30, 2021, at 7:12 AM, Alan Gauld via Python-list 
 wrote:

I've just published, in Kindle and paperback formats,
my book on "Programming curses with Python".

https://www.amazon.co.uk/dp/B091B85B77/

(It should be available in most other Amazon stores too)

I just found it and put it in the cart, and got this on checkout -


Items:$5.99

Shipping & handling:$0.00



Total before tax:$5.99

Estimated tax to be collected:$0.36



Order total:$6.35

It must be available here as well, now. (I'm in the US).

--
https://mail.python.org/mailman/listinfo/python-list


pip issue

2020-02-21 Thread Jack Dangler

Hi, all

Went to setup path and got an error. attempted to update pip and got the 
same error... The error being thrown is -


Traceback (most recent call last):
  File "/home/jack/.local/bin/pip", line 11, in 
    sys.exit(main())
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/cli/main.py", 
line 73, in main

    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/commands/__init__.py", 
line 96, in create_command

    module = importlib.import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in 
import_module

    __import__(name)
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/commands/install.py", 
line 24, in 

    from pip._internal.cli.req_command import RequirementCommand
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", 
line 15, in 

    from pip._internal.index.package_finder import PackageFinder
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/index/package_finder.py", 
line 21, in 

    from pip._internal.index.collector import parse_links
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_internal/index/collector.py", 
line 12, in 

    from pip._vendor import html5lib, requests
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", 
line 97, in 

    from pip._vendor.urllib3.contrib import pyopenssl
  File 
"/home/jack/.local/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", 
line 46, in 

    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, 
in 

    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in 


    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Any input, as always, is appreciated.

Regards


--
https://mail.python.org/mailman/listinfo/python-list


requests

2019-04-04 Thread Jack Dangler
Hi, all. Just getting started but already have an idea for something to 
save me some grief


we have lists of files that reside on a sharepoint site at work that we 
pick from. These have a variety of data items in them and we need to 
start the process by copying the entire contents into a local work file 
and then use that as a part of a runbook to develop the solution to the 
problem statement (one of the items within the file). I've done the 
copy/paste on all 31 parts 4 times and I'm already tired. "This would be 
a good place to learn a little Python" says me. So I figure I can either 
go the requests route to the sharepoint site and navigate the path to 
the place where the work items are and then figure out (based on the 
responses) how to pick the right item and get the data back, or connect 
to the SP database and work through the schema (assuming I even have any 
access to the backend database). Has anyone here used Py for extracting 
item data from SP? Is there a preferred method for this? Thanks for the 
input - really appreciate the wealth of knowledge here.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Not Defined error in basic code

2019-03-14 Thread Jack Dangler



On 3/14/19 3:49 PM, DL Neil wrote:
Just getting started with tutorials and such, and don't understand 
this -
Did you answer the post asking which tutorial you were 
following/copying?

Sorry - it is this -
https://www.learnpython.org/en/ ..
The section is on classes and objects - 
https://www.learnpython.org/en/Classes_and_Objects



Wanted to check: Someone publishing the 'first code' in this thread as 
training material, would have been 'unhelpful'.


Those guys have a good reputation - if the code camp approach suits 
the learner, rapid progress can be made.


The examples they provide illustrate attributes being 'defined' with a 
value. (unlike the first code 'here' which only listed attributes)


This feature of Python's dynamic nature often confuses folk who come 
from other, more rigidly defined, languages - there is no need to 
declare "id" as an integer per-se, passing it an integer constant as 
its value performs two tasks for the price of one!


Advice (if I may): don't be too literal in attempting to write Python 
the way you currently write xyz-language code.


You may find it helpful to combine those tutorials with similar 
information from additional sources, eg the Python docs site's 
tutorial, other on-line books, 'dead-tree' sources, other on-line 
training, etc. Whilst it seems like more work (it's certainly more 
reading/scanning), two non-identical statements of 'the same thing', 
will express things differently. Often something from one source that 
is initially puzzling, when compared with another presentation of the 
'same', helps learners' minds go 'click' or to enjoy that 'ahah moment'.


All the best...
Thank you sir. I think you may be on to something there. I've done 
mainframe, machine, 3GL, and 4GL languages, but the last couple I've 
taken on have given me headaches. I guess I'll have to just read a bunch 
first and then try and write something simpler than what I'm attempting 
to take on... Thanks for your help and understanding.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Not Defined error in basic code

2019-03-14 Thread Jack Dangler



On 3/14/19 2:28 PM, DL Neil wrote:

Jack,


On 15/03/19 3:05 AM, Jack Dangler wrote:
Just getting started with tutorials and such, and don't understand 
this -



Did you answer the post asking which tutorial you were following/copying?


Sorry - it is this -

https://www.learnpython.org/en/ ..

The section is on classes and objects - 
https://www.learnpython.org/en/Classes_and_Objects

--
https://mail.python.org/mailman/listinfo/python-list


Re: Not Defined error in basic code

2019-03-14 Thread Jack Dangler


On 3/14/19 12:50 PM, Calvin Spealman wrote:
You still need to get of the two lines at the start of your class, 
they are unnecessary and reference variables you never defined:


class weapon:
    weaponId  # Get rid of this line!
    manufacturerName  # And this one, too!

On Thu, Mar 14, 2019 at 12:43 PM Jack Dangler <mailto:tdl...@gmail.com>> wrote:



On 3/14/19 10:39 AM, Calvin Spealman wrote:

A few notes, Jack:

On Thu, Mar 14, 2019 at 10:32 AM Jack Dangler mailto:tdl...@gmail.com>> wrote:


On 3/14/19 10:11 AM, Calvin Spealman wrote:

Where are you seeing something like this? The two lines
under `class weapon:` are not correct because they are
variable names that you've never defined.

Maybe you intended this to "declare" the attributes for the
class? That isn't something you need to do in Python. If you
simply remove these lines your example should work.

On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler
mailto:tdl...@gmail.com>> wrote:

Just getting started with tutorials and such, and don't
understand this -



class weapon:
 weaponId
 manufacturerName

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s Model: %s" %
(self.weaponId,
self.manufacturerName)
 return infoString



import class_weapon

MyWeapon=weapon()
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

print(MyWeapon.printWeaponInfo)

executing 'python3 weaponTrack.py' results in this
bailing on the first
element in the class with "not defined". I've been
staring at templates
of this exact structure for about an hour trying to
figure out why this
isn't running at all. Is it simply because it isn't all
in one file?
Thanks for any guidance. Really appreciate the help.


Thanks.

-- 
https://mail.python.org/mailman/listinfo/python-list




-- 


CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com <mailto:cspea...@redhat.com> M:
+1.336.210.5107 

<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>


Calvin

Thank you for the reply. I tried defining them in the form of
'int weaponId' but that didn't help. I finally put it in this
form 'weaponId=0" and it liked that. So, i updated the class
file to be as follows -



class weapon:
 weaponId=0
 manufacturerName=""

Technically this will work, but it won't always work. You're
assigning these values directly to the class (or type) and not to
individual objects of that type.

This will break very badly if you try to do this with any type of
value that can be changed (like a list, which you can add things
to) because you'll accidentally
modify values shared between ALL objects of the same type.
Instead, you want to define a __init__ method, which is called
when all objects of this type are
created, and assign the attributes in there. Like this:

def __init__(self):
    self.weaponId = 0
self.manufacturerName = ""

Of course, you could make it easier to create the specific
objects you want by passing parameters at the creation of the object:

def __init__(self, weaponId, manufacturerName):
    self.weaponId = weaponId
self.manufacturerName = manufacturerName

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s " % (self.weaponId,
self.manufacturerName)
 return infoString

The second file now looks like this -



import class_weapon
MyWeapon=class_weapon.weapon
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

If you follow my advice above, you won't need to override the
values here.

But you aren't actually creating anything here, because this line:

MyWeapon = class_weapon.weapon
Doesn't create anything. It just assigns the class you made to a
new name. What you probably meant to do, and can do with the
__init__ I suggest above, is create an instance of your weapon
class like this:

MyWeapon = class_weapon.weapon(100, "Glock")


print(MyWeapon.printWeaponInfo)

Similarly, you probably meant to call this method but without
parenthesis on the method you just printed the object representing
the method itself, rather than calling it and printing the value
it returns.

print(MyWeapon.pr

Re: Not Defined error in basic code

2019-03-14 Thread Jack Dangler


On 3/14/19 10:39 AM, Calvin Spealman wrote:

A few notes, Jack:

On Thu, Mar 14, 2019 at 10:32 AM Jack Dangler <mailto:tdl...@gmail.com>> wrote:



On 3/14/19 10:11 AM, Calvin Spealman wrote:

Where are you seeing something like this? The two lines under
`class weapon:` are not correct because they are variable names
that you've never defined.

Maybe you intended this to "declare" the attributes for the
class? That isn't something you need to do in Python. If you
simply remove these lines your example should work.

On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler mailto:tdl...@gmail.com>> wrote:

Just getting started with tutorials and such, and don't
understand this -



class weapon:
 weaponId
 manufacturerName

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s Model: %s" %
(self.weaponId,
self.manufacturerName)
 return infoString



import class_weapon

MyWeapon=weapon()
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

print(MyWeapon.printWeaponInfo)

executing 'python3 weaponTrack.py' results in this bailing on
the first
element in the class with "not defined". I've been staring at
templates
of this exact structure for about an hour trying to figure
out why this
isn't running at all. Is it simply because it isn't all in
one file?
Thanks for any guidance. Really appreciate the help.


Thanks.

-- 
https://mail.python.org/mailman/listinfo/python-list




-- 


CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com <mailto:cspea...@redhat.com> M:
+1.336.210.5107 

<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>


Calvin

Thank you for the reply. I tried defining them in the form of 'int
weaponId' but that didn't help. I finally put it in this form
'weaponId=0" and it liked that. So, i updated the class file to be
as follows -



class weapon:
 weaponId=0
 manufacturerName=""

Technically this will work, but it won't always work. You're assigning 
these values directly to the class (or type) and not to individual 
objects of that type.


This will break very badly if you try to do this with any type of 
value that can be changed (like a list, which you can add things to) 
because you'll accidentally
modify values shared between ALL objects of the same type. Instead, 
you want to define a __init__ method, which is called when all objects 
of this type are

created, and assign the attributes in there. Like this:

def __init__(self):
    self.weaponId = 0
    self.manufacturerName = ""

Of course, you could make it easier to create the specific objects you 
want by passing parameters at the creation of the object:


def __init__(self, weaponId, manufacturerName):
    self.weaponId = weaponId
    self.manufacturerName = manufacturerName

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s " % (self.weaponId,
self.manufacturerName)
 return infoString

The second file now looks like this -



import class_weapon
MyWeapon=class_weapon.weapon
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

If you follow my advice above, you won't need to override the values here.

But you aren't actually creating anything here, because this line:

MyWeapon = class_weapon.weapon
Doesn't create anything. It just assigns the class you made to a new 
name. What you probably meant to do, and can do with the
__init__ I suggest above, is create an instance of your weapon class 
like this:


MyWeapon = class_weapon.weapon(100, "Glock")


print(MyWeapon.printWeaponInfo)

Similarly, you probably meant to call this method but without 
parenthesis on the method you just printed the object representing
the method itself, rather than calling it and printing the value it 
returns.


print(MyWeapon.printWeaponInfo())

so now, when I run 'python3 weaponTrack.py', I get , but am expecting

ID: 100 Mfg: Glock ...

I hope this helps.

--

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com <mailto:cspea...@redhat.com> M: +1.336.210.5107 



<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>



Calvin

Really great explanation! Giving me a lot to go on. I changed the files 
as suggested (I think), and now have this -


The first file now looks like this -



class weapon:
    weaponId
    manufacturerName

    # Creation/Instantiation
    def __init__(self, weaponId, manufacturerName):
    self.weaponId = weaponId
    self.manufacturerName = manufacturerName

    # Pri

Re: Not Defined error in basic code

2019-03-14 Thread Jack Dangler


On 3/14/19 10:11 AM, Calvin Spealman wrote:
Where are you seeing something like this? The two lines under `class 
weapon:` are not correct because they are variable names that you've 
never defined.


Maybe you intended this to "declare" the attributes for the class? 
That isn't something you need to do in Python. If you simply remove 
these lines your example should work.


On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler <mailto:tdl...@gmail.com>> wrote:


Just getting started with tutorials and such, and don't understand
this -



class weapon:
 weaponId
 manufacturerName

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId,
self.manufacturerName)
 return infoString



import class_weapon

MyWeapon=weapon()
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

print(MyWeapon.printWeaponInfo)

executing 'python3 weaponTrack.py' results in this bailing on the
first
element in the class with "not defined". I've been staring at
templates
of this exact structure for about an hour trying to figure out why
this
isn't running at all. Is it simply because it isn't all in one file?
Thanks for any guidance. Really appreciate the help.


Thanks.

-- 
https://mail.python.org/mailman/listinfo/python-list




--

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com <mailto:cspea...@redhat.com> M: +1.336.210.5107 



<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>


Calvin

Thank you for the reply. I tried defining them in the form of 'int 
weaponId' but that didn't help. I finally put it in this form 
'weaponId=0" and it liked that. So, i updated the class file to be as 
follows -




class weapon:
 weaponId=0
 manufacturerName=""

 def printWeaponInfo(self):
 infoString = "ID: %d Mfg: %s " % (self.weaponId, 
self.manufacturerName)

 return infoString

The second file now looks like this -



import class_weapon
MyWeapon=class_weapon.weapon
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

print(MyWeapon.printWeaponInfo)

so now, when I run 'python3 weaponTrack.py', I get weapon.printWeaponInfo at 0x7f2bd3ae7510>, but am expecting


ID: 100 Mfg: Glock ...

--
https://mail.python.org/mailman/listinfo/python-list


Not Defined error in basic code

2019-03-14 Thread Jack Dangler

Just getting started with tutorials and such, and don't understand this -



class weapon:
    weaponId
    manufacturerName

    def printWeaponInfo(self):
    infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId, 
self.manufacturerName)

    return infoString



import class_weapon

MyWeapon=weapon()
MyWeapon.weaponId = 100
MyWeapon.manufacturerName = "Glock"

print(MyWeapon.printWeaponInfo)

executing 'python3 weaponTrack.py' results in this bailing on the first 
element in the class with "not defined". I've been staring at templates 
of this exact structure for about an hour trying to figure out why this 
isn't running at all. Is it simply because it isn't all in one file? 
Thanks for any guidance. Really appreciate the help.



Thanks.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python program to phone?

2019-02-07 Thread Jack Dangler



On 2/4/19 3:20 PM, Steve wrote:

I have written my first python program (600 lines!) to help control my blood
sugar and it has been so successful that my A1c dropped form 9.3 to an
impressive 6.4.  It will be much more useful if I had it on my phone.
(MotoG, Android)  The .py file reads/writes to two txt files.

  


About a year ago, I installed Kivy and managed to transfer the "Hello World"
app to my phone and it worked.  I am not on a different computer and believe
that I got all the way through the installation but I do not see how to
invoke it.  I am sure that I can go through the tutorial again and use my
program instead.

  


How do I figure out what is wrong and might there ne a better way to get the
program onto my phone?

  


Steve

  


P.S.  Yes, I tried to post this about two weeks ago but could not seem to
respond to the replies I received.  I could contact one or two individuals
but apparently not the masses.  How do I find out how this list works?

  

  


Foornote:
There's 99 bugs in the code, in the code.

99 bugs in the code.

Take one down and patch it all around.

Now there's 117 bugs in the code.

  


Steve

I'm not sure but I think there is an Android lib for py that is 
available to help convert your app to a mobile platform. Also, if you're 
of a mind, I'd love to see the code you wrote for blood sugar. I need to 
lower my A1C as well and could use all the help I can get.


Regards

Jack

--
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Jack Dangler


On 1/27/19 7:34 AM, Frank Millman wrote:

"^Bart" wrote in message news:q2k1kk$1anf$1...@gioia.aioe.org...


>    You need to do this exercize just by using if, elif and else,
>    but in the quotation above, you use "=".

We can use > < and =

Now I wrote:

number1 = int( input("Insert the first number: "))

number2 = int( input("Insert the second number: "))

number3 = int( input("Insert the third number: "))



[snip stuff that doesn’t work]



But it doesn't work... :\



You have got to a starting point - you have three numbers. Good.

Where do you do go from here?

I would start with two of the numbers, and work out which one is higher.

Once you know that, you can compare that one with the third number, 
and work out which one is higher.


From that, you can work out which one is the highest of all three.

Then you can apply the same logic to work out which is the lowest.

Give that a go, and come back here if you get stuck.

Frank Millman


Frank - The OP didn't appear to need to 'sort' the inputs, but only to 
solve for the highest value of the three using limited arithmetic 
operators. I like your text walkthrough. It should give the OP enough 
to go on. I only supplied a linear solution because I am not sure why 
this would be a struggle.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-29 Thread Jack Dangler


On 1/27/19 5:19 AM, ^Bart wrote:

In my experience based on decades of writing programs...

1. The assignment/exercise/problem should be a write a function with 
a particular signature.  So first decide on the signature.


def max3(n1, n2, n3):
 "Return the max of the three inputs."
 return None  # To be replaced.


I need to do this exercize just by using if, elif and else, in the 
next lesson we'll discuss other kind of rules! :)


So I need to insert three int numbers and I should show which is the 
high, the middle and the min.


# Exercize 305

number1 = int( input("Insert the first number: "))

number2 = int( input("Insert the second number: "))

number3 = int( input("Insert the third number: "))

numbermax = number1

numbermiddle = number2

numbermin = number3

if number2 > number1 and number2 > number3:
    numbermax = number2

if number3 < number2 and number3 < number1:
    numbermin = number3

else:
    numbermiddle is number1

print("Number max is: ",numbermax, "Number middle is; 
",numbermiddle,"Number min is: ", numbermin)


if number2 < number1 and number2 < number3:
    numbermin = number2

if number3 > number2 and number3 > number1:
    numbermax = number3

else:
    numbermiddle is number2

print("Number min is: ",numbermin)

I don't understand how could I fix it :\


wow. Seems like a lot going on. You have 3 ints and need to determine 
the max? Doesn't this work?


N1, N2, N3

if N1>N2
  if N1>N3
    MaxNum = N1
elif N2>N3
  MaxNum = N2
elif N1https://mail.python.org/mailman/listinfo/python-list


Re: Guido (Sarducci)

2019-01-17 Thread Jack Dangler



On 1/16/19 9:48 PM, Avi Gross wrote:

Dennis,

I wish to apologize for introducing any suggestion to name anything as
Guido, let alone any language that springs from a python. Yes, it may be a
stereotypic Italian name related to what you hint at. You probably
recognized it as an allusion to someone who is clearly Dutch and has some
finite relationship with python. The name is ultimately Germanic and used in
many countries.

I, in a Monty Python Spirit, insist I was thinking about the Saturday Night
Live comedic  character from generations ago, Father Guido Sarducci, who
does indeed appear to be Italian. That is the pythonic way to choose a name
although 3.X might well have been named after the Three Stooges.

Again, my apologies. I will try to resume being serious and maybe talk about
mission creep.

Avi

-Original Message-
From: Python-list  On
Behalf Of Dennis Lee Bieber
Sent: Wednesday, January 16, 2019 4:36 PM
To: python-list@python.org
Subject: Re: the python name

On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross" 
declaimed the following:


[HUMOR for the ALERT]

But as languages develop and evolve, sometimes a name change may be a
decent idea. Perhaps version 4.0 should be renamed Guido so we can get
more silly questions.


So we can make jokes about a mafia hitman (which is where many might
go with the name)


Imagine people developing languages like X and Y and over the years
enhancing them.

An Enhanced or Extended X, naturally, might be renamed EX.

Getting too close to REXX (which was something like Restructured
EXtended eXecutor).


With further Super new features (think super-symmetry in Physics) we
would have a Super Extended X, or SEX in brief.


Computer science already has sexpr
https://en.wikipedia.org/wiki/S-expression



Finda de pope ina de pizza! A very funny skit!

--
https://mail.python.org/mailman/listinfo/python-list


Re: the python name

2019-01-03 Thread Jack Dangler
Odd that COBOL (Common Business Oriented Language)  and DIBOL (Digital 
Business Oriented Language) follow the paradigm, but SNOBOL went with 
"symBOlic"...


On 1/2/19 7:22 PM, Rich Shepard wrote:

On Wed, 2 Jan 2019, Dennis Lee Bieber wrote:


Which was a derivative of BCPL (so one could claim a successor of C
should be named P), ?, mathematician, beginners all-purpose symbolic
instruction code. R? maybe a subtle implication to be better/in-front-of
S. SNOBOL is the ugly one, since the SN come from "string", and the BO
from the middle of "symbolic".


  R is the open source implemention of the S statistical/data analysis
language developed by Chambers at the AT Labs. S-Plus is the 
proprietary,

windows-requiring implementation of S.

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Re: Number 7 syntax ERROR

2018-11-08 Thread Jack Dangler

On 11/7/18 8:52 PM, NoHaxAllSwagg wrote:

Hello,
I have been experiencing difficulty while trying to run scripts on my IDLE 
software, considering that when I run my program, I get an error at the top of 
the page in the “Python 3.7.1” area, highlighting the seven telling me that 
there is a syntax error, in this case, I cant remove that area, so I cant run 
my script, please help
Sincerely,
Zed

Sent from Mail for Windows 10

Just curious what happens when you run that same script outside of IDLE? 
Does it work?

--
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-01 Thread Jack Dangler



On 02/01/2018 12:06 PM, alister via Python-list wrote:

On Thu, 01 Feb 2018 09:01:35 -0800, superchromix wrote:


Our own programming discussion newsgroup, located at
comp.lang.idl-pvwave, started receiving spam messages several months
ago.

Two weeks ago, access to comp.lang.idl-pvwave was blocked by Google
Groups.

When trying to access comp.lang.idl-pvwave, a message is now displayed,
stating that the group owner needs to remove the spam, and can then
apply to Google in order to have access reinstated.

However, old public Usenet groups like this have no owner.  The
comp.lang.idl-pvwave group is more than 20 years old.  Hence, there is
no way to unblock the group.

This is a serious problem, since the entire collection of postings going
back many years has been blocked, no just the spam.  This resource is
frequently used by IDL programmers.

Seeing the spam postings in this newsgroup, I expect something similar
may happen to comp.lang.python, soon.

simple solution stop using google groups & use either the mailing list or
a news server with an NNTP client



Is it possible to name an 'owner' and then get into the group archive to 
remove the spam by account "recovery" ?


--
https://mail.python.org/mailman/listinfo/python-list