Re: Line continuation and comments

2023-02-22 Thread Paul Bryan
Adding to this, there should be no reason now in recent versions of
Python to ever use line continuation. Black goes so far as to state
"backslashes are bad and should never be used":

https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#using-backslashes-for-with-statements

On Wed, 2023-02-22 at 01:24 -0800, Edmondo Giovannozzi wrote:
> Il giorno mercoledì 22 febbraio 2023 alle 09:50:14 UTC+1 Robert
> Latest ha scritto:
> > I found myself building a complicated logical condition with many
> > ands and ors 
> > which I made more manageable by putting the various terms on
> > individual lines 
> > and breaking them with the "\" line continuation character. In this
> > context it 
> > would have been nice to be able to add comments to lines terms
> > which of course 
> > isn't possible because the backslash must be the last character on
> > the line. 
> > 
> > Question: If the Python syntax were changed to allow comments after
> > line-ending 
> > backslashes, would it break any existing code? I can't think of an
> > example.
> 
> Well you can if you use parenthesis like in:
> x = 5
> a = (x > 3 and
> # x < 21 or
>  x > 100
>  )
> You don't need the "\" to continue a line in this case
> 

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


Re: Typing Number, PyCharm

2023-02-06 Thread Paul Bryan
On Mon, 2023-02-06 at 12:11 +, Weatherby,Gerard wrote:

> On the one hand, it is a well-known type, so it should be
> recognizable to users of an API. On the other hand, Number is
> entirely abstract, so it doesn’t provide useful type checking for the
> implementation; I had to add # noinspection PyTypeChecker to 2 *
> value to keep PyCharm from complaining. Additionally, it does not
> include the Decimal type.

Hmm...

Python 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from numbers import Number
>>> from decimal import Decimal as D
>>> isinstance(D("1.0"), Number)
True

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


Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Paul Bryan
On Thu, 2023-01-19 at 09:47 +1300, dn via Python-list wrote:

> The longer an identifier, the more it 'pushes' code over to the right
> or 
> to expand over multiple screen-lines. Some thoughts on this are
> behind 
> PEP-008 philosophies, eg line-limit.

I sympathize with this issue. I've pushed the line limit to 96, which
in my case removed this pain point. My argument—though subjective—is
that we have wide screens now, and it's quite unlikely production code
will be accessed through a vintage VT-100 terminal or printed on a 80-
column dot-matrix printer. That said, even if you stick to PEP-8
proper, `black` does most of the formatting work, and it seems to do a
reasonable job despite longer module identifiers.

> In the body of the code, if every time an external identifier is used
> it 
> must be prefixed by a full 'path', the cognitive "burden" shifts from
> the aspect highlighted (above), to a reading-burden. Thus, (in
> extreme 
> cases) moving towards a 'wall of text' problem.

I tend to agree this can be a problem in some cases, but I think those
can be made manageable. For brevity's sake, I import often-used data
types directly into the module's name space. It's far more rare that I
try to abbreviate a module name; common ones like importing pandas as
pd is a good counterexample.

> In using TDD, code is constructed module-by-module (not necessarily
> a 
> Python Module). So, when it comes time to call
> avMedia.fetch_the_file() 
> [sic] there is little thinking about the "avMedia" bit. The emphasis
> is 
> on the function-name, and it's parameters. 'I need that file so that
> I 
> can ...'.

I'm not entirely sure what you mean by not a Python module. Even in
test modules, I would only import what's required. If it turns out
`fetch_the_file` is called dozens of times or more, I would have no
qualm about importing it directly into the test module's namespace so
that it doesn't need to be prefixed at all.

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


Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Paul Bryan
I would suggest allowing each module to define its own imports, don't
import what a module doesn't consume, keep them simple, avoid devising
a common namespace for each, and let tools like isort/black work out
how to order/express them in source files.

On Wed, 2023-01-18 at 10:43 -0800, Dan Kolis wrote:
> This program has lots of files and each is well segregated for a
> concept.
> 
> the top of each as a heap of imports, all identical. Well the very
> top has some one of's
> 
> import os as    os
> import sys as   sys
> import importlib as importlib
> import datetime as  dt
> from   tokenize import  maybe
> import signal
> 
> from   tkinter import filedialog as fd
> from   tkinter.messagebox import    showinfo
> import tkinter as   tk  
> from   tkinter import   ttk
> from   tkinter import   font
>  
> from   PIL import Image as  pl
> from   PIL import ImageTk   as  ii
> 
> # Imports part of this program 
> import aboutTime as tt  # Time dates timestamps and the
> like
> import avMedia as   av  # Audio and maybe video 'someday'
> well definitely lots of TTS text to speech
> import basicSwitchboard as  sc  # First switchboard lurking.
> Kickoff to sequence viewers
> import bestNotifications as bn  # Alerts, modals and
> notifications of many kinds including TK windows
> import bitBlitting as   bb  # Help - # A setup window with
> basic facts written into files and the workspace
> import configSetting as cs  # A setup window with basic facts
> written into files and the workspace
> import devPeeks as  dp  # Developments peek assets code
> for adding features and debugging
> import fileIo as    io  # File reads, writes even some of
> the the pickle and unpickling
> import forFun as    ff  # Staging area for uncertian
> features, also some dynamic code inclusion
> import fractionScreens as   fs  # Common window pieces for TK
> windows in sequence viewers
> import genomeDb as  gd  # IO to from databases external
> files gbk and others sure
> import globalIdeas as   gi  # Common code for stuff used
> everywhere and definition of share DOT OBJECTS
> import insertableEditors as ie  # Text editor(s) and support for
> that, some language issues managed too
> import modalSimple as   mo  # Modal windows icp seq ssues,
> not used much currently
> import osDependant as   od  # Operating system dependant
> calls and adaptions
> import pickle as    pk  # Packaging to and from file
> system for objects especially DOT OBJECTS
> import screenBuilder1 as    sb  # Screen maker for TKinter and
> TKinter ++ windows
> import selectViewer as  sv  # Window for picking which
> sequence viewers are enabled
> import sequencesMaintain as sm  # Touching up temporal version
> issues of DOT OBJECTS
> import sequencesOverview as so  # Working with sequences as macro
> facts, lists, see turn off etc
> import serverHttp1 as   sh1 # Servers for HTTP - User Support
> import serverHttp2 as   sh2 # Servers for HTTP - Protein
> viewing
> import specialFour as   sf  # Classes and stuff for viewer
> four, a very complex viewer
> import stagingNow as    sn  # More stabler new ideas getting
> tried out and moved in
> import taskingFunction as   tf  # Tasker for real timeish event
> processor calls. Has two versions both work
> import toastMaker as    tm  # Notifications
> import transFormations as   xf  # Sequence transFormations from
> mother natures ideas like DNA and RNA
> import unlovedMenus as  um  # Pretty rarely used ond
> fashioned menus. A while interface is in here that works
> import wayOffline as    wo  # Code not discarded but just
> studies, etc
> import windowsX as  wx  # Windows Life ! X11 esp TK not
> MS Windoze ...
> 
> So the file for instance fileIo.py has a duplicate of this.
> 
> I want to be able to call any code by using the two char prefix form
> anywhere. ex: io.get_Sequence(  'abc.fa' )
> 
> this seems weirdly disorderly. when it starts it sort of iterates
> down into objects, backs up etc.
> 
> What's the right way to do this ?
> 
> Thank you
> Dan

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


Re: set.add() doesn't replace equal element

2022-12-30 Thread Paul Bryan
It seems to me like you have to ideas of what "equal" means. You want 
to update a "non-equal/equal" value in the set (because of a different 
time stamp). If you truly considered them equal, the time stamp would 
be irrelevant and updating the value in the set would be unnecessary.


I would:

a) /not/ consider two different leases with two different time stamps 
to be equal, and
b) as already mentioned, store them in another data structure like a 
dictionary.


Not knowing the specifics of the DHCP object structure, if a DHCP lease 
object has some immutable key or other durable immutable attribute, I 
would be inclined to make that the dictionary key, and store the DHCP 
object as the value.



On Fri, Dec 30 2022 at 04:27:56 PM -0600, Ian Pilcher 
 wrote:

On 12/30/22 15:47, Paul Bryan wrote:
What kind of elements are being added to the set? Can you show 
reproducible sample code?


The objects in question are DHCP leases.  I consider them "equal" if
the lease address (or IPv6 prefix) is equal, even if the timestamps 
have

changed.  That code is not small, but it's easy to demonstrate the
behavior.

>>> import datetime
>>> class Foo(object):
... def __init__(self, index):
... self.index = index
... self.timestamp = datetime.datetime.now()
... def __eq__(self, other):
... return type(other) is Foo and other.index == self.index
... def __hash__(self):
... return hash(self.index)
... def __repr__(self):
... return f'Foo({self.index}) created at 
{str(self.timestamp)}'

...
>>> f1 = Foo(1)
>>> s = { f1 }
>>> s
{Foo(1) created at 2022-12-30 16:24:12.352908}
>>> f2 = Foo(1)
>>> f2
Foo(1) created at 2022-12-30 16:24:35.489208
>>> s.add(f2)
>>> s
{Foo(1) created at 2022-12-30 16:24:12.352908}

--

Google  Where SkyNet meets 
Idiocracy





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


Re: set.add() doesn't replace equal element

2022-12-30 Thread Paul Bryan
What kind of elements are being added to the set? Can you show 
reproducible sample code?


On Fri, Dec 30 2022 at 03:41:19 PM -0600, Ian Pilcher 
 wrote:
I just discovered this behavior, which is problematic for my 
particular

use.  Is there a different set API (or operator) that can be used to
add an element to a set, and replace any equal element?

If not, am I correct that I should call set.discard() before calling
set.add() to achieve the behavior that I want?

--

Google  Where SkyNet meets 
Idiocracy


--



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


Re: Are these good ideas?

2022-11-14 Thread Paul Bryan
Seems like this is a use case for context managers and/or context
variables:

https://docs.python.org/3/library/contextlib.html
https://docs.python.org/3/library/contextvars.html


On Mon, 2022-11-14 at 17:14 +, Stephen Tucker wrote:
> Hi,
> 
> I have two related issues I'd like comments on.
> 
> Issue 1 - Global Values
> 
> Some years ago, I had a situation where
> (a) I could supply low-level functions that carry out tasks,
> (b) I needed those functions to communicate with each other, but
> (c) I had no access to the module that invoked my functions.
> 
> In order to achieve this, I hit on the idea that I also supply a
> module
> that I describe as a "global values" module. This module …
> (i) … defines the values that the functions use to communicate with
> each
> other;
> (ii) … is the subject of an import statement in each of my functions;
> (iii) … initialises its values at the start of each run (since the
> import
> only carries out an actual import once per session);
> (iv) … acts as a repository for the values thereafter.
> 
> This solution works well.
> 
> Given that I am not particularly concerned about efficiency,
> (1) Is this a reasonable way to achieve this goal?
> (2) Do you know of any better ways?
> 
> Issue 2 - Passed Parameters
> 
> I am now facing another situation where I am wanting to pass 6 or 7
> parameters down through several layers of logic (function A calling
> function B calling ... ) and for results to be passed back.
> 
> Having had the idea described above, I am considering using it again
> to
> save all the parameter-and-results passing.
> 
> I see nothing wrong with doing that, but I may well be missing
> something!
> 
> Comments, please!
> 
> Stephen Tucker.

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


Re: python 3.10 vs breakage

2022-08-26 Thread Paul Bryan
The pronterface README doc [1] recommends Python 3.6, so I'd say that
it's likely incompatible with changes in Python 3.10. I think your best
option would be to either downgrade to their recommended version of
Python, or file an issue in their GitHub repository to address the
incompatibility. 

[1] https://github.com/kliment/Printrun/blob/master/README.md

On Fri, 2022-08-26 at 17:36 -0400, gene heskett wrote:
> On 8/26/22 16:54, Paul Bryan wrote:
> > Why can't you build linuxcnc with it? Why has Octoprint quit
> > talking to
> > 3d printers? Why won't pronterface buy it? Why can't you find a
> > 4.0.7
> > version of wxPython? Why is it sitting there staring at you? What
> > is
> > bookworm? What is bullseye?
> 
> Bullseye is the current debian-11, buster is last years, bookworm is
> next.
> 
> Linuxcnc builds just fine on armhf buster, with its python-3.9.4.
> fails 
> from 3.10 in bullseye. Pronterface.py can't find wxPython 4.0 or 
> greater, with 4.0.7 installed. Octoprint did work, but has now
> stopped. 
> So my 3d printing has become a sneakernet exercise again. Adding 3 to
> 5 
> more steps between OpenCSAD and the printer that will make my
> designs. 
> The error code file from this mornings attempt to run pronterface.py
> is at
> 
> <http://geneslinuxbox.net:6309/armhf>
> 
> Is there a workaround?
> 
> Thank you.
> > On Fri, 2022-08-26 at 16:37 -0400, gene heskett wrote:
> > > Greetings all;
> > > 
> > > Its now become obvious that 3.10 has broken some things. I can't
> > > build
> > > linuxcnc with it. And
> > > Octoprint has quit talking to 3d printers, now pronterface won't
> > > buy
> > > it,
> > > can't find a 4.0.7
> > > version of wxPython with it sitting there staring at us.
> > > 
> > > Whats chances of a fixed version for bookworm? Or even a bugs
> > > fixed
> > > release for bullseye?
> > > 
> > > Thanks all.
> > > 
> > > Cheers, Gene Heskett.
> > > -- 
> > > "There are four boxes to be used in defense of liberty:
> > >    soap, ballot, jury, and ammo. Please use in that order."
> > > -Ed Howdershelt (Author, 1940)
> > > If we desire respect for the law, we must first make the law
> > > respectable.
> > >    - Louis D. Brandeis
> > > Genes Web page <http://geneslinuxbox.net:6309/>
> > > 
> > 
> 
> 
> Cheers, Gene Heskett.

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


Re: python 3.10 vs breakage

2022-08-26 Thread Paul Bryan
Why can't you build linuxcnc with it? Why has Octoprint quit talking to
3d printers? Why won't pronterface buy it? Why can't you find a 4.0.7
version of wxPython? Why is it sitting there staring at you? What is
bookworm? What is bullseye?

On Fri, 2022-08-26 at 16:37 -0400, gene heskett wrote:
> Greetings all;
> 
> Its now become obvious that 3.10 has broken some things. I can't
> build 
> linuxcnc with it. And
> Octoprint has quit talking to 3d printers, now pronterface won't buy
> it, 
> can't find a 4.0.7
> version of wxPython with it sitting there staring at us.
> 
> Whats chances of a fixed version for bookworm? Or even a bugs fixed 
> release for bullseye?
> 
> Thanks all.
> 
> Cheers, Gene Heskett.
> -- 
> "There are four boxes to be used in defense of liberty:
>   soap, ballot, jury, and ammo. Please use in that order."
> -Ed Howdershelt (Author, 1940)
> If we desire respect for the law, we must first make the law
> respectable.
>   - Louis D. Brandeis
> Genes Web page 
> 

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


