[issue41592] Make _SubParsersAction public

2021-10-25 Thread Eric Pederson


Eric Pederson  added the comment:

But is _SubParsersAction really private if there are methods on it that are 
required to use (add_parser())?

--

___
Python tracker 
<https://bugs.python.org/issue41592>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41592] Make _SubParsersAction public

2021-10-22 Thread Eric Pederson


Eric Pederson  added the comment:

Yes - that was the first thing I tried and why I logged the bug.  I will log a 
bug with Pycharm but it still seems like the long term solution is to make 
_SubParsersAction public since it is used like a public object.  I thought that 
logging the bug here would be the start of the discussion by the argparse 
maintainers.  Where can I get their attention?

--

___
Python tracker 
<https://bugs.python.org/issue41592>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41592] Make _SubParsersAction public

2020-08-19 Thread Eric Pederson


New submission from Eric Pederson :

ArgumentParser.add_subparsers() returns a _SubParsersAction.  This requires 
user code using type annotations to use a protected type which causes type 
checkers like PyCharm to complain.  For example:

def add_subparser(name: str, subparser: _SubParsersAction, subparsers: dict) -> 
ArgumentParser:
parser = subparser.add_parser(name)
parser.add_argument('-v', '--verbose', action='store_true')
subparsers[name] = parser
return parser

You can't use plain Action because Action doesn't have the add_parser() method.

--
components: Library (Lib)
messages: 375670
nosy: sourcedelica
priority: normal
severity: normal
status: open
title: Make _SubParsersAction public
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue41592>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Convert to binary and convert back to strings

2007-02-23 Thread Eric Pederson
Harlin Seritt wrote:

Hi...

I would like to take a string like 'supercalifragilisticexpialidocius'
and write it to a file in binary forms -- this way a user cannot read
the string in case they were try to open in something like ascii text
editor. I'd also like to be able to read the binary formed data back
into string format so that it shows the original value. Is there any
way to do this in Python?

Thanks!

Harlin

  


To my mind, the more sensible job you do at programming this the worse 
off you are, unless you use strong encryption.  There are nearly 
infinite approaches, so the random approach you use will be part of the 
security of the obfuscation.

OK, I am not really taking this so seriously, but it is a fun question 
(Python makes these minor things fun).  Is there anyway to do this in 
Python?  You bet, so many ways... here's another:

s=I would like to take a string like 'supercalifragilisticexpialidocius'
and write it to a file in binary forms -- this way a user cannot read
the string in case they were try to open in something like ascii text
editor. I'd also like to be able to read the binary formed data back
into string format so that it shows the original value. Is there any
way to do this in Python?

s0=s+$
s2=0 .join([str(ord(c)) for c in s])
s1=.join([chr(int(i[:-1])) for i in s2.split( 
)[:-1]])+chr(int(s2[-1]))[:-1]

def codeMe(s):
s0=s+$
return 0 .join([str(ord(c)) for c in s0])

def uncodeMe(s):
return .join([chr(int(i[:-1])) for i in s.split( 
)[:-1]])+chr(int(s[-1]))[:-1]

def testit(s):
s2=codeMe(s)
s1=uncodeMe(s2)
strings={original:s, obfuscated:s2, decoded:s1}
for k in strings.keys():
print k,:  ,\n,strings[k], \n\n
   
testit(s)

-
the obfuscated looks like this:

730 320 1190 1110 1170 1080 1000 320 1080 1050 1070 1010 320 1160 1110 
320 1160 970 1070 1010 320 970 320 1150 1160 1140 1050 1100 1030 320 
1080 1050 1070 1010 320 390 1150 1170 1120 1010 1140 990 970 1080 1050 
1020 1140 970 1030 1050 1080 1050 1150 1160 1050 990 1010 1200 1120 1050 
970 1080 1050 1000 1110 990 1050 1170 1150 390 100 970 1100 1000 320 
1190 1140 1050 1160 1010 320 1050 1160 320 1160 1110 320 970 320 1020 
1050 1080 1010 320 1050 1100 320 980 1050 1100 970 1140 1210 320 1020 
1110 1140 1090 1150 320 450 450 320 1160 1040 1050 1150 320 1190 970 
1210 320 970 320 1170 1150 1010 1140 320 990 970 1100 1100 1110 1160 320 
1140 1010 970 1000 100 1160 1040 1010 320 1150 1160 1140 1050 1100 1030 
320 1050 1100 320 990 970 1150 1010 320 1160 1040 1010 1210 320 1190 
1010 1140 1010 320 1160 1140 1210 320 1160 1110 320 1110 1120 1010 1100 
320 1050 1100 320 1150 1110 1090 1010 1160 1040 1050 1100 1030 320 1080 
1050 1070 1010 320 970 1150 990 1050 1050 320 1160 1010 1200 1160 100 
1010 1000 1050 1160 1110 1140 460 320 730 390 1000 320 970 1080 1150 
1110 320 1080 1050 1070 1010 320 1160 1110 320 980 1010 320 970 980 1080 
1010 320 1160 1110 320 1140 1010 970 1000 320 1160 1040 1010 320 980 
1050 1100 970 1140 1210 320 1020 1110 1140 1090 1010 1000 320 1000 970 
1160 970 320 980 970 990 1070 100 1050 1100 1160 1110 320 1150 1160 1140 
1050 1100 1030 320 1020 1110 1140 1090 970 1160 320 1150 1110 320 1160 
1040 970 1160 320 1050 1160 320 1150 1040 1110 1190 1150 320 1160 1040 
1010 320 1110 1140 1050 1030 1050 1100 970 1080 320 1180 970 1080 1170 
1010 460 320 730 1150 320 1160 1040 1010 1140 1010 320 970 1100 1210 100 
1190 970 1210 320 1160 1110 320 1000 1110 320 1160 1040 1050 1150 320 
1050 1100 320 800 1210 1160 1040 1110 1100 630 36

Of course some overly curious application user may note the pattern of 
0 endings, strip those off, concatenate the numbers, and try several 
conversions on them, at which point they may figure this out-  and 
contact you to gloat that they have hacked the file.

That's when you recruit them onto your development team and give them 
some real work.  :-)

Have fun


EP

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


Re: Why does Python never add itself to the Windows path?

2006-12-30 Thread Eric Pederson
Ben Sizer wrote:

I've installed several different versions of Python across several
different versions of MS Windows, and not a single time was the Python
directory or the Scripts subdirectory added to the PATH environment
variable. Every time, I've had to go through and add this by hand, to
have something resembling a usable Python installation. No such
problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or
Kubuntu. So why is the Windows install half-crippled by default? I just
rediscovered this today when trying to run one of the Turbogears
scripts, but this has puzzled me for years now.


+1

It is a pain for me because it is something I need to remember to do 
maybe once a year or less.

It seems best practice with Windows is to throw away the machine every 2 
years - so much crap gets automatically installed in places and ways not 
solicited I'd think only cybermonks get away clean.  That the Python 
install is a good citizen in this regard is noble, but does it really 
make a difference in regard to the overall Windows installation?  And is 
that difference worth the recurring pain of not having Python on the 
path automatically?

There must be hundreds of programs on the PATH of the machine I type on, 
its ugly.  And lets not even talk about the Registry.  Time to throw 
away the machine. That's what I get for being a cheap slut for any 
interesting program.


Windows will never be UNIX, invest in penicillin.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Famous Error Message: ImportError: No module named python_script

2006-12-13 Thread Eric Pederson
rich murphy wrote:

So, I assumed the current directory is C:\Python25 which did not
work. Then I placed the fibo.py file in C: director. That did not work
either. What directory does it mean then?

OK, forgive me for using 2.4...  Can you import sys?  Assuming you've 
got python_script.py at path:  C:\\python_script.py you might try this 
quick test:
  
  import sys
  sys.path