Re: subprocess.popen how wait complete open process

2022-08-21 Thread Paul Bryan
Sometimes, launching subprocesses can seem like punishment. I don't
think there is a standard cross-platform way to know when a launched
asynchronous process is "fully open" (i.e. fully initialized, accepting
user input).

On Sun, 2022-08-21 at 02:11 -0700, simone zambonardi wrote:
> Hi, I am running a program with the punishment subrocess.Popen(...)
> what I should do is to stop the script until the launched program is
> fully open. How can I do this? I used a time.sleep() function but I
> think there are other ways. Thanks

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


Re: Information about Dying kernel

2022-08-07 Thread Paul Bryan
Have you tried turning it off and back on again?

On Sun, 2022-08-07 at 18:59 +0200, nhlanhlah198506 wrote:
> Greetings What can I do if my computer said my kernels has died Thank
> you Sent from my Galaxy

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


Re: Which linux distro is more conducive for learning the Python programming language?

2022-08-03 Thread Paul Bryan
I wouldn't say any particular Linux distribution is appreciably better
for Python development than another. I would suggest using a version of
a Linux distribution that supports a recent Python release (e.g. 3.9 or
3.10).

On Thu, 2022-08-04 at 10:22 +0800, Turritopsis Dohrnii Teo En Ming
wrote:
> Subject: Which linux distro is more conducive for learning the Python
> programming language?
> 
> Good day from Singapore,
> 
> May I know which linux distro is more conducive for learning the
> Python programming language?
> 
> Since I have absolutely and totally FREE RHEL developer subscription
> (I don't need to spend a single cent), can I use Red Hat Enterprise
> Linux version 9.0 to learn Python?
> 
> Is it the most popular linux distro for learning Python?
> 
> I just want to know which linux distro and version is more conducive
> for learning Python. Because there are thousands of linux distros out
> there. And I just want to settle down on a particular linux distro
> and
> version.
> 
> Thank you.
> 
> Regards,
> 
> Mr. Turritopsis Dohrnii Teo En Ming
> Targeted Individual in Singapore
> 4 Aug 2022 Thursday
> Blogs:
> https://tdtemcerts.blogspot.com
> https://tdtemcerts.wordpress.com

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


Re: Subtract n months from datetime

2022-06-20 Thread Paul Bryan
Here's how my code does it:


import calendar

def add_months(value: date, n: int):
  """Return a date value with n months added (or subtracted if
negative)."""
  year = value.year + (value.month - 1 + n) // 12
  month = (value.month - 1 + n) % 12 + 1
  day = min(value.day, calendar.monthrange(year, month)[1])
  return date(year, month, day)

Paul

On Tue, 2022-06-21 at 05:29 +0100, Paulo da Silva wrote:
> Hi!
> 
> I implemented a part of a script to subtract n months from datetime.
> Basically I subtracted n%12 from year and n//12 from the month adding
> 12 
> months when it goes<=0. Then used try when converting to datetime
> again. 
> So, if the day is for example 31 for a 30 days month it raises a 
> ValuError exception. Then I subtract 1 to day and repeat.
> 
> The code seems too naive and very very complicated!
> What is the best way to achieve this? Any existent module?
> 
> At the very end, what I want is to subtract nx where x can be y, m,
> w, d 
> for respectively years, months, weeks or days.
> 
> I feel I am missing something here ...
> 
> Thanks.
> Paulo
> 

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


Re: F-string usage in a print()

2022-05-24 Thread Paul Bryan
Try something like:

print(f"Year = {years}, Future value = {future_value}")

On Tue, 2022-05-24 at 21:14 +, Kevin M. Wilson via Python-list
wrote:
> future_value = 0
> for i in range(years):
> # for i in range(months):
>    future_value += monthly_investment
>    future_value = round(future_value, 2)
>    # monthly_interest_amount = future_value * monthly_interest_rate
>    # future_value += monthly_interest_amount
>    # display the result
>    print(f"Year = ", years + f"Future value = \n", future_value)When
> joining a string with a number, use an f-string otherwise, code a
> str() because a implicit convert of an int to str causes a
> TypeError!Well...WTF! Am I not using the f-string function
> correctly...in the above line of code???
> Caddy Man
> 
> Good sense makes one slow to anger, and it is his glory tooverlook an
> offense.
> 
> Proverbs 19:11
> 

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


Re: Non-deterministic set ordering

2022-05-15 Thread Paul Bryan
This may explain it:
https://stackoverflow.com/questions/27522626/hash-function-in-python-3-3-returns-different-results-between-sessions

On Mon, 2022-05-16 at 04:20 +0100, Rob Cliffe via Python-list wrote:
> 
> 
> On 16/05/2022 04:13, Dan Stromberg wrote:
> > 
> > On Sun, May 15, 2022 at 8:01 PM Rob Cliffe via Python-list 
> >  wrote:
> > 
> >     I was shocked to discover that when repeatedly running the
> > following
> >     program (condensed from a "real" program) under Python 3.8.3
> > 
> >     for p in { ('x','y'), ('y','x') }:
> >      print(p)
> > 
> >     the output was sometimes
> > 
> >     ('y', 'x')
> >     ('x', 'y')
> > 
> >     and sometimes
> > 
> >     ('x', 'y')
> >     ('y', 'x')
> > 
> >     Can anyone explain why running identical code should result in
> >     traversing a set in a different order?
> > 
> > 
> > Sets are defined as unordered so that they can be hashed internally
> > to 
> > give O(1) operations for many tasks.
> > 
> > It wouldn't be unreasonable for sets to use a fixed-by-arbitrary 
> > ordering for a given group of set operations, but being
> > unpredictable 
> > deters developers from mistakenly assuming they are ordered.
> > 
> > If you need order, you should use a tuple, list, or something like 
> > https://grantjenks.com/docs/sortedcontainers/sortedset.html
> Thanks, I can work round this behaviour.
> But I'm curious: where does the variability come from?  Is it
> deliberate 
> (as your answer seems to imply)?  AFAIK the same code within the
> *same 
> run* of a program does produce identical results.
> Best wishes
> Rob Cliffe

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


Re: .0 in name

2022-05-13 Thread Paul Bryan
On Fri, 2022-05-13 at 22:02 +, Avi Gross via Python-list wrote:

> So why you wonder where it is documented that variables cannot be
> what you feel like is a bit puzzling! 

I had just assumed on good faith that the request to the documentation
would be so that the OP could determine what is valid identifier
syntax.

Paul


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


Re: .0 in name

2022-05-13 Thread Paul Bryan
On Sat, 2022-05-14 at 00:47 +0800, bryangan41 wrote:

> May I know (1) why can the name start with a number?

The name of an attribute must be an identifier. An identifier cannot
begin with a decimal number.

> (2) where in the doc is it?!

https://docs.python.org/3/reference/lexical_analysis.html#identifiers

Paul

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


Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

2022-04-14 Thread Paul Bryan
I think because minutes and hours can easily be composed by multiplying
seconds. days is separate because you cannot compose days from seconds;
leap seconds are applied to days at various times, due to
irregularities in the Earth's rotation.

On Thu, 2022-04-14 at 15:38 +0200, Loris Bennett wrote:
> "Loris Bennett"  writes:
> 
> > Hi,
> > 
> > With Python 3.9.2 I get
> > 
> >   $ import datetime
> >   $ s = "1-00:01:01"
> >   $ t = datetime.datetime.strptime(s, "%d-%H:%M:%S")
> >   $ d = datetime.timedelta(days=t.day, hours=t.hour,
> > minutes=t.minute, seconds=t.second)
> >   $ d.days
> >   1
> >   $ d.seconds
> >   61
> >   $ d.minutes
> >   AttributeError: 'datetime.timedelta' object has no attribute
> > 'minutes'
> > 
> > Is there a particular reason why there are no attributes 'minutes'
> > and
> > 'hours and the attribute 'seconds' encompasses is the entire
> > fractional
> > day?
> 
> That should read:
> 
>   Is there a particular reason why there are no attributes 'minutes'
> and
>   'hours' and the attribute 'seconds' encompasses the entire
> fractional
>   day?
> 
> > Cheers,
> > 
> > Loris
> -- 
> Dr. Loris Bennett (Herr/Mr)
> ZEDAT, Freie Universität Berlin Email
> loris.benn...@fu-berlin.de

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


Re: for convenience

2022-03-21 Thread Paul Bryan
No, nor did I suggest that you did. `context` is presumably an
attribute in the `bpy` module, for which you are creating a `context`
attribute in your module.

On Mon, 2022-03-21 at 22:31 +0100, Paul St George wrote:
> Hi,
> I do not (knowingly) have a module called ‘context'.
> 
> 
> 
> 
> > On 21 Mar 2022, at 22:24, Paul Bryan  wrote:
> > 
> > Assuming `bpy` is a module, you're creating a new attribute in your
> > module, `context`, that contains a reference to the same object
> > that is referenced in the `context` attribute in the `bpy` module.
> > 
> > On Mon, 2022-03-21 at 22:12 +0100, Paul St George wrote:
> > > 
> > > When I am writing code, I often do things like this:
> > > 
> > > context = bpy.context  # convenience
> > > 
> > > then whenever I need bpy.context, I only need to write context
> > > 
> > > 
> > > Here’s my question:
> > > 
> > > When I forget to use the convenient shorter form 
> > > 
> > > why is bpy.context not interpreted as bpy.bpy.context?
> > > 
> > > 
> > > —
> > > Paul St George
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> > 
> 

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


Re: for convenience

2022-03-21 Thread Paul Bryan
Assuming `bpy` is a module, you're creating a new attribute in your
module, `context`, that contains a reference to the same object that is
referenced in the `context` attribute in the `bpy` module.

On Mon, 2022-03-21 at 22:12 +0100, Paul St George wrote:
> 
> When I am writing code, I often do things like this:
> 
> context = bpy.context  # convenience
> 
> then whenever I need bpy.context, I only need to write context
> 
> 
> Here’s my question:
> 
> When I forget to use the convenient shorter form 
> 
> why is bpy.context not interpreted as bpy.bpy.context?
> 
> 
> —
> Paul St George
> 
> 
> 
> 
> 

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


Re: A Newspaper for Python Mailing Lists

2022-01-11 Thread Paul Bryan
Subscribed. 🙂️

On Wed, 2022-01-12 at 00:35 +0400, Abdur-Rahmaan Janhangeer wrote:
> Added RSS:
> 
> 2.0 unless later versions have some advantages:
> 
> https://pyherald.com/rss.xml
> 
> Kind Regards,
> 
> Abdur-Rahmaan Janhangeer
> about | blog 
> github
> Mauritius
> 

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


Re: A Newspaper for Python Mailing Lists

2022-01-08 Thread Paul Bryan
+1 to RSS.

On Sun, 2022-01-09 at 10:28 +0400, Abdur-Rahmaan Janhangeer wrote:
> Well yes XD though LWN covers Py topics well when it wants
> 
> 
> 1. Yes sure, did not expect RSS interest
> 2. Excuse my blunder, will do!
> 
> On Sun, 9 Jan 2022, 01:15 Peter J. Holzer,  wrote:
> 
> > On 2021-12-26 20:40:03 +0400, Abdur-Rahmaan Janhangeer wrote:
> > > I have started a newspaper (not newsletter) focused
> > > on interesting reads on Python mailing lists. Don't tag
> > > on the fact that holiday seasons are the worst times for
> > > launch according to marketing folks, I started this to note
> > > down interesting mails. This might also be a great way to
> > > bring mailing list gems to a wider readership. So, here's
> > > the url https://pyherald.com/
> > 
> > Something like [LWN](https://lwn.net/) for Python? Neat.
> > 
> > Two suggestions:
> > 
> > 1. Could you add an RSS or Atom feed?
> > 
> > 2. CSS «word-break: break-all» seems like a really weird choice for
> >    English language text. If you really want to break words across
> >    lines, use «hyphens: auto».
> > 
> >     hp
> > 
> > --
> >    _  | Peter J. Holzer    | Story must make more sense than
> > reality.
> > > _|_) |    |
> > > >   | h...@hjp.at |    -- Charles Stross, "Creative
> > > > writing
> > __/   | http://www.hjp.at/ |   challenge!"
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


Re: Custom designed alarm clock

2021-12-18 Thread Paul Bryan
Suggested reading:

https://pypi.org/project/python-for-android/
https://play.google.com/store/apps/details?id=org.qpython.qpy3
https://www.androidauthority.com/an-introduction-to-python-on-android-759685/
https://data-flair.training/blogs/android-app-using-python/

On Sat, 2021-12-18 at 18:36 -0500, Steve wrote:
> 
> I have designed a simple alarm using Python. It has about 10 limes.
> How do I convert it to an app that I can on my android Moto E power
> 2021
> phone?
> 
> Steve
> 

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


Re: Isn't TypeError built in?

2021-12-12 Thread Paul Bryan
Yes, TypeError is built in. The only thing I can think of is that
something has deleted `TypeError` from `__builtins__`? It would be
interesting to see what's in `__builtins__` when `__del__` is called.

On Mon, 2021-12-13 at 12:22 +1100, Mike Dewhirst via Python-list wrote:
> Obviously something is wrong elsewhere but I'm not sure where to
> look. 
> Ubuntu 20.04 with plenty of RAM.
> 
>  def __del__(self):
>  try:
>  for context_obj in self._context_refs:
>  try:
>  delattr(context_obj, self._attr_name)
>  except AttributeError:
>  pass
> 
>  except TypeError:        # THIS IS LINE 96 IN THE APACHE2
> ERROR 
> LOG BELOW
> 
>  # WeakSet.__iter__ can crash when interpreter is
> shutting 
> down due
>  # to _IterationGuard being None.
>  pass
> 
> [Mon Dec 13 01:15:49.875993 2021] [mpm_event:notice] [pid 1033:tid 
> 140446449658944] AH00493: SIGUSR1 received.  Doing graceful restart
> [Mon Dec 13 01:15:49.878443 2021] [so:warn] [pid 1033] AH01574:
> module 
> dav_module is already loaded, skipping
> [Mon Dec 13 01:15:49.885659 2021] [mpm_event:notice] [pid 1033:tid 
> 140446449658944] AH00489: Apache/2.4.41 (Ubuntu) SVN/1.13.0 
> OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming
> normal 
> operations
> [Mon Dec 13 01:15:49.885664 2021] [core:notice] [pid 1033:tid 
> 140446449658944] AH00094: Command line: '/usr/sbin/apache2'
> Exception ignored in: 
> Traceback (most recent call last):
>    File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py",
> line 
> 96, in __del__
> NameError: name 'TypeError' is not defined
> Exception ignored in: 
> Traceback (most recent call last):
>    File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py",
> line 
> 96, in __del__
> NameError: name 'TypeError' is not defined
> 
> Any hints welcome ...
> 
> Thanks
> 
> Mike
> 
> -- 
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
> 

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


Re: Urllib.request vs. Requests.get

2021-12-07 Thread Paul Bryan
Cloudflare, for whatever reason, appears to be rejecting the `User-
Agent` header that urllib is providing:`Python-urllib/3.9`. Using a
different `User-Agent` seems to get around the issue:

import urllib.request

req = urllib.request.Request(
url="https://juno.sh/direct-connection-to-jupyter-server/";,
method="GET",
headers={"User-Agent": "Workaround/1.0"},
)

res = urllib.request.urlopen(req)

Paul

On Tue, 2021-12-07 at 12:35 +0100, Julius Hamilton wrote:
> Hey,
> 
> I am currently working on a simple program which scrapes text from
> webpages
> via a URL, then segments it (with Spacy).
> 
> I’m trying to refine my program to use just the right tools for the
> job,
> for each of the steps.
> 
> Requests.get works great, but I’ve seen people use
> urllib.request.urlopen()
> in some examples. It appealed to me because it seemed lower level
> than
> requests.get, so it just makes the program feel leaner and purer and
> more
> direct.
> 
> However, requests.get works fine on this url:
> 
> https://juno.sh/direct-connection-to-jupyter-server/
> 
> But urllib returns a “403 forbidden”.
> 
> Could anyone please comment on what the fundamental differences are
> between
> urllib vs. requests, why this would happen, and if urllib has any
> option to
> prevent this and get the page source?
> 
> Thanks,
> Julius

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


Re: Advantages of Default Factory in Dataclasses

2021-11-21 Thread Paul Bryan
On Sun, 2021-11-21 at 21:51 +0400, Abdur-Rahmaan Janhangeer wrote:
> 
> On Tue, Nov 16, 2021 at 7:17 PM Paul Bryan  wrote:
> > On Tue, 2021-11-16 at 17:04 +0400, Abdur-Rahmaan Janhangeer wrote:
> > 
> > > A simple question: why do we need field(default_factory ) in
> > > dataclasses?
> > 
> > 
> > To initialize a default value when a new instance of the dataclass
> > is created. For example, if you want a field to default to a dict.
> > A new dict is created for each instance of the dataclass created.
> > 
> 
> 
> Why not have an attribute which returns a deep copy of a dict?

You can certainly write a default factory to return a deep copy. I'm
not understanding your question about the attribute though. Attribute
in what object? What might the code look like using an attribute?

> Like the only advantage of default factory is copying whatever we
> specify? 

The advantage of the default factory is that it can generate a value at
the time a data class is initialized.

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


Re: Advantages of Default Factory in Dataclasses

2021-11-16 Thread Paul Bryan
On Tue, 2021-11-16 at 17:04 +0400, Abdur-Rahmaan Janhangeer wrote:

> A simple question: why do we need field(default_factory ) in
> dataclasses?

To initialize a default value when a new instance of the dataclass is
created. For example, if you want a field to default to a dict. A new
dict is created for each instance of the dataclass created.

> Why not make that field as an attribute return a function?

I do not understand the question.

> Useful implementation examples / use cases appreciated.

Any case where a you want a dataclass field to default to a mutable
value. Examples: dicts, lists, other dataclasses.

Paul

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


Re: Python script seems to stop running when handling very large dataset

2021-10-29 Thread Paul Bryan
With so little information provided, not much light will be shed. When
it stops running, are there any errors? How is the dataset being
processed? How large is the dataset? How large a dataset can be
successfully processed? What libraries are being used? What version of
Python are you using? On what operating system? With how much memory?
With how much disk space is used? How much is free? Are you processing
files or using a database? If the latter, what database? Does it write
intermediate files during processing? Can you monitor memory usage
during processing (e.g. with a system monitor) to see how much memory
is consumed?


On Fri, 2021-10-29 at 23:42 +0100, Shaozhong SHI wrote:
> Python script works well, but seems to stop running at a certain
> point when
> handling very large dataset.
> 
> Can anyone shed light on this?
> 
> Regards, David

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


Re: Request for argmax(list) and argmin(list)

2021-08-31 Thread Paul Bryan
Why not:

>>> l = [1, 3, 5, 9, 2, 7]
>>> l.index(max(l))
3
>>> l.index(min(l))
0

On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> I dont want to import numpy
> 
> argmax(list) 
>    returns index of (left most) max element
> 
>  argmin(list)
>    returns index of (left most) min element

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


Re: src layout for projects seems not so popular

2021-08-31 Thread Paul Bryan
An interesting thread in PyPA (with links to other threads) discussing
src layout:
https://github.com/pypa/packaging.python.org/issues/320

On Tue, 2021-08-31 at 10:53 +0400, Abdur-Rahmaan Janhangeer wrote:
> Greetings list,
> 
> Just an observation. Out of Github's trending repos for
> Python for today, I could find only 2 repos using the src layout.
> Matplotlib and another one.
> https://github.com/trending/python?since=daily
> 
> Kind Regards,
> 
> Abdur-Rahmaan Janhangeer
> about  | blog
> 
> github 
> Mauritius

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


Re: a simple question

2021-07-26 Thread Paul Bryan
It would help to know the error message you get every time.

On Mon, 2021-07-26 at 22:19 +, Glenn Wilson via Python-list wrote:
> I recently downloaded the latest version of python, 3.9.6. Everything
> works except, the turtle module. I get an error message every time ,
> I use basic commands like forward, backward, right and left. My
> syntax is correct: pat.forward(100) is an example. Can you tell me
> what is wrong.
>      thanks, glenn

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


Re: Where to keep local Python modules?

2021-07-23 Thread Paul Bryan
On my Arch Linux box, slightly different path, but still in .local/bin:

pbryan@dynamo:~$ python3
Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', 
'/usr/lib/python3.9/lib-dynload', 
'/home/pbryan/.local/lib/python3.9/site-packages', 
'/usr/lib/python3.9/site-packages']
>>> 