['C:\\Python24\\Lib\\idlelib', 'C:\\windows\\system32\\python24.zip', 
'C:\\Python24', 'C:\\Python24\\DLLs', 'C:\\Python24\\lib', 
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 
'C:\\Python24\\lib\\site-packages', 
'C:\\Python24\\lib\\site-packages\\win32', 
'C:\\Python24\\lib\\site-packages\\win32\\lib']   ## your ouput may be 
different
  sys.path.append(C:\\)
  sys.path
['C:\\Python24\\Lib\\idlelib', 'C:\\windows\\system32\\python24.zip', 
'C:\\Python24', 'C:\\Python24\\DLLs', 'C:\\Python24\\lib', 
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 
'C:\\Python24\\lib\\site-packages', 
'C:\\Python24\\lib\\site-packages\\win32', 
'C:\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\']
  import python_script


6.1.1 The Module Search Path

When a module named spam is imported, the interpreter searches for a 
file named spam.py in the current directory [...]

Actually, modules are searched in the list of directories given by the 
variable |sys.path| which is initialized from the directory containing 
the input script (or the current directory), PYTHONPATH and the 
installation-dependent default. This allows Python programs that know 
what they're doing to modify or replace the module search path. Note 
that because the directory containing the script being run is on the 
search path, it is important that the script not have the same name as a 
standard module, or Python will attempt to load the script as a module 
when that module is imported. This will generally be an error. See 
section 6.2 #standardModules, ``Standard Modules,'' for more information.


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


Re: merits of Lisp vs Python

2006-12-09 Thread Eric Pederson

  No programmer who learned Lisp ever gave up before he learned Lisp.That 
  would be the obvious retort, but my observation was empirical, so I
 am afraid you need numbers, not word games.

 You seem awfully hostile, by the way. Won't that make it harder to
 conduct an intelligent exchange of value to lurkers?

  I wonder, how many people gave up trying to learn Lisp because the
  language was too hard for them to read? Anyone like to bet that the number
  was more than zero?Sorry, no one ever discovered Lisp, decided it would be 
  great for
 programming, started learning it and then gave up because they could not
 handle the syntax.



Uh.  Clearly no one would be dumb enough to admit it in front of the
entire usenet world, right?

- Mr. NoOne


P.S.  I am still going to get back to it when I get some time, really.
LISP seems intriguing and superior, almost a magical Rubik's cube
waiting for me.  I just stumbled across Python in the meantime and code
started flowing - I got distracted.  I have CL ( Scheme) on all my
machines awaiting my focus I'll join the flock any day now.  :-)
I've just been busy.  There is a cost to learning and I've not had the
spare change to date.

But New Years resolutions need to be made: I could get up a couple
hours early and spend some quality time with CL, do a daily hour jog,
and eat a really heathly breakfast.  Writing myself a note on this.


P.P.S.  Undoubtedly not learning a syntax either means not enough time
was put in or the student lacked proper intelligence.  This will always
bias the significance of learning syntax as a factor in choice of
language to be under reported. cheers

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


Re: OT: What encoding is this?

2006-09-09 Thread Eric Pederson
[EMAIL PROTECTED] wrote:

Way off-topic for Python, but can someone tell me what encoding was used in
this web page:

http://www.loppen.dk/side.php?navn=getin

I'm guessing ISO-8859-15, but the page doesn't indicate and it's none of the
ones available in Safari.

Thanks,

Skip
  

ISO-8859-1 per Mozilla
-- 
http://mail.python.org/mailman/listinfo/python-list


Python -- (just) a successful experiment?

2005-08-07 Thread Eric Pederson

Raise your hand if you think the best technology wins!


For those of you with your hands in the air, tell me: if Python is so good, why 
has PHP achieved such greater adoption and mindshare?  Why do web scripters 
still cling to their Perl, even in corporate environments?  Why hasn't Python 
made inroads against Java?  Why is Ruby, and Ruby on Rails, getting such strong 
play?

Are these better programming languages, or is it other factors?

On a whim I installed Ruby on Rails today - pretty much a one-click deal.  It 
was a very slick (Windows) installation, as it automatically figured out and 
downloaded dependencies  - there was no question it was properly installed, and 
I ended up with a couple IDEs for Ruby, examples, etc.  Markedly better than 
installing Python - no contest - and this downloaded a useful and easy to 
employ application, with a clear path to show me how to use it.

As I perused the tutorial like documentation, I realized I wasn't anxious to 
jump into the language (Ruby), but I saw that I could certainly achieve a 
quicker success putting together a web application with RoR than with (take 
your pick: Perl, Lisp, Java, etc. etc.)  If my mind wasn't appreciative of the 
Python language, though, Ruby would have hooked me right there.

While I perceive that the future of the language Python is in good development 
hands - well debated, and thoughtfully strategized; the Python accoutrements 
can be lacking.

Imagine, if you will, a new car, that does 0-60 in 2 seconds, 60-0 in .2 
seconds, has a top speed of 185 mph, corners on par with an F-1 car, costs no 
more than a Volkswagen Passat... but comes without tires or seats, and you have 
to install the electrics and brakes yourself.

Sure, car geeks are going to love it, but you just are not going to see that 
many at the grocery store, or doing car pool duty, and no garage really works 
on them much... forget about finding parts, you have to make your own 
replacements.

I am not saying Python is that car, but I do think that Python, as opposed to 
Python the computer language specification, is done a great disservice by the 
lack of certain accoutrements.  I do not know if there are features of the 
language (specification or philosophy) which thwart the development of the 
complementary items, but I firmly believe that the lack of them is a factor in 
Python's ho-hum adoption rate.

A good computer language is great, but it pales in comparison with what can be 
done with such a language.

What is missing?

Maybe:
-- Automatic dependency handling
-- Tightly coupled GUI package (tightly coupled ~= Pythonic)
-- High level IDE (i.e. intuitive drag and drop GUI builder)
-- High level database framework (perhaps a mature, killer Dabo)
-- Powerful web framework as good as the language (and simple enough for the 
PHP guys to use)
-- Etc.

Applications like Zope and Plone help drive more people toward the language, 
though the competition is stiff.

Dozens of competing half baked tools/applications... they just confuse people 
and take up their time with decision paralysis, though they may be fun to write.


Is it wrong to appreciate Python as a language, but want to have the nice 
accoutrements we see in some competing languages?



EP
Disclaimer: only recently downloaded Eric3 for Windows, and it looks good, but 
I haven't had time to learn it yet.  Whatsup with the troll, though?



::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: is this pythonic?

2005-07-23 Thread Eric Pederson
Caleb Hattingh [EMAIL PROTECTED] wrote:

In another  
 newsgroup, I could have been flamed for letting Simon know he helped 
 more  
 than just the OP with his post :)


+1

OP asks, thousands are educated (perhaps).

The group's generosity is greatly appreciated, even if that appreciation is 
under-expressed.


-Anon (well, sort of)


P.S.  You mean this list isn't TFM?

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


Re: Just remember that Python is sexy

2005-05-30 Thread Eric Pederson
 I often can't remember that to remove spaces from a string whether it's
 strip() or trim(), and when finding patterns with the re library
 whether it's find() or search() and when iterating over key, values of
 a dictionary whether it's items() or entries().
 But then I remember that Python is sexy.
 It is sexier to strip() than to trim().
 You do a strip search() not a find() search.
 And you remove items() of clothing and not entries() of clothing.


Genius!  I will never perplex myself with string_foo.trim() again. (I do forget)

I recommend this be adopted as a naming standard for Python methods:

The method name should have a sexy connotation












Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Best way to make a list unique?

2005-03-08 Thread Eric Pederson
I have 

 listA=[1,2,3,4,5,4,3,4,3,2,1]

and I want a list of only the unique members.

This seems inefficient, but works fine over my small sample lists:

 listA=[a for a in set(listA)]


Is there a more efficient approach for cases where listA is large?






Eric Pederson
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: Impersonating other broswers...

2005-03-05 Thread Eric Pederson
Skip Montanaro [EMAIL PROTECTED] wrote

 It doesn't look any easier to do this using urllib2.  Seems like a
 semi-obvious oversight for both modules.  That suggests few people have 
 ever
 desired this capability.