On Fri, 2021-07-23 at 22:46 +0300, Roland Mueller via Python-list
wrote:
> Hello,
> 
> pe 23. heinäk. 2021 klo 21.44 Chris Green (c...@isbd.net) kirjoitti:
> 
> > This isn't a question about how to set PYTHONPATH so that Python
> > code
> > can find imported modules, it's about what is a sensible layout for
> > one's home directory - i.e. where to put Python modules.
> > 
> > I'm running Linux and have a number of Python modules that are only
> > used by my own code.  My top level Python code is all in ~/bin. 
> > I'd
> > prefer to separate the modules so that they don't clutter the name
> > space.
> > 
> > Currently I have my Python modules in a subdirectory of ~/bin and
> > my
> > Python path is set as:-
> > 
> >     PYTHONPATH=/home/chris/bin/pymods
> > 
> > Is this a reasonable approach?  Is there a 'standard' name for the
> > directory containing modules, or a standard place for it?  (I don't
> > mean a system-wide standard place, I mean a 'my' standard place).
> > 
> > Under recent Linux distros there is $HOME/.local/ containing bin
> > and lib
> directories. May be it's ok to use this for user-specific python
> settings
> under Linux.
> 
> E.g. in .bashrc
> export PYTHONPATH=$HOME/.local/python
> 
> Result can be checked then in Python:
> python
> > > > import sys
> > > > sys.path
> ['', '/home/someuser/.local/lib/python', '/usr/lib64/python39.zip',
> '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload',
> '/usr/local/lib/python3.9/site-packages',
> '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-
> packages']
> 
> BR,
> Roland
> 
> 
> 
> 
> > 
> > --
> > Chris Green
> > ·
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


Re: Replacement for Mailman

2021-06-08 Thread Paul Bryan
How about Mailman 3.x on Python 3.x?

On Tue, 2021-06-08 at 15:08 -0400, D'Arcy Cain wrote:
> Given that mailman still runs under 2.7 and that's being deprecated,
> does
> anyone have a suggestion for a replacement?
> 

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


Re: Proposal: Disconnect comp.lang.python from python-list

2021-05-06 Thread Paul Bryan
I do not believe my proposal has reached—or will reach—consensus. It
seems there are some who still value the linkage between the two, and
the S/N ratio is indeed low enough it doesn't warrant changing from the
status quo. Thanks everyone for the consideration and discussion. 

Paul

On Thu, 2021-05-06 at 18:49 +0100, Stestagg wrote:
> Where's this discussion going?
> 
> Let's not get too caught up on definitions or the sizes of everyone's
> respective .. newsgroups.
> 
> Which of the practically possible options are best for this list <->
> newsgroup setup?
> 
> Thanks
> 
> Steve
> 
> On Thu, May 6, 2021 at 6:47 PM Jon Ribbens via Python-list <
> python-list@python.org> wrote:
> 
> > On 2021-05-06, Richard Damon  wrote:
> > > On 5/6/21 9:44 AM, Jon Ribbens via Python-list wrote:
> > > > Sounds like nearly all moderated lists/forums then.
> > > 
> > > Then perhaps you have never been on a real Moderated mailing list
> > > or
> > > Forum.
> > 
> > Ah, the "no true scotsforum" argument ;-)
> > 
> > > > > While you could setup a robo-moderator to do a similar thing,
> > > > > Usenet
> > > > > posters will not have 'pre-subscribed' before posting, and
> > > > > the From
> > > > > address is no where near as relaible as invalid From
> > > > > addresses ARE
> > > > > allowed, and since the message comes via a NNTP injection
> > > > > source relay,
> > > > > non-verifiable. This make the job a LOT harder.
> > > > It makes essentially no difference at all.
> > > It sure does. Have you every actually TRIED to run a moderated
> > > Usenet
> > > group, or know anyone who has, especially a somewhat busy group?
> > 
> > As I already mentioned, I am a moderator of a Usenet group.
> > 
> > > I am presuming that the current gateway isn't bringing all the
> > > messages
> > > from Usenet into the mailing list. This is obvious as we don't
> > > see the
> > > noise here. The Cabal that runs the 'Big-8' doesn't really care
> > > what
> > > sort of filters are added at such a gateway.
> > > 
> > > To setup a moderated group that defines similar filters in place
> > > for
> > > messages getting to Usenet, particularly for a group intended to
> > > replace
> > > a 'reasonably' working unmoderated group, is likely not going to
> > > be
> > > viewed well.
> > 
> > Have you every actually TRIED to run a moderated Usenet group, or
> > know
> > anyone who has, especially a somewhat busy group? Of *course*
> > moderated
> > groups put filters on what they receive, what do you think group
> > moderation is *for* if not to block things?
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


Re: Proposal: Disconnect comp.lang.python from python-list

2021-05-06 Thread Paul Bryan
I will also add that it can get confusing when someone replies to a
newsgroup posting that was originally suppressed to the mailing list.
This has happened as recently as today.

On Thu, 2021-05-06 at 14:36 +, Grant Edwards wrote:
> On 2021-05-06, Chris Angelico  wrote:
> > On Thu, May 6, 2021 at 10:43 AM Avi Gross via Python-list
> >  wrote:
> > > 
> > > Chris,
> > > 
> > > Given some notice, what stops anyone from joining the mailing
> > > list before
> > > there is a divorce between the forums?
> > 
> > Nothing! Nothing at all. That is, if you're talking about *people*.
> > People are absolutely welcome to join. The reason the S/N would
> > improve is all the non-people who post to the newsgroup.
> > 
> > But there are some people who simply don't want to use the mailing
> > list, and that's currently a fully-welcomed option. I won't name
> > names, but there definitely are people who would prefer a
> > newsreader,
> 
> Pointing a newsreader at news.gmane.io allows one to participate in
> the mailing list just fine without using Usenet.
> 
> Not that I support shutting down the Usenet/email gateway -- the
> signal/noise ration seems fine to me.
> 
> --
> Grant
> 
> 

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


Re: Proposal: Disconnect comp.lang.python from python-list

2021-05-05 Thread Paul Bryan
What's involved in moderating c.l.p? Would there be volunteers willing
to do so?

On Thu, 2021-05-06 at 00:43 +, Jon Ribbens via Python-list wrote:
> On 2021-05-06, Chris Angelico  wrote:
> > On Thu, May 6, 2021 at 10:32 AM Paul Bryan  wrote:
> > > 
> > > Given the ease of spoofing sender addresses, and its propensity
> > > for use
> > > in anonymous spamming and trolling (thanks python-list-owner for
> > > staying on top of that!), I propose to disconnect
> > > comp.lang.python from
> > > the python-list mailing list. Both would then operate
> > > independently.
> > > 
> > 
> > As someone who exclusively follows the mailing list, I selfishly
> > want
> > to support this, as it would notably improve the signal-to-noise
> > ratio. But I'm aware that there are a number of good people who
> > currently use the newsgroup, and those people would then be
> > abandoned
> > in the cess-pool.
> 
> Counter-proposal that I have suggested several times before that
> would
> solve both these problems: make the newsgroup moderated.
> 
> (Or, I suppose, create comp.lang.python.moderated and gateway it
> to the mailing list, and disconnect comp.lang.python from the list.)

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


Proposal: Disconnect comp.lang.python from python-list

2021-05-05 Thread Paul Bryan
Given the ease of spoofing sender addresses, and its propensity for use
in anonymous spamming and trolling (thanks python-list-owner for
staying on top of that!), I propose to disconnect comp.lang.python from
the python-list mailing list. Both would then operate independently.

Paul

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


Re: Not found in the documentation

2021-04-26 Thread Paul Bryan
I agree. I would be useful for it to be documented elsewhere,
especially in docstrings. I wonder if this is/was a conscious decision
to keep Python runtime smaller?

Paul

On Mon, 2021-04-26 at 18:24 -0700, elas tica wrote:
> Le mardi 27 avril 2021 à 01:44:04 UTC+2, Paul Bryan a écrit :
> > From
> > https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy
> >  
> > : 
> > 
> 
> 
> Thanks for the reference. I was expecting to find this information in
> the Built-in Types section from the PSL documentation. The
> representation returned by str over a complex number is not stated.
> The same for fraction objects. All the docstrinds are meaningless,
> showing :
> 
> __str__(self)
>     str(self)
> (END)
> 
> not very informative.

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


Re: Not found in the documentation

2021-04-26 Thread Paul Bryan
From 
https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy
:

> The string representations of the numeric classes, computed
> by__repr__() and __str__(), have the following properties:
>  * They are valid numeric literals which, when passed to their
>class constructor, produce an object having the value of the
>original numeric.
>  * The representation is in base 10, when possible.
>  * Leading zeros, possibly excepting a single zero before a
>decimal point, are not shown.
>  * Trailing zeros, possibly excepting a single zero after a
>decimal point, are not shown.
>  * A sign is shown only when the number is negative.

Paul

On Mon, 2021-04-26 at 16:24 -0700, elas tica wrote:
> 
> Python documentation doesn't seem to mention anywhere what is the str
> value of an int: is it right?  the same for float, Fraction, complex,
> etc? Not worth to be documented? Perphaps str(42) returns "forty two"
> or "XLII" or "101010" ...

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


Re: Current thinking on required options

2021-04-19 Thread Paul Bryan
Calling them options—when they're required—seems like a problem. 🙂

On Mon, 2021-04-19 at 09:04 -0700, Dan Stromberg wrote:
> On Mon, Apr 19, 2021 at 2:55 AM Loris Bennett
> 
> wrote:
> 
> > However, the options -o, -u, and -g are required, not optional.
> > 
> > The documentation
> > 
> >   https://docs.python.org/3/library/argparse.html#required
> > 
> > advises against required options and here
> > 
> > 
> > https://stackoverflow.com/questions/24180527/argparse-required-arguments-listed-under-optional-arguments
> > 
> > a way of adding a section 'required arguments' to the usage is
> > described.
> > 
> 
> Of _course_ some options need to be required.
> 
> I can't imagine what the author of that page was thinking.

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


Re: Website

2021-04-14 Thread Paul Bryan
Yes.

On Wed, 2021-04-14 at 15:41 +0200, Rainyis wrote:
> Hello,
> I am Sergio Llorente, and I want to create a web about python. I
> will publish apps, scripts.. made by python. I will like to put
> python in
> the domain. The domain will be like all-about-python.com but in
> Spanish(
> todosobrepython.com). Can I use it?
> 
> Thanks in advance,
> Sergio

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


Re: question about basics of creating a PROXY to MONITOR network activity

2021-04-10 Thread Paul Bryan
Cloudflare operates as a reverse proxy in front of your service(s);
clients of your services access them through an endpoint that
Cloudflare stands up. DNS records point to Cloudflare, and TLS
certificates must be provisioned in Cloudflare to match. For all
intents and purposes, you would be outsourcing a part of your service
network infrastructure to Cloudflare.

Paul 

On Sat, 2021-04-10 at 13:35 -0500, Christian Seberino wrote:
> > 
> > a) your reverse proxy must be colocated with the service it fronts
> > on the same machine;
> > b) your network infrastructure transparently encrypts traffic
> > between your proxy and the service; or 
> > c) your proxy must negotiate its own TLS connection(s) with the
> > service.
> > 
> 
> 
> Paul
> 
> Thanks. I'm curious, do you know which of your options CloudFlare
> uses?  It has to stand in between
> you and all the sites you visit while allowing encryption right?
> 
> cs 

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


Re: question about basics of creating a PROXY to MONITOR network activity

2021-04-10 Thread Paul Bryan
There is absolutely nothing wrong with building your own reverse proxy
in front of your own service, as long as you control both. This
constitutes a tiered network/application architecture, and it's a
common practice. There's no man in the middle; there's no imposter; its
all "you". 

If your proxy becomes the endpoint that clients now must connect to
(i.e. nothing "in front" of your new proxy), you will have to deal with
TLS (aka SSL). Having the TLS certificate match the DNS address of your
new endpoint is a central tenet of security, and allows clients to
trust that they are connecting to the intended endpoint (there is
not a man in the middle).

How you secure the network traffic between your proxy and the service
it fronts becomes an important factor. If you claim that data is always
encrypted in transit, then either:

a) your reverse proxy must be colocated with the service it fronts on
the same machine;
b) your network infrastructure transparently encrypts traffic between
your proxy and the service; or 
c) your proxy must negotiate its own TLS connection(s) with the
service.

Negotiating TLS connections independently for each hop through a
network will add overhead, and degrade the performance of your service.
This can be major pain point when composing an application of
microservices, where each service must be able to securely connect to
another over a network. This is where a service mesh proxy (e.g. Envoy)
comes into play, or even full blown service mesh with service
discovery, certificate management, access policies (e.g. Istio). 


On Sat, 2021-04-10 at 07:52 -0700, cseb...@gmail.com wrote:
> 
> > Is it even possible to be secure in that way? This is, by
> > definition, 
> > a MITM, and in order to be useful, it *will* have to decrypt 
> > everything. So if someone compromises the monitor, they get 
> > everything. 
> 
> Chris
> 
> I hear all your security concerns and I'm aware of them.  I *really*
> don't want to have to
> fight SSL.  Encryption was the biggest concern and I'd rather not
> mess with it to do something 
> useful.
> 
> I've never used CloudFlare but if I'm not mistaken, it can be
> considered a useful "MITM" service?
> Do they have to decrypt traffic and increase the attack surface to be
> useful?
> 
> I just want to create a "safe" MITM service so to speak.
> 
> cs

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


Re: Problem in uninstalling python

2021-04-09 Thread Paul Bryan
Please describe your problem in detail.

Paul


On Fri, 2021-04-09 at 11:03 +0530, arishmallick...@gmail.com wrote:
>    I am encountering problem in uninstalling python. Please help me
> in this.
> 
> 
> 
>    Sent from [1]Mail for Windows 10
> 
> 
> 
> References
> 
>    Visible links
>    1. https://go.microsoft.com/fwlink/?LinkId=550986

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


Re: Code Formatter Questions

2021-03-28 Thread Paul Bryan
On Sun, 2021-03-28 at 15:42 +, Travis Griggs wrote:
> I've been looking into using a code formatter as a code base size has
> grown as well as contributing developers. I've found and played with
> autopep, black, and yapf. As well as whatever pycharm has (which may
> just be gui preferences around one of those 3).
> 
> I have 2 questions:
> 1) Are there any major other formatters that I can/should look at? I
> see some "online" pretty printers, but I'm after something I can run
> on whole recursive directories of code.

I assume you mean autopep8. I'm not aware of any other currently
popular formatters. 

> 2) I use more and type annotations (at least at the trivial level).
> But I like to have variable annotations tightly bound to the
> identifier, kind of like a subscript. So I want to see 
> 
>   def foo_bar(baz:int) -> bool:
>     yak:str = 'howdy mates'
> 
> And NOT 
> 
>   def foo_bar(baz: int) -> bool:
>     yak: str = 'howdy mates'
> 
> In other cases though (dictionaries for example), I'm fine with (and
> prefer) the spacing.
> 
> Is there anyway to make any of these formatters do this?

Formatters are typically strongly opinionated (autopep8 being an
exception), so I think you'll be going against the grain by trying to
make exceptions. I suggest accepting their opinions (pick the formatter
that most closely aligns with your taste), or, if you can make a case
for general use, suggest/request one change their opinions.

Paul

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


Re: .title() - annoying mistake

2021-03-21 Thread Paul Bryan
The topic of titles is complex, and would be significant undertaking to
automate. It's not only highly language-dependent, it's also based on
the subject work itself, and subject to guidelines of those charged
with indexing such works.

MusicBrainz guidelines:
https://wiki.musicbrainz.org/Style/Titles
https://wiki.musicbrainz.org/Style#Language_specific_guidelines

Wikipedia guidelines:
https://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(capitalization)
https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Titles#Capital_letters

Addressing such complexities isn't going to be baked into the
simplistic `str.title` method. As demonstrated by the OP, it will
almost certainly come up short, even in the simplest use case. I
suggest the best approach then is to find (or write) a module that
addresses the specific use case, not try to address such shortcomings
in `str`.

Paul

On Sun, 2021-03-21 at 23:01 +1100, Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
>  wrote:
> > 
> > Chris Angelico wrote:
> > > On Sun, Mar 21, 2021 at 4:31 AM Robert Latest via Python-list
> > >  wrote:
> > > > 
> > > > Mats Wichmann wrote:
> > > > > The problem is that there isn't a standard for title case,
> > > > 
> > > > The problem is that we owe the very existence of the .title()
> > > > method to too
> > > > much weed being smoked during Python development. It makes
> > > > specific
> > > > assumptions about a specific use case of one specific language.
> > > > It doesn't
> > > > get more idiotic, frankly.
> > > > 
> > > 
> > > The problem is that you haven't read the documentation :) It very
> > > carefully
> > > does NOT define itself by language, and its behaviour is
> > > identical regardless
> > > of the language used.
> > 
> > The documentation says: "The algorithm uses a simple language-
> > independent
> > definition of a word as groups of consecutive letters..."
> > 
> > Yes, I get that. But the purpose it (improperly) serves only makes
> > sense in the
> > English language.
> 
> Why? Do titles not exist in other languages? Does no other language
> capitalize words in book or other titles?
> 
> ChrisA

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


Re: .title() - annoying mistake

2021-03-19 Thread Paul Bryan
From https://docs.python.org/3.9/library/stdtypes.html#str.title:

> The algorithm uses a simple language-independent definition of a word
> as groups of consecutive letters. The definition works in many
> contexts but it means that apostrophes in contractions and
> possessives form word boundaries, which may not be the desired result

The link above includes a workaround for apostrophes.

Paul

On Fri, 2021-03-19 at 18:43 +0400, Abdur-Rahmaan Janhangeer wrote:
> Greetings list,
> 
> See this:
> 
> > > > "Python's usage".title()
> "Python'S Usage"
> 
> It should have been Python's Usage
> 
> Why capitalise the S?
> 
> Kind Regards,
> 
> Abdur-Rahmaan Janhangeer
> about  | blog
> 
> github 
> Mauritius

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


Re: SSL certificate issue

2021-03-18 Thread Paul Bryan
In order for us to help, we'll need to know the details of your
problem.

On Thu, 2021-03-18 at 10:58 +, Sagar, Neha wrote:
> Hi,
> 
> I am facing SSL certificate issue working with python. Can you help
> me on this.
> 
> Thanks,
> Neha
> 
> DXC Technology India Private Limited - Unit 13, Block 2, SDF
> Buildings, MEPZ SEZ, Tambaram, Chennai 600 045, Tamil Nadu.
> Registered in India, CIN: U72900TN2015FTC102489.
> DXC Technology Company -- This message is transmitted to you by or on
> behalf of DXC Technology Company or one of its affiliates. It is
> intended exclusively for the addressee. The substance of this
> message, along with any attachments, may contain proprietary,
> confidential or privileged information or information that is
> otherwise legally exempt from disclosure. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the
> intended recipient of this message, you are not authorized to read,
> print, retain, copy or disseminate any part of this message. If you
> have received this message in error, please destroy and delete all
> copies and notify the sender by return e-mail. Regardless of content,
> this e-mail shall not operate to bind DXC Technology Company or any
> of its affiliates to any order or other contract unless pursuant to
> explicit written agreement or government initiative expressly
> permitting the use of e-mail for such purpose.

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


Re: Apriori Algorithm

2021-03-06 Thread Paul Bryan
Google tells me this:
https://github.com/tommyod/Efficient-Apriori

On Sat, 2021-03-06 at 18:46 -0800, sarang shah wrote:
> I want to make apriori algorithm from start. Anybody have any
> reference file?

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


Re: program python

2021-03-04 Thread Paul Bryan
I don't see a Python program in that link.

Are you asking how to extract data from a CSV?
A good start will be to look into the csv.reader function and
csv.DictReader class.

Paul

On Thu, 2021-03-04 at 12:36 -0800, alberto wrote:
> Hi I'm tring to write a program with python to evaluate data of csv
> data
> In particular I would extract this information 
> 
> View data on the presence of men and women in Affori over time.
> 
> * Carry out an analysis relating to the last available year. Of the
> 10 most populous neighborhoods show:
> * the proportion of births out of the total
> * the proportion of 80+ to the total
> * The ratio of minors / number of kindergartens
> 
> this is the file
> https://drive.google.com/file/d/1zKflvSpB-oDAqYscLsEgUhSnqL1XPdql/view?usp=sharing
> 
> How could fix it?
> 
> regards 

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


Re: Fw: Scipy installation

2021-02-18 Thread Paul Bryan
Can you describe what you tried, and how it failed? Pasting error
messages and such would be helpful.

On Thu, 2021-02-18 at 17:53 +, Mustafa Althabit via Python-list
wrote:
>  
> 
>    Hi,I am trying to install Scipy but it failed, I have python
> 3.9. I need your assistance with that. 
> Thank you Mustafa Althabit8133825988  

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


Re: New Python implementation

2021-02-11 Thread Paul Bryan
On Thu, 2021-02-11 at 17:56 +, Mr Flibble wrote:

> Actually it is a relatively small task due to the neos universal
> compiler's architectural design.  If it was a large task I wouldn't
> be doing it.

When do you estimate this task will be completed?

> I am not particularly interested in any of the existing
> implementations as they bear no relation to the design of my language
> agnostic universal compiler, runtime, VM and JIT; the only use they
> will have will be to disambiguate certain Python language constructs
> that I cannot disambiguate from documentation alone: this is a
> natural consequence of Python not being standardized; those steering
> the language need to grow a pair and get Python standardized
> preferably as an ISO Standard.

I take it you don't hope to receive any support from those you're
insulting by such a statement?

> Thanks for the sentiment but I am not relying on luck.

By your conduct so far, I think you will also not be relying on the
goodwill of this community.

Paul

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


Re: Mutable defaults

2021-02-10 Thread Paul Bryan
Also -1 on changing the existing default behavior. +1 to an opt-in
late-bound solution.

On Thu, 2021-02-11 at 10:29 +1100, Chris Angelico wrote:
> On Thu, Feb 11, 2021 at 10:17 AM J. Pic  wrote:
> > 
> > > Most of us know of the perils of mutable default values.
> > 
> > And those who don't pay the price.
> > 
> > I wonder what would be the harm in removing them
> 
> Define "removing". Most objects in Python are mutable; would that
> mean
> you can no longer use any custom class, or any object at all that has
> a __dict__, as a default?
> 
> > or doing copy on call by default.
> 
> I assume you are referring only to argument defaults, because
> copy-on-call for ALL parameters would be ridiculously costly, not to
> mention problematic in many ways.
> 
> The main problem is that mutable defaults are only very rarely an
> issue (for starters, you have to actually mutate the object - just
> because it's mutable, that doesn't mean you'll change anything), but
> any global "solution" to the "problem" is going to have a very high
> global cost. Not every mutable object is copyable. And it would have
> to be a deep copy (in case, for instance, the default is a tuple
> containing a list), which has even more cost.
> 
> Strongly -1 on any proposal to change the defaults.
> 
> Now, if you're interested in some kind of proposal for opt-in
> late-bound defaults, I think there'd be some value in researching
> that. It would probably require language support, but there'd be a
> few
> potential advantages:
> 
> 1) The function signature would actually say the real default. For
> instance, "def flurble(stuff=[]):" shows that the default is a list,
> but "def flurble(stuff=None): if stuff is None: stuff = []" doesn't.
> 2) This could be more flexible than just copying. The default could
> simply be an expression that's evaluated at call time, and could even
> refer to other arguments (eg "def frob(things, start=0,
> stop=len(things)):"), and, again, the displayed signature would show
> the real default, instead of some placeholder.
> 3) It's far cleaner to read a coherent function signature than to
> have
> to read a handful of lines at the top of the function. That's why we
> have defaults in the first place.
> 
> But this would depend heavily on finding a really good syntax for it.
> It's been investigated at times, but no proposal has ever been strong
> enough to push forward. Feel free to try a few things out, see if you
> can find something that makes sense.
> 
> ChrisA

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