my $.02:

I have trouble believing few people have not desired this for two reasons:

(1)  some web sites will shut out user agents they do not recognize to preserve 
bandwidth or for other reasons; the right User Agent ID can be required to get 
the data one wants;

(2)  It seems like it is a worthwhile courtesy to identify oneself when 
spidering or data scraping, and the User Agent ID seems like the obvious way to 
do that. I'd guess (and like to think) that Python users are generally a little 
more concerned with such courtesies than the user population of some other 
languages.

e.g.  Your website might get a hit from:  Mozilla/5.0 (Songzilla MP3 Blog, 
http://songzilla.blogspot.com) Gecko/20041107 Firefox/1.0

And you'll get to decide whether to shut them out or not, but at least it won't 
seem like the black hats are attacking.




Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: exercise: partition a list by equivalence

2005-02-20 Thread Eric Pederson
 From: Xah Lee [EMAIL PROTECTED]

 The GOTO statement from Perl has been messed up.


hey, I didn't do it!


 
 This block:
 for group in interm:



what do the funny little s stand for?





Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: variable declaration

2005-02-08 Thread Eric Pederson
Arthur artfully argued:

 What if:
 
 There was a well conducted market survey conclusive to the effect that
 adding optional strict variable declaration would, in the longer run,
 increase Python's market share dramatically.


It's always good to examine one's objectives and motives.  I am an enthusiast 
for marketing Python, but why?  Would I get something out of Python being the 
language du jour?  If everyone starts using Python when I am an old hand with 
the language, will it elevate me?  Is a world where people use a programming 
language called Python necessarily a better world?

For me the answer to those questions is no.

So what would I like?

Just the option to use Python when and where it suits me and my tasks  - and 
the continued excellent quality development and maintenance of Python and 
Python libraries.


 It just would. 

Right!

All the cool kids (and if you want to be popular you need to):

smoke/smoke dope/get tatoo'd/fight/climb the water tower/get pierced/get 
drunk/call their girlsfriends a b!#ch/shop lift/ditch school/put their fingers 
into an electrical outlet


Declare variables?

Hey, what's one more compromise to get popular?!


(I shudder thinking where that slippery slope leads)




[Nothing above is meant to imply I haven't done stupid things; rather perhaps 
that I've already done more than enough to know better; and, by the way, I'm 
still not popular.  I'd hope GvR and the crew keep Python Python]




Eric Pederson
http://www.songzilla.blogspot.com

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


Re: variable declaration

2005-02-01 Thread Eric Pederson
Thomas Bartkus wrote

 As has been pointed out, it's not a big deal for a programmer who's 
 been
 there, done that. But the original posters example is a beginners trap 
 for
 certain.
 
 *If* Python were a beginners language, then it would be missing one 
 of
 it's training wheels.


If you put training wheels on your bicycle, it's not going to be any good for 
moderately serious cycling.  The OP was clearly not new to programming, and it 
was a hypothetical problem.

We're all adults here (even my 12 year old!) - and we have only beginners in my 
house.  This purported wart has never bothered me  -- Python is so friendly to 
develop in.  If this sort of code error bites my 12 year old, I'm sure he will 
be able to find it and feel good about fixing it.  It's not the kind of code 
error that has you shutting down your computer at 4AM, perplexed and frustrated 
- those feelings are usually attributable to subtle, complex, dastardly 
language features (unexpected behavoirs).  Just my opinion, of course.

Among the great and enlightening posts in this thread, I liked this:

QOTW?
We should concentrate on *real* problems, ones that exist in real code, not 
ones that mostly
exist in wild-eyed prose that consists of predictions of pain and death
that conspicuously fail to occur, no matter how many times they are
repeated or we are exhorted to heed them or face our doom. 

http://groups-beta.google.com/group/comp.lang.python/messages/178fef06830cc779?thread_id=a75da70b0845b6femode=threadnoheader=1#doc_178fef06830cc779


[Go PyPy!]



Eric Pederson
http://www.songzilla.blogspot.com

:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: The next Xah-lee post contest

2005-01-30 Thread Eric Pederson
 From: Arthur [EMAIL PROTECTED]

 Not sure how Xah got himself into all this.  


One can easily see that Java programmers are geeks who secretly wanted to make 
the football team and are now trying to conform, ignoring their language's 
critical lack of Prolog syntax.  Python coders, similarly, do not recognize 
that they may be violating several open source patents each time they write: 
class(Object):, and both languages may become unusable when the Government 
changes the inheritance tax.

Rather than throw stones or make fun, all but the closet Republicans should 
examine how poor Xah came to such a state of misunderstanding IPv8, and try to 
help him.

From Aahz tag line we have a clue:

19. A language that doesn't affect the way you think about programming,is 
not worth knowing. --Alan Perlis

Further understanding will require research.  Was it Perl that did this to Mr. 
Lee's brain, or perhaps it was trying to ascertain the web services standard? 
 Was it a massive PHP program that simply grew beyond comprehendability and 
blew all normal circuits?  Or perhaps an attempt to jump straight from Fortran 
77 into Ruby?

Perhaps we will never know the cause, but surely when the ill come to us we 
must prescribe something.

Ah, perhaps if he will join us in a song we will all be OK:

Python Choir:
Lee's a lumberjack, and he's OK,
He codes all night and he posts all day.

XL:
I cut down trees, I eat my lunch,
I go to the lavatory.
On Wednesdays I go shopping,
And have buttered scones for tea.

Python Choir:
Lee cuts down trees, He eats his lunch,
He goes to the lavatory.
On Wednesdays he goes shopping,
And have buttered scones for tea.

Lees a lumberjack, and he's OK,
He codes all night and he posts all day.

XL:
I cut down trees, I skip and jump,
I like to press wild flowers.
I put on women's clothing,
And hang around in bars.

Python Choir:
Lee cuts down trees, he skips and jumps,
He likes to press wild flowers.
He puts on women's clothing
And hangs around In bars???


Well.  At least I feel better.  For now.



/Eric - sentenced to re-learn and write an application in Perl 5.0
What will that do to my mind?


http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: File objects? - under the hood question

2005-01-20 Thread Eric Pederson
Jeremy responds:


[kind enough not to mention I must have had only 10% of my brain cells 
functioning when I posted]

 And note that with the possible exception of that last one, there is no
 relationship between these two questions. 


Right, I just want there to be.


 There is no argument you can pass to file() that will read 
 an
 HTTP file.


A file is a file, no matter where it resides; yes I know it's not that simple.

Here the sort of thing (seek, then read) I think I want:

 IDV2=open((http://musicsite.com/song453.mp3,rb;)[:-128])

 song453.tags=IDV2.read()

 len(song453.tags)

128


But it's not a Python problem.  :-(


Thanks for the responses and indulgence.


I'm OK now - the repair man fixed the coffee pot.



Eric Pederson
http://www.songzilla.blogspot.com

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


File objects? - under the hood question

2005-01-18 Thread Eric Pederson

I didn't come across any illuminating discussion via Google, thus my question 
here (though it may be a neophyte question.) I am interested in the workings 
under the hood of Python's access of files.

What is actually happening at the various stages when I create a file object 
and read it?

(1) f = file(C:/GuidosParrot.txt,r)

(2) hesjustsleeping = f.read()

At (1) have I loaded the file from hard drive into RAM when I create the file 
object?  What does this object know and how did it find it out?

At (2) am I loading the file contents into RAM, or just assigning what is 
already in RAM to a variable? 

Where is the work split between the OS and Python?  I assume the OS is 
responsible for presenting the file to Python, so perhaps the OS assembles 
this file from the blocks on disk and loads it into RAM at the time the file 
object is created?  Or would the OS simply have pointers that can assemble the 
file, and pass those pointers to Python?

Perhaps I've answered my question and the under-the-hood mechanics are handled 
on the OS side, and Python is just making requests of the OS...


My brain-teaser:  What I'd like to do is read the last ~2K of a large number of 
large files on arbitrary servers across the net, without having to read each 
file from the beginning (which would be slow and resource inefficient)...




Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:

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


Re: OT: MoinMoin and Mediawiki?

2005-01-10 Thread Eric Pederson
Paul Rubin wrote:

 What I'm getting at is I might like to install MoinMoin now and
 migrate to Mediawiki sometime later.  Anyone have any thoughts about
 whether that's a crazy plan?  


Disclaimer, I am neither using Moinmoin nor Mediawiki, and don't really have 
your answer.

From what I read, Mediawiki stores each page as wikitext in a MySQL 
database; wikitext is a mixture of content, markup, and metadata.

It seems essentially what you'd need for migration is a mapping function and I 
do not know how complex the mapping between the systems would be.  I could 
imagine migrating from Moinmoin to Mediawiki via a script looping through the 
Moinmoin files in a directory, modifying a copy of each, and storing them in 
MySQL.

I suspect it's less painful to just start with the wiki you want to end up 
with, but if you're going to migrate between the two, won't Python come in 
handy!  ;-)



Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: The Industry choice

2005-01-04 Thread Eric Pederson
 (the gravity model).  On a decision making basis 
there seems to be an aspect of it that is binary: (0) either give in to gravity 
and gain shared advantage as part of a massive object, or (1) choose an 
alternate location far enough away not to be much affected by the force of 
the massive objects, and try to build mass there.  I suspect Python is a (1) 
in that regard, but I may be wrong.


Gravity as a model of technology adoption appeals to me as I've been thinking 
about cosmology a fair bit, and I have grave suspicions that much of the 
universe's dark (and green) matter is in Redmond.




Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: The Industry choice

2005-01-02 Thread Eric Pederson
Cameron Laird wrote:

 
 Let me add a cautionary note, though:  Big Companies, 
 including Oracle, Software AG, IBM, Cisco, and so on, have
 adopted Tcl over and over.  All of them still rely on Tcl
 for crucial products.  All of them also have employees who
 sincerely wonder, Tcl?  Isn't that dead?
 
 I offer this as a counter-example to the belief that Adop-
 tion by a heavyweight necessarily results in widespread
 acceptance.
 -- 


I think the adoption of computer languages is quite complex, but one useful 
metaphorical model may be gravity, e.g. the clumpy universe of stars, with 
gravity working on different scales to shape the overall distribution of 
matter.  Adoption by a heavyweight may have some effect if that force is 
allowed to operate on other bodies, but the overall distribution of mass is 
complex.

In the practice of business, companies generally find a need to consciously 
limit methodological diversity as they grow in size.  Control is usually made 
more centralized, but becomes more distant from the atom (programmer writing 
code) as the firm grows large, and entropy becomes the enemy, lower level 
entropy a source of uncertainty and risk.  If so, there is some legitimate 
reason for trying to standardize on tools (i.e. programming languages).

Less sophisticated business minds may latch onto the notion of gains from 
economies of scale, which is usually an easy sell (and good route for a fast 
career rise) but an overly simple optimization.

Not to say that such restrictive mindsets and policies are inevitable, but they 
seem the prevailing wind.

Preserving intellectual diversity and innovation may be critical to a big 
company in the long run, and allowing the use of (for example) Python would 
seem very in tune with those goals.

It might be nice if it was widely understood (in IT) that Python was a language 
any competent programmer could pick up in an afternoon, such that Java, C, and 
Perl shops would not be concerned about the need for their staff to learn a new 
language.



Eric Pederson
Linear?  What is linear?




Digital M4 (music) http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: PHP vs. Python

2004-12-22 Thread Eric Pederson
Paul Rubin did say:

 For sites that get less traffic than that, they only reason they need
 to scale if they're written in Python is that Python is too slow.


Asked earnestly: is there a feel or quantification that Python is slower than 
PHP in network applications?

If, so, I am wondering if it is because of the traction PHP has in the web 
community leading to possibly tighter integration with (e.g.) Apache.

My beloved Python-oriented webhost doesn't currently support Mod-Python due to 
concerns about unknown security risks, and without that one carries the 
interpreter start-up burden for each invocation, as I understand it.  Speed in 
a server-client environment does concern me a bit because 100+ hits per second 
would be the minimum realm of success for the web app I am building in Python 
(I do not foresee using PHP, so maybe I would convert everything to C++ if I 
had to, but I really would not want to have to...)

In everything I have done so far, Python's speed has been quite satisfactory, 
and I always remember the loud complainings in the MySQL forum about SQL 
queries that take seconds, minutes, days... only to end up magnitudes faster 
when someone points out the folly of the code or table set-up.

Not sure if the OP is considering Python v.s. PHP on the server or on the 
desktop (PHP isn't web only, except by common use); they are very different use 
cases.




Eric Pederson
http://www.songzilla.blogspot.com
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: NO REALLY

2004-12-15 Thread Eric Pederson
  Jive [EMAIL PROTECTED] taunted:
 
  Subject: NO REALLY
 
  Isn't there a comp.lang.flame or something?
 


Oh, my, don't you have BIG CAPS!  Someone should wash them, thoroughly!

Why don't you come up to my room, big boy.

-DIRK


[is that flaming enough?]

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


Re: Python mascot proposal

2004-12-13 Thread Eric Pederson
 
 Since the word 'Python' would bring -some- sort of snake associations, 
 I 
 thought of combining snake and Monty Python symbolic, like making a 
 snake wind around a giant foot, or adding long mustache and an english 
 hat to a snake or something in that manner, or even put a snake into a 
 holy grail heh.
 
 But then again, I'm not sure if there'll be no copyright issues.


But surely only you and I and the other Pythonistas will recognize a Norwegian 
Blue when we see one.


Might be hard to get away from the snake, as was noted, its a level or two 
easier mental association than MP.


Logo?  Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead 
off to is ide, grinningly wit a char-grin?



es not dead!




Eric Pederson
:::
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
:::

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


Re: PajamaScript

2004-12-05 Thread Eric Pederson
Jerome (aka evil tofu) advised:

 I wrote something called PajamaScript. Basically, it parses a text
 file and looks for pj tags. Then it calls python to handle the
 scripting. Why learn another language when you already know Python?
 
 html
 head
 titleThis is fun!/title
 /head
 body
 The Date is pj module=misc function=zdate / .br
 The Time is pj module=misc function=ztime / .p
 
 pj module=database function=generateTableOfResults / 
 /body
 /html
 
 PajamaScript then calls the function zdate in module misc and the
 output replaces the tag. This is not really tested in any production
 system, just a proof of concept I did for a project that never
 materialized. In order to access cgi variables, you can use the cgi
 module or any other python module! Would this be useful to anyone?


Every tool has a use!  Offhand it occurs to me this might a simple, well 
organized structure for a cgi environment, though I wonder if the extra level 
of processing might make it a little slow.  Ought to be other uses too...

I _do_ think the pj tags and the title PajamaScript is brilliant marketing. 
 Highest kudos!


[PajamaScript beats PyTxtParse2ModuleExecEnviron.py !]

Any functioning examples of its use?



Eric Pederson
:::
def eAddy():
domainNot=@something.com
domainIs=domainNot.replace(s,z)
ePrefix=.join([chr(ord(x)+1) for x in do])
mailMeAt=ePrefix+domainIs
return mailMeAt
:::

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