Re: Python cannot count apparently

2021-02-07 Thread Paul Bryan
That's not the only problem with the code. There's a missing close-
paren and a reference to "string" which I presume was meant to be
"myString".

Suggest OP create a reproducible case, and paste the code and output
verbatim.


On Sun, 2021-02-07 at 20:40 +0100, Karsten Hilbert wrote:
> Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via
> Python-list:
> 
> > I recently coded this snippet of code:
> > myString=„hello“
> 
> I doubt you have (coded *this* snippet of code) -- because
> those quotes wouldn't work.
> 
> Karsten
> --
> GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

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


Re: IDE tools to debug in Python?

2021-01-27 Thread Paul Bryan via Python-list
My experience with IntelliJ (related to PyCharm): it scans all source
files in the project, compiles them, graphs all dependencies, compiles
those (if necessary) or inspects their class bytecode, and so on to
build a full graph in memory to support showing errors in real time
(highlighting in source) and autocomplete when user is typing. In my
experience, it's heavyweight, and creates more reliance on the features
of an IDE than I feel is healthy (IDE becomes a crutch). I suspect
PyCharm is doing much of the same.

On Wed, 2021-01-27 at 15:36 -0500, C W wrote:
> I don't know exactly, but it shows as inspection on the bottom left
> corner.
> 
> I believe it's indexing in the background.
> 
> On Wed, Jan 27, 2021 at 3:25 PM Grant Edwards
> 
> wrote:
> 
> > On 2021-01-27, C W  wrote:
> > > I'm not expert in Python, but I sure tried many IDEs to kick off
> > > Python
> > > programming.
> > > 
> > > I started with PyCharm, but I had a problem with it constantly
> > > scanning
> > the
> > > background, even after I turned that feature off.
> > 
> > What is it scanning?
> > 
> > > My favorite (I'm using now) is VS Code with Python extension,
> > > it's very
> > > light. Recently also started background scanning, but that's
> > > generally
> > done
> > > in 30 seconds.
> > 
> > Same question, what is it scanning?
> > 
> > --
> > Grant
> > 
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Paul Bryan
Maybe this will help:

>>> def get(key, default):
...   print("entering get")
...   print(f"{key=} {default=}")
...   print("exiting get")
... 
>>> def generate_default():
...   print("entering generate_default")
...   print("exiting generate_default")
...   return 1
... 
>>> get("a", generate_default())
entering generate_default
exiting generate_default
entering get
key='a' default=1
exiting get
>>> 

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Paul Bryan
On Wed, 2020-12-16 at 10:01 +0100, Loris Bennett wrote:

> OK, I get the point about when the default value is generated and
> that
> potentially being surprising, but in the example originally given,
> the
> key 'a' exists and has a value of '1', so the default value is not
> needed.

But the function is still called. The get method just doesn't use (or
return) the value it generates because the key exists. Nevertheless,
you're passing the return value of the get_default function as an
argument.

> Thus, I am still unsurprised when dict.get returns the value of an
> existing key.

As am I.

> What am I missing?

You'll need to tell me at this point.

Paul

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


Re: dict.get(key, default) evaluates default even if key exists

2020-12-16 Thread Paul Bryan
On Wed, 2020-12-16 at 08:59 +0100, Loris Bennett wrote:

> Isn't the second argument to D.get() the value to be return if the
> first
> argument is not a valid key?  In that case, why does it make any
> difference here what the second argument of D.get() is since the key
> 'a'
> does exist?
> 
> Thus, I would indeed expect the code above to print '1'.  I am
> obviously
> missing something here.

Yes, the second argument is what to return if there is no valid key.
The second argument is evaluated before the call to the get function.
It's return value is being supplied as an argument to the get function.

Let's write a couple of quick functions to demonstrate...

>>> def get(key, default):
...   print(f"{key=} {default=}")
... 
>>> def generate_a_default_value():
...   return 1
... 
>>> get("a", generate_a_default_value())
key='a' default=1
>>> 

The generate_a_default_value function was called before the call to
get. It was called so it could produce a value that is actually passed
in as an argument to the get function.

Paul

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


Re: Function returns old value

2020-12-11 Thread Paul Bryan
Sorry, actually, if you do not answer yes, will always return None, not
the first answer as I suggested.

On Fri, 2020-12-11 at 18:55 -0700, Joe Pfeiffer wrote:
> Bischoop  writes:
> 
> > I've function asking question and comparing it, if is not matching
> > 'yes'
> > it does call itself to ask question again. The problem is that when
> > function is called second time it returns old value or with
> > additional
> > else statement it returns none.
> > 
> > Code: https://bpa.st/KVGA
> 
> It calls itself again, but what does it return in that case?

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


Re: Function returns old value

2020-12-11 Thread Paul Bryan
It won't return until the inner call to question (and it's not using
the return value on inner call). Eventually, (and not until you answer
yes) it will return the first answer.

On Fri, 2020-12-11 at 18:55 -0700, Joe Pfeiffer wrote:
> Bischoop  writes:
> 
> > I've function asking question and comparing it, if is not matching
> > 'yes'
> > it does call itself to ask question again. The problem is that when
> > function is called second time it returns old value or with
> > additional
> > else statement it returns none.
> > 
> > Code: https://bpa.st/KVGA
> 
> It calls itself again, but what does it return in that case?

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


Re: Property type hints?

2020-12-09 Thread Paul Bryan
Thanks for the comprehensive response, dn!

I guess I'm influenced by data classes here, where the object's
attribute type hints are represented by class variable annotations.


On Thu, 2020-12-10 at 07:49 +1300, dn via Python-list wrote:
> On 09/12/2020 13:17, Paul Bryan wrote:
> > Would this be a reasonably correct way to annotate a property with
> > a
> > type hint?
> > 
> > > > > class Foo:
> > ... bar: int
> 
> 
> If we build a class with (only) the above two lines, Python's help 
> lookup offers the following documentation:
> 
> <<<
> Help on Foo in module __main__ object:
> 
> class Foo(builtins.object)
>   |  Data descriptors defined here:
>   |
>   |  __dict__
>   |  dictionary for instance variables (if defined)
>   |
>   |  __weakref__
>   |  list of weak references to the object (if defined)
>   |
>   |  
> --
>   |  Data and other attributes defined here:
>   |
>   |  __annotations__ = {'bar': }
>  >>>
> 
> Note the last line identifying 'bar' as having integer-type.
> 
> However, when we continue, by adding a property/lookup-method called
> 'bar'.
> 
> > ... @property
> > ... def bar(self):
> > ... return 1
> 
> 
> ...the help lookup becomes:
> 
> <<<
> class Foo(builtins.object)
>   |  Readonly properties defined here:
>   |
>   |  bar
>   |
>   |  
> --
>   |  Data descriptors defined here:
>   |
>   |  __dict__
>   |  dictionary for instance variables (if defined)
>   |
>   |  __weakref__
>   |  list of weak references to the object (if defined)
>   |
>   |  
> --
>   |  Data and other attributes defined here:
>   |
>   |  __annotations__ = {'bar': }
>  >>>
> 
> Note that 'bar' has now been listed as a read-only property.
> 
> Further, if we remove the explicit typing (int) of 'bar', the help 
> listing doesn't change.
> 
> 
> <<<
> class Foo(builtins.object)
>   |  Readonly properties defined here:
>   |
>   |  bar
>   |
>   |  
> --
>   |  Data descriptors defined here:
>   |
>   |  __dict__
>   |  dictionary for instance variables (if defined)
>   |
>   |  __weakref__
>   |  list of weak references to the object (if defined)
>  >>>
> 
> Except that the annotation documentation has disappeared!
> 
> Hence, one assumes, the question!
> 
> The problem is that the help system appears to be talking about two 
> different things: 'bar' the class int, and 'bar' the method/property.
> At 
> run-time however, there cannot be two uses of the same name, and the 
> last-defined 'wins'.
> 
> Continuing:-
> 
> > ...
> > > > > foo = Foo()
> > > > > import typing
> > > > > typing.get_type_hints(foo)
> > {'bar': }
> > 
> > I could also decorate the property method return value:
> > ... def bar(self) -> int:
> 
> ...and when the typing-hint is added to the property's def, the help 
> listing still doesn't change/improve.
> 
> 
> That said, I've been following this last convention since moving to
> typing.
> 
> Putting a separate description at the beginning of the class invites
> the 
> reader to think of 'foo' as an integer. That's not 'wrong', in the
> sense 
> that a property is/produces an attribute in the same dotted-notation 
> from the object-name. However,there could be quite a lot of code
> between 
> this 'declaration' line and the property def!
> 
> However, there is another line of logic built upon the idea that all 
> class-attributes should be defined in the class 'header' and all 
> instance-attributes in __init__() or __post_init__(). Does this
> underlie 
> the discussion?
> 
> 
> > I don't see the point though, because you can't access it with
> > get_type_hints.
> 
> Correct: if one codes (only) the property-bar, then:
> 
>  >>> get_type_hints( Foo )
> {}
> 
> However, reverting back to the first class-definition, we do see 
> something for our money:
> 
>  >>> get_type_hints( foo )
> {'bar': }
> 
> Unfortunately, as mentioned above, there is this confusion between
> th

Property type hints?

2020-12-08 Thread Paul Bryan
Would this be a reasonably correct way to annotate a property with a
type hint?

>>> class Foo:
... bar: int
... @property
... def bar(self):
... return 1
... 
>>> foo = Foo()
>>> import typing
>>> typing.get_type_hints(foo)
{'bar': }

I could also decorate the property method return value:
... def bar(self) -> int:

I don't see the point though, because you can't access it with get_type_hints.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help(list[int]) → TypeError

2020-12-04 Thread Paul Bryan
Thanks, will bring it to the dev list.

On Fri, 2020-12-04 at 07:07 -0800, Julio Di Egidio wrote:
> On Thursday, 3 December 2020 at 19:28:19 UTC+1, Paul Bryan wrote:
> > Is this the correct behavior? 
> > 
> > Python 3.9.0 (default, Oct 7 2020, 23:09:01) 
> > [GCC 10.2.0] on linux 
> > Type "help", "copyright", "credits" or "license" for more
> > information. 
> > > > > help(list[int]) 
> > Traceback (most recent call last): 
> > File "", line 1, in  
> > File "/usr/lib/python3.9/_sitebuiltins.py", line 103, in __call__ 
> > return pydoc.help(*args, **kwds) 
> > File "/usr/lib/python3.9/pydoc.py", line 2001, in __call__ 
> > self.help(request) 
> > File "/usr/lib/python3.9/pydoc.py", line 2060, in help 
> > else: doc(request, 'Help on %s:', output=self._output) 
> > File "/usr/lib/python3.9/pydoc.py", line 1779, in doc 
> > pager(render_doc(thing, title, forceload)) 
> > File "/usr/lib/python3.9/pydoc.py", line 1772, in render_doc 
> > return title % desc + '\n\n' + renderer.document(object, name) 
> > File "/usr/lib/python3.9/pydoc.py", line 473, in document 
> > if inspect.isclass(object): return self.docclass(*args) 
> > File "/usr/lib/python3.9/pydoc.py", line 1343, in docclass 
> > (str(cls.__name__) for cls in type.__subclasses__(object) 
> > TypeError: descriptor '__subclasses__' for 'type' objects doesn't
> > apply to a 'types.GenericAlias' object 
> > > > > 
> > 
> > I would have expected the output to the identical to help(list).
> 
> As I get it from the docs (*), these new generics still only work in
> type hinting contexts,
> and I'd rather have expected a more useful error message: but,
> whether that is temporary
> (possibly a plain bug, as in a forgotten case) or, instead, just "how
> things are", I wouldn't
> know... might be a good question for Python developers.
> 
> (*) As in this one for a starter, but see also PEP 585:
> "*In type annotations* you can now use ...", my emphasis.
> <https://docs.python.org/3.9/whatsnew/3.9.html#type-hinting-generics-in-standard-collections
> >
> 
> Julio

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


Re: list[type, type, ...] ?!

2020-12-03 Thread Paul Bryan
Thanks, Greg. Would it make sense for list's __class_getitem__
(GenericAlias?) to perform similar checking as
typing._SpecialGenericAlias (nparams)?

On Fri, 2020-12-04 at 12:15 +1300, Greg Ewing wrote:
> On 3/12/20 7:37 pm, Paul Bryan wrote:
> > > > > list[int, int]
> > list[int, int]
> > 
> > In fact, it appears I can specify an indeterminate number of types.
> 
> I think the built-in generic alias just provides the minimum
> necessary to be able to write sometype[arg, ...]. It doesn't
> know anything about the semantics with respect to particular
> types -- that's left to the type checkers.
> 
> -- 
> Greg

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


help(list[int]) → TypeError

2020-12-03 Thread Paul Bryan
Is this the correct behavior?

Python 3.9.0 (default, Oct  7 2020, 23:09:01) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help(list[int])
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.9/_sitebuiltins.py", line 103, in __call__
return pydoc.help(*args, **kwds)
  File "/usr/lib/python3.9/pydoc.py", line 2001, in __call__
self.help(request)
  File "/usr/lib/python3.9/pydoc.py", line 2060, in help
else: doc(request, 'Help on %s:', output=self._output)
  File "/usr/lib/python3.9/pydoc.py", line 1779, in doc
pager(render_doc(thing, title, forceload))
  File "/usr/lib/python3.9/pydoc.py", line 1772, in render_doc
return title % desc + '\n\n' + renderer.document(object, name)
  File "/usr/lib/python3.9/pydoc.py", line 473, in document
if inspect.isclass(object): return self.docclass(*args)
  File "/usr/lib/python3.9/pydoc.py", line 1343, in docclass
(str(cls.__name__) for cls in type.__subclasses__(object)
TypeError: descriptor '__subclasses__' for 'type' objects doesn't apply to a 
'types.GenericAlias' object
>>> 

I would have expected the output to the identical to help(list).
-- 
https://mail.python.org/mailman/listinfo/python-list


list[type, type, ...] ?!

2020-12-03 Thread Paul Bryan
Using the typing.List generic alias, I can only specify a single type.
Example:

>>> typing.List[int]
typing.List[int]

When I try to specify additional types, it fails. Example:

>>> typing.List[int, int]
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.9/typing.py", line 243, in inner
return func(*args, **kwds)
  File "/usr/lib/python3.9/typing.py", line 775, in __getitem__
_check_generic(self, params, self._nparams)
  File "/usr/lib/python3.9/typing.py", line 197, in _check_generic
raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for 
{cls};"
TypeError: Too many parameters for typing.List; actual 2, expected 1

This makes sense to me. An item has one type, and we use Union if we
want variants. What's not making sense to me in Python 3.9: I can use
the built-in generic alias in list in this manner, apparently
successfully:

>>> list[int, int]
list[int, int]

In fact, it appears I can specify an indeterminate number of types. Can
someone explain what this construct means? I suspect this will fail to
be interpreted by type validators, but wonder why it doesn't fail fast
when I express it.

Thanks,

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


Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-11 Thread bryan . gene . olson
Christian Seberino wrote:
> A beginner I think could learn Lisp much faster than Python.

For talented beginners, Lisp rocks much like Python, in that easy assignments 
are easy enough to implement. On the high end, Lisp rocks again: Lisp masters 
are astonishingly productive. In between, beyond pedagogical exercises but 
short of our Turing Award masterwork, Lisp's extreme flexibility has a 
significant down-side in violating the middle third of Python Zen (PEP 20) 
guiding principle: "There should be one -- and preferably only one -- obvious 
way to do it."

Flexibility is good. In a programming language it's great, and Python is super 
flexible. Lisp is beyond. There are many Lisps, the big two of which are Common 
Lisp (CL) and Scheme. Common Lisp has been more industrially important, but 
Scheme out-Lisps CL. As we deal with Python's recent additions, such as "enum", 
the walrus operator, type hints, and async/await, I remain in awe of [call with 
current current 
continuation](https://en.wikipedia.org/wiki/Call-with-current-continuation), 
which in Scheme is abbreviated "call/cc".
-- 
https://mail.python.org/mailman/listinfo/python-list


RV: CodecRegistryError problem for an IDE.

2020-05-15 Thread Bryan Cabrera Ramírez
   Hi,

    

   I'm trying to insall an INET package for an IDE called OMNeT++ and when

   I try to build the INET the following happens in the command window:

    

    

   Fatal Python error: Py_Initialize: unable to load the file system codec

     File "C:\Python27\Lib\encodings\__init__.py", line 123

       raise CodecRegistryError,\

       ^

   SyntaxError: invalid syntax

    

    

   I did python repair from the setup installer but it still doesn't work.

    

   Do you know what should I do in order to solve the problem ?

    

    

   Best regards,

    

   Thank you,

    

   Bryan Cabrera Ramirez

    

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


Re: How to detect if a file is executable on Windows?

2019-02-19 Thread bryan rasmussen
Well, I used to know the answer to this question but I haven't done this
kind of thing since 2009, so hopefully what I suggest is not out of date,
so for everything I say here assume I put provisos in like it used to be or
whatever.

Anyway if the type of a file is executable , for example a file with
extension .xyz, is determined by the registry in windows
read here and google onward
https://docs.microsoft.com/en-us/windows/desktop/shell/app-registration#finding-an-application-executable

As I recall somewhere in PyWin32
http://timgolden.me.uk/pywin32-docs/contents.html there was a method to
find out if an individual file was an executable.

Hope it helps, because that means I still have some usable knowledge in
that area!

Best Regards,
Bryan Rasmussen



On Tue, Feb 19, 2019 at 2:49 PM Stephane Wirtel  wrote:

> And based on a determinist solution?
>
> Yes, you can check the extension but sometimes I prefer to be sure.
>
> For example, the API of Win32 has the GetTypeBinaryW function, this one
> could be used but I need to create a mapping, with CPython api, ctypes
> or CFFI.
>
> I could also use the 2 first bytes of a file and determine if the file
> is a binary because on Windows, the executable files start with b'MZ'.
>
> But I wanted an elegant and minimalist solution.
>
> Thank you for your proposal.
>
> Have a nice day,
>
> Stéphane
>
> On 02/18, Igor Korot wrote:
> >Hi,
> >
> >On Tue, Feb 19, 2019 at 7:26 AM Stephane Wirtel 
> wrote:
> >>
> >> Hi all,
> >>
> >> on Linux/Unix/BSD, we can detect if a file is an executable with
> >> os.access(path, os.X_OK) but this is not the case on Windows.
> >>
> >> Do you have an idea?
> >
> >Check file extension?
> >
> >Thank you.
> >
> >>
> >> Have a nice day,
> >>
> >> Stéphane
> >>
> >> --
> >> Stéphane Wirtel - https://wirtel.be - @matrixise
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
>
> --
> Stéphane Wirtel - https://wirtel.be - @matrixise
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


pip failed installs

2017-12-16 Thread Bryan Zimmer
Wait! Cancel my last post!

In exploring the virtual environment, I was struck by the existence of an
executable *pip *in the virtual environment's "bin" directory. So I tried
again to install BeautifulSoup, but this time I got a very different error
message. This pip couldn't find BeautifulSoup, unlike the module I had been
using. (My python3.6 installation does not include a command-line
executable pip).

So I reissued the command, this time giving it the name of the module,"bs4".

And this time, pip found and installed beautifulsoup (note the lowercasing)
into my virtual environment!

Thanks for your help.
-- 
https://mail.python.org/mailman/listinfo/python-list


pip failed installs

2017-12-16 Thread Bryan Zimmer
I believe it's because you're installing that into a directory that the
current user has no write privileges for. Try installing those into a
virtual environment (if you don't know what that is, let us know!).

-Jorge

On Sat, Dec 16, 2017 at 1:27 PM, Bryan Zimmer 
wrote:
I have had only partial success with pip. Some things seem to install OK.
But I've tried a couple of packages, specifically "BeautifulSoup" and
"WxPython", and they fail with the same message, e.g.:

*Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-ku98d6jd/BeautifulSoup/*

Thanks for the reply.

I have taken to performing pip installs as root (on Slackware Linux),
precisely because my regular user (baz) does not have the permissions
necessary to install most software. So root, when performing a pip install,
also gets error 1 when trying to install packages.

I did follow your advice and set up a virtual environment using
python3.6's *venv
*module. According to the documentation, installations would go into the
virtual environment if it is activated at install-time. But I got the same
error. This time it took the following form:


*Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-zhuoo23l/BeautifulSoup/*
Permissions on the /tmp directory are 1777, or read-write-execute allowed
for everybody, plus it is a sticky directory (which shouldn't be important
here).
-- 
https://mail.python.org/mailman/listinfo/python-list


pip failed installs

2017-12-16 Thread Bryan Zimmer
I have had only partial success with pip. Some things seem to install OK.
But I've tried a couple of packages, specifically "BeautifulSoup" and
"WxPython", and they fail with the same message, e.g.:

*Command "python setup.py egg_info" failed with error code 1 in
/tmp/pip-build-ku98d6jd/BeautifulSoup/*

I've gotten this error for most of the packages I have tried to install,
but I don't know what causes the error. I have successfully installed some
packages, such as html5lib, so my installation isn't totally messed up.

I am using a Slackware Linux. I have gotten this error message both on a
64-bit installation and a 32-bit installation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Module _socket not found in python3.6 "No module named _socket"

2017-12-06 Thread Bryan Zimmer
I have been getting this message, "No module named '_socket'", since I
installed python 3.6, about two months ago.

My platform is Slackware Linux (14.2). I compiled python3.6 from source,
because binary python packages aren't distributed by python.org for Linux.
I have the same experience on multiple Slackware computers, not just one.
Actually, this problem hits the 64-bit distribution. I have a 32-bit
Slackware box that has no trouble with _socket.

I can not 'import socket' into a program, nor can I use 'pip' to install
modules. These require the _socket module, which doesn't exist. What does
exist is a shared library object called '_
socket.cpython-36m-i386-linux-gnu.so'. This looks tantalizingly like the
missing module, but it is for a 32-bit architecture.

This is not the only missing module for 64-bit Slackware Linux. I can not
find a trace of the 'math' module, which, again, works fine on my 32-bit
computer.

I am far from an expert on installing python modules, so I am asking for
advice on how I should proceed to find these modules.

Thanks in advance.

"BryGuy" (my handle on linuxquestions.org)
-- 
https://mail.python.org/mailman/listinfo/python-list


Traversal help

2017-04-02 Thread R. Bryan Smith
Hello,

I am working with Python 3.6.  I’ve been trying to figure out a solution to my 
question for about 40 hrs with no success and hundreds of failed attempts.  
Essentially, I have bitten off way more than I can chew with processing this 
file.  Most of what follows, is my attempt to inform as best I can figure.

I have a JSONL (new line) file that I downloaded using requests and the 
following code: 
with open(fname, 'wb') as fd:
for chunk in r.iter_content(chunk_size=1024):
fd.write(chunk)

The file was in gzip format (the encoding on the API says - UTF-8) to a windows 
8 (it’s current, but 8) machine.
These files are rather large, maybe around 4GB.
I used the ‘shebang' for ‘UTF-8’ at the top of my Python program: # -*- 
encoding: utf-8 -*-

After I save the file, I read it using this:
def read_json(path):
'''Turns a normal json LINES (cr) file into an array of objects'''
temp_array = []
f = codecs.open(path, 'r', 'utf-8', ‘backslashreplace')
for line in f:
record = json.loads(line.strip('\n|\r'))
temp_array.append(record)
return temp_array

I am working on a Linux server to partitioning the List returned above, there 
are three linked levels of detail (A, B, C) that can exist in any collection 
within the JSON and each Collection can contain wildly varying and/or repeating 
fields.  The data contained within is scraped from websites all over the world. 
 I wanted to ‘traverse' the file structure and found an algorithm that I think 
will work:

def traverser(obj, path=None, callback=None):
if path is None:
path = []

if isinstance(obj, dict):
value = {k: traverser(v, path+[k], callback)
 for k, v in obj.items()}
elif isinstance(obj, list):
value = [traverser(elem, path+[[]], callback)
 for elem in obj]
else:
value = obj

if callback is None:
return value
else:
return callback(path, value)

The only problem and the subsequent question that follows is:  I have yet to 
successfully decode / How do I then ‘collect’ each of these objects while I am 
traversing the JSON New Line Collection into some sort of container (handling 
encoding errors) so that I can then write to a csv file (w/ ‘utf-8’ and won’t 
error out when I try to import it into a IBM ‘utf-8’ encoded DB)?  Actually, 
after that, I would like to learn how to grab a specific element, if present in 
each Collection, whenever I need it, as well - but, that can wait.

I’ve tried using the JSON module on the JSONL file, but the structure is really 
complicated and changing with lot’s of different control and spacing 
characters, in addition to some odd (potentially non-unicode characters).  
Here’s the schema: http://json-schema.org/fraft-04/schema# 
 

I’m not a programmer, but I am learning through assimilation.  Any help is 
greatly appreciated.  Even if it’s pointing me to documentation that can help 
me learn what to consider and lead me to what to do.  

Thank you,
R. Smith

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


Re: Modify Setup

2017-02-06 Thread Bryan Carey
Good evening! I just installed both python 3.4 & the PyCharm IDE this
evening. While trying to run a simple "Hello World" program, I keep getting
"Modify Setup" pop up windows. In addition to that, the output of my
program is not displayed. Could you help me resolve my issue?

On Sat, Feb 4, 2017 at 3:25 PM, Bryan Carey  wrote:

> Good evening! I just installed both python 3.4 & the PyCharm IDE this
> evening. While trying to run a simple "Hello World" program, I keep getting
> "Modify Setup" pop up windows. In addition to that, the output of my
> program is not displayed. Could you help me resolve my issue?
>
> On Fri, Feb 3, 2017 at 7:00 PM, Bryan Carey  wrote:
>
>> Good evening! I just installed both python 3.4 & the PyCharm IDE this
>> evening. While trying to run a simple "Hello World" program, I keep getting
>> "Modify Setup" pop up windows. In addition to that, the output of my
>> program is not displayed. Could you help me resolve my issue?
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need explanation of this error

2016-03-19 Thread Bryan Bateman


Having the same error with python 3.5 windows 64 bit and scipy for same on
Windows 10.  I did dependency walker and it came up with a large number of
DLL's.  Do you want the source of the scipy binary and the DLL list?

 

https://mail.python.org/pipermail/python-list/2013-July/651190.html

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


Re: Accessible tools

2015-02-21 Thread Bryan Duarte
Tim,

I am also on the blind linux list. I do not often post there as I predominately 
use a Mac and the Unix terminal but I am using Linux Kali on the side for some 
side tinkering and learning. I would use Linux a lot more if the screen reader 
was not so robotic... Would you be willing to be included in some accessibility 
Q&A or to bounce some ideas off of? 
> On Feb 19, 2015, at 11:43 AM, Tim Chase  wrote:
> 
> While not blind, I have an interest in accessibility and answer a
> number of questions on the Blinux (Blind Linux Users) mailing list.
> 
> On 2015-02-19 08:33, Bryan Duarte wrote:
>> A professor and I have been throwing around the idea of developing
>> a completely text based IDE. There are a lot of reasons this could
>> be beneficial to a blind developer and maybe even some sighted
>> developers who are comfortable in the terminal. The idea would be
>> really just to provide a way of easily navigating blocks of code
>> using some kind of tabular formatting, and being able to collapse
>> blocks of code and hearing from a high level information about the
>> code within. All tools and features would obviously be spoken or
>> output in some kind of audio manor. 
> 
> It would seem that the traditional Unix-as-IDE[1] would serve you well
> here.  This is my method of choice, and it allows me to pick my
> components and combine them.  I usually use tmux, though GNU screen
> would do too.  Within that, I usually have the following:
> 
> - vim to edit my code.  Though swap in your favorite, whether
>  emacs/emacspeak, ed/edbrowse, joe, nano, or whatever.  I know that
>  at least Vim and emacs support "folding" away blocks of code (what
>  you describe as "collapsing") which I usually prefix with a comment
>  that would give you a description of the block
> 
> - a command-line (I use bash, some prefer zsh or tcsh or whatever)
>  for things like version-control, running my code, and file
>  management (move/copy/delete/rename/link/etc)
> 
> - a Python command-line REPL that allows me to do quick tests on a
>  line of code as well as well as make extensive use of Python's
>  built-in dir() and help() commands which are invaluable.
> 
> - when doing web-development (Django in my case), I'll often have the
>  dev-server running in one pane, and a console browser like
>  lynx/links/links2/elinks/w3m in another pane so that I can put my
>  code through its paces
> 
> Another benefit of this is that I can run this on my development
> machine, but then SSH into the machine from anywhere, reattach to the
> tmux/screen session, and have the same configuration right as I left
> it.
> 
> The entire tmux/screen session can be run within an accessible
> terminal window (I know that some are more accessible than others),
> within a terminal screen-reader session (like yasr, screader, or
> emacspeak), or even remoted into via an accessible SSH program on your
> platform of choice.
> 
> -tkc
> 
> [1]
> http://blog.sanctum.geek.nz/series/unix-as-ide/
> 
> 
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Accessible tools

2015-02-21 Thread Bryan Duarte
Eric,

Although I would most likely enjoy the former option I feel the latter would be 
most appropriate for contacting you. Thanks for getting back to me and 
explaining some of this. I will contact you off list for sure so as not to fill 
up the lists mailboxes with this topic. 

I will say that Jacob is absolutely correct in the fact that those of us who 
rely on screen readers to interact with our computers have a few things we do, 
and tend to not do.
• Do type very efficiently
• Do listen to our speech output very fast
• Do interact with the text line, word, and character at a time.
• Do not, use a mouse
• Do not, enjoy reading through several lines of code at a time to locate a 
specific issue, method, or block of code.
• Do not, have access to debugging tools.

This is just a few things we do and do not do typically, but the point is that 
even though some things are similar there are some things that are quite 
different. Here is an example. I would not use a voice driven editor because I 
tend to build out a layout of code before I begin filling in methods, 
functions, and constructors. For me to do this with voice would require the use 
of a mouse to place the cursor where I want each line of code to be placed, and 
since I do not have access to the mouse in that way this would not work well. 
On the other hand if the program could interpret what you are speaking to build 
out method signatures and individual lines of code accurately, then there is a 
good chance that same system could provide a great interface for a screen 
reader. Thank you again for the response and be expecting an email from me 
shortly sir.  
> On Feb 20, 2015, at 11:39 AM, Jacob Kruger  wrote:
> 
> Eric, issue is that with screenreaders, we're generally way more into
> navigating code and interface character by character/by keyboard, so , yes,
> keeping interface relatively simple is a good thing, but, we also would
> prefer to primarily keep all interface elements to make use of standard UI
> controls, and make sure tab index/order is suitable/relevant at times, etc.
> etc.
> 
> As in, I think we'd primarily want to avoid having to use a mouse at all if
> possible, but anyway.
> 
> Stay well
> 
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> "Roger Wilco wants to welcome you...to the space janitor's closet..."
> 
> - Original Message - From: "Eric S. Johansson" 
> To: 
> Sent: Friday, February 20, 2015 7:22 PM
> Subject: Re: Accessible tools
> 
> 
>> 
>> On 2/19/2015 10:33 AM, Bryan Duarte wrote:
>>> Thank you jwi, and Jacob,
>>> 
>>> I took a look at that posting and it seems pretty unique. I am not much 
>>> interested in the speech driven development, but I am very interested in 
>>> developing an accessible IDE.
>> 
>> Well you should be because it looks like an aural interface (uses speech 
>> instead of keyboards) uses the same kinds of data to present to either a 
>> text to speech or speech recognition driven environment.
>>> A professor and I have been throwing around the idea of developing a 
>>> completely text based IDE. There are a lot of reasons this could be 
>>> beneficial to a blind developer and maybe even some sighted developers who 
>>> are comfortable in the terminal. The idea would be really just to provide a 
>>> way of easily navigating blocks of code using some kind of tabular 
>>> formatting, and being able to collapse blocks of code and hearing from a 
>>> high level information about the code within. All tools and features would 
>>> obviously be spoken or output in some kind of audio manor.
>> I've been working with another professor working on some of these issues as 
>> well. His focus has been mostly blind young adults in India.  come up with 
>> some pretty cool concepts that looks very usable. The challenge now is to 
>> make them work and, quite frankly monetize the effort to pay for the 
>> development.
>> 
>> Again, this shows the similarities in functionality used by both speech 
>> recognition and text-to-speech. All I care about is text and what I can say. 
>> We're now working with constructs such as with-open, argument by number, 
>> plaintext symbol names (with bidirectional transform to and from code form), 
>> guided construct generation for things like classes, methods, comprehensions 
>> etc.
>> 
>> All of these things would be useful to handed programmers as well as a way 
>> of accelerating co-creation and editing. Unfortunately, like with disabled 
>> people stove piping text-to-speech versus speech recognition, handed 
>> developers stovepipe keyboard interfaces and don't really think abou

Re: Accessible tools

2015-02-19 Thread Bryan Duarte
Thank you jwi, and Jacob,

I took a look at that posting and it seems pretty unique. I am not much 
interested in the speech driven development, but I am very interested in 
developing an accessible IDE. A professor and I have been throwing around the 
idea of developing a completely text based IDE. There are a lot of reasons this 
could be beneficial to a blind developer and maybe even some sighted developers 
who are comfortable in the terminal. The idea would be really just to provide a 
way of easily navigating blocks of code using some kind of tabular formatting, 
and being able to collapse blocks of code and hearing from a high level 
information about the code within. All tools and features would obviously be 
spoken or output in some kind of audio manor. 

Jacob, I know your name and I do know Jamal's name as well. I think I recall 
your names from either back in the "Mobile Speak" days, or maybe from the jaws 
mailing list. Either way thank you for the feedback and I will take a look at 
edSharp today. The Python interpreter is great for small tests or scripts but 
for lengthy programs there is no easy way to save your code other than 
capturing the entire history with extra code and all. How do you typically 
handle that issue? Thank you both. 

Oh and before I forget does anyone know how to contact Eric who was developing 
that accessible speech driven IDE? Thanks
> On Feb 19, 2015, at 3:08 AM, Jonas Wielicki  wrote:
> 
> Dear Bryan,
> 
> I don’t have a finished solution for you, but I would like to link you
> to a previous thread on this list:
> <https://mail.python.org/pipermail/python-list/2015-January/696276.html>
> 
> The poster seems to be researching into the direction of developing a
> speech-friendly IDE. You may want to follow his work.
> 
> regards,
> jwi
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Accessible tools

2015-02-19 Thread Bryan Duarte
Hello all,

I have been posting to another group which directed me to this group. I am a 
blind software engineering student at Arizona State University. I am currently 
doing research and have decided to use Python as my developing language. I am 
in search of an accessible IDE or other tool set which will allow me to use the 
features with a screen reader. I have tried a number of tools but so far have 
been unsuccessful in finding one that allows me to use the tools and features 
of the IDE with my screen reader. 

I understand that I do not need an IDE to use Python, I am looking for an IDE 
to allow me to explore the classes and methods easily and quickly. I have tried 
the following tools.
• pyCharm
• iPy
• iPy Notebook
• Idle
• and Eclipse

So far only Eclipse was accessible but I did still incounter some difficulties 
like the IDE freezing up when tool tips would pop up. Finally I am using a Mac 
mostly but can use Windows, or Linux if need be. Thank you and I appreciate any 
and all suggestions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can post a code but afraid of plagiarism

2014-01-20 Thread bryan rasmussen
>When you take a course, you should be learning, not just passing. That
>means that getting someone else to do your work for you is completely
>wrong, so I won't help you.

I have decided to become an MBA.



On Mon, Jan 20, 2014 at 9:48 AM, Chris Angelico  wrote:

> On Mon, Jan 20, 2014 at 6:55 PM, indar kumar 
> wrote:
> > Actually, I tried to ask some questions but I was discouraged to do so
> saying that I was working on a project or some assignment. Truth be told I
> am stuck at one point and since I don't have experience with programming
> language, I have been working for it for two days but couldn't come up with
> some idea so posted some questions of the same format just to know whether
> there is particular method etc to do so. Hint would have been enough but I
> was strictly discouraged.
> >
>
> Here's my policy on homework. Others may vary, but you'll find a lot
> will be broadly similar.
>
> When you take a course, you should be learning, not just passing. That
> means that getting someone else to do your work for you is completely
> wrong, so I won't help you. But if you've put down some code and it's
> not working, then by all means, ask for help with the details; it's
> easy if you have an error message you don't understand (you might be
> able to get that by Googling it), but a lot harder if you're getting
> output you don't understand, and then it can help a LOT to have an
> expert look at your code. You would need to post your code and exactly
> what you're seeing as wrong (exception traceback, or "expected this
> output, got this instead"); and if you make it clear up-front that
> it's homework and you're looking for hints rather than an
> answer-on-a-plate, I'm happy to help.
>
> What you will find, though, is that most requests are more of the
> nature of "please do my homework for me", so people are more likely to
> be annoyed than helpful when they see what's obviously homework. So
> you have a bit of an uphill battle just to get heard. But if you can
> show that you're here to learn - and showing that you've already
> written most of the code is a good way to do that - you can get help,
> and often a lot of it.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Input Error issues - Windows 7

2014-01-10 Thread bryan . kardisco
I'm new to python and am trying to just get some basic stuff up and going.

I have a very basic module called foo

It's in the following directory on my machine

C:\workspace\PyFoo\src\foo
In that folder is __init__.py (created automatically)  and foo.py

foo.py looks like this

class foo():
def __init__(self, name, number):
self.name = name
self.number = number
def getName(self):
return self.name
def getNumber(self):
return self.number


If I open up command prompt and do following it works:

C:\workspace\PyFoo\src\foo>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from foo import foo
>>> f = foo(1,2)
>>> f.getName()
1
>>>


However, if I run this from C:\ I get the following

C:\>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from foo import foo
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named 'foo'
>>>


I thought, well maybe it's a system error

>>> import sys
>>> print(sys.path)
['', 'C:\\Python33', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 
'C:\\workspace', 'C:\\Windows\\system32\\python33.zip',
 'C:\\Python33\\lib\\site-packages']
>>>

C:\>echo %PYTHONPATH%
C:\Python33;C:\Python33\Lib;C:\Python33\DLLs;C:\workspace

However, that seems OK.

Is there something I'm missing?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: One liners

2013-12-07 Thread bryan rasmussen
Someone was thinking in ruby there.



On Sat, Dec 7, 2013 at 1:14 AM, Dan Stromberg  wrote:

>
> On Fri, Dec 6, 2013 at 4:10 PM, Michael Torrie  wrote:
>
>> On 12/06/2013 04:54 PM, Dan Stromberg wrote:
>> > Does anyone else feel like Python is being dragged too far in the
>> direction
>> > of long, complex, multiline one-liners?  Or avoiding temporary variables
>> > with descriptive names?  Or using regex's for everything under the sun?
>> >
>> > What happened to using classes?  What happened to the beautiful
>> emphasis on
>> > readability?  What happened to debuggability (which is always harder
>> than
>> > writing things in the first place)?  And what happened to string
>> methods?
>> >
>> > I'm pleased to see Python getting more popular, but it feels like a lot
>> of
>> > newcomers are trying their best to turn Python into Perl or something,
>> > culturally speaking.
>>
>> I have not seen any evidence that this trend of yours is widespread.
>> The Python code I come across seems pretty normal to me.  Expressive and
>> readable.  Haven't seen any attempt to turn Python into Perl or that
>> sort of thing.  And I don't see that culture expressed on the list.
>> Maybe I'm just blind...
>
>
> I'm thinking mostly of stackoverflow, but here's an example I ran into (a
> lot of) on a job:
>
> somevar = some_complicated_thing(somevar) if
> some_other_complicated_thing(somevar) else somevar
>
> Would it really be so bad to just use an if statement?  Why are we
> assigning somevar to itself?  This sort of thing was strewn across 3 or 4
> physical lines at a time.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


python 2.7 SSL to fetch servers notAfter date

2013-09-19 Thread Bryan Irvine
I'm trying to connect to an SSL application using client certs to grab the 
remote certs notAfter time.  When I connect using 'openssl s_client' and pass 
my client cert/key I can see it in the cert chain, but when I attempt to use 
get_peer_certificate() in python (2.7) I only get a blank dict and cannot pull 
the notAfter date.

I think this means that Python is unable to validate the cert, but I'm not sure 
the next steps to fix it.

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


Re: *.csv to *.txt after adding columns

2013-09-18 Thread Bryan Britten
Peter nailed it. Adding in the two lines of code to ensure I was just working 
with *.csv files fixed the problem. Thanks to everyone for the help and 
suggestions on best practices. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: *.csv to *.txt after adding columns

2013-09-17 Thread Bryan Britten
Dave -

I can't print the output because there are close to 1,000,000 records. It would 
be extremely inefficient and resource intensive to look at every row. Like I 
said, when I take just one file and run the code over the first few records I 
get what I'd expect to see. Here's an example(non-redacted code):

INPUT:

import csv

fileHandle = 'C:/Users/Bryan/Data Analysis/Crime Analysis/Data/'

varNames = 
'ID\tCaseNum\tDate\tTime\tBlock\tIUCR\tPrimaryType\tDescription\tLocDesc\tArrest\tDomestic\tBeat\tDistrict\tWard\tCommArea\tFBICode\tXCoord\tYCoord\tYear\tUpdatedOn\tLat\tLong\tLoc\n'

outFile = open(fileHandle + 'ChiCrime01_02.txt', 'w')
inFile = open(fileHandle + 'ChiCrime01_02.csv', 'rb')
reader = csv.reader(inFile, delimiter=',')
rowNum = 0
for row in reader:
if rowNum < 5:
if rowNum >= 1:
date, time = row[2].split()
row.insert(3, date)
row.insert(4, time)
row.remove(row[2])
print '\t'.join(row)
rowNum+=1
else:
print varNames
rowNum+=1


OUTPUT:

ID  CaseNum DateTimeBlock   IUCRPrimaryType Description 
LocDesc Arrest  DomesticBeatDistrictWardCommArea
FBICode XCoord  YCoord  YearUpdatedOn   Lat LongLoc

2924745 HJ60260212/31/2002  23:59   006XX W 117TH ST841 
THEFT   FINANCIAL ID THEFT:$300 &UNDER  RESIDENCE PORCH/HALLWAY FALSE   FALSE   
524 5   34  53  6   1173831 1827387 20023/30/2006 21:10 
41.68175482 -87.63931351(41.681754819160666, -87.63931350564216)

2523290 HJ10109112/31/2002  23:59   002XX W 112TH PL1310
CRIMINAL DAMAGE TO PROPERTY APARTMENT   FALSE   FALSE   522 
34  49  14  1176848 1830383 20023/30/2006 21:10 41.68990907 
-87.62817988(41.689909072449474, -87.62817987594765)

2527332 HJ10513912/31/2002  23:55   005XX E 89TH PL 486 BATTERY 
DOMESTIC BATTERY SIMPLE RESIDENCE   FALSE   TRUE633 6   
44  08B 1181369 1845794 20023/30/2006 21:10 41.73209609 
-87.61115533(41.732096089465905, -87.61115532670617)

2524251 HJ10017512/31/2002  23:55   012XX S KARLOV AVE  041A
BATTERY AGGRAVATED: HANDGUN SIDEWALKFALSE   FALSE   1011
24  29  04B 1149196 1894387 20023/30/2006 21:10 41.86612296 
-87.72776536(41.86612295941429, -87.72776535755746)


Like I said, the output is exactly what I want, but it doesn't seem to be 
writing to the file and I don't know why. I said I didn't know if it was 
raising an exception because I'm new to Python and I didn't know if there were 
some methods that included "silent" errors where it would continue the code but 
produce the wrong results, such as not writing my files. 

Lastly, why does everyone seem to push for os.path.join versus the method I 
have used? Is it just a 'standard' that people like to see?

Thanks for your help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I calculate a mean with python?

2013-09-17 Thread Bryan Britten
William -

I'm also self-teaching myself Python and get stuck quite often, so I understand 
both the thrill of programming and the frustration. Given your young age and 
presumably very little exposure to other programming languages, I would highly 
recommend you check out http://www.Codecademy.com and work through their Python 
tutorials. It will teach you about the different object types (lists, dicts, 
tuples, etc) and about things like functions, methods and classes. I think 
you'll have a MUCH better understanding of Python that will allow you to choose 
which YouTube videos to watch much more wisely.

Good luck with your endeavors!
-- 
https://mail.python.org/mailman/listinfo/python-list


*.csv to *.txt after adding columns

2013-09-17 Thread Bryan Britten
Hey, gang, I've got a problem here that I'm sure a handful of you will know how 
to solve. I've got about 6 *.csv files that I am trying to open; change the 
header names (to get rid of spaces); add two new columns, which are just the 
results of a string.split() command; drop the column I just split; and then 
finally export to *.txt files. Here's the code I'm using:

import os
import csv


fileHandle = 'Path/To/Data'
varNames = 
'ID\tCaseNum\tDate\tTime\tBlock\tIUCR\tPrimaryType\tDescription\tLocDesc\tArrest\tDomestic\tBeat\tDistrict\tWard\tCommArea\tFBICode\tXCoord\tYCoord\tYear\tUpdatedOn\tLat\tLong\tLoc\n'

for csvFile in os.listdir(fileHandle):
outFile = open(fileHandle + os.path.splitext(csvFile)[0] + '.txt', 'w')
inFile = open(fileHandle + csvFile, 'rb')
reader = csv.reader(inFile, delimiter=',')
rowNum = 0
for row in reader:
if rowNum == 0:
outFile.write(varNames)
rowNum += 1
else:
date, time = row[2].split()
row.insert(3, date)
row.insert(4, time)
row.remove(row[2])
outFile.write('\t'.join(row) + '\n')
outFile.close()
inFile.close()  


The issue I'm having is that the *.txt files I'm generating are empty. I assume 
some unraised error is being thrown, but I'm new to Python and am self taught, 
so I don't know where to look or how to troubleshoot.

When I run the code on just one file and print the output instead of writing 
it, it looks exactly like what I'd want. So I'm at a loss for where the problem 
is.

Any help is appreciated!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Limit Lines of Output

2013-06-25 Thread Bryan Britten
Joel -

I don't want to send it to a text file because it's just meant to serve as a 
reference for the user to get an idea of what words are mentioned. The words 
being analyzed are responses to a survey questions and the primary function of 
this script is to serve as a text analytics program. Exporting the output to a 
text file would just be an unnecessary/undesirable step for the user.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Limit Lines of Output

2013-06-25 Thread Bryan Britten
Ah, I always forget to mention my OS on these forums. I'm running Windows.

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


Limit Lines of Output

2013-06-25 Thread Bryan Britten
Hey, group, quick (I hope) question:

I've got a simple script that counts the number of words in a data set (it's 
more complicated than that, but that's one of the functions), but there are so 
many words that the output is too much to see in the command prompt window. 
What I'd like to be able to do is incorporate the "More..." feature that help 
libraries have, but I have no idea how to do it. I also don't know if I'm 
asking the question correctly because a Google search yielding nothing.

Any insight would be appreciated. Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-28 Thread Bryan Britten
Thanks to everyone for the help and insight. I think for now I'll just back 
away from this file and go back to something much easier to practice with. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
On Monday, May 27, 2013 7:58:05 PM UTC-4, Dave Angel wrote:
> On 05/27/2013 04:47 PM, Bryan Britten wrote:
> 
> > Hey, everyone!
> 
> >
> 
> > I'm very new to Python and have only been using it for a couple of days, 
> > but have some experience in programming (albeit mostly statistical 
> > programming in SAS or R) so I'm hoping someone can answer this question in 
> > a technical way, but without using an abundant amount of jargon.
> 
> >
> 
> > The issue I'm having is that I'm trying to pull information from a website 
> > to practice Python with, but I'm having trouble getting the data in a 
> > timely fashion. If I use the following code:
> 
> >
> 
> > 
> 
> > import json
> 
> > import urllib
> 
> >
> 
> > urlStr = "https://stream.twitter.com/1/statuses/sample.json";
> 
> >
> 
> > twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]
> 
> > 
> 
> >
> 
> > I get a memory issue. I'm running 32-bit Python 2.7 with 4 gigs of RAM if 
> > that helps at all.
> 
> 
> 
> Which OS?

I'm operating on Windows 7.

> 
> The first question I'd ask is how big this file is.  I can't tell, since 
> 
> it needs a user name & password to actually get the file.  

If you have Twitter, you can just use your log-in information to access the 
file.

> But it's not unusual to need at least double that space in memory, and in 
> Windoze 
> 
> you're limited to two gig max, regardless of how big your hardware might be.
> 
> 
> 
> If you separately fetch the file, then you can experiment with it, 
> 
> including cutting it down to a dozen lines, and see if you can deal with 
> 
> that much.
> 
> 
> 
> How could you fetch it?  With wget, with a browser (and saveAs), with a 
> 
> simple loop which uses read(4096) repeatedly and writes each block to a 
> 
> local file.  Don't forget to use 'wb', as you don't know yet what line 
> 
> endings it might use.
> 
I'm not familiar with using read(4096), I'll have to look into that. When I 
tried to just save the file, my computer just sat in limbo for some time and 
didn't seem to want to process the command. 
> 
> Once you have an idea what the data looks like, you can answer such 
> 
> questions as whether it's json at all, whether the lines each contain a 
> 
> single json record, or what.
> 
Based on my *extremely* limited knowledge of JSON, that's definitely the type 
of file this is. Here is a snippet of what is seen when you log in:

{"created_at":"Tue May 28 03:09:23 + 
2013","id":339216806461972481,"id_str":"339216806461972481","text":"RT 
@aleon_11: Sigo creyendo que las noches lluviosas me acercan mucho m\u00e1s a 
ti!","source":"\u003ca href=\"http:\/\/blackberry.com\/twitter\" 
rel=\"nofollow\"\u003eTwitter for 
BlackBerry\u00ae\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":310910123,"id_str":"310910123","name":"\u2661","screen_name":"LaMarielita_","location":"","url":null,"description":"MERCADOLOGA
 & PUBLICISTA EN PROCESO, AMO A MI DIOS & MI FAMILIA\u2665 ME ENCANTA REIRME , 
MOLESTAR & HABLAR :D BFF, pancho, ale & china :) 
LY\u2661","protected":false,"followers_count":506,"friends_count":606,"listed_count":1,"created_at":"Sat
 Jun 04 15:24:19 + 
2011","favourites_count":207,"utc_offset":-25200,"time_zone":"Mountain Time (US 
& Canada)","geo_enabled":false,"
 
verified":false,"statuses_count":17241,"lang":"es","contributors_enabled":false,"is_translator":false,"profile_background_color":"FF6699","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme11\/bg.gif","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme11\/bg.gif","profile_background_tile":true,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/3720425493\/13a48910e56ca34edeea07ff04075c77_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/3720425493\/13a489

Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
Try to not sigh audibly as I ask what I'm sure are two asinine questions. 

1) How is this approach different from twtrDict = [json.loads(line) for line in 
urllib.urlopen(urlStr)]?

2) How do I tell how many JSON objects are on each line?



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


Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
Hey, everyone! 

I'm very new to Python and have only been using it for a couple of days, but 
have some experience in programming (albeit mostly statistical programming in 
SAS or R) so I'm hoping someone can answer this question in a technical way, 
but without using an abundant amount of jargon.

The issue I'm having is that I'm trying to pull information from a website to 
practice Python with, but I'm having trouble getting the data in a timely 
fashion. If I use the following code:


import json
import urllib

urlStr = "https://stream.twitter.com/1/statuses/sample.json";

twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]


I get a memory issue. I'm running 32-bit Python 2.7 with 4 gigs of RAM if that 
helps at all.

If I use the following code:


import urllib

urlStr = "https://stream.twitter.com/1/statuses/sample.json";

fileHandle = urllib.urlopen(urlStr)

twtrText = fileHandle.readlines()


It takes hours (upwards of 6 or 7, if not more) to finish computing the last 
command.

With that being said, my question is whether there is a more efficient manner 
to do this. I'm worried that if it's taking this long to process the 
.readlines() command, trying to work with the data is going to be a 
computational nightmare.

Thanks in advance for any insights or advice!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set x to to None and del x doesn't release memory in python 2.7.1 (HPUX 11.23, ia64)

2013-03-06 Thread Bryan Devaney
On Wednesday, March 6, 2013 10:11:12 AM UTC, Wong Wah Meng-R32813 wrote:
> Hello there,
> 
> 
> 
> I am using python 2.7.1 built on HP-11.23 a Itanium 64 bit box. 
> 
> 
> 
> I discovered following behavior whereby the python process doesn't seem to 
> release memory utilized even after a variable is set to None, and "deleted". 
> I use glance tool to monitor the memory utilized by this process. Obviously 
> after the for loop is executed, the memory used by this process has hiked to 
> a few MB. However, after "del" is executed to both I and str variables, the 
> memory of that process still stays at where it was. 
> 
> 
> 
> Any idea why?
> 
> 
> 
> >>> for i in range(10L):
> 
> ... str=str+"%s"%(i,) 
> 
> ... 
> 
> >>> i=None
> 
> >>> str=None
> 
> >>> del i
> 
> >>> del str

Hi, I'm new here so I'm making mistakes too but I know they don't like it when 
you ask your question in someone else's question. 

that being said, to answer your question:

Python uses a 'garbage collector'. When you delete something, all references 
are removed from the object in memory, the memory itself will not be freed 
until the next time the garbage collector runs. When that happens, all objects 
without references in memory are removed and the memory freed.  If you wait a 
while you should see that memory free itself.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sync databse table based on current directory data without losign previous values

2013-03-06 Thread Bryan Devaney
On Wednesday, March 6, 2013 9:43:34 AM UTC, Νίκος Γκρ33κ wrote:
> Perhaps because my filenames is in greek letters that thsi error is presented 
> but i'am not sure.
> 
> 
> 
> Maybe we can join root+files and store it to the set() someway differenyl

well, the error refers to the line "if b.startswith('/'): " and states "'list' 
object has no attribute 'startswith'" 

so b is assigned to a list type and list does not have a 'startswith' method or 
attribute.

I Thought .startswith() was a string method but if it's your own method then I 
apologize (though if it is, I personally would have made a class that inherited 
from list rather than adding it to list itself)

can you show where you are assigning b (or if its meant to be a list or string 
object)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: book advice

2013-03-05 Thread Bryan Devaney
On Friday, March 1, 2013 8:59:12 PM UTC, leonardo selmi wrote:
> hi
> 
> 
> 
> is there anyone can suggest me a good book to learn python? i read many but 
> there is always something unclear or examples which give me errors.
> 
> how can I start building a sound educational background
> 
> 
> 
> thanks for any help 
> 
> 
> 
> best regards

If you have net access and are learning your first programming language, I'd 
say head on over to one of the free web python courses that include an online 
interpreter. It sorts out a great deal of the 'incompatible version' problems 
people have with offline tutorials. I'm not sure what the policy is in regards 
linking to one so I'll just say Google one.  

Once you've found your feet, I do hear good things about 'learn python the hard 
way' but I've not read it myself. 

Generally once you've covered the foundations and understand the terms, 
Python.org's docs are very good.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question on for loop

2013-03-05 Thread Bryan Devaney
On Monday, March 4, 2013 4:37:11 PM UTC, Ian wrote:
> On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney  wrote:
> 
> >> if character not in lettersGuessed:
> 
> >>
> 
> >> return True
> 
> >>
> 
> >> return False
> 
> >
> 
> > assuming a function is being used to pass each letter of the letters 
> > guessed inside a loop itself that only continues checking if true is 
> > returned, then that could work.
> 
> >
> 
> > It is however more work than is needed.
> 
> >
> 
> > If you made secretword a list,you could just
> 
> >
> 
> > set(secretword)&set(lettersguessed)
> 
> >
> 
> > and check the result is equal to secretword.
> 
> 
> 
> Check the result is equal to set(secretword), I think you mean.
> 
> 
> 
> set(secretword).issubset(set(lettersguessed))
> 
> 
> 
> might be slightly more efficient, since it would not need to build and
> 
> return an intersection set.
> 
> 
> 
> One might also just do:
> 
> 
> 
> all(letter in lettersguessed for letter in secretword)
> 
> 
> 
> Which will be efficient if lettersguessed is already a set.

You are correct. sorry for the misleading answer, was digging through old shell 
scripts all day yesterday and brain was obviously not not the better for it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i need help

2013-03-04 Thread Bryan Devaney
On Sunday, March 3, 2013 6:45:26 PM UTC, Kwpolska wrote:
> On Sun, Mar 3, 2013 at 7:46 AM, Michael Torrie  wrote:
> 
> > On 02/21/2013 03:18 AM, leonardo wrote:
> 
> >> thanks, problem solved
> 
> >
> 
> > Apparently not.  The shift key on your keyboard still seems to be
> 
> > non-functional. ;)
> 
> > --
> 
> > http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
> It is!  How else could he type those two question marks and 10 double-quotes?
> 
> 
> 
> -- 
> 
> Kwpolska  | GPG KEY: 5EAAEA16
> 
> stop html mail| always bottom-post
> 
> http://asciiribbon.org| http://caliburn.nl/topposting.html

Onscreen Keyboard?
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   